<%@ 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>
<form id="searchForm" action="${ctx}/admin/exam/score" 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>
        <input type="text" name="name" value="${query.name}" maxlength="10" class="input-mini"
                <c:if test="${(web_user.subjectHeader==true||web_user.schoolViewer==true) && forbiddenInfo==true}"> disabled="disabled"</c:if>/>
        <label>准考证号</label>
        <input type="text" name="examNumber" value="${query.examNumber}" maxlength="50" class="input-small"
                <c:if test="${(web_user.subjectHeader==true||web_user.schoolViewer==true) && forbiddenInfo==true}"> disabled="disabled"</c:if>/>
        <label>学号</label>
        <input type="text" name="studentCode" value="${query.studentCode}" maxlength="30" class="input-small"
                <c:if test="${(web_user.subjectHeader==true||web_user.schoolViewer==true) && forbiddenInfo==true}"> disabled="disabled"</c:if>/>
        <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" name="filter">
            <option value="0">无</option>
            <option value="1" <c:if test="${filter==1}">selected</c:if>>客观0分，主观有分</option>
            <option value="2" <c:if test="${filter==2}">selected</c:if>>客观有分，主观0分</option>
        </select>
        <br/><br/>
        <label>是否缺考</label>
        <select id="absent" name="absent" class="input-small">
            <option value="">不限</option>
            <option value="1" <c:if test="${query.absent!=null && query.absent==true}">selected</c:if>>缺考</option>
            <option value="0" <c:if test="${query.absent!=null && query.absent==false}">selected</c:if>>正常</option>
        </select>
        <label>是否上传</label>
        <select id="upload" name="upload" class="input-small">
            <option value="">不限</option>
            <option value="1" <c:if test="${query.upload!=null && query.upload==true}">selected</c:if>>已上传</option>
            <option value="0" <c:if test="${query.upload!=null && query.upload==false}">selected</c:if>>未上传</option>
        </select>
        <label>是否违纪</label>
        <select id="breach" name="breach" class="input-small">
            <option value="">不限</option>
            <option value="1" <c:if test="${query.breach!=null && query.breach==true}">selected</c:if>>违纪</option>
            <option value="0" <c:if test="${query.breach!=null && query.breach==false}">selected</c:if>>正常</option>
        </select>
        <br/><br/>
        <!--     总分 > startScore and 总分 <=endScore             -->
        <label>总分：从</label>
        <input type="text" number="true" id="startScore" name="startScore" value="${query.startScore}"
               class="input-mini"/>
        <label> 到&nbsp;&nbsp;&nbsp;</label>
        <input type="text" number="true" id="endScore" name="endScore" value="${query.endScore}" class="input-mini"/>

        <label>电厂</label>
        <input type="text" name="college" value="${query.college}" maxlength="64" class="input-mini"/>
        <label>机组</label>
        <input type="text" name="className" value="${query.className}" maxlength="64" class="input-mini"/>
        <label>总评</label>
        <input type="text" name="teacher" value="${query.teacher}" maxlength="64" class="input-mini"/>
        <label>考点</label>
        <input type="text" name="examSite" value="${query.examSite}" maxlength="64" class="input-mini"/>
        <label>考场</label>
        <input type="text" name="examRoom" value="${query.examRoom}" maxlength="64" class="input-mini"/>
        &nbsp;
        <input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
        &nbsp;
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_score-export')}">
            <%--  <input id="export-button" class="btn" type="button" value="导出" onclick="goExport()"
                    <c:if test="${!enableExport}">disabled</c:if> title="${exportMessage}"/> --%>
            <input id="export-button-2" class="btn" type="button" value="导出" onclick="goExport2()"
                   <c:if test="${!enableExport}">disabled</c:if> title="${exportMessage}"/>
        </c:if>
    </div>
</form>
<form id="exportForm" action="${ctx}/admin/exam/score/export" method="post" class="breadcrumb form-search hide">
    <input type="text" name="name" value="${query.name}" maxlength="10" class="input-mini"/>
    <input type="text" name="examNumber" value="${query.examNumber}" maxlength="50" class="input-small"/>
    <input type="text" name="studentCode" value="${query.studentCode}" maxlength="30" class="input-small"/>
    <input type="text" name="subjectCode" value="${query.subjectCode}" class="input-small"/>
    <input type="text" name="upload" value="${query.upload}" class="input-small"/>
    <input type="text" name="absent" value="${query.absent}" class="input-small"/>
    <input type="text" name="breach" value="${query.breach}" class="input-small"/>
    <input type="text" name="filter" value="${filter}" class="input-small"/>
    <input type="text" name="startScore" value="${query.startScore}" class="input-small"/>
    <input type="text" name="endScore" value="${query.endScore}" class="input-small"/>
    <input type="text" name="college" value="${query.college}" class="input-small"/>
    <input type="text" name="className" value="${query.className}" class="input-small"/>
    <input type="text" name="teacher" value="${query.teacher}" class="input-small"/>
    <input type="text" name="examSite" value="${query.examSite}" maxlength="64" class="input-mini"/>
    <input type="text" name="examRoom" value="${query.examRoom}" maxlength="64" class="input-mini"/>
</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>
        <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="student">
        <tr>
            <td>
                    <%--    <a href="##" class="detail-link" data-exam-number="${student.examNumber}">${student.examNumber}</a>  --%>
                <c:if test="${(web_user.subjectHeader==true||web_user.schoolViewer==true) && forbiddenInfo==true}">
                    ***
                </c:if>
                <c:if test="${web_user.schoolAdmin==true || forbiddenInfo==false}">
                    ${student.examNumber}
                </c:if>
            </td>
            <td>
                <c:if test="${(web_user.subjectHeader==true||web_user.schoolViewer==true) && forbiddenInfo==true}">
                    ***
                </c:if>
                <c:if test="${web_user.schoolAdmin==true || forbiddenInfo==false}">
                    ${student.name}
                </c:if>
            </td>
            <td>
                <c:if test="${(web_user.subjectHeader==true||web_user.schoolViewer==true) && forbiddenInfo==true}">
                    ***
                </c:if>
                <c:if test="${web_user.schoolAdmin==true || forbiddenInfo==false}">
                    ${student.studentCode}
                </c:if>
            </td>
            <td>${student.subjectCode}-${student.subjectName}&nbsp;${student.subjectRemark}</td>
            <td>${student.subjectLevel}</td>
            <td>${student.subjectCategory}</td>
            <td style="text-align: center;">
                <c:choose>
                    <c:when test="${student.absent == true || student.upload == false }">
                        -
                    </c:when>
                    <c:when test="${student.breach == true}">
                        0
                    </c:when>
                    <c:otherwise>
                        ${student.objectiveScoreString}
                    </c:otherwise>
                </c:choose>
            </td>
            <td style="text-align: center;">
                <c:choose>
                    <c:when test="${student.absent == true || student.upload == false }">
                        -
                    </c:when>
                    <c:when test="${student.breach == true}">
                        0
                    </c:when>
                    <c:otherwise>
                        ${student.subjectiveScoreString}
                    </c:otherwise>
                </c:choose>
            </td>
            <td style="text-align: center;">
                <c:choose>
                    <c:when test="${student.absent == true || student.upload == false }">
                        -
                    </c:when>
                    <c:when test="${student.breach == true}">
                        0
                    </c:when>
                    <c:otherwise>
                        ${student.totalScoreString}
                    </c:otherwise>
                </c:choose>
            </td>
            <td>
                <!--在成绩查询页面 未上传或者缺考的情况都判断为缺考情况 -->
                <c:if test="${student.absent == true || student.upload == false }">
                    缺考
                </c:if>
            </td>
            <td>
                <c:choose>
                    <c:when test="${student.upload == false }">
                        未上传
                    </c:when>
                    <c:otherwise>
                        已上传
                    </c:otherwise>
                </c:choose>
            </td>
            <td>
                <c:if test="${student.breach == true}">
                    违纪
                </c:if>
            </td>
            <td>${student.college}</td>
            <td>${student.className}</td>
            <td>${student.teacher}</td>
            <td>${student.examSite}</td>
            <td>${student.examRoom}</td>
            <td>
                <c:if test="${student.upload==true}">
                    <c:if test="${examType!='MULTI_MEDIA'}">
                        <c:if test='${web_user.schoolAdmin==true}'>
                            <a class="sheet-link" href="##" data-id="${student.id}"
                               data-sheet-url="${student.sheetUrlString}"
                               data-answer-url="<c:if test="${student.answerUrl!=null}">${fileServer}${student.answerUrl}</c:if>"
                               data-title="${student.examNumber}&nbsp;&nbsp;${student.name}&nbsp;&nbsp;客观总分${student.objectiveScoreString}&nbsp;&nbsp;主观总分${student.subjectiveScoreString}&nbsp;&nbsp;全卷总分${student.totalScoreString}">原图</a>
                        </c:if>
                        <a href="${ctx}/web/admin/exam/track/student?studentId=${student.id}&subjectCode=${student.subjectCode}"
                           target="_blank">轨迹图</a>
                    </c:if>
                    <c:if test="${examType=='MULTI_MEDIA'}">
                        <%--  <a class="json-link" href="${ctx}/admin/exam/library/getJson?studentId=${student.id}" target="_blank">原图</a> --%>
                        <a href="${ctx}/web/admin/exam/track/student?studentId=${student.id}&subjectCode=${student.subjectCode}"
                           target="_blank">原卷</a>
                    </c:if>
                </c:if>
                <c:if test="${student.packageUrlString!=null && student.packageUrlString!=''}">
                    <a class="package-link" href="##" data-image-url="${student.packageUrlString}"
                       data-title="${student.packageCode}">签到表</a>
                </c:if>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${query}</div>
<%@include file="/WEB-INF/views/include/sheetTagView.jsp" %>
<%@include file="/WEB-INF/views/include/imageView.jsp" %>
<script type="text/javascript">
    $(document).ready(function () {
        $("#searchForm").validate();

        $('.detail-link').click(function () {
            var url = '${ctx}/admin/exam/score/detail?examNumber=' + $(this).attr('data-exam-number') + '&queryString=' + encodeURIComponent($('#searchForm').serialize());
            window.location.href = url;
        });
        $('.sheet-link').click(function () {
            initSheetTagPopover($(this).attr('data-id'), $(this).attr('data-title'), '${fileServer}', $(this).attr('data-sheet-url'), $(this).attr('data-answer-url'));
            //initSheetPopover($(this).attr('data-title'), '', $(this).attr('data-sheet-url'));
            return false;
        });
        $('.package-link').click(function () {
            initImagePopover($(this).attr('data-title'), '${fileServer}', $(this).attr('data-image-url'));
            return false;
        });
        $('#subject-select').change(function () {
            let subjectCode = $('#subject-select').val();
            $.post('${ctx}/admin/exam/score/enableExport', {subjectCode: subjectCode}, function (result) {
                if (result.enableExport) {
                    $("#export-button").removeAttr("disabled");
                    $("#export-button").removeAttr("title");
                } else {
                    $("#export-button").attr("disabled", "disabled");
                    $("#export-button").attr("title", result.exportMessage);
                }
            });
        });
    });

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

    function goSearch() {
        var startScore = $("#startScore").val();
        var endScore = $("#endScore").val();
        if (startScore.length > 0) {
            if (endScore.length == 0) {
                alert("请输入结束分数值！");
                return false;
            }
        }
        if (endScore.length > 0) {
            if (startScore.length == 0) {
                alert("请输入开始分数值！");
                return false;
            }
        }
        if (endScore.length > 0 && startScore.length > 0) {
            if (parseInt(startScore) > parseInt(endScore)) {
                alert("开始分值必须小于结束分值");
                return false;
            }
        }
        $("#pageNumber").val(1);
        $("#pageSize").val('${query.pageSize}');
        $("#searchForm").attr('action', '${ctx}/admin/exam/score');
        $("#searchForm").submit();
        return false;
    }

    function goExport() {
        $("#exportForm").attr('action', '${ctx}/admin/exam/score/export');
        $("#exportForm").submit();
    }

    function goExport2() {
        $("#exportForm").attr('action', '${ctx}/admin/exam/score/export2');
        $("#exportForm").submit();
    }

</script>
</body>
</html>