<%@ 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/exam-admin.jsp"%>
	<div data-options="region:'center',title:'首页 - 【考试管理】 - 考生导入'">
		<div class="easyui-layout" data-options="fit:true,border:false">
			<div class="border" data-options="region:'center'">
			
				<ul class="nav nav-tabs">
					<li class="active"><a href="#manual-div" data-toggle="tab">手工录入</a></li>
					<li><a href="#import-div" data-toggle="tab">EXCEL导入</a></li>
					<li><a href="#library-div" data-toggle="tab">学生库导入</a></li>
				</ul>
				<div class="tab-content">
						<div class="tab-pane active change" id="manual-div">
							<form id="single-import-form" class="form-horizontal" action="${ctx}/admin/exam-param/student/single-import" method="post">
								<input type="hidden" name="examId" value="${examId}"/>
								<%-- <input type="hidden" name="schoolId" value="${schoolId}"/> --%>
								<c:if test="${web_user.roleMap['department_admin']!=null }">
									<div class="control-group">
										<label class="control-label" for="">学校</label>
										<div class="controls">
											<select name="schoolId" class="span2">
												<c:forEach var="school" items="${schoolList}">
													<option value="${school.id}">${school.name}</option>
												</c:forEach>
											</select>
											<span class="help-inline"></span>
										</div>
									</div>
								</c:if>
								<div class="control-group">
									<label class="control-label" for="">准考证号</label>
									<div class="controls">
										<input type="text" name="examNumber" class="info-input required-input"/>
										<span class="help-inline"></span>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="">姓名</label>
									<div class="controls">
										<input type="text" name="name" class="info-input required-input"/>
										<span class="help-inline"></span>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="">班级代码</label>
									<div class="controls">
										<input type="text" name="classCode" class="info-input required-input"/>
										<span class="help-inline"></span>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="">文理科</label>
									<div class="controls">
										<select name="classTypeValue">
										<c:forEach var="classType" items="${classTypeList}">
											<option value="${classType.value}">${classType.name}</option>
										</c:forEach>
										</select>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="">应往届</label>
									<div class="controls">
										<select name="graduateTypeValue">
										<c:forEach var="graduateType" items="${graduateTypeList}">
											<option value="${graduateType.value}">${graduateType.name}</option>
										</c:forEach>
										</select>
									</div>
								</div>
								<div class="control-group">
									<div class="controls">
										<a class="btn btn-primary submit-button" href="#">保存</a> 
										<a class="btn" href="${ctx}/admin/exam-param/student">返回</a>
									</div>
								</div>
							</form>
						</div>
						<div class="tab-pane leading-in" id="import-div">
							<form id="excel-import-form" class="form-horizontal" action="${ctx}/admin/exam-param/student/excel-import" method="post" enctype="multipart/form-data">
								<input type="hidden" name="examId" value="${examId}"/>
								<input type="hidden" name="schoolId" value="${schoolId}"/>
								<div class="control-group">
									<label class="control-label" for="">模板文件</label>
									<div class="controls">
										<c:if test="${isDepartment==true }">
										<a class="btn btn-success" type="button" href="${properties['download.server']}/template-area.xls" target="_blank">
											<i class="icon-arrow-down icon-white"></i>下载
										</a>
										</c:if>
										<c:if test="${isSchool==true }">
										<a class="btn btn-success" type="button" href="${properties['download.server']}/template-school.xls" target="_blank">
											<i class="icon-arrow-down icon-white"></i>下载
										</a>
										</c:if>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="">上传文件</label>
									<div class="controls">
										<input name="sourceFile" type="file"/>
									</div>
								</div>
								<div class="controls">
									<a class="btn btn-primary submit-button">提交</a>
									<a class="btn" href="${ctx}/admin/exam-param/student">返回</a>
								</div>
							</form>
						</div>
						<div class="tab-pane leading-in" id="library-div">
							<form id="batch-import-form" class="form-horizontal" action="${ctx}/admin/exam-param/student/batch-import" method="post">
								<input type="hidden" name="examId" value="${examId}"/>
								<input type="hidden" name="schoolId" value="${schoolId}"/>
								<input type="hidden" name="classCode" value=""/>
								<input type="hidden" name="schoolLevelValue" value=""/>
								<input type="hidden" name="graduateYear" value=""/>
								<div class="control-group">
									<label class="control-label" for="">年级选择</label>
									<div class="controls">
										<select name="gradeSelect">
											<option value="">请选择</option>
										<c:forEach var="grade" items="${gradeList}">
											<option value="${grade.schoolLevel}-${grade.graduateYear}">${grade.name}</option>
										</c:forEach>
										</select>
									</div>
								</div>
								<div class="control-group" id="class-select-div" style="display:none">
									<label class="control-label" for="">班级选择</label>
									<div class="controls">
										<span class="controls-list span5"> 
										</span>
									</div>
								</div>
								<div class="control-group">
									<div class="controls">
										<a class="btn btn-primary submit-button" href="#">导入</a> 
										<a class="btn" href="${ctx}/admin/exam-param/student">返回</a>
									</div>
								</div>
							</form>
						</div>
					</div>
			
				<%-- <div class="easyui-tabs">
					<div class="padding10" title="手动录入">
						<form id="single-import-form" class="form-horizontal" action="${ctx}/admin/exam-param/student/single-import" method="post">
							<input type="hidden" name="examId" value="${examId}"/>
							<input type="hidden" name="schoolId" value="${schoolId}"/>
							<div class="control-group">
								<label class="control-label" for="">准考证号</label>
								<div class="controls">
									<input type="text" name="examNumber" class="info-input required-input"/>
									<span class="help-inline"></span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="">姓名</label>
								<div class="controls">
									<input type="text" name="name" class="info-input required-input"/>
									<span class="help-inline"></span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="">班级代码</label>
								<div class="controls">
									<input type="text" name="classCode" class="info-input required-input"/>
									<span class="help-inline"></span>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="">文理科</label>
								<div class="controls">
									<select name="classTypeValue">
									<c:forEach var="classType" items="${classTypeList}">
										<option value="${classType.value}">${classType.name}</option>
									</c:forEach>
									</select>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="">应往届</label>
								<div class="controls">
									<select name="graduateTypeValue">
									<c:forEach var="graduateType" items="${graduateTypeList}">
										<option value="${graduateType.value}">${graduateType.name}</option>
									</c:forEach>
									</select>
								</div>
							</div>
							<div class="control-group">
								<div class="controls">
									<a class="btn btn-primary submit-button" href="#">保存</a> 
									<a class="btn" href="${ctx}/admin/exam-param/student">返回</a>
								</div>
							</div>
						</form>
					</div>
					<div class="padding10" title="EXCEL导入">
						<form id="excel-import-form" class="form-horizontal" action="${ctx}/admin/exam-param/student/excel-import" method="post" enctype="multipart/form-data">
							<input type="hidden" name="examId" value="${examId}"/>
							<input type="hidden" name="schoolId" value="${schoolId}"/>
							<div class="control-group">
								<label class="control-label" for="">模板文件</label>
								<div class="controls">
									<a class="btn btn-success" type="button" href="${properties['download.server']}/考生导入模板.xls" target="_blank">
										<i class="icon-arrow-down icon-white"></i>下载
									</a>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="">上传文件</label>
								<div class="controls">
									<input name="sourceFile" type="file"/>
								</div>
							</div>
							<div class="controls">
								<a class="btn btn-primary submit-button">提交</a>
								<a class="btn" href="${ctx}/admin/exam-param/student">返回</a>
							</div>
						</form>
					</div>
					<div class="padding10" title="学生库导入">
						<form id="batch-import-form" class="form-horizontal" action="${ctx}/admin/exam-param/student/batch-import" method="post">
							<input type="hidden" name="examId" value="${examId}"/>
							<input type="hidden" name="schoolId" value="${schoolId}"/>
							<input type="hidden" name="classCode" value=""/>
							<input type="hidden" name="schoolLevelValue" value=""/>
							<input type="hidden" name="graduateYear" value=""/>
							<div class="control-group">
								<label class="control-label" for="">年级选择</label>
								<div class="controls">
									<select name="gradeSelect">
										<option value="">请选择</option>
									<c:forEach var="grade" items="${gradeList}">
										<option value="${grade.schoolLevel}-${grade.graduateYear}">${grade.name}</option>
									</c:forEach>
									</select>
								</div>
							</div>
							<div class="control-group" id="class-select-div" style="display:none">
								<label class="control-label" for="">班级选择</label>
								<div class="controls">
									<span class="controls-list span5"> 
									</span>
								</div>
							</div>
							<div class="control-group">
								<div class="controls">
									<a class="btn btn-primary submit-button" href="#">导入</a> 
									<a class="btn" href="${ctx}/admin/exam-param/student">返回</a>
								</div>
							</div>
						</form>
					</div>
				</div> --%>
				
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
$(document).ready(function() {
	$('.nav-tabs a').click(function (e) {
		e.preventDefault();
		$(this).tab('show');
	});
	$('.class-select').live("click", function(){
		$(this).toggleClass('curr');
	});
	$('.info-input').keyup(function(){
		validInfoInput($(this));
	});
	$('#batch-import-form select[name="gradeSelect"]').change(function(){
		var value = $(this).val();
		$('#batch-import-form .controls-list').empty(); 
		if(value!=''){
			var values = value.split('-');
			$('#batch-import-form input[name="schoolLevelValue"]').val(values[0]);
			$('#batch-import-form input[name="graduateYear"]').val(values[1]);
			$.post('${ctx}/admin/exam-param/student/classList', {schoolLevelValue: values[0], graduateYear: values[1]}, function(obj){
				if(obj!=undefined){
					$.each(obj, function(index, classCode){
						$('#batch-import-form .controls-list').append('<a class="class-select" href="#">'+classCode+'</a>');
					});
					$('#class-select-div').show();
				}
			})
		}else{
			$('#class-select-div').hide();
		}
	});
	$('#single-import-form .submit-button').click(function(){
		var flag = true;
		$('#single-import-form input.info-input').each(function(index, obj){
			flag = validInfoInput($(obj)) && flag;
		});
		if(flag){
			$('#single-import-form').submit();
		}
	});
	$('#excel-import-form .submit-button').click(function(){
		var file = $('#excel-import-form input[name="sourceFile"]').val();
		if(file==undefined || file==''){
			alert("请选择上传文件");
			return;
		}
		if(!file.endWith('xls')){
			alert("上传文件扩展名不是xls");
			return;
		}
		$('#excel-import-form').submit();
	});
	$('#batch-import-form .submit-button').click(function(){
		var classCode = new Array();
		$('#class-select-div a.curr').each(function(index, obj){
			classCode.push($(obj).html());
		});
		if(classCode.length==0){
			alert('请选择班级');
			return;
		}
		$('#batch-import-form input[name="classCode"]').val(classCode.join(','));
		$('#batch-import-form').submit();
	});
});
</script>
</html>