<!--导入清单Excel-->
<div class="modal fade" id="upload-ledger" data-backdrop="static" enctype="multipart/form-data">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">导入</h5>
            </div>
            <div class="modal-body">
                <p>请上传符合格式的 <b>0号台帐</b> 格式的 .xls和.xlsx 文件，<a id="downloadLedgerTemplate" href="/tender/<%- ctx.tender.id %>/ledger/download/template">下载示例</a>。</p>
                <div class="form-group">
                    <label for="exampleFormControlFile1">选择文件</label>
                    <input type="file" class="form-control-file" id="upload-ledger-file" accept="*.xls">
                </div>
                <div id="upload-ledger-sheets" style="display: none;">
                    <hr></hr>
                    <h6>选择导入的工作表</h6>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="upload-ledger-ok">确认上传</button>
            </div>
        </div>
    </div>
</div>
<!--上传签约清单-->
<div class="modal fade" id="upload-deal" data-backdrop="static" enctype="multipart/form-data">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">上传签约清单</h5>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label for="exampleFormControlFile1">Excel模板</label>
                    <div class="form-control"><a id="downloadDealTemplate" href="/tender/<%- ctx.tender.id %>/deal/download/template.xls" class="btn btn-sm btn-link">下载</a></div>
                </div>
                <div class="form-group">
                    <label for="exampleFormControlFile1">上传签约清单Excel文件</label>
                    <div class="form-control"><input type="file" class="form-control-file" id="deal-bills-file"></div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="upload-deal-bills">确认上传</button>
            </div>
        </div>
    </div>
</div>
<!--批量添加清单部位-->
<div class="modal fade" id="batch" 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-6">
                        <h6>清单信息</h6>
                        <div class="batch-l-t">
                        </div>
                        <h6>部位数量复核表</h6>
                        <div class="batch-l-b">
                        </div>
                    </div>
                    <div class="col-6">
                        <h6>签约清单</h6>
                        <div class="batch-r">
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="batch-ok">确定</button>
            </div>
        </div>
    </div>
</div>
<% if ((tender.ledger_status === auditConst.status.uncheck || tender.ledger_status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === tender.user_id) { %>
<!--上报审批-->
<div class="modal fade" id="sub-sp" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">上报审批</h5>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label>选择审批人</label>
                    <div class="input-group">
                        <div class="input-group-prepend">
                            <select class="form-control" id="account_group">
                                <option value="0">所有分组</option>
                                <% for (const dw in accountGroup) { %>
                                    <option value="<%= dw %>"><%= accountGroup[dw] %></option>
                                <% } %>
                            </select>
                        </div>
                        <select class="form-control" id="account_list">
                            <option value="0">选择审批人</option>
                            <% for (const account of accountList) { %>
                                <option value="<%= account.id %>"><%= account.name %><% if (account.role !== '') { %>（<%= account.role %>）<% } %><% if (account.company !== '') { %> -<%= account.company %><% } %></option>
                            <% } %>
                        </select>
                    </div>
                </div>
                <div class="card mt-3">
                    <div class="card-header">
                        审批流程
                    </div>
                    <ul class="list-group list-group-flush" id="auditors">
                        <% for (let i = 0, iLen = auditorList.length; i < iLen; i++) { %>
                        <li class="list-group-item" auditorId="<%- auditorList[i].audit_id %>">
                            <a href="javascript: void(0)" class="text-danger pull-right">移除</a>
                            <%- auditorList[i].audit_order %> <%- auditorList[i].name %>
                            <small class="text-muted"><%- auditorList[i].role %></small>
                        </li>
                        <% } %>
                    </ul>
                </div>
            </div>
            <form class="modal-footer" method="post" action="/tender/<%- tender.id %>/ledger/audit/start" onsubmit="return checkAuditorFrom()">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                <input type="hidden" name="_csrf" value="<%= ctx.csrf %>">
                <button class="btn btn-primary" type="submit">确认上报</button>
            </form>
        </div>
    </div>
</div>
<% } %>
<% if (tender.ledger_status === auditConst.status.checkNo && ctx.session.sessionUser.accountId === tender.user_id) { %>
<!--审批流程/结果-->
<div class="modal fade" id="sp-list2" 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">
                        <a href="#sub-sp" data-toggle="modal" data-target="#sub-sp" id="hideSp">修改审批流程</a>
                        <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>
                            </ul>
                            <ul class="list-group list-group-flush" id="auditors-list">
                                <% for (let i = 0; i < auditorList.length; i++) { %>
                                    <li class="list-group-item" data-auditid="<%- auditorList[i].audit_id %>">
                                        <% if (i < auditorList.length - 1) { %>
                                            <i class="fa fa-chevron-circle-down"></i> <%- auditorList[i].name %>  <small class="text-muted"><%- auditorList[i].role %></small>
                                        <% } else {%>
                                            <i class="fa fa fa-stop-circle"></i> <%- auditorList[i].name %>  <small class="text-muted"><%- auditorList[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"><small class="text-muted"><%- ah[iA].begin_time.toLocaleDateString() %></small></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 mb-1"><%- ah[iA].opinion %></p>
                                                    <p class="card-text"><small class="text-muted"><%- ah[iA].end_time.toLocaleDateString() %></small></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 mb-1"><%- ah[iA].opinion %></p>
                                                    <p class="card-text"><small class="text-muted"><%- ah[iA].end_time.toLocaleDateString() %></small></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 mb-1"><%- ah[iA].opinion %></p>
                                                    <p class="card-text"><small class="text-muted"><%- ah[iA].end_time.toLocaleDateString() %></small></p>
                                                <% } %>
                                            </li>
                                        <% } %>
                                    <% } %>
                                </ul>
                            </div>
                        <% } %>
                        <% if (tender.ledger_status === auditConst.status.checkNo) {%>
                            <div class="card mt-3">
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item">
                                        <span class="pull-right">重新上报中</span>
                                        <h5 class="card-title"><i class="fa fa-play-circle fa-rotate-90"></i> <%- user.name %> <small class="text-muted"><%- user.role %></small></h5>
                                        <p class="card-text"><small class="text-muted"></small></p>
                                    </li>
                                </ul>
                                <ul class="list-group list-group-flush" id="auditors-list2">
                                    <% for (let iA = 0; iA < auditorList.length; iA++) { %>
                                        <% if (iA === auditorList.length - 1) { %>
                                            <li class="list-group-item" data-auditid="<%- auditorList[iA].audit_id %>">
                                                <h5 class="card-title"><i class="fa fa-stop-circle"></i> <%- auditorList[iA].name %> <small class="text-muted"><%- auditorList[iA].role %></small></h5>
                                            </li>
                                        <% } else { %>
                                            <li class="list-group-item" data-auditid="<%- auditorList[iA].audit_id %>">
                                                <h5 class="card-title"><i class="fa fa-chevron-circle-down"></i> <%- auditorList[iA].name %> <small class="text-muted"><%- auditorList[iA].role %></small></h5>
                                            </li>
                                        <% } %>
                                    <% } %>
                                </ul>
                            </div>
                        <% } %>
                    </div>
                </div>
            </div>
            <form class="modal-footer" action="/tender/<%- tender.id %>/ledger/audit/start" method="post" onsubmit="return checkAuditorFrom()">
                <button type="submit" class="btn btn-primary">确认上报</button>
                <input type="hidden" name="_csrf" value="<%= ctx.csrf %>">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
            </form>
        </div>
    </div>
</div>
<% } %>
<% if ((tender.ledger_status !== auditConst.status.unCheck) || (tender.ledger_times > 1)) { %>
<!--审批流程/结果-->
<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"><small class="text-muted"><%- ah[iA].begin_time.toLocaleDateString() %></small></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 mb-1"><%- ah[iA].opinion %></p>
                                    <p class="card-text"><small class="text-muted"><%- ah[iA].end_time.toLocaleDateString() %></small></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 mb-1"><%- ah[iA].opinion %></p>
                                    <p class="card-text"><small class="text-muted"><%- ah[iA].end_time.toLocaleDateString() %></small></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 mb-1"><%- ah[iA].opinion %></p>
                                    <p class="card-text"><small class="text-muted"><%- ah[iA].end_time.toLocaleDateString() %></small></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"><small class="text-muted"><%- auditors[iA].begin_time.toLocaleDateString() %></small></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 mb-1"><%- auditors[iA].opinion %></p>
                                    <p class="card-text"><small class="text-muted"><%- auditors[iA].end_time.toLocaleDateString() %></small></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 mb-1"><%- auditors[iA].opinion %></p>
                                    <p class="card-text"><small class="text-muted"><%- auditors[iA].end_time.toLocaleDateString() %></small></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 mb-1"><%- auditors[iA].opinion %></p>
                                    <p class="card-text"><small class="text-muted"><%- auditors[iA].end_time.toLocaleDateString() %></small></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>
<% } %>
