<?php

/**
 *      【橙创家校通v4.0】 (C)2010-2012 Tuntron Inc.
 *      
 *    	 http://www.tuntron.com   QQ：1121251729
 *
 *      &系统管理模块&
 */
 
 $c=_get('c','index');
 
 $M = G_class('system');
 
 $Modname = '系统设置';
 
  //左侧菜单开始 --后面考虑转到模块入口文件
  $left_menu_html = G_class('menu') ->get_left_menu_html($arrgroup['menuid'],$do,$c);
 
 switch ($c){
	 
	 case 'index':
	 
	 $Modname = '系统信息设置 - '.$Modname;
	 
	 break;
	 
	 case 'upinfo':

		$post = $M->get_post($_POST);
			
		$M-> update($post);
	 
		 Note('修改成功！','>>点击返回<<',SITEURL.'?mod=system');
	 break;
	 
	 case 'changepwd':
	 
	 	
		if($_POST){
		$post = G_class('user')->get_post($_POST);
		
		G_class('user')-> change_password($post['oldpasswd'],$post['password'],$post['password2'],$post['uid']);
		
		Note('密码修改成功！','>>点击返回<<',SITEURL.'?mod=system&c=changepwd');
		}
	 
	 $Modname = '修改密码 - '.$Modname;
	 
	 break;
	 
	 case 'changeinfo':
	 
	 $md5_safecode = md5(random());
	 
	 break;
	 
	 
	 case 'setsms':
	 
	 	$arrsmsconfig = $M->S-> read_one();
		$remainderSMS = G_class('sendsms')->G_remainderSMS();//剩余短信数
		$havesendSMS = G_class('sendsms')->G_havesendSMS();//已发短信数
	 	
		if($_POST){
		$post = $M->S->get_post($_POST);
		
		$M->S->update($post);
		
		Note('短信配置成功！','>>点击返回<<',SITEURL.'?mod=system&c=setsms');
		}
	 
	 $Modname = '短信设置 - '.$Modname;
	 
	 break;
	 
	 case 'setmenu':
	 
	 $parentid = $_GET['parentid'] ? $_GET['parentid'] : '';
     $list = G_class('menu')->read_all($parentid);
     if($parentid) {
        $goto_info = G_class('menu')->read($parentid);
        $goto_parentid = $goto_info['parentid'];
        }
	 
		
	 $Modname = '菜单管理 - '.$Modname;
	 
	 break;
	 
	 case 'add_menu':
	 case 'edit_menu':
	 
	 $Modname = '增加菜单 - '.$Modname;
	 $parentid= $_GET['parentid'];
	 $menuid= $_GET['menuid'];
	 $select_menu = G_class('menu')->create_leve_option($parentid);
	 if($c=='edit_menu'){
	  if(!$menu = G_class('menu')->read($menuid)) Note('该菜单不存在！');
	 }
	 
	 if($_POST){
	 if($_POST['menuid']) {
                $menuid = (int) $_POST['menuid'];
                if($menuid < 1)  Note('该菜单不存在！');
            }
            $parentid = $_POST['menu']['parentid'];
            G_class('menu')->save($_POST['menu'], $menuid);
           Note('菜单配置成功！','>>点击返回<<',SITEURL.'?mod=system&c=setmenu&parentid='.$parentid);
	 }
	 $no_temp=1;
	 require_once Template('add_menu');
	 break;
	 
	 case 'delete_menu':
	 
        G_class('menu')->delete($_GET['menuid']);
		$backurl = $_GET['parentid']?SITEURL.'?mod=system&c=setmenu&parentid='.$_GET['parentid']:SITEURL.'?mod=system&c=setmenu';
        Note('菜单删除成功！','>>点击返回<<',$backurl);
        break;
	 
	 case 'mysql':
	 	$backup_dir = TUNTRON_DAT . '/backup';
	 	$backup_dir = str_replace('\\', '/', $backup_dir);
 		if(!is_dir($backup_dir)){
	 		if(!mkdir($backup_dir)){
	 			exit('备份目录创建失败');
	 		}
	 	}
	 	$backup_file = array();
	 	$M_dirfile = G_class('getDirFile');
	 	$filearr = $M_dirfile->getFile($backup_dir);
		krsort($filearr);//倒叙数组 By CC
	 	foreach($filearr as $key => $file){
	 		$pathinfo = pathinfo($file);
	 		if($pathinfo['extension'] == 'sql'){
	 			$backup_file[$key]['filename'] = $file;
	 			$backup_file[$key]['edittime'] = filemtime($backup_dir . '/' . $file);
	 			$backup_file[$key]['size'] = sizeFormat($backup_dir . '/' . $file);
	 		}
	 	}
	 	break;
	 
	 case 'smsassign':
	 	//获取该部门所有下属部门
	 	$M_user = G_class('user');
		$adminSub = $M_user->B->findbid_by_sub_admin($_CO['userbid']);
		foreach($adminSub as $key=>$value){
			$adminSub[$key]['bname'] = $M_user->B->findbranch($value['bid']);
		}
		$my_balance_info = $M_user->get_my_balance($_CO['uid']);
		//系统总可用短信条数
		$usable='10000';
		//当前用户总可用短信条数
		$my_balance = $my_balance_info['sms_balance'];
		break;
	case 'usergroup':
	 	location(SITEURL.'?mod=system&do=usergroup');
	break;

 }
 
 
 
 
 

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


?>