<%@ 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" %>
	<style type="text/css">.sort{color:#0663A2;cursor:pointer;}</style>
</head>
<body>
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/admin/exam-param/student/import" method="post" enctype="multipart/form-data"
			style="padding-left:20px;text-align:center;" class="form-search" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="考生信息导入"/>
			<a href="${ctx}/admin/exam-param/student/template">下载模板</a>
		</form>
	</div>
    <div id="breachImportBox" class="hide">
        <form id="breachImportForm" action="${ctx}/admin/exam-param/student/breachImport" method="post" enctype="multipart/form-data"
              style="padding-left:20px;text-align:center;" class="form-search" onsubmit="loading('正在导入，请稍等...');"><br/>
            <input id="breachUploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
            <input id="breachBtnImportSubmit" class="btn btn-primary" type="submit" value="违纪考生导入"/>
            <a href="${ctx}/admin/exam-param/student/breachTemplate">下载模板</a>
        </form>
    </div>
	<form id="searchForm"  action="${ctx}/admin/exam-param/student" 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="name" value="${query.name}"  maxlength="10" class="input-mini"/>
			<label>准考证号</label>
			<input type="text" name="examNumber" value="${query.examNumber}" maxlength="50" class="input-mini"/>
			<label>学号</label>
			<input type="text" name="studentCode" value="${query.studentCode}" maxlength="30" class="input-small"/>
            <label>专业类型</label>
            <select class="input-small" id="subjectCategory" name="subjectCategory">
                <option value="">请选择</option>
                <c:forEach items="${categoryList }" var="category">
                    <option value="${category}" <c:if test="${query.subjectCategory eq category }">selected</c:if>>${category}</option>
                </c:forEach>
            </select>
			<label>科目</label>
			<select class="input-large" id="subjectCode" name="subjectCode">
				<option value="">请选择</option>
				<c:forEach items="${subjectList }" var="subject">
					<option value="${subject.code }" <c:if test="${query.subjectCode eq subject.code }">selected</c:if>>${subject.code}-${subject.name}</option>
				</c:forEach>
			</select>
			<label>层次</label>
			<select class="input-small" id="subjectLevel" name="subjectLevel">
				<option value="">请选择</option>
				<c:forEach items="${levelList }" var="level">
					<option value="${level}" <c:if test="${query.subjectLevel eq level }">selected</c:if>>${level}</option>
				</c:forEach>
			</select>
            <br><br>
            <label>学习中心</label>
            <select class="input-large" id="campusName" name="campusName">
                <option value="">请选择...</option>
                <c:forEach items="${campusList }" var="campus">
                    <option value="${campus}" <c:if test="${query.campusName eq campus }">selected</c:if>>${campus}</option>
                </c:forEach>
            </select>

			
			<label>状态</label>
			<select id="upload" name="upload" class="input-small">
				<option value="">不限</option>
				<option value="1" <c:if test="${query.upload!=null && query.upload==true}">selected</c:if>>已上传</option>
				<option value="0" <c:if test="${query.upload!=null && query.upload==false}">selected</c:if>>未上传</option>
			</select>
			<select id="absent" name="absent" class="input-small">
				<option value="">不限</option>
				<option value="1" <c:if test="${query.absent!=null && query.absent==true}">selected</c:if>>缺考</option>
				<option value="0" <c:if test="${query.absent!=null && query.absent==false}">selected</c:if>>正常</option>
			</select>
			<select id="breach" name="breach" class="input-small">
				<option value="">不限</option>
				<option value="1" <c:if test="${query.breach!=null && query.breach==true}">selected</c:if>>违纪</option>
				<option value="0" <c:if test="${query.breach!=null && query.breach==false}">selected</c:if>>正常</option>
			</select>
			<label>签到表编号</label>
			<input type="text" name="packageCode" value="${query.packageCode}" maxlength="30" class="input-small"/>
			<label>批次编号</label>
			<input type="text" name="batchCode" value="${query.batchCode}" maxlength="30" class="input-small"/>
			<br><br>
			&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
			&nbsp;<a href="${ctx}/admin/exam-param/student/add" class="btn btn-primary">添加</a>
			&nbsp;<input id="btnImport" class="btn" type="button" value="导入"/>
			<c:if test="${query.totalCount>0 && query.totalCount<=10000}">
			&nbsp;<input id="export-button" class="btn" type="button" value="导出"/>
			</c:if>
            &nbsp;<input id="breachBtnImport" class="btn" type="button" value="违纪名单导入"/>
			<!-- &nbsp;<input id="clear-button" class="btn btn-danger" type="button" value="清空"/> -->
		</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>
				<th>专业类型</th>
				<th>学习中心</th>
				<th>状态</th>
				<th>批次编号</th>
				<th>签到表编号</th>
				<th>考试备注信息</th>
				<th>是否违纪</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${studentList}" var="student">
			<tr>
				<td>${student.examNumber}</td>
				<td>${student.name}</td>
				<td>${student.studentCode}</td>
				<td>${student.subjectCode}-${student.subjectName}&nbsp;${student.subjectRemark}</td>
				<td>${student.subjectLevel}</td>
				<td>${student.subjectCategory}</td>
				<td>${student.campusName}</td>
				<td>
				<c:if test="${student.upload==true}">
				    <a class="sheet-link" href="##" data-sheet-url="${student.sheetUrlString}" data-answer-url="<c:if test="${student.answerUrl!=null}">${cardServer}${student.answerUrl}</c:if>" data-title="${student.examNumber}&nbsp;&nbsp;${student.name}&nbsp;&nbsp;客观总分${student.objectiveScoreString}&nbsp;&nbsp;主观总分${student.subjectiveScoreString}&nbsp;&nbsp;全卷总分${student.totalScoreString}">已上传</a>
				    &nbsp;
				    <c:if test="${student.manualAbsent==true}">
				    人工指定
				    </c:if>
				    <c:if test="${student.absent==true}">
				    缺考
				    </c:if>
				    <c:if test="${student.absent==false}">
				    正常
				    </c:if>
				</c:if>
				
				<c:if test="${student.upload==false}">
				    未上传
				</c:if>

				</td>
				<td>${student.batchCode}</td>
				<td>
				<c:if test="${student.packageUrlString!=null && student.packageUrlString!=''}">
					<a class="package-link" href="##" data-image-url="${student.packageUrlString}" data-title="${student.packageCode}">${student.packageCode}</a>
				</c:if>
				<c:if test="${student.packageUrlString==null || student.packageUrlString==''}">
					${student.packageCode}
				</c:if>
				</td>
				<td>${student.examSite}&nbsp;${student.examRoom}</td>
                <td >
                    <c:if test="${student.breach==true}">
                        <a href="##" onclick="updateBreach(${student.id});">违纪</a>
                    </c:if>
                    <c:if test="${student.breach==false}">
                        正常
                    </c:if>
                </td>
				<td>
                    <c:if test="${student.upload==false}">
    				    <a href="${ctx}/admin/exam-param/student/update?id=${student.id}">修改</a>
                    </c:if>
					<a href="${ctx}/admin/exam-param/student/delete?id=${student.id}" onclick="return confirmx('确认要删除该考生吗？', this.href)">删除</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${query}</div>
	<%@include file="/WEB-INF/views/include/sheetView.jsp" %>
	<%@include file="/WEB-INF/views/include/imageView.jsp" %>
<script type="text/javascript">

$(document).ready(function() {
    $('.sheet-link').click(function(){
    	initSheetPopover($(this).attr('data-title'), '${imageServer}', $(this).attr('data-sheet-url'), $(this).attr('data-answer-url'));
    	return false;
    });
    $('.package-link').click(function(){
    	initImagePopover($(this).attr('data-title'), '${packageServer}', $(this).attr('data-image-url'));
    	return false;
    });
});

$('#packageCode').click(function(){
	console.log(1111);
	$('#collapse1 > div > ul > li:nth-child(5)').addClass('active');
});

$("#btnImport").click(function(){
	$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
		bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
});
$("#breachBtnImport").click(function(){
	$.jBox($("#breachImportBox").html(), {title:"导入数据", buttons:{"关闭":true},
		bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
});
$("#clear-button").click(function(){
	if(confirm('确定要删除当前的所有考生?')){
		$("#searchForm").attr("action","${ctx}/admin/exam-param/student/clear");
		$("#searchForm").submit();
	}
});
$("#export-button").click(function(){
	$("#searchForm").attr("action","${ctx}/admin/exam-param/student/export");
	$("#searchForm").submit();
});
function page(n,s){
	$("#pageNumber").val(n);
	$("#pageSize").val(s);
	$("#searchForm").attr("action","${ctx}/admin/exam-param/student");
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#pageSize").val('${query.pageSize}');
	$("#searchForm").attr("action","${ctx}/admin/exam-param/student");
	$("#searchForm").submit();
	return false;
}
function updateBreach(studentId) {
  top.$.jBox.confirm("确认要将该考生违纪重置为正常？","提示",function(v,h,f){
    if(v=="ok"){
      var url = '${ctx}/admin/exam-param/student/updateBreach?id='+studentId;
      $.ajax( {
        url : url,
        type : "POST",
        success : function(val) {
          if(val.success){
            window.location.href="${ctx}/admin/exam-param/student";
          }
        }})
    }
  });
}
</script>	
</body>
</html>