<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>学校管理员信息</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
</head>
<body>
	<form id="searchForm"  action="${ctx}/admin/sys/school/user" method="post" class="breadcrumb form-search">
		<input type="hidden" id="pageNumber" name="pageNumber" value="${query.pageNumber}"/>
		<input type="hidden" id="pageSize" name="pageSize" value="${query.pageSize}"/>
		<div>
			<label>登录账号</label>
			<input type="text" name="loginName" value="${query.loginName}"  maxlength="20" class="input-medium"/>
			&nbsp;&nbsp;&nbsp;&nbsp;
            <label>登录名</label>
            <input type="text" name="name" value="${query.name}"  maxlength="20" class="input-medium"/>
			&nbsp;
			<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
			&nbsp;
			<a href="${ctx}/admin/sys/school/user/add" class="btn btn-primary">新建</a>
		</div>
	</form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>登录账号</th>
				<th>登录名</th>
				<th>最后一次访问时间</th>
                <th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${query.result}" var="user">
			<tr>
				<td>${user.loginName}</td>
				<td>${user.name}</td>
				<td>${user.lastLoginTime}</td>
				<td>${user.status eq 1 ? "启用" : "禁用"}</td>
				<td>
					<a href="#" onclick="reSetPW(${user.id});">重置密码</a>
					&nbsp;
                    <c:if test="${user.status==1}">
                        <a href="javascript:void(0)" onclick="setStartOrStop(${user.status},${user.id},0);">禁用</a>
                    </c:if>
                    <c:if test="${user.status==0}">
                        <a href="javascript:void(0)" onclick="setStartOrStop(${user.status},${user.id},1);">启用</a>
                    </c:if>
                    &nbsp;
                    <a href="${ctx}/admin/sys/school/user/edit?id=${user.id}">管理学校</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${query}</div>
<script type="text/javascript">
function page(n,s){
	$("#pageNumber").val(n);
	$("#pageSize").val(s);
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#pageSize").val('${query.pageSize}');
	$("#searchForm").submit();
	return false;
}
function reSetPW(userId) {
  $.post('${ctx}/admin/sys/school/adminList/reSetPW',{userId:userId},function(obj){
    if(obj.success){
      alert("重置成功！");
    }else{
      alert(obj.message);
    }
  })
}
function setStartOrStop(status,userId,type){
  $.post('${ctx}/admin/sys/school/adminList/update',{userId:userId,status:type},function(obj){
    if(obj.success){
      alert("修改成功！");
      window.location.href='${ctx}/admin/sys/school/user';
    }else {
      alert(obj.message);
    }
  })
}
</script>	
</body>
</html>