<%@ 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>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/admin/exam/mark">评卷进度</a></li>
		<li><a href="${ctx}/admin/exam-param/markerInfo">评卷员一览</a></li>
	</ul>
	<form id="searchForm" action="${ctx}/admin/exam/mark" 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>
			<select class="input-large" name="code">
				<c:if test="${web_user.type.value==5}">
					<c:forEach items="${subjectList}" var="subject">
						<c:if test="${subject.code==subjectCode}">
						<option value="${subject.code}" >${subject.code}-${subject.name}</option>
						</c:if>
					</c:forEach>
				</c:if>
				<c:if test="${web_user.type.value==0}">
					<option value="">请选择</option>
					<c:forEach items="${subjectList}" var="subject">
					<option value="${subject.code}" <c:if test="${subject.code==query.code}">selected</c:if>>${subject.code}-${subject.name}</option>
				</c:forEach>
				</c:if>
			</select>
			<label>层次</label>
			<select class="input-small" name="level" id="level-select">
				<option value="">请选择</option>
				<c:forEach items="${levelList}" var="level">
				<option value="${level}" data-level="${level}" <c:if test="${level==query.level}">selected</c:if>>${level}</option>
				</c:forEach>
			</select>
			<label>专业类型</label>
			<select class="input-small" name="category" id="category-select">
				<option value="">请选择</option>
				<c:forEach items="${categoryList}" var="category">
				<option value="${category}" <c:if test="${category==query.category}">selected</c:if>>${category}</option>
				</c:forEach>
			</select>
			<label>排序</label>
			<select name="sortField" class="input-small" data-field="${sortField}">
				<option value="">请选择</option>
				<option value="libraryCount" <c:if test="${sortField eq 'libraryCount'}">selected</c:if>>总数</option>
				<option value="markedCount" <c:if test="${sortField eq 'markedCount'}">selected</c:if>>完成数</option>
				<option value="leftCount" <c:if test="${sortField eq 'leftCount'}">selected</c:if>>剩余数</option>
			</select>
			<select name="sortOrder" class="input-small" data-order="${sortOrder}">
				<option value="">请选择</option>
				<option value="true" <c:if test="${sortOrder==true}">selected</c:if>>顺序</option>
				<option value="false" <c:if test="${sortOrder==false}">selected</c:if>>倒序</option>
			</select>
			<br/><br/>
			<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
			&nbsp;
			<a href="${ctx}/admin/exam/mark/check-count" class="btn">数量校对</a>
			&nbsp;
			<div class="btn-group">
				<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
					导出<span class="caret"></span>
				</a>
				<ul class="dropdown-menu">
					<li><a href="##" onclick="goExport()">整体进度</a></li>
					<li><a href="##" onclick="goExportMarker()">评卷员工作量</a></li>
				</ul>
			</div>
			<!-- 
			&nbsp;
			<c:if test="${query.currentCount>0}">
			 <a href="${ctx}/admin/exam/mark/reset" class="btn btn-danger reset-button" data-subject="">重置</a>
			</c:if>
			-->
			&nbsp;
			<input id="btnProgress" class="btn" type="button" value="总进度：${percent}%"/>
		</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>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${resultList}" var="result">
			<tr>
				<td>${result.subject.code}-${result.subject.name}&nbsp;${result.subject.remark}</td>
				<td>${result.subject.status.name}</td>
				<td>${result.totalCount}</td>
				<td>${result.markedCount}</td>
				<td>${result.leftCount}</td>
				<td>${result.currentCount}</td>
				<td>
				${result.percent}%
				<!-- 
					<c:if test="${result.totalCount==0}">
						0%
					</c:if>
					<c:if test="${result.totalCount>0}">
						<fmt:formatNumber minFractionDigits="3" type="PERCENT" value="${result.markedCount*1.0/result.totalCount}"/>
					</c:if>
					 -->
				</td>
				<td>
					<c:if test="${result.subject.status.value==0}">
					<a href="${ctx}/admin/exam/mark/toggle?enable=false&subjectCode=${result.subject.code}&pageNumber=${query.pageNumber}">暂停</a>
					</c:if>
					<c:if test="${result.subject.status.value==1}">
					<a href="${ctx}/admin/exam/mark/toggle?enable=true&subjectCode=${result.subject.code}&pageNumber=${query.pageNumber}">继续</a>
					</c:if>
					<c:if test="${result.currentCount>0}">
					<a href="${ctx}/admin/exam/mark/release?subjectCode=${result.subject.code}&pageNumber=${query.pageNumber}">回收</a>
					</c:if>
					<c:if test="${result.totalCount>0}">
					<a href="${ctx}/admin/exam/mark/reset?subjectCode=${result.subject.code}&pageNumber=${query.pageNumber}" data-subject="${result.subject.name}" class="reset-button">重置</a>
					</c:if>
					<a href="${ctx}/admin/exam-param/marker/progress?subjectCode=${result.subject.code}">评卷员进度</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${query}</div>
<script type="text/javascript">
$('.reset-button').click(function(){
	var subject = $(this).attr('data-subject');
	if(subject==''){
		subject='所有科目';
	}
	return confirm('确定要重置'+subject+'的评卷任务吗?');
});
function page(n,s){
	$("#pageNumber").val(n);
	$("#searchForm").attr('action', '${ctx}/admin/exam/mark');
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#searchForm").attr('action', '${ctx}/admin/exam/mark');
	$("#searchForm").submit();
	return false;
}
function goExport(){
	$("#searchForm").attr('action', '${ctx}/admin/exam/mark/export');
	$("#searchForm").submit();
	return false;
}
function goExportMarker(){
	$("#searchForm").attr('action', '${ctx}/admin/exam/mark/export-marker');
	$("#searchForm").submit();
	return false;
}
</script>	
</body>
</html>