<?php 
class CUserInfo
{
	var $user_id;
	var $user_name ;
	var $user_pwd	 ;
	var $real_name ;
	var $email		 ;
	var $ip				 ;
	var $phone 		 ;
	var $photo		 ;
	var $dept_id	 ;
	var $dept_name ;
	var $role_id 	 ;
	var $role_name ;
	var $user_state;
};

class CModuleUser extends CModuleBase
{
	function Init($user_id=0)
	{
		$sql = "select a.*, b.dept_name, c.role_name from tb_user a, tb_dept b, tb_role c ";
		$sql = $sql . " where a.dept_id=b.dept_id and a.role_id=c.role_id ";
		if($user_id != 0)
			$sql = $sql . " and a.user_id=".$user_id;
		$sql = $sql . " order by 1";		
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{			
			$mod = new CUserInfo();
			$mod->user_id		 = $this->db->Get("user_id");
			$mod->user_name  = $this->db->Get("user_name")  ;
			$mod->user_pwd	 = $this->db->Get("user_pwd")	  ; 
			$mod->real_name  = $this->db->Get("real_name")  ;
			$mod->email		 	 = $this->db->Get("email")		 	;
			$mod->ip				 = $this->db->Get("ip")				  ; 
			$mod->phone 		 = $this->db->Get("phone") 		  ; 
			$mod->photo		 	 = $this->db->Get("photo")		 	;
			$mod->dept_id	 	 = $this->db->Get("dept_id")	 	;
			$mod->dept_name	 = $this->db->Get("dept_name") ;
			$mod->role_id 	 = $this->db->Get("role_id") 	  ; 
			$mod->role_name	 = $this->db->Get("role_name") ;
			$mod->user_state = $this->db->Get("state") ;
			$this->modules[$this->GetSize()] = $mod;
		} 
		  
		$this->db->FreeResult();
	}   
	
	function InitDeptMember($dept_id)
	{
		$sql = "select * from tb_user where dept_id=".$dept_id." order by 1";		
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{			
			$mod = new CUserInfo();
			$mod->user_id		 = $this->db->Get("user_id");
			$mod->user_name  = $this->db->Get("user_name")  ;
			$mod->user_pwd	 = $this->db->Get("user_pwd")	  ; 
			$mod->real_name  = $this->db->Get("real_name")  ;
			$mod->email		 	 = $this->db->Get("email")		 	;
			$mod->ip				 = $this->db->Get("ip")				  ; 
			$mod->phone 		 = $this->db->Get("phone") 		  ; 
			$mod->photo		 	 = $this->db->Get("photo")		 	;
			$mod->dept_id	 	 = $this->db->Get("dept_id")	 	;
			$mod->role_id 	 = $this->db->Get("role_id") 	  ; 
			$mod->user_state = $this->db->Get("state") ;
			$this->modules[$this->GetSize()] = $mod;
		} 
		  
		$this->db->FreeResult();
	}   
	
	function InitModule($module_id)
	{
		$this->module = new CUserInfo();
		
		$sql = "select * from tb_user where user_id=".$module_id;		
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{
			$this->module->user_id		= $this->db->Get("user_id");
			$this->module->user_name  = $this->db->Get("user_name");
			$this->module->user_pwd	  = $this->db->Get("user_pwd");
			$this->module->real_name  = $this->db->Get("real_name");
			$this->module->email		 	= $this->db->Get("email");
			$this->module->ip				  = $this->db->Get("ip");
			$this->module->phone 		  = $this->db->Get("phone");
			$this->module->photo		 	= $this->db->Get("photo");
			$this->module->dept_id	 	= $this->db->Get("dept_id");
			$this->module->role_id 	  = $this->db->Get("role_id"); 
			$this->module->user_state = $this->db->Get("state");
		} 
		$this->db->FreeResult();   
	}
	
};
?>
