<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
class Employee
{
	function Employee()
	{
		//$GLOBALS['WebSe'] -> isOnLine();
	}
	
	function infolist(  )
	{
		
		$pageSize = 20 ;
		
		$keywordval 	= $GLOBALS['Reque'] -> funpost("keyword");
		$pageNumval 	= $GLOBALS['Reque'] -> reqval["pageNum"];
		$searchtypeval 	= $GLOBALS['Reque'] -> reqval["searchtype"];
		
		//var_dump( $searchtypeval );
		
		if( $pageNumval > 1 )
		{
			$pageNum  = $pageNumval;
			$LIMITnum = ceil( ( $pageNumval -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}
		
		if($GLOBALS['Reque'] -> getval["keyword"] !='')
		{   
			$keywordval 	= $GLOBALS['Reque'] -> getval["keyword"];
			$keywordval  	= urldecode($keywordval); 
		}
		if($keywordval!='')
		{ 	
			$endArray["keyword"] =$keywordval;
			$endurl 	   .= '&keyword='.urlencode($keywordval);
			
			//$whereadd .= " AND (  use_name LIKE  '%".$keywordval."%' )";
			
			if( $searchtypeval =='' )
			{
				$whereadd .= " AND (  use_name LIKE  '%".$keywordval."%' )"; 
				$searchtypeval['0'] = 'use_name';
				$endArray["searchtype[0]"] = 'use_name';
			}else if($searchtypeval[0] !='' and $searchtypeval[1] !='')
			{
				$whereadd .= " AND  (  ".$searchtypeval[0]." LIKE  '%".$keywordval."%' OR ".$searchtypeval[1]." LIKE  '%".$keywordval."%' )";
				$endArray["searchtype[0]"] =$searchtypeval[0];
				$endArray["searchtype[1]"] =$searchtypeval[1];
			}else if($searchtypeval[0] !='' and $searchtypeval[1] =='')
			{
				$whereadd .= " AND  (  ".$searchtypeval[0]." LIKE  '%".$keywordval."%' )";
				$endArray["searchtype[0]"] =$searchtypeval[0];
			}else if( $searchtypeval[0] =='' and $searchtypeval[1] !='')
			{
				$whereadd .= " AND  (  ".$searchtypeval[1]." LIKE  '%".$keywordval."%' )";
				$endArray["searchtype[1]"] =$searchtypeval[1];
			}

			
		}
		
		
		//echo $whereadd;
		//exit();

		$listval  = $GLOBALS['Reque'] -> getval["listval"];
		$listtype = $GLOBALS['Reque'] -> getval["listtype"];

		$orderbyval = "";
		if($listval!='' and $listtype =='DESC' )
		{
			$endArray["listtype"] = 'DESC';
			$endArray["listval"]  = $listval;
			$orderbyval = $listval ."  DESC ";
			$listhtml = '';	//反向排序参数
			
		}elseif($listval!='' )
		{
			$orderbyval = $listval;
			$listhtml = 'DESC';
			
			$endArray["listtype"] = '';
			$endArray["listval"]  = $listval;

		}else{
			$endArray["listtype"] = 'DESC';
			$endArray["listval"]  = 'u.use_id';
			$orderbyval = " u.`use_id` DESC , u.`use_regtime` DESC ";	
		}
		
		//帐号 	真实姓名 	Email地址 	登录次数 	加入时间 	最后登录时间
		//adminsys` (`use_id` , `dep_id`,`emp_occupation`
		
		
		$sqlQuery = " SELECT u.use_id, u.use_name,  u.use_email, u.use_locked, u.use_logcount ,u.use_regtime ,u.use_logintime,e.emp_occupation ,d.dep_name FROM  ".SQL_PREFIX."user as u left join  ".SQL_PREFIX."employee as e  on   e.use_id = u.use_id left join ".SQL_PREFIX."dept  as d on d.dep_id = e.dep_id  WHERE 1 and u.use_type = 'e'  $whereadd  GROUP BY u.use_id ORDER BY  $orderbyval LIMIT  $LIMITnum , $pageSize ";
		
		$info = $GLOBALS['MySql'] -> selectInfo($sqlQuery);
		
		$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."user as u  WHERE 1 $whereadd  ORDER BY u.`use_id`  ";
		
		$infocount = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		
		$PageStr = $GLOBALS['Page']->buildPageStr( $url = '?load=employee&act=infolist', $pageNum  , $pageSize  , $resultCount = $infocount["CNUM"], $endArray );

		$GLOBALS['Templ']->assign('searchtype',$searchtypeval);
		$GLOBALS['Templ']->assign('listhtml',$listhtml);
		$GLOBALS['Templ']->assign('listval',$listval);
		$GLOBALS['Templ']->assign('listtype',$listtype);

		$GLOBALS['Templ']->assign('keywordval',$keywordval);
		$GLOBALS['Templ']->assign('PageStr',$PageStr);
		$GLOBALS['Templ']->assign('info',$info);
		
		$GLOBALS['Templ']->display('employee_tpl.html');
		
		
	}
	
	function add(  )
	{
		
		//$GLOBALS['Templ'] -> caching = true;
		//$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24

		$sqlQuery = " SELECT dep_id,dep_name, dep_parentid, dep_list  FROM  ".SQL_PREFIX."dept  WHERE dep_enabled = 1 GROUP BY dep_id ORDER BY dep_list,`dep_id` LIMIT 0, 200 ";
		
		$infosm 		= $GLOBALS['MySql'] -> selectInfo($sqlQuery);

		$depInfo = array();
		   foreach ($infosm as $rowkey => $rowval)
		   {
		   		if($rowval["dep_parentid"] == 0)
				{
				
					$depInfo[$rowval["dep_id"]]['dep_id'] 		 = $rowval["dep_id"] ;
					$depInfo[$rowval["dep_id"]]['dep_name'] 	 = $rowval["dep_name"] ;
					$depInfo[$rowval["dep_id"]]['dep_parentid']  = $rowval["dep_parentid"] ;
					//$depInfo[$rowval["dep_id"]]['dep_enabled']   = $rowval["dep_enabled"] ;
					//$depInfo[$rowval["dep_id"]]['dep_locked']    = $rowval["dep_locked"] ;
					$depInfo[$rowval["dep_id"]]['dep_list'] 	 = $rowval["dep_list"] ;
				}else{
					$depInfo[$rowval["dep_parentid"]]['array'][] = $rowval;	
				}
		   }
		 
		// var_dump($depInfo);
		  
		$GLOBALS['Templ']->assign('depInfo',$depInfo);

		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=employee&act=addinfo");
		$GLOBALS['Templ']->display('employeeadd_tpl.html');
	}
	
	function addinfo()
	{
		
		$use_idval 			= $GLOBALS['Reque'] -> funpost("use_id");
		$use_nameval 		= $GLOBALS['Reque'] -> funpost("use_name");
		$use_emailval 		= $GLOBALS['Reque'] -> funpost("use_email");
		$usd_truenameval 	= $GLOBALS['Reque'] -> funpost("usd_truename");
		$usd_mobileval 		= $GLOBALS['Reque'] -> funpost("usd_mobile");
		$dep_idval 			= $GLOBALS['Reque'] -> funpost("dep_id");
		$emp_occupationval 	= $GLOBALS['Reque'] -> funpost("emp_occupation");
		
		if($use_idval =='' and $use_nameval =='' and $use_emailval =='' and $usd_truenameval == '' and $usd_mobileval == '' )
		{
 
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=add");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			
		}else{
			
			$addstruser = '';
			
			if($use_idval!='')
			{
				$addstruser .= " and use_id = '".$use_idval."'";
			}
			
			if($use_nameval!='')
			{
				$addstruser .= " and use_name = '".$use_nameval."' ";
			}
			
			if($use_emailval!='')
			{
				$addstruser .= " and use_email = '".$use_emailval."' ";
			}
			
			if($addstruser != ''){
				$sqlQuery = " SELECT use_id  FROM  ".SQL_PREFIX."user  WHERE 1  ".$addstruser." ORDER BY `use_id` ";
				$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
			}
			
			
			$addstruserdetail = '';
			
			if($usd_truenameval!='')
			{
				$addstruserdetail .= " and usd_truename = ".$usd_truenameval;
			}
			
			if($usd_mobileval!='')
			{
				$addstruserdetail .= " and usd_mobile = '".$usd_mobileval."' ";
			}

			
			if($addstruserdetail != ''){
				$sqlQuerydetail = " SELECT use_id  FROM  ".SQL_PREFIX."userdetail  WHERE 1  ".$addstruserdetail."  ORDER BY `use_id` ";
				$infodetail = $GLOBALS['MySql'] -> selectOne($sqlQuerydetail);
			}
			
			if( $info["use_id"] > 0)
			{
				$adduse_idval = $info["use_id"];
			}elseif($infodetail["use_id"]){
				$adduse_idval = $infodetail["use_id"];
			}
			
			if( $adduse_idval > 0 )
			{
				//MD5加密码！！
				$insertuser ="UPDATE  `".SQL_PREFIX."user` SET use_type = 'e' WHERE  use_id =".$info["use_id"];
				$GLOBALS['MySql'] -> querySql($insertuser);
				
				
				$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."employee  WHERE use_id = '".$adduse_idval."' ";
				
				$infoNUM = $GLOBALS['MySql'] -> selectOne($sqlQuery);
				
				//添加或者修改部门信息
				if( $infoNUM["CNUM"] < 1 )
				{
					$insertsql ="INSERT INTO `".SQL_PREFIX."employee` (`use_id` , `dep_id`,`emp_occupation`) VALUES ( '".$info["use_id"]."', '$dep_idval','$emp_occupationval')";
					$GLOBALS['MySql'] -> querySql( $insertsql );	
				}else{
					$updateuserdetail = "UPDATE `".SQL_PREFIX."employee` SET    dep_id = '".$dep_idval."',emp_occupation = '".$emp_occupationval."' WHERE  use_id = '".$use_idval."' ";
					$GLOBALS['MySql'] -> querySql( $updateuserdetail );
				}

				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_addsusse']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infolist");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');
				
			}else{
				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_norealyerror']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=add");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
			}
			
		}
			//var_dump($_REQUEST);
	}
 
 
	
	function delpower( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		//查询一下是否超级帐号
		$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."user  WHERE `use_id` in ( $infoid ) and use_name = '".EMPLOYEE_BASEUSER."'   ";
			
		$infocnum = $GLOBALS['MySql'] -> selectOne( $sqlQuery );

		
		if($infocnum["CNUM"]> 0 )
		{
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_deladminerror']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infolist");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			
		}else{
			
			$updateuser = " UPDATE `".SQL_PREFIX."user` SET    use_type = 'u'   WHERE  use_id = '".$infoid."' ";
			$GLOBALS['MySql'] -> querySql( $updateuser );
			
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_delsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infolist");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
		}
		

		
	}
	
	
	function info(  )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$sqlQuery = " SELECT u.use_id ,u.use_name, u.use_email ,d.usd_truename,d.usd_sex,d.usd_nick,d.usd_birthday,d.usd_salt ,d.usd_msn,d.usd_qq,d.usd_officephone,d.usd_homephone ,d.usd_mobile,d.usd_province,d.usd_address  FROM  ".SQL_PREFIX."user as u  left join  ".SQL_PREFIX."userdetail as d  on d.use_id = u.use_id  WHERE u.use_id = '".$infoid."' ORDER BY u.`use_id` ";
		$info = $GLOBALS['MySql'] -> selectOne( $sqlQuery );
		
		//var_dump( $info );
		
		//$GLOBALS['Templ'] -> caching = true;
		//$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24 
		
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=employee&act=editinfo");
		$GLOBALS['Templ'] -> assign('info',$info);
		$GLOBALS['Templ'] -> display('useredit_tpl.html');
	
	}
	
	function infopwd(  )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$sqlQuery = " SELECT use_id ,use_name  FROM  ".SQL_PREFIX."user   WHERE use_id = '".$infoid."' ORDER BY `use_id` ";
		$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		
		//$GLOBALS['Templ'] -> caching = true;
		//$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24 
		
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=employee&act=editinfopwd");
		$GLOBALS['Templ'] -> assign('info',$info);
		$GLOBALS['Templ'] -> display('usereditpwd_tpl.html');
	
	}
	
	function editinfo( )
	{	
	
		$use_idval 	= $GLOBALS['Reque'] -> funpost("use_id");
				
		//$use_nameval 	= $GLOBALS['Reque'] -> funpost("use_name"); //不可修改
		
		$use_emailval 	 = $GLOBALS['Reque'] -> funpost("use_email");


		$addsetUp = '';
		if($use_idval !='' and $use_emailval !='' )
		{
		
			$updateuser = "UPDATE `".SQL_PREFIX."user` SET    use_email = '".$use_emailval."'   WHERE  use_id = '".$use_idval."' ";
			
			$GLOBALS['MySql'] -> querySql( $updateuser );
			
			$usd_truenameval 	= $GLOBALS['Reque'] -> funpost("usd_truename");
			$usd_sexval 	 	= $GLOBALS['Reque'] -> funpost("usd_sex");
			
			$usd_nickval 	 	= $GLOBALS['Reque'] -> funpost("usd_nick");
			$usd_birthdayval 	= $GLOBALS['Reque'] -> funpost("usd_birthday");
			
			$usd_saltval 	 	= $GLOBALS['Reque'] -> funpost("usd_salt");
			$usd_msnval 	 	= $GLOBALS['Reque'] -> funpost("usd_msn");

			$usd_qqval 			= $GLOBALS['Reque'] -> funpost("usd_qq");
			$usd_officephoneval = $GLOBALS['Reque'] -> funpost("usd_officephone");
			
			$usd_homephoneval 	= $GLOBALS['Reque'] -> funpost("usd_homephone");
			$usd_mobileval 		= $GLOBALS['Reque'] -> funpost("usd_mobile");
			
			$usd_provinceval 	= $GLOBALS['Reque'] -> funpost("usd_province");
			$usd_addressval  	= $GLOBALS['Reque'] -> funpost("usd_address");
			
			$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."userdetail  WHERE use_id = '".$use_idval."' ";
			
			$infoNUM = $GLOBALS['MySql'] -> selectOne($sqlQuery);
			
			if( $infoNUM["CNUM"] < 1 )
			{
				
				$insertsql ="INSERT INTO `".SQL_PREFIX."userdetail` (`use_id` , `usd_truename` , `usd_sex` , `usd_nick` , `usd_birthday` , `usd_salt` , `usd_msn` , `usd_qq` , `usd_officephone` , `usd_homephone` , `usd_mobile` , `usd_province` , `usd_address`  ) VALUES (  '$use_idval', '$usd_truenameval', '$usd_sexval', '$usd_nickval', '$usd_birthdayval', '$usd_saltval', '$usd_msnval', '$usd_qqval', '$usd_officephoneval', '$usd_homephoneval', '$usd_mobileval','$usd_provinceval','$usd_addressval')";
				$GLOBALS['MySql'] -> querySql( $insertsql );	
				
			}else{
				
				$updateuserdetail = "UPDATE `".SQL_PREFIX."userdetail` SET    usd_truename = '".$usd_truenameval."',usd_sex = '".$usd_sexval."',usd_nick = '".$usd_nickval."',usd_birthday = '".$usd_birthdayval."',usd_salt = '".$usd_saltval."',usd_msn = '".$usd_msnval."',usd_qq = '".$usd_qqval."',usd_officephone = '".$usd_officephoneval."',usd_homephone = '".$usd_homephoneval."',usd_mobile = '".$usd_mobileval."',usd_province = '".$usd_provinceval."',usd_address = '".$usd_addressval."'   WHERE  use_id = '".$use_idval."' ";
				$GLOBALS['MySql'] -> querySql( $updateuserdetail );
			}
			
			

			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infolist");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
				
		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=info&id=".$use_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
		}
		
	}

	function editinfopwd( )
	{	
	
		$use_idval 		 = $GLOBALS['Reque'] -> funpost("use_id");		
		$use_pwdval 	 = $GLOBALS['Reque'] -> funpost("use_pwd");
		$use_repwdval 	 = $GLOBALS['Reque'] -> funpost("use_repwd");

		$addsetUp 		 = '';
		
		if($use_idval !='' and $use_pwdval !='' and  $use_repwdval !='' )
		{
			
			if($use_pwdval == $use_repwdval)
			{
				$updateuser = "UPDATE  `".SQL_PREFIX."user` SET    use_email = '".$use_emailval."'   WHERE  use_id = '".$use_idval."' ";
			
				$GLOBALS['MySql'] -> querySql( $updateuser );
				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infolist");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');		
					
			}else{
				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['js_repwd']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infopwd&id=".$use_idval);
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	

			}

		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infopwd&id=".$use_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
		}
		
	}

	function powerinfo(   )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$sqlQuery = " SELECT *  FROM  ".SQL_PREFIX."user  WHERE use_id = '".$infoid."' and use_type = 'e'  ORDER BY `use_id` ";
		
		$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		
		
		if(EMPLOYEE_BASEUSER == $info["use_name"] ) //and EMPLOYEE_BASEUSER != $_SESSION["webAdmin"]["use_name"]
		{
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['adminbaseuser']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=infolist");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			exit();
		}
		
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=employee&act=editpowerinfo");
		$GLOBALS['Templ'] -> assign('info',$info);

		//一般情况是添加，修改，删除。
		$powerForm = array( 
			'companyweb' => array( 
					'product' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					'prosort' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					'artlice' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					'artsort' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
						'ad'  => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				 'adposition' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					 'invite' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					 'employ' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					'webmenu' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					   'vote' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false,'item'=>false),
					  'links' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					  
				   'employee' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				   'picture' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				   'picsort' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				     'video' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				   'vidsort' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				  'download' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					   'msg' => array('infolist'=>false, 'del'=>false,'replyinfo'=>false), //查看回复
					'config' => array('infolist'=>false, 'editinfo'=>false),//查看修改
					  'user' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					 
				   'employee' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				       'dept' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				 'userconfig' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				   	   'user' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				    'address' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					'message' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					
				  'bbsconfig' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				      'forum' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				  'moderator' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				     'thread' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
				      'reply' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false), 
					 
					   'book' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					  'order' => array('infolist'=>false, 'addinfo'=>false,'del'=>false,'editinfo'=>false),
					  'login' => array('actpwd'=>false) //登录，登出，修改密码
								)
						);
						
/*					
$GLOBALS['_LANG']['powerArray']  = array( 'product'=>'商品管理','prosort'=>'商品分类','artlice'=>'文章管理' , 'artsort'=>'文章分类', 'ad'=>'广告管理','adposition' =>'广告位置',
								 'invite'=>'招聘管理','employ'=>'应聘管理' , 'webmenu'=>'网站菜单', 'vote'=>'投票调查','book' =>'预订管理','links'=>'友情连接' , 'admins'=>'管理员管理',
								  'config'=>'网站设置', 'login'=>'个人信息',
								  
								  
								  'picture'=>'图库管理','picsort'=>'图库分类',
								 'video'=>'视频管理','vidsort'=>'视频分类','download'=>'下载管理','employee'=>'职工管理','dept'=>'部门管理','userconfig'=>'注册设置','user'=>'会员管理',
								 'address'=>'客户资料','msg'=>'留言管理' ,'bbsconfig'=>'论坛信息设置','forum'=>'版块管理','moderator'=>'版主管理','thread'=>'主题管理','reply'=>'回复管理',
								 'book'=>'预订管理','order'=>'订单管理',
								 'login'=>'个人信息');
*/			
						
						
						
	 	$sqlQuery 	= " SELECT * FROM  ".SQL_PREFIX."userpower  WHERE use_id = '".$infoid."' ORDER BY `use_id` ";			
		$infoclass 	= $GLOBALS['MySql'] -> selectInfo( $sqlQuery );
 		$usp_actionval = base64_decode($infoclass[0]["usp_action"]);
		
		@eval($usp_actionval);
		
		//base64_decode($addstrval);
		
		foreach($powerForm["companyweb"] as $keykey => $valval)
		{
			//echo $keykey;
			if($companywebArray[$keykey])
			{
				
				$fillArray = array_fill_keys( $companywebArray[$keykey], true);
				 
				$powerForm["companyweb"][$keykey] = array_merge( $valval ,$fillArray);
				
			}
		}
		
		//var_dump($powerForm);
		
		$GLOBALS['Templ'] -> assign('powerForm',$powerForm);
		$GLOBALS['Templ'] -> display('userpowerinfo_tpl.html');
		
	}
	
	//第一为组权限名称
	//第二为文件名称
	//第三为文件处理方法名称（数组）
	
	function editpowerinfo(  )
	{
		$use_idval 		= $GLOBALS['Reque'] -> funpost("use_id");
		$menuval 		= $GLOBALS['Reque'] -> funpost("menu");
		$menuitemval 	= $GLOBALS['Reque'] -> funpost("menuitem");
		
		//echo $use_idval ;
		$usp_formval = 'companyweb';
		
		if(is_array($menuitemval))
		{

			$addstr = "\$companywebArray =  array( ";
			
			$ff = 0; 
			foreach( $menuitemval as $key => $val )
			{
				if($ff==0){
					$addstr .= "'".$key."'=> array( ";  // implode(',',$val);
				}else{
					$addstr .= ",'".$key."'=> array( ";  // implode(',',$val);
				}
				$vv = 0;
				foreach($val as $vkey =>$vval)
				{
					
					if($vv==0)
					{
						$addstr = $addstr."'".$vval."'";
					}else{
						$addstr = $addstr.",'".$vval."'";
					}
					$vv++;
				}
				$addstr .= " ) ";
				
				$ff++;
				
			}
			$addstr .= " ); ";
			
	   }

		$sqlQuery 	= " SELECT count(1) as CNUM   FROM  ".SQL_PREFIX."userpower  WHERE use_id = '".$use_idval."' and usp_form = '".$usp_formval."' ORDER BY `use_id` ";
				
		$infoclass 	= $GLOBALS['MySql'] -> selectOne( $sqlQuery );

		$addstrval = base64_encode($addstr);
		

		
		if( $infoclass["CNUM"] < 1 )
		{
			$insertsql ="INSERT INTO `".SQL_PREFIX."userpower` (`use_id` , `usp_form` ,  `usp_action`  ) VALUES (  '$use_idval', '$usp_formval', '".$addstrval."')";
			$GLOBALS['MySql'] -> querySql( $insertsql );		
		}else{
					
			$updatesql = "UPDATE `".SQL_PREFIX."userpower` SET  usp_action = '".$addstrval."'  WHERE  use_id = '".$use_idval."' and  usp_form = '".$usp_formval."' ";
			$GLOBALS['MySql'] -> querySql( $updatesql );
		}
			
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employee&act=powerinfo&id=".$use_idval);
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
		
	}

	
	function actlogout()
	{
		$GLOBALS['WebSe'] -> dropSession();
		header("location:".EMPLOYEE_WEBURL."/index.php?load=employee&act=act");
		exit();
	}
	
	function pwd()
	{
		//$GLOBALS['WebSe'] -> isOnLine();
		$GLOBALS['Templ'] -> caching = true;
		$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24	
		$GLOBALS['Templ'] -> assign('use_name',$_SESSION["emplyeeUser"]["use_name"]);
		$GLOBALS['Templ'] -> assign('actUrl',EMPLOYEE_WEBURL."/?load=user&act=actpwd");
		$GLOBALS['Templ'] -> display('pwd_tpl.html');
		//exit();
	}
	
	function actpwd()
	{
		//$GLOBALS['WebSe'] -> isOnLine();
		
		$oldpwdval  	= $GLOBALS['Reque'] -> funpost("oldpwd");
		$use_pwdval		= $GLOBALS['Reque'] -> funpost("use_pwd");
		$reuse_pwdval 	= $GLOBALS['Reque'] -> funpost("reuse_pwd");
		$use_idval 		= $_SESSION["emplyeeUser"]["use_id"];
		
		$sql = " SELECT use_id  FROM ".SQL_PREFIX."user WHERE use_id= '".$use_idval."' AND  use_pwd = '".md5($oldpwdval)."' LIMIT 1 ";
		
		$User = $GLOBALS['MySql'] -> selectOne($sql);
		
		if($User["use_id"]!='')
		{
			//修改成功！
			$sqlup = " UPDATE ".SQL_PREFIX."user  set  use_pwd = '".md5($use_pwdval)."'  WHERE  use_id= ".$use_idval;
			$GLOBALS['MySql'] -> querySql($sqlup);
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['LA_pwdsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/?load=user&act=pwd");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			//exit();
		}else{
			//修改有误!
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['LA_pwderror']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/?load=user&act=pwd");	
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			
		}
		
		//exit();
	}
	
}

$Employee = new Employee();

?>