<%@ 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"%>
<script type="text/javascript">
        $(document).ready(function () {
         	$("#uploadFile").change(function (e) {
         		var ob=e.currentTarget.files[0];
                var size = ob.size;
                var name=ob.name.toLowerCase();
               	if(!name.endsWith(".xls")&&!name.endsWith(".xlsx")){
               		alert("仅允许导入“xls”或“xlsx”格式文件");
                	$("#uploadFile").val(null);
                	return;
               	}
                if(size>10485760){
                	alert("文件大小不能超过10M");
                	$("#uploadFile").val(null);
                	return;
                }
            }); 
            $("#inputForm").validate({
                submitHandler: function (form) {
                	$("#btnSubmit").attr("disabled","disabled")
                    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>
</head>
<body>
	<form:form id="inputForm" action="${ctx}/admin/exam/subject/split/save"
		method="post" class="form-horizontal" enctype="multipart/form-data">
		<tags:message content="${message}" />
		<tags:message content="${errmsg}" type="error" />
		<input type="hidden" id="schoolId" name="schoolId" value="${schoolId}" />
		<div class="control-group">
			<label class="control-label">名称</label>
			<div class="controls">
				<input type="text" disabled="disabled" id="schoolName"
					name="schoolName" value="${schoolName}" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">考试</label>
			<div class="controls">
				<select class="input-large required" name="examId" id="examId">
					<option value="" selected="selected">请选择考试</option>
					<c:forEach items="${examList}" var="item">
						<option <c:if test="${item.id==examId}">selected</c:if>
							value="${item.id}">${item.id}-${item.name}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">导入拆分表</label>
			<div class="controls">
				<input id="uploadFile" name="file" type="file" style="width: 210px"
					class="required" accept=".xls,.xlsx" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"></label>
			<div class="controls">
				<a href="${ctx}/admin/exam/subject/split/template">下载模板</a>
				<c:if test="${errmsgFile!=null}">
					<a href="${ctx}/admin/exam/subject/split/err" style="margin-left: 50px">error.txt</a>
				</c:if>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit"
				value="导入" /> &nbsp; <a href="${ctx}/admin/sys/school" class="btn">返回</a>
		</div>
	</form:form>
</body>
</html>
