<%@ 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" %>
	<%@include file="/WEB-INF/views/include/dialog.jsp" %>
	<style type="text/css">.sort{color:#0663A2;cursor:pointer;}</style>
</head>
<body>
	<%@include file="/WEB-INF/views/include/examInfoNavTabs.jsp" %>
	<form id="searchForm" action="${ctx}/admin/exam-param/subject/scan/list" method="post" class="breadcrumb form-search">
		<input type="hidden" id="pageNumber" name="pageNumber" />
		<input type="hidden" id="pageSize" name="pageSize" value="20"/>
		<div>
			<label>科目：</label>
			<select name="subjectCode">
				<option value="">请选择</option>
				<c:forEach items="${subjectList}" var="subject">
				<option value="${subject.code}" <c:if test="${subject.code==query.subjectCode}">selected</c:if>>${subject.code}-${subject.name}</option>
				</c:forEach>
			</select>
			&nbsp;<label>状态：</label>
			<select name="statusValue">
				<option value="">请选择</option>
				<c:forEach items="${statusList}" var="status">
				<option value="${status.value}" <c:if test="${status.value==statusValue}">selected</c:if>>${status.name}</option>
				</c:forEach>
			</select>
			&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
			&nbsp;
			<div class="btn-group">
  				<a class="btn btn-info dropdown-toggle" data-toggle="dropdown" href="#">批量操作
    			<span class="caret"></span>
  				</a>
  				<ul class="dropdown-menu">
					<li>
						<a href="${ctx}/admin/exam-param/subject/start-mark" class="batch-mark-button">开始评卷</a>
					</li>
					<li>
						<a href="${ctx}/admin/exam-param/subject/calculate" class="batch-calculate-button">开始统分</a>
					</li>
  				</ul>
			</div>
		</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>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${query.result}" var="subject">
			<tr>
				<td>${subject.examSubject.code}</td>
				<td>${subject.examSubject.name}</td>
				<td class="subject-status">${subject.status.name}</td>
				<td>
				<c:if test="${subject.markSubject!=null }">
				<a href="${ctx}/admin/exam-param/subject/mark/detail/${subject.subjectCode}">
				${subject.markSubject.status.name}
				</a>
				</c:if>
				</td>
				<td>${subject.totalCount}</td>
				<td>${subject.scanCount}</td>
				<td>
				<c:if test="${subject.scanCount>0 &&  subject.markSubject==null}">
				<a href="${ctx}/admin/exam-param/subject/start-mark?subjectCode=${subject.subjectCode}">开始评卷</a>
				</c:if>
				<c:if test="${subject.status.value==0}">
				<a href="#" class="end-scan-button" data-subject-code="${subject.subjectCode}">结束扫描</a>
				<a href="#" class="hide start-scan-button" data-subject-code="${subject.subjectCode}">开启扫描</a>
				</c:if>
				<c:if test="${subject.status.value==1}">
				<a href="#" class="hide end-scan-button" data-subject-code="${subject.subjectCode}">结束扫描</a>
				<a href="#" class="start-scan-button" data-subject-code="${subject.subjectCode}">开启扫描</a>
				</c:if>
				<c:if test="${subject.status.value==3}">
				<a href="#" class="calculate-button" data-subject-code="${subject.subjectCode}">开始统分</a>
				</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${query}</div>
<script type="text/javascript">
$('.end-scan-button').click(function(){
	var row =$(this).parent().parent();
	$.post("${ctx}/admin/exam-param/subject/end-scan",{subjectCode: $(this).attr('data-subject-code')},function(e){
		if(e.success){
			$.jBox.info("修改成功！");
			row.find('.subject-status').html(e.name);
			row.find('.end-scan-button').hide();
			row.find('.start-scan-button').show();
		}
	});
});
$('.start-scan-button').click(function(){
	var row =$(this).parent().parent();
	$.post("${ctx}/admin/exam-param/subject/start-scan",{subjectCode: $(this).attr('data-subject-code')},function(e){
		if(e.success){
			$.jBox.info("修改成功！");
			row.find('.subject-status').html(e.name);
			row.find('.start-scan-button').hide();
			row.find('.end-scan-button').show();
		}
	});
});
$('.calculate-button').click(function(){
	var row =$(this).parent().parent();
	$.post("${ctx}/admin/exam-param/subject/calculate?subjectCode="+$(this).attr('data-subject-code'),{},function(e){
		row.find('.subject-status').html('正在统分');
		row.find('.calculate-button').hide();
	});
});
function page(n,s){
	$("#pageNumber").val(n);
	$("#pageSize").val(s);
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#pageSize").val('${query.pageSize}');
	$("#searchForm").submit();
	return false;
}
</script>	
</body>
</html>