<?php include $this->admin_tpl('meta');?>
<title>修改管理员 - YzmCMS内容管理系统</title>
</head>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			 <li><label>用户名：</label>
			 	<input type="text" class="input disabled" placeholder="用户名" name="adminname" disabled="disabled" value="<?php echo $data['adminname'];?>">
			 </li>
			 <li><label>密码：</label>
			 	<input type="password" class="input" autocomplete="off" value="" placeholder="不修改请留空" name="password">
			 </li>	
			 <li><label>确认密码：</label>
			 	<input type="password" class="input" autocomplete="off" value=""  placeholder="不修改请留空" id="password2" name="password2">
			 </li>	
			 <li><label>邮箱：</label>
			 	<input type="email" class="input" placeholder="@" name="email" value="<?php echo $data['email'];?>">
			 </li>
			 <li><label>真实姓名：</label>
			 	<input type="text" class="input" placeholder="真实姓名" name="realname" value="<?php echo $data['realname'];?>">
			 </li>
			 <li class="yzm-explain-box"><label>用户昵称：</label>
			 	<input type="text" class="input" placeholder="发布内容时显示" name="nickname" value="<?php echo $data['nickname'];?>"> 
			 	<span class="yzm-explain">发布内容时显示，<br>修改后重新登录生效.</span>
			 </li>
			 <li>
			 <label>角色：</label>
			 <select  name="roleid" size="1">
			   <?php 
				 foreach($roles as $val){
					$str = $val['roleid']==$data['roleid'] ? 'selected="selected"' : '';
					echo '<option value="'.$val['roleid'].'" '.$str.'>'.$val['rolename'].'</option>';
				 }
			   ?>			
			 </select>
			 </li>
		</ul>
		<div class="footer_btn">
			<input type="hidden" name="dosubmit" value="1">
			<input type="hidden" name="adminid" value="<?php echo $data['adminid'];?>">
			<input class="btn btn-primary radius" type="submit" value="提 交">
			<input class="btn btn-default radius" type="button" value="取 消" onclick="yzmcms_close()">	
		</div>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer');?>

<script type="text/javascript">
	function dosub(obj){
		if(obj.password.value!=''){
				if(obj.password.value.length < 6 || obj.password.value.length > 20){
					layer.msg('密码长度为6-20位！', {icon:2});
					return false;
				}
				if(obj.password.value!==obj.password2.value){
					layer.msg('两次密码值不相等！', {icon:2});
					return false;
				}
		 }
        $.ajax({
            type: 'POST',
            url: '<?php echo U('edit');?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:800}, function(){
						parent.location.reload();
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>