@model Com._9pm2.ClientWeb.Model.FinanceReport
@{
    ViewBag.Title = "收支报表";
}
<script src="../../Scripts/financereport.js?vn=20180813"></script>
<style>
    th, td {
        height: 24px;
        padding-left: 5px !important;
    }
</style>

<form method="post">
    <div class="divSearch" id="dSearch">
        <div>
            @Html.TextBox("sb", null, new { maxlength = "50", @class = "text-date", placeholder = "交易日期" }) ~ @Html.TextBox("se", null, new { maxlength = "50", @class = "text-date", placeholder = "交易日期" })
            <span class="redStar"></span>
            <button class="btn btn-default" id="btnSearch" onclick="return checkRequired('dSearch', '')">搜索</button>
            <button class="btn btn-default" type="button" id="btnExport" onclick="return checkRequired('dSearch', '')">下载收支报表</button>
            <span style="top:10px;position:relative;margin-right:10px;margin-left:10px;">
                @Html.CheckBox("so") 统计客户订单
            </span>
            <span style="top:10px;position:relative;margin-right:10px;margin-left:10px;">
                @Html.CheckBox("sf") 统计外协订单
            </span>
            <span style="top:10px;position:relative;margin-right:10px;margin-left:10px;">
                @Html.CheckBox("ss") 统计进货单
            </span>
            <span style="top:10px;position:relative;">
                @Html.CheckBox("sd", false) 下载明细
            </span>
        </div>
    </div>
</form>

<div class="list">
    <table id="tReport">
        <thead>
            <tr>
                <th colspan="2">收入（单位：元）</th>
                <th colspan="2">支出（单位：元）</th>
            </tr>
        </thead>
        <tbody>
            @{int maxRow = Model.InList.Count > Model.OutList.Count ? Model.InList.Count : Model.OutList.Count;}
            @for (int i = 0; i < maxRow; i++)
            {
                <tr>
                    @if (i < Model.InList.Count)
                    {
                        <td>@Model.InList[i].AccountTitle</td>
                        <td>@string.Format("{0:N2}", Model.InList[i].Amount)</td>
                    }
                    else
                    {
                        <td></td>
                        <td></td>
                    }
                    @if (i < Model.OutList.Count)
                    {
                        <td>@Model.OutList[i].AccountTitle</td>
                        <td>@string.Format("{0:N2}", Model.OutList[i].Amount)</td>
                    }
                    else
                    {
                        <td></td>
                        <td></td>
                    }
                </tr>
            }
            <tr>
                <td style="width:35%"><b>收入合计：</b></td>
                <td style="width:15%"><b>@string.Format("{0:N2}", Model.TotalIn)</b></td>
                <td style="width:35%"><b>支出合计：</b></td>
                <td style="width:15%"><b>@string.Format("{0:N2}", Model.TotalOut)</b></td>
            </tr>
            <tr>
                <td><b>结余（收入-支出）：</b></td>
                <td colspan="3"><b>@string.Format("{0:N2}", Model.Balance)</b></td>
            </tr>

            <tr>
                <td colspan="4">
                    <b>备注：</b>
                    @if (Model.so.Value)
                    {
                        <span>
                            订单收入总金额中，已收款 <b>@string.Format("{0:N2}", Model.OrderPaid)</b>元，未收款 <b>@string.Format("{0:N2}", Model.OrderUnpaid)</b>元。
                        </span>
                    }
                    @if (Model.sf.Value)
                    {
                        <span>
                            订单外协总费用中，已支付 <b>@string.Format("{0:N2}", Model.OrderFactoryPaid)</b>元，未支付 <b>@string.Format("{0:N2}", Model.OrderFactoryUnpaid)</b>元。
                        </span>
                    }
                    @if (Model.ss.Value)
                    {
                        <span>
                            进货总费用中，已支付 <b>@string.Format("{0:N2}", Model.StockInPaid)</b>元，未支付 <b>@string.Format("{0:N2}", Model.StockInUnpaid)</b>元。
                        </span>
                    }
                </td>
            </tr>

        </tbody>
    </table>
</div>
