<% if (tender.ledger_status === auditConst.status.checking && curAuditor.audit_id === ctx.session.sessionUser.accountId) { %>
<!--审批通过-->
<div class="modal fade" id="sp-done" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <form class="modal-content" action="/tender/<%- tender.id %>/ledger/audit/check" method="post">
            <div class="modal-header">
                <h5 class="modal-title">审批通过</h5>
            </div>
            <div class="modal-body">
                <div class="card mt-3">
                    <ul class="list-group list-group-flush">
                        <% for (let i = 0, iLen = auditors.length; i < iLen; i++) { %>
                        <li class="list-group-item" auditorId="<%- auditors[i].audit_id %>">
                            <% if (auditors[i].status !== auditConst.status.uncheck) { %>
                            <span class="<%- auditConst.statusClass[auditors[i].status] %> pull-right"><%- auditConst.statusString[auditors[i].status] %></span>
                            <% } %>
                            <h5 class="card-title"><%- auditors[i].audit_order %> <%- auditors[i].name %> <small class="text-muted"><%- auditors[i].role %></small></h5>
                            <% if (auditors[i].status === auditConst.status.checked) { %>
                            <p class="card-text"><%- auditors[i].opinion %> <%- auditors[i].end_time ? auditors[i].end_time.toLocaleString() : '' %></p>
                            <% } else if (auditors[i].status === auditConst.status.checking) { %>
                            <div class="form-group">
                                <label>审批意见<b class="text-danger">*</b></label>
                                <textarea class="form-control" name="opinion"></textarea>
                            </div>
                            <% } %>
                        </li>
                        <% } %>
                    </ul>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                <input type="hidden" name="_csrf" value="<%= ctx.csrf %>" />
                <input type="hidden" name="checkType" value="<%= auditConst.status.checked %>" />
                <button type="submit" class="btn btn-success" >确认通过</button>
            </div>
        </form>
    </div>
</div>
<!--审批退回-->
<div class="modal fade" id="sp-back" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <form class="modal-content" action="/tender/<%- tender.id %>/ledger/audit/check" method="post">
            <div class="modal-header">
                <h5 class="modal-title">审批退回</h5>
            </div>
            <div class="modal-body">
                <div class="card mt-3">
                    <ul class="list-group list-group-flush">
                        <% for (let i = 0, iLen = auditors.length; i < iLen; i++) { %>
                        <li class="list-group-item" auditorId="<%- auditors[i].audit_id %>">
                            <% if (auditors[i].status !== auditConst.status.uncheck) { %>
                            <span class="<%- auditConst.statusClass[auditors[i].status] %> pull-right"><%- auditConst.statusString[auditors[i].status] %></span>
                            <% } %>
                            <h5 class="card-title"><%- auditors[i].audit_order %> <%- auditors[i].name %> <small class="text-muted"><%- auditors[i].role %></small></h5>
                            <% if (auditors[i].status === auditConst.status.checked) { %>
                            <p class="card-text"><%- auditors[i].opinion %> <%- auditors[i].end_time ? auditors[i].end_time.toLocaleString() : '' %></p>
                            <% } else if (auditors[i].status === auditConst.status.checking) { %>
                            <div class="form-group">
                                <label>审批意见<b class="text-danger">*</b></label>
                                <textarea class="form-control" name="opinion"></textarea>
                            </div>
                            <% } %>
                        </li>
                        <% } %>
                    </ul>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                <input type="hidden" name="_csrf" value="<%= ctx.csrf %>" />
                <input type="hidden" name="checkType" value="<%= auditConst.status.checkNo %>" />
                <button type="submit" class="btn btn-warning" >确认退回</button>
            </div>
        </form>
    </div>
</div>
<% } else { %>
<!--审批流程/结果-->
<div class="modal fade" id="sp-list" data-backdrop="static">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">审批流程</h5>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-4">
                        <div class="card mt-3">
                            <ul class="list-group list-group-flush">
                                <li class="list-group-item">
                                    <i class="fa fa fa-play-circle fa-rotate-90"></i> <%- user.name %>  <small class="text-muted"><%- user.role %></small>
                                </li>
                                <% for (let i = 0; i < auditors.length; i++) { %>
                                <li class="list-group-item">
                                    <% if (i < auditors.length - 1) { %>
                                    <i class="fa fa-chevron-circle-down"></i> <%- auditors[i].name %>  <small class="text-muted"><%- auditors[i].role %></small>
                                    <% } else {%>
                                    <i class="fa fa fa-stop-circle"></i> <%- auditors[i].name %>  <small class="text-muted"><%- auditors[i].role %></small>
                                    <% } %>
                                </li>
                                <% } %>
                            </ul>
                        </div>
                    </div>
                    <div class="col-8 modal-height-500" style="overflow: auto">
                        <% for (const ah of auditHistory) { %>
                        <div class="card mt-3">
                            <ul class="list-group list-group-flush">
                                <% for (let iA = 0; iA < ah.length; iA++) { %>
                                    <% if (iA === 0) { %>
                                        <li class="list-group-item">
                                            <span class="text-success pull-right"><% if (auditHistory.indexOf(ah) > 0) { %>重新<% } %>上报</span>
                                            <h5 class="card-title"><i class="fa fa-play-circle fa-rotate-90 text-success"></i> <%- user.name %> <small class="text-muted"><%- user.role %></small></h5>
                                            <p class="card-text"><%- ah[iA].begin_time.toLocaleDateString() %></p>
                                        </li>
                                        <li class="list-group-item">
                                            <% if (ah[iA].status !== auditConst.status.uncheck) { %>
                                            <span class="<%- auditConst.statusClass[ah[iA].status] %> pull-right"><%- auditConst.statusString[ah[iA].status]%><% if (ah[iA].status === auditConst.status.checkNo) { %> <%- user.name %><% } %></span>
                                            <% } %>
                                            <h5 class="card-title"><i class="fa fa-chevron-circle-down <%- auditConst.statusClass[ah[iA].status] %>"></i> <%- ah[iA].name %> <small class="text-muted"><%- ah[iA].role %></small></h5>
                                            <% if (ah[iA].status === auditConst.status.checked || ah[iA].status === auditConst.status.checkNo) { %>
                                            <p class="card-text"><%- auditConst.statusString[ah[iA].status]%>，<%- ah[iA].opinion %>。<%- ah[iA].end_time.toLocaleDateString() %></p>
                                            <% } %>
                                        </li>
                                    <% } else if (iA === ah.length - 1) { %>
                                        <li class="list-group-item">
                                            <% if (ah[iA].status !== auditConst.status.uncheck) { %>
                                            <span class="<%- auditConst.statusClass[ah[iA].status] %> pull-right"><%- auditConst.statusString[ah[iA].status]%><% if (ah[iA].status === auditConst.status.checkNo) { %> <%- user.name %><% } %></span>
                                            <% } %>
                                            <h5 class="card-title"><i class="fa fa-stop-circle <%- auditConst.statusClass[ah[iA].status] %>"></i> <%- ah[iA].name %> <small class="text-muted"><%- ah[iA].role %></small></h5>
                                            <% if (ah[iA].status === auditConst.status.checked || ah[iA].status === auditConst.status.checkNo) { %>
                                            <p class="card-text"><%- auditConst.statusString[ah[iA].status]%>，<%- ah[iA].opinion %>。<%- ah[iA].end_time.toLocaleDateString() %></p>
                                            <% } %>
                                        </li>
                                    <% } else { %>
                                        <li class="list-group-item">
                                            <% if (ah[iA].status !== auditConst.status.uncheck) { %>
                                            <span class="<%- auditConst.statusClass[ah[iA].status] %> pull-right"><%- auditConst.statusString[ah[iA].status]%><% if (ah[iA].status === auditConst.status.checkNo) { %> <%- user.name %><% } %></span>
                                            <% } %>
                                            <h5 class="card-title"><i class="fa fa-chevron-circle-down <%- auditConst.statusClass[ah[iA].status] %>"></i> <%- ah[iA].name %> <small class="text-muted"><%- ah[iA].role %></small></h5>
                                            <% if (ah[iA].status === auditConst.status.checked || ah[iA].status === auditConst.status.checkNo) { %>
                                            <p class="card-text"><%- auditConst.statusString[ah[iA].status]%>，<%- ah[iA].opinion %>。<%- ah[iA].end_time.toLocaleDateString() %></p>
                                            <% } %>
                                        </li>
                                    <% } %>
                                <% } %>
                            </ul>
                        </div>
                        <% } %>
                        <% if (tender.ledger_status === auditConst.status.checking || tender.ledger_status === auditConst.status.checked) {%>
                        <div class="card mt-3">
                            <ul class="list-group list-group-flush">
                                <% for (let iA = 0; iA < auditors.length; iA++) { %>
                                    <% if (iA === 0) { %>
                                    <li class="list-group-item">
                                        <span class="text-success pull-right"><% if (tender.ledger_times > 1) { %>重新<% } %>上报</span>
                                        <h5 class="card-title"><i class="fa fa-play-circle fa-rotate-90 text-success"></i> <%- user.name %> <small class="text-muted"><%- user.role %></small></h5>
                                        <p class="card-text"><%- auditors[iA].begin_time.toLocaleDateString() %></p>
                                    </li>
                                    <li class="list-group-item">
                                        <% if (auditors[iA].status !== auditConst.status.uncheck) { %>
                                        <span class="<%- auditConst.statusClass[auditors[iA].status] %> pull-right"><%- auditConst.statusString[auditors[iA].status]%><% if (auditors[iA].status === auditConst.status.checkNo) { %> <%- user.name %><% } %></span>
                                        <% } %>
                                        <h5 class="card-title"><i class="fa fa-chevron-circle-down <%- auditConst.statusClass[auditors[iA].status] %>"></i> <%- auditors[iA].name %> <small class="text-muted"><%- auditors[iA].role %></small></h5>
                                        <% if (auditors[iA].status === auditConst.status.checked || auditors[iA].status === auditConst.status.checkNo) { %>
                                        <p class="card-text"><%- auditConst.statusString[auditors[iA].status]%>，<%- auditors[iA].opinion %>。<%- auditors[iA].end_time.toLocaleDateString() %></p>
                                        <% } %>
                                    </li>
                                    <% } else if (iA === auditors.length - 1) { %>
                                    <li class="list-group-item">
                                        <% if (auditors[iA].status !== auditConst.status.uncheck) { %>
                                        <span class="<%- auditConst.statusClass[auditors[iA].status] %> pull-right"><%- auditConst.statusString[auditors[iA].status]%><% if (auditors[iA].status === auditConst.status.checkNo) { %> <%- user.name %><% } %></span>
                                        <% } %>
                                        <h5 class="card-title"><i class="fa fa-stop-circle <%- auditConst.statusClass[auditors[iA].status] %>"></i> <%- auditors[iA].name %> <small class="text-muted"><%- auditors[iA].role %></small></h5>
                                        <% if (auditors[iA].status === auditConst.status.checked || auditors[iA].status === auditConst.status.checkNo) { %>
                                        <p class="card-text"><%- auditConst.statusString[auditors[iA].status]%>，<%- auditors[iA].opinion %>。<%- auditors[iA].end_time.toLocaleDateString() %></p>
                                        <% } %>
                                    </li>
                                    <% } else { %>
                                    <li class="list-group-item">
                                        <% if (auditors[iA].status !== auditConst.status.uncheck) { %>
                                        <span class="<%- auditConst.statusClass[auditors[iA].status] %> pull-right"><%- auditConst.statusString[auditors[iA].status]%><% if (auditors[iA].status === auditConst.status.checkNo) { %> <%- user.name %><% } %></span>
                                        <% } %>
                                        <h5 class="card-title"><i class="fa fa-chevron-circle-down <%- auditConst.statusClass[auditors[iA].status] %>"></i> <%- auditors[iA].name %> <small class="text-muted"><%- auditors[iA].role %></small></h5>
                                        <% if (auditors[iA].status === auditConst.status.checked || auditors[iA].status === auditConst.status.checkNo) { %>
                                        <p class="card-text"><%- auditConst.statusString[auditors[iA].status]%>，<%- auditors[iA].opinion %>。<%- auditors[iA].end_time.toLocaleDateString() %></p>
                                        <% } %>
                                    </li>
                                    <% } %>
                                <% } %>
                            </ul>
                        </div>
                        <% } %>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<% } %>