<%@ 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="##">打回卷</a></li>
    <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_reject_list-history')}">
    <li><a href="${ctx}/admin/exam/reject/history">打回记录</a></li>
    </c:if>
</ul>
<form id="searchForm" action="${ctx}/admin/exam/reject/list" 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="subjectCode" id="subject-select">
            <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>
        <label>分组</label>
        <select class="input-medium" id="group-select" name="groupNumber">
            <option value="">请选择</option>
            <c:forEach items="${groupList}" var="item">
                <option value="${item.number}" <c:if test="${item.number==query.groupNumber}">selected</c:if>>${item.number}-${item.title}</option>
            </c:forEach>
        </select>
        <label>打回原因</label>
        <select class="input-small" id="reason-select" name="rejectReason">
            <option value="">不限</option>
            <option value="给分较高" <c:if test="${query.rejectReason=='给分较高'}">selected</c:if>>给分较高</option>
            <option value="给分较低" <c:if test="${query.rejectReason=='给分较低'}">selected</c:if>>给分较低</option>
            <option value="判分错误" <c:if test="${query.rejectReason=='判分错误'}">selected</c:if>>判分错误</option>
            <option value="其它" <c:if test="${query.rejectReason=='其它'}">selected</c:if>>其它</option>
        </select>
        <label>评卷员</label>
        <select class="input-medium" id="marker-select" name="markerId">
            <option value="0">不限</option>
            <c:forEach items="${markerList}" var="item">
                <option value="${item.id}" <c:if test="${item.id==query.markerId}">selected</c:if>>${item.loginName}</option>
            </c:forEach>
        </select>
        <label>打回人</label>
        <select class="input-medium" id="rejecter-select" name="headerId">
            <option value="0">不限</option>
            <c:forEach items="${headerList}" var="item">
                <option value="${item.id}" <c:if test="${item.id==query.headerId}">selected</c:if>>${item.loginName}</option>
            </c:forEach>
        </select>
        &nbsp;
        <input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
    </div>
</form>
<tags:message content="${message}"/>
<form id="restForm" action="${ctx}/admin/exam/problem/history/restBatch" method="post" class="breadcrumb form-search">
<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>
        <th>打回时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${query.result}" var="result">
        <tr>
            <td>${result.subject.code}-${result.subject.name}</td>
            <td>${result.groupNumber}-${result.title}</td>
            <td>
            	<c:if test="${web_user.subjectHeader==true && forbiddenInfo==true}">
	            ***
	            </c:if>
	            <c:if test="${web_user.schoolAdmin==true || forbiddenInfo==false}">
	            ${result.examNumber}
	            </c:if>
            </td>
            <td>${result.secretNumber}</td>
            <td>${result.rejectReason}</td>
            <td>${result.markerLoginName}</td>
            <td>${result.markerScoreList}</td>
            <td>${result.headerLoginName}</td>
            <td>
            	<c:if test="${result.headerTime!=null}">
	                    <fmt:formatDate value="${result.headerTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
	            </c:if>
            </td>
            <td>
               	<a href="${ctx}/web/admin/exam/track/library?libraryId=${result.id}&subjectCode=${result.subjectCode}" target="_blank">试卷详情</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</form>
<div class="pagination">${query}</div>
<%@include file="/WEB-INF/views/include/trackView.jsp" %>
<script type="text/javascript">
    $(document).ready(function () {
        $('.track-link').click(function () {
            initTrackPopover($(this).attr('data-title'), $(this).attr('data-image-url'));
            return false;
        });
        $('#subject-select').change(function () {
            var code = $(this).val();
            $('#group-select').empty();
            if (code == '') {
                $('#group-select').val('').trigger('change');
                $('#marker-select').empty();
                $('#marker-select').append('<option value="0">不限</option>');
                $('#marker-select').val('0').trigger('change');
                $('#rejecter-select').empty();
                $('#rejecter-select').append('<option value="0">不限</option>');
                $('#rejecter-select').val('0').trigger('change');
                return;
            }

            $.post('${ctx}/admin/exam/group/query', {subjectCode: code, status: 'FORMAL'}, function (result) {
                var parent = $('#group-select');
                var first = '';
                $('<option value="">请选择</option>').appendTo(parent);
                for (var i = 0; i < result.length; i++) {
                    var group = result[i];
                    $('<option value="' + group.number + '">' + group.number + '-' + group.title + '</option>').appendTo(parent);
                    /* if (i == 0) {
                        first = group.number;
                    } */
                }
               parent.val(first).trigger('change');
            });
            
            $('#marker-select').empty();
            $('#marker-select').append('<option value="0">不限</option>');
            $('#marker-select').val('0').trigger('change');
            $.post('${ctx}/admin/exam/marker/query', {subjectCode: code}, function (result) {
                var parent = $('#marker-select');
                var first = '';
                for (var i = 0; i < result.length; i++) {
                    var marker = result[i];
                    $('<option value="' + marker.id + '">' + marker.loginName + '</option>').appendTo(parent);
                    /* if (i == 0) {
                        first = marker.id;
                    } */
                }
            });
            
            $('#rejecter-select').empty();
            $('#rejecter-select').append('<option value="0">不限</option>');
            $('#rejecter-select').val('0').trigger('change');
            $.post('${ctx}/admin/exam/reject/user/query', {subjectCode: code}, function (result) {
                var parent = $('#rejecter-select');
                var first = '';
                for (var i = 0; i < result.length; i++) {
                    var marker = result[i];
                    $('<option value="' + marker.id + '">' + marker.loginName + '</option>').appendTo(parent);
                    /* if (i == 0) {
                        first = marker.id;
                    } */
                }
            });
            
        });
    });

    function page(n, s) {
        $("#pageNumber").val(n);
        $("#pageSize").val(s);
        $("#searchForm").attr('action', '${ctx}/admin/exam/reject/list');
        $("#searchForm").submit();
        return false;
    }

    function goSearch() {
        $("#pageNumber").val(1);
        $("#pageSize").val('${query.pageSize}');
        $("#searchForm").attr('action', '${ctx}/admin/exam/reject/list');
        $("#searchForm").submit();
        return false;
    }
</script>
</body>
</html>