<?php
$job = 'add';
$title = '新增用户';
$user_id = '';

$user_name  = "";
$user_pwd	  = "";
$real_name  = "";
$email		  = "";
$ip				  = "";
$phone 		  = "";
$photo		  = "";
$dept_id	  = "";
$role_id 	  = "";
$user_state = "";
	
require_once("../module/module.dept.php");
$depts = new CModuleDept();
$depts->Init();

require_once("../module/module.role.php");
$roles = new CModuleRole();
$roles->Init();

if(array_key_exists("job", $_REQUEST))
	$job = $_REQUEST['job'];

if($job=='mod')
{
	$title = '修改用户';
	$user_id=$_REQUEST['user_id'];
	require_once('../module/module.user.php');
	$user = new CModuleUser();
	$user->InitModule($user_id);
	if($user->module != '')
	{
		$user_name  = $user->module->user_name ;     
		$user_pwd	  = $user->module->user_pwd	 ;     
		$real_name  = $user->module->real_name ;     
		$email		  = $user->module->email		 ;     
		$ip				  = $user->module->ip				 ;     
		$phone 		  = $user->module->phone 		 ;     
		$photo		  = $user->module->photo		 ;     
		$dept_id	  = $user->module->dept_id	 ;     
		$role_id 	  = $user->module->role_id 	 ;     
		$user_state = $user->module->user_state;     

	} 
}   

if($roles->GetSize() == 0)
{
	echo "请先设置角色信息";
	return;	
}
?>  
<input type='hidden' id='user_id' value='<?php echo $user_id?>'>
<table border=0 cellspacing='1' cellpadding='0' width=100% bgcolor='#ffffff'>
	<tr bgcolor="#efefef" height=20>
		<td colspan=2>
			<b><span id="dept_form_desc"><?php echo $title?></span></b>
		</td>
	</tr>
	<tr>
		<td width=210 height=130 valign=top>
			<img src="<?php echo $photo?>" border=1 width=200 height=150 align="center" id='photo'><br>
		</td>
		<td valign=top>
			用户帐号: <input value="<?echo $user_name?>" <?if($job=="mod") echo "disabled";?> type=text id='user_name' class='txtput' size=12> <font color=red>*</font><br>
			登陆密码: <input value="<?echo $user_pwd?>" type=password id='user_pwd' class='txtput' size=12> <font color=red>*</font><br>
			真实姓名: <input value="<?echo $real_name?>" type=text id='real_name' class='txtput' size=12> <font color=red>*</font><br>
			邮件地址: <input value="<?echo $email?>" type=text id='email' class='txtput' size=20><br>
			I P 地址: <input value="<?echo $ip?>" type=text id='ip' class='txtput' size=20><br>
			联系电话: <input value="<?echo $phone?>" type=text id='phone' class='txtput' size=20><br>
			所属部门:
				<select id='dept_id' class='box'>
				<?php for($i=0; $i<$depts->GetSize();$i++){?>
					<option value="<?php echo $depts->modules[$i]->dept_id?>"  <?php if($dept_id==$depts->modules[$i]->dept_id){echo "selected";}?>><?php echo $depts->modules[$i]->dept_name;?></option>
				<?php }?>
				</select>
			<br>
			选择角色:
				<select id='role_id' class='box'>
				<?php for($i=0; $i<$roles->GetSize();$i++){?>
					<option value="<?php echo $roles->modules[$i]->role_id?>" <?php if($role_id==$roles->modules[$i]->role_id){echo "selected";}?>><?php echo $roles->modules[$i]->role_name;?></option>
				<?php }?>
				</select>
			<br>
				<!--
				用户状态: 
				<input type="radio" name="user_state" id='user_state' value="1" <?if($user_state==1) echo "checked"?>>开启
				<input type="radio" name="user_state" id='user_state' value="0" <?if($user_state==0)?>>关闭 
				-->
			<span class='small'>(标注 <font color=red>*</font> 的输入框不能为空 )</span>
		</td>
	</tr>
	<tr height=30>
		<td colspan=2 bgcolor="#efefef" align=center>
				<input type=button value=" 提交 " class=btn onclick="SubmitUser('<?php echo $job?>')">
				&nbsp;&nbsp;&nbsp;&nbsp;
				<input type=button value=" 取消 " class=btn onclick="CloseDialog(0)">
		</td>
	</tr>
</table>