<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/taglib/c.tld" prefix="c"%>
<%@ include file="../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="../common/top.jsp"%>
</head>
<body class="easyui-layout">
	<%@ include file="../common/header.jsp"%>
	<%@ include file="../leftMenu/campus-admin.jsp"%>
	<div data-options="region:'center',title:'首页 -【基础数据维护】- 学生信息管理'">
		<div class="easyui-layout" data-options="fit:true,border:false">
			<div data-options="region:'north',border:false" class="domain">
				<%@ include file="../common/message.jsp"%>
				<form class="form-inline" action="${ctx}/admin/student/list" method="post" id="search-form">
					<input type="hidden" name="pageNumber" value="${query.pageNumber}" /> 
					<input type="hidden" name="pageSize" value="${query.pageSize}" /> 
					<span class="help-inline">学号：</span> 
					<input class="input-mini" type="text" id="studentCode" name="studentCode" value="${query.studentCode}"/> 
					<span class="help-inline">姓名：</span> 
					<input class="input-mini" type="text" id="studentName" name="studentName" value="${query.studentName}"/> 
					<span class="help-inline">班级：</span> 
					<select class="span2" name="classCode" id="classCode">
						<option value="">不限</option>
						<c:forEach items="${classes}" var="c">
							<option value="${c}" <c:if test="${query.classCode==c}">selected</c:if>>${c}</option>
						</c:forEach>
					</select> 
					<span class="help-inline">级别：</span> 
					<select class="span2" id="schoolLevel" name="schoolLevelValue" onchange="selectGY(this.value)">
						<option value="-1">请选择</option>
						<c:forEach items="${level}" var="l">
							<option value="${l.value}" <c:if test="${query.schoolLevel.value==l.value}">selected</c:if>>${l.name}</option>
						</c:forEach>
					</select> 
					<span class="help-inline">毕业年份：</span> 
					<select class="span2" id="graduateYear" name="graduateYear">
					</select>
					<button class="btn">
						<i class="icon-search"></i>&nbsp;查询
					</button>
					<a href='${ctx}/admin/student/add/${schoolId}' class="btn btn-primary">
						<i class="icon-plus icon-white"></i> 添加学生
					</a>
				</form>
			</div>
			<div class="border" data-options="region:'center'">
				<div class="table-container col8">
					<div class="tab-header">
						<i class="list-text"><strong>学籍号</strong></i>
						<i class="list-text"><strong>姓名</strong></i>
						<i class="list-text"><strong>班级</strong></i> 
						<i class="list-text"><strong>文理科</strong></i> 
						<i class="list-text"><strong>级别</strong></i>
						<i class="list-text"><strong>毕业年份</strong></i>
						<p class="list-edit"><strong>操作</strong></p>
					</div>
					<c:if test="${studentList!=null}">
					<c:forEach var="student" items="${studentList}">
					<div class="tab-list" data-id="${student.id}">
						<i class="list-text">${student.studentCode}</i>
						<i class="list-text">${student.name}</i>
						<i class="list-text">${student.classCode}</i>
						<i class="list-text">${student.classType.name}</i>
						<i class="list-text">${student.schoolLevel.name}</i>
						<i class="list-text">${student.graduateYear}</i>
						<p class="list-edit">
							<a href="#" class="btn btn-primary btn-small edit-button" onclick="edit(${student.id})">编辑</a> 
							<a href="#" class="btn btn-danger btn-small delete-button" onclick="del(${student.id})">删除</a>
						</p>
					</div>
					</c:forEach>
					</c:if>
					
					<c:set var="pageNumber" value="${query.pageNumber}"></c:set>
					<%@ include file="../common/paginator.jsp"%>
				</div>
			</div>	
		</div>
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function() {
		$('.pagination a').click(function(){
			var pageNumber = $(this).attr('data-page');
			if(pageNumber!=undefined && pageNumber>0){
				$('#search-form input[name="pageNumber"]').val(pageNumber);
				$('#search-form').submit();
			}
		});
		selectGY($('#schoolLevel option:selected').val());
	});

	function selectGY(level) {
		$('#graduateYear').empty();
		if (level != -1) {
			$.post('${ctx}/admin/student/selectgraduateyear.json', {
				level : level
			}, function(res) {
				$.each(res, function(n, obj) {
							var selected='${query.graduateYear}';
							var opt='';
							if(obj==selected){
								opt = $('<option value="'+obj+'" selected>' + obj + '</option>');
							}else{
								opt = $('<option value="'+obj+'">' + obj + '</option>');
							}
							$('#graduateYear').append(opt);
						});
			});
		}
	}
	
	function edit(studentId) {
		window.location.href = "${ctx}/admin/student/edit/" + studentId;
	}
	function del(studentId) {
		$.messager.confirm('删除', '确定删除这个学生吗?', function(r) {
			if (r) {
				window.location.href = "${ctx}/admin/student/delete/"
						+ studentId;
			}
		});
	}
</script>
</html>
