<?php

/**
 *      【橙创家校通v4.0】 (C)2010-2012 Tuntron Inc.
 *      
 *    	 http://www.tuntron.com   QQ：1121251729
 *
 *      &系统管理-人员管理模块&
 */
 
 if (!defined('IS_RUN')) die('Forbidden');
 
 $M = G_class('user');
 $c= _get('c','sch');$d= _get('d','');$gid= _get('gid','');$bid= _get('bid',$_CO['userbid']);$uid= _get('uid','');
 $keyword=_get('keyword','');
 $T = !empty($d)?$d:'member';
 
 $sysgroupid = $M->G->get_usergroupid_str($_CO['groupid'],$c);

 $Group = !empty($gid)? $gid:$sysgroupid;
 
 $topBranch = $M->B->findbid($_CO['userbid']);
 
 $TOPBranch_1 = $M->B->read($_CO['userbid']);
 
 $_CO_bidauthcode = fields_code($_CO['userbid'],'bid');


 $Modname = '人员架构 - 系统管理';
 
switch ($d) {
		
		case "":
			
			$strbid = $M->B->findbid($bid);
			$thisBranch = $M->B->read($bid);
			$bname = $M->B->findbranch($bid);
			$arrMembers = $M->arrmember($Group,$bid,$c,'*',$keyword);
			//获取参数验证代码
			$arrMembers[1]=fields_code($arrMembers[1],'bid');
			$arrMembers[1]=fields_code($arrMembers[1],'uid');
			$authcode=$authcode?$authcode:fields_code($bid,'bid');
			if(empty($thisBranch['bname'])&&$bid) location(SITEURL.'?mod=system&do=member&c=sch');
			$Modname = $bname?str_replace('/',' - ',$bname).' - '.$Modname:$Modname;
			
			//每页显示数据量
			$listNum = _get('listNum','20');
			//当前页
			$pid=$_GET['p'];
			if(is_numeric($pid)&&$pid>0){
				$pid=(int)$pid;
			}else{
				$pid='1';
			}
			//链接地址
			$url = SITEURL . '?mod=system&do=member&c='.$c.'&bid='.$bid.'&gid='.$Group.'&authcode='.$authcode;
			//数据总数
			$sum = $arrMembers[0];
			$pidf = $pid-1;
			$start = $pidf*$listNum;
			$end = $listNum;
			foreach($arrMembers[1] as $key=>$value){
				$array[] = $value;
			}
			$arrMembers[1] = array();
			$arrMembers[1] = array_slice($array, $start, $end);
			$pageinfo = grtpageno($url, $sum, $listNum, $pid);
			
			$usergroupshow_html = $M->G->usergroup_show($_CO['groupid'],$Group,$c,$bid,$pid);

		break;
		
		
		case "member_add":
		
		$thisBranch = $M->B->read($bid);
		$gBranch = $M->B->findbranch($bid);
		$usergroup_option = G_class('usergroup')->usergroup_option();
		$Modname = '新增成员 - '.$Modname;
		
		break;
		
		case "member_show":
		
		$authcode = _get('authcode');
		$oneMember = $M->read($uid);
		$gBranch = $M->B->findbranch($oneMember['bid']);
		$usergroup = G_class('usergroup')->read($oneMember['groupid']);
		$bid = $oneMember['bid'];
		$Modname = '查看'.$oneMember['realname'].' - '.$Modname;
		
		break;
		
		case "member_edit":
	    $oneMember = $M->read($uid);
		$thisBranch = $M->B->read($oneMember['bid']);
		$gBranch = $M->B->findbranch($oneMember['bid']);
		$bid = $oneMember['bid'];
		$usergroup_option = G_class('usergroup')->usergroup_option($oneMember['groupid']);
		$Modname = '编辑'.$oneMember['realname'].' - '.$Modname;

		break;
		
		case "member_import":
			$bname = $M->B->findbranch($bid);
			$Modname = '批量导入 - '.$Modname;
			$M_usergroup = G_class('usergroup');
			$usergroupArr = $M_usergroup->read_all();
			foreach($usergroupArr as $key=>$value){
				$branchArr[$value['groupid']]=$value['groupname'];
			}
			$key = array_keys($branchArr, '家长');
			if($key){
				unset($branchArr[$key[0]]);
			}
			$branchArr['6'] = '学生';
			$usergroupString = implode('、', $branchArr);
			break;
		
		case "member_import_show":
		
				Note('正版家校通请到橙创官网咨询','>> 进入官网  <<', 'http://www.tuntron.com/');
				
		break;
		
		case 'export_excel':
				Note('正版家校通请到橙创官网咨询','>> 进入官网  <<', 'http://www.tuntron.com/');
			break;
		
		case 'export_excel_member':
				Note('正版家校通请到橙创官网咨询','>> 进入官网  <<', 'http://www.tuntron.com/');
	}

 if($bid) {

	 $strbid = $M->B->FindAllBid($bid);
	 $str_bid = $strbid;
	 $Allhtml = $M->B->get_do_branchhtml($str_bid,'null',$c);
 }

require_once Template($T);

?>