<% include ../tender/tender_sub_menu.ejs %>
<div class="panel-content">
    <div class="panel-title">
        <div class="title-main d-flex justify-content-between">
            <h2>
                期列表
            </h2>
            <div>
                <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id && ctx.tender.data.ledger_status === auditConst.status.checked &&
                        (stages.length === 0 || stages[stages.length- 1].status === auditConst.status.checked)) { %>
                <a href="#add-qi" data-toggle="modal" data-target="#add-qi" class="btn btn-primary btn-sm pull-right">开始新一期</a>
                <% } %>
            </div>
        </div>
    </div>
    <div class="content-wrap">
        <div class="c-body">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>期数</th>
                    <th class="text-center">计量月份</th>
                    <th class="text-center">本期合同计量</th>
                    <th class="text-center">本期数量变更计量</th>
                    <th class="text-center">本期完成计量</th>
                    <th class="text-center">截止上期完成计量</th>
                    <th class="text-center">截止本期完成计量</th>
                    <th class="text-center">审批状态</th>
                    <th class="text-center">审批进度</th>
                </tr>
                </thead>
                <tbody>
                <% for (const s of stages) { %>
                <tr>
                    <td>
                        <a href="<%- '/tender/' + ctx.tender.id + '/measure/stage/' + s.order %>">第 <%- s.order %> 期</a>
                        <% if (s.status === auditConst.status.uncheck && s.user_id === ctx.session.sessionUser.accountId) { %>
                        <a href="#edit" data-toggle="modal" data-target="#edit"><i class="fa fa-pencil-square-o "></i></a>
                        <% } %>
                    </td>
                    <td class="text-center"></td>
                    <td class="text-right"></td>
                    <td class="text-right"></td>
                    <td class="text-right"></td>
                    <td class="text-right"></td>
                    <td class="text-right"></td>
                    <td class="text-center"><a href="" class="btn <%- auditConst.statusButtonClass[s.status] %> btn-sm"><%- auditConst.auditStatusString[s.status] %></a></td>
                    <td class="<%- auditConst.statusClass[s.status] %>">
                        <% if (s.curAuditor) { %>
                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" s-order="<%- s.order %>"><%- s.curAuditor.name %>-<%s.curAuditor.role %></a>
                        <% } %>
                        <%- auditConst.auditStatusString[s.status] %>
                    </td>
                </tr>
                <% } %>
                </tbody>
            </table>
        </div>
    </div>
</div>