<?php

/**
 *      【橙创家校通v4.0】 (C)2010-2012 Tuntron Inc.
 *      
 *    	 http://www.tuntron.com   QQ：1121251729
 *
 *      &校务管理模块&
 */
 
 if (!defined('IS_RUN')) die('Forbidden');
 
 $M_user = G_class('user');
 $M_ann=G_class('ann');
 $c= _get('c','subject');
 
 $T=$c=='index'?$do:$do.'_'.$c;
 
 //左侧菜单开始 --后面考虑转到模块入口文件
  $left_menu_html = G_class('menu') ->get_left_menu_html($arrgroup['menuid'],$do,$c);
 
 $Modname = '校务管理 - 学校管理';
 
switch ($c){
		
		case "index":
		
		$Modname = '功能开关 - '.$Modname;
		
		break;
		
		
		case "exam":
		
		$Modname = '考试设置 - '.$Modname;
		
		$M_examtype=G_class('examtype');
		
		$arrexamtype = $M_examtype->read_all($_CO['userbid']);
		
		break;
		
		case "subject":
		
		$Modname = '科目管理 - '.$Modname;
		/*
		 * Edit from zhaobin 2012/11/13 14:24 START
		 */
		$M_subject = G_class('subject_item');
		$arrSubject = $M_subject -> read_all($_CO['userbid']);
		/*
		 * Edit from zhaobin 2012/11/13 14:24 END
		 */
		
		break;
		
		case "attendance":
		
		$Modname = '考勤设置 - '.$Modname;

		break;
		
		case "ann":
		
			$all_bid = $M_user->B->FindAllBid($_CO['userbid']);
			$arr_all_bid=explode("/",'1/'.$all_bid);
			$arrann=$M_ann->read_all($arr_all_bid);
			//获取参数验证代码
			$arrann=fields_code($arrann,'id');
			
			$Modname = '公告管理 - '.$Modname;
			
			
			

		break;
		
		case "ann_content":
		
		$Modname = '查看公告 - '.$Modname;
		$id = _get('id');
		
		$content = $M_ann->read_one($id);
		
		
		break;
		
		case "addann":
		
		$Modname = '发布公告 - '.$Modname;
		$gBranch = $M_user->B->findbranch($_CO['userbid']);
		
		if($_POST){
		$post = $M_ann->get_post($_POST);
		$post['bid'] = $_CO['userbid'];
		$M_ann-> save($post);
		Note('公告添加成功！','>>点击返回<<',SITEURL.'?mod=school&do=affairs&c=ann');
		}
		
		break;
		
		
		case "addexamtype":
		
		$Modname = '添加考试类型 - '.$Modname;
		$M_examtype=G_class('examtype');
		// Edit from zhaobin 15:45 2012/11/14 START
		$M_subject_item = G_class('subject_item');
		$subject_item = $M_subject_item->read_all($_CO['userbid']);
		
		if($_POST){
			
			check_access('set_exam');
			if($_POST['dztype'] == '1'){
				$post['subject'] = implode(',', $_POST[subject1]);
			}else{
				if($_POST['subject0'] == '0'){
					Note('请选择考试科目');
				}
				$post['subject'] = $_POST['subject0'];
			}
			$post['bid'] = $_CO['userbid'];
			$post['dztype'] = $_POST['dztype'];
			$post['tname'] = $_POST['tname'];
			$M_examtype-> save($post);
			Note('考试类型添加成功！','>>点击返回<<',SITEURL.'?mod=school&do=affairs&c=exam');
		// Edit from zhaobin 15:45 2012/11/14 END
		}
		
		break;
		
		// Edit from zhaobin 16:06 2012/11/14 START
		case "editexamtype":
			$Modname = '编辑考试类型 - ' . $Modname;
			$M_examtype = G_class('examtype');
			$M_subject_item = G_class('subject_item');
			$subject_item = $M_subject_item->read_all($_CO['userbid']);
			
			if($_POST['examtypeid']>0){
				check_access('set_exam');
				$post['examtypeid'] = $_POST['examtypeid'];
				$post['bid'] = $_CO['userbid'];
				$post['dztype'] = $_POST['dztype'];
				if($_POST['dztype'] == '1'){
					$post['subject'] = implode(',', $_POST[subject1]);
				}else{
					if($_POST['subject0'] == '0'){
						Note('请选择考试科目');
					}
					$post['subject'] = $_POST['subject0'];
				}
				$post['tname'] = $_POST['tname'];
				$M_examtype->update2($post);
				Note('考试类型修改成功！','>>点击返回<<',SITEURL.'?mod=school&do=affairs&c=exam');
			}else{
				if($_GET['examtypeid'] && is_numeric($_GET['examtypeid'])){
					$examtype_info = $M_examtype->get_one($_GET['examtypeid']);
				}else{
					Note('非法参数');
				}
			}
			break;
			
		case 'delexamtype':
			
			$M_examtype = G_class('examtype');
			if($_GET['examtypeid'] && is_numeric($_GET['examtypeid'])){
				check_access('set_exam');
				$examtype_info = $M_examtype->del_one($_GET['examtypeid']);
				Note('已成功删除！','>>点击返回<<',SITEURL.'?mod=school&do=affairs&c=exam');
			}else{
				Note('非法参数');
			}
			break;
		// Edit from zhaobin 16:06 2012/11/14 END
		
		case 'delann':
		
		 check_access('school_ann');
		 $annid = _get('id');
		 $one_ann = $M_ann->read_one($annid);
		 if($one_ann['bid']==1) Note('系统公告禁止删除！','>>点击返回<<',SITEURL.'?mod=school&do=affairs&c=ann');
		 $M_ann-> delann($annid);
		 Note('公告删除成功！','>>点击返回<<',SITEURL.'?mod=school&do=affairs&c=ann');
		  
		break;
		
	}
	

 if($no_temp<0) require_once Template($T);

?>