<?php include $this->admin_tpl('meta');?>
<title>管理员列表 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span> 管理员列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<div class="page-container">
	<div> 
		<form action="<?php echo U(ROUTE_A);?>" method="get">
			<input type="hidden" value="admin" name="m">
			<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
			<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">
			添加时间：<input type="text" class="input-text laydate-icon" style="width:175px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start'] != '') echo 'value="'.$_GET['start'].'"'; ?>>
			至 <input type="text" class="input-text laydate-icon" style="width:175px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end'] != '') echo $_GET['end']; else echo date('Y-m-d H:i:s'); ?>">
			<span class="select-box inline">
				<select name="roleid" class="select">
				<option value="0">角色</option>
				<?php foreach($role_data as $val){ ?>
				<option <?php if(isset($_GET['roleid']) && $_GET['roleid']==$val['roleid']){?> selected <?php }?> value="<?php echo $val['roleid'];?>"><?php echo $val['rolename'];?></option>
				<?php } ?>
				</select>
			</span>
			<span class="select-box inline">
				<select name="type" class="select">
				<option <?php if(isset($_GET['type']) && $_GET['type']=='1'){?> selected <?php }?> value="1">用户名</option>
				<option <?php if(isset($_GET['type']) && $_GET['type']=='2'){?> selected <?php }?> value="2">邮箱</option>	
				<option <?php if(isset($_GET['type']) && $_GET['type']=='3'){?> selected <?php }?> value="3">真实姓名</option>	
				<option <?php if(isset($_GET['type']) && $_GET['type']=='4'){?> selected <?php }?> value="4">添加人</option>	
				</select>
			</span>
			<input type="text" name="searinfo" class="input-text" style="width:170px" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success btn-search" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
			<a href="<?php echo U('init');?>" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</a>
		</form>	
	</div>
	<div class="cl mt-15 tb-top">
		<span class="l">
			<a href="javascript:;" onclick="yzm_open('添加管理员','<?php echo U('add');?>','600','420')" class="btn btn-primary radius"><i class="yzm-iconfont yzm-icontianjia"></i> 添加管理员</a>
			<a href="javascript:;" onclick="move_role()" class="btn btn-success radius"><i class="yzm-iconfont yzm-iconyidong"></i> 变更角色</a>
		</span>
	</div>
	<form action="" id="myform">
	<div id="show_pop" style="margin:20px 20px 0 20px;display:none">
		<select class="select" name="move_id" style="min-width:270px;height:30px;line-height:30px;display:block;">
			<?php foreach($role_data as $val){ ?>
			<option value="<?php echo $val['roleid'] ?>"><?php echo $val['rolename'] ?></option>
			<?php } ?>
		</select>
	</div>
	<table class="table table-border table-bg table-hover yzm-table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox"></th>
				<th>ID<?php echo field_order('adminid');?></th>
				<th>用户名<?php echo field_order('adminname');?></th>
				<th>真实姓名<?php echo field_order('realname');?></th>
				<th>邮箱<?php echo field_order('email');?></th>
				<th>角色<?php echo field_order('roleid');?></th>
				<th>添加时间<?php echo field_order('addtime');?></th>
				<th>最后登录时间<?php echo field_order('logintime');?></th>
				<th>最后登录IP<?php echo field_order('loginip');?></th>
				<th>添加人<?php echo field_order('addpeople');?></th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<?php 
			   foreach($data as $val){
			 ?>
			<tr class="text-c">
				<td><input type="checkbox" value="<?php echo $val['adminid']?>" name="id[]"></td>
				<td><?php echo $val['adminid'];?></td>
				<td>
					<?php echo $val['adminname'];?>
					<?php if($val['realname']){echo '<br>('.$val['realname'].')';} ?>	
				</td>
				<td><?php echo $val['realname'] ? $val['realname'] : '暂无';;?></td>
				<td><?php echo $val['email'] ? $val['email'] : '暂无';?></td>
				<td><?php echo $val['rolename'];?></td>
				<td><?php echo date('Y-m-d H:i:s',$val['addtime']);?></td>
				<td><?php echo $val['logintime'] ? date('Y-m-d H:i:s',$val['logintime']) : '从未登录';?></td>
				<td><?php echo $val['loginip'] ? $val['loginip'] : '从未登录';?></td>
				<td><?php echo $val['addpeople'];?></td>
				<td class="td-manage">
					<a title="编辑" href="javascript:;" onclick="yzm_open('管理员编辑','<?php echo U('edit',array('adminid'=>$val['adminid']));?>','600','420')" class="yzm-box-img btn-primary"><i class="yzm-iconfont yzm-iconbianji1"></i> 编辑</a> 
					<a title="删除" href="javascript:;" onclick="yzm_confirm('<?php echo U('delete',array('adminid'=>$val['adminid']));?>', '确定要删除【<?php echo $val['adminname'];?>】吗？', 1)" class="yzm-box-img btn-danger ml-5"><i class="yzm-iconfont yzm-iconshanchu2"></i> 删除</a>
				</td>
			</tr>
			<?php 
			   }		 
			?>	
		</tbody>
	</table>
	</form>
	<?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
	<div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
	<span class="page_right"><?php echo $page->getfull();?></span></div>
</div>
<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript">
	var start = {elem:'#start',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);

	function move_role() {
		if ($("input[name='id[]']:checked").length<1){
			layer.alert('请选择要操作的记录！', {title:"操作提示"});
			return false;
		}

		layer.open({
			type: 1,
			title: '变更角色',
			btn: ['确定', '取消'],
			content: $('#show_pop'),
			yes: function(index, layero){
			    $.ajax({
	               type: "POST",
	               url: "<?php echo U('change_role');?>", 
				   data: $("#myform").serialize(),
	   		       dataType: "json", 
	               success: function (msg) {
						if(msg.status == 1){
							layer.msg(msg.message, {icon:1,time:1000},function(){
								window.location.reload();
							});
						}else{
							layer.msg(msg.message, {icon:2,time:2500});
						}
	               }
	           })
			}
		});
	}
</script>
</body>
</html>