<%@ 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/adminList" method="post" class="breadcrumb form-search">
		<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/adminList/add?id=${schoolId}" class="btn btn-primary">新建</a>
            &nbsp;
            <input id="btnCancel" class="btn" type="button" value="返 回" onclick="backCtn();"/>
		</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}" 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>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
<script type="text/javascript">

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/admin/view/${schoolId}';
    }else {
      alert(obj.message);
    }
  })
}
function backCtn() {
  window.location.href='/admin/sys/school';
}
</script>	
</body>
</html>