<%@ 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>
    <input hidden id="updateDate" value="${student.upload}" data-subjectcode="${student.subjectCode}" data-campusname="${student.campusName}" data-examnumber="${student.examNumber}"/>
	<form:form id="inputForm" modelAttribute="student" action="${ctx}/admin/exam-param/student/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">学习中心</label>
			<div class="controls">
				<form:select id="campusName" path="campusName" cssClass="required">
					<%-- <form:option value="0" label="不区分考试中心"/> --%>
					<form:options items="${campusList}" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">科目</label>
			<div class="controls">
				<select id="subjectCode" name="subjectCode">
				<c:forEach items="${subjectList }" var="subject">
					<option value="${subject.code }" <c:if test="${student.subjectCode eq subject.code }">selected</c:if>>${subject.code}-${subject.name}</option>
				</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">姓名</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">学号</label>
			<div class="controls">
				<form:input path="studentCode" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">准考证号</label>
			<div class="controls">
				<form:input id="examNumber" path="examNumber" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">签到表编号</label>
			<div class="controls">
				<form:input path="packageCode" htmlEscape="false" maxlength="200" class=""/>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<a href="${ctx}/admin/exam-param/student" class="btn">返回</a>
		</div>
	</form:form>
<script type="text/javascript">
	$(document).ready(function() {
		//$("#name").focus();
		$("#inputForm").validate({
			
			submitHandler: function(form){
				//alert("studentId="+$("#studentId").val()+" subjectCode="+$("#subjectCode").val());
                var subjectCode = $("#updateDate").attr("data-subjectcode");
                var campusname = $("#updateDate").attr("data-campusname");
                var examnumber = $("#updateDate").attr("data-examnumber");
                var upload = $("#updateDate").val();
                //||
                if(upload == 'true'){
                    if(subjectCode != $("#subjectCode").val() || campusname != $("#campusName").val()|| examnumber != $("#examNumber").val()){
                        top.$.jBox.confirm("修改考生信息后必须重新上传考生答题卡,是否确认保存？","系统提示",function(v,h,f){
                            if(v=="ok"){
                                loading('正在提交，请稍等...');
                                form.submit();
                            }else {
                                return;
                            }
                        })
                    }else {
                        loading('正在提交，请稍等...');
                        form.submit();
                    }
                }else {
                    loading('正在提交，请稍等...');
                    form.submit();
                }
			},
			errorContainer: "#messageBox",
			errorPlacement: function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
					error.appendTo(element.parent().parent());
				} else {
					error.insertAfter(element);
				}
			}
		});
	});
</script>	
</body>
</html>
