@model Com._9pm2.ClientWeb.Models.CompanyAccountList
@{
    ViewBag.Title = "收支明细";
    Com._9pm2.ClientWeb.Models.LoginUser user = Session["LoginUser"] as Com._9pm2.ClientWeb.Models.LoginUser;
}
<div class="callout callout-warning lead ">提示：此页用于记录 [订单收支之外] 的收支情况。客户订单、外协订单及进货单的收支无需在此重复录入。</div>
<script src="../../Scripts/companyaccount.js?vn=20180813"></script>
<div class="divSearch">
    <form method="post" action="/Finance/InAndOut">
        <div id="dSearch">
            <div class="div-search-select2">
                @Html.DropDownList("km", new SelectList(Model.DdlAccountTitle, "ItemValue", "ItemText"))
            </div>
            @Html.DropDownList("kl", new SelectList(Model.DdlAccountType, "ItemValue", "ItemText"))
            @Html.TextBox("sb", null, new { maxlength = "50", @class = "text-date", placeholder = "记账日期" }) ~ @Html.TextBox("se", null, new { maxlength = "50", @class = "text-date", placeholder = "记账日期" })
            @Html.TextBox("sUserName", null, new { maxlength = "50", @Style = "width:140px", placeholder = "经办人" })
            @Html.TextBox("sk", null, new { maxlength = "50", @Style = "width:140px", placeholder = "关键字" })
            <button class="btn btn-default" id="btnSearch">搜索</button>
            @if (user.PermissionList.Contains(Com._9pm2.ClientWeb.Common.PT_PermissionType.P4_收支明细新增))
            {
                <button id="btnNew" type="button" class="btn btn-default">新增</button>
            }
            <button class="btn btn-default" type="button" id="btnExportExcel">下载(Excel)</button>
        </div>

    </form>
</div>
<div class="error-msg"></div>

<div class="list">
    <table id="tFinance">
        <thead>
            <tr>
                <th>科目</th>
                <th style="width:100px">记账日期</th>
                <th style="width:100px">录入日期</th>
                <th style="width:75px">金额(收入)</th>
                <th style="width:75px">金额(支出)</th>
                <th>备注</th>
                <th style="width:100px">经办人</th>
                <th style="width:100px">操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.InAndOutList)
            {
                <tr id="@item.CompanyAccountNo">

                    <td>@Html.DisplayFor(modelItem => item.AccountTitleName)</td>
                    <td>@item.TransactionDate.ToString("yyyy-MM-dd")</td>
                    <td>@item.Createtime.ToString("yyyy-MM-dd")</td>
                    <td>
                        @if (item.AccountTitleType == "1")
                        {
                            <span>@item.Amount</span>
                        }
                        else
                        {
                            <span></span>
                        }

                    <td>
                        @if (item.AccountTitleType == "2")
                        {
                            <span>@item.Amount</span>
                        }
                        else
                        {
                            <span></span>
                        }
                    </td>
                    <td>@Html.DisplayFor(modelItem => item.Memo)</td>
                    <td>@Html.Raw(item.Creator)</td>
                    <td>

                        @if (user.PermissionList.Contains(Com._9pm2.ClientWeb.Common.PT_PermissionType.P4_收支明细编辑) || 
                            user.PermissionList.Contains(Com._9pm2.ClientWeb.Common.PT_PermissionType.P4_收支明细删除))
                        {
                            <div class="operation-btns">
                                <div>
                                    <button id="select">&nbsp;</button>
                                </div>
                                <ul>
                                    @if (user.PermissionList.Contains(Com._9pm2.ClientWeb.Common.PT_PermissionType.P4_收支明细编辑))
                                    {
                                        <li><a href="javascript:void(0);" onclick="EditCompanyAccount('@item.CompanyAccountNo');">编辑 </a></li>
                                    }
                                    @if (user.PermissionList.Contains(Com._9pm2.ClientWeb.Common.PT_PermissionType.P4_收支明细删除))
                                    {
                                        <li><a href="javascript:void(0);" onclick="DeleteCompanyAccount('@item.CompanyAccountNo');">删除</a></li>
                                    }
                                </ul>
                            </div>
                        }


                    </td>
                </tr>
            }
            <tr class="totalTd">
                <td>总计(所有页):</td>

                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td class="oderAmountTotal">@Model.TotalIn</td>
                <td class="oderAmountTotal">@Model.TotalOut</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
        </tbody>
    </table>
    @Html.Pager("InAndOut", "Finance", Model.RouterDirectory, Model.PagerConfig, "pagerDiv", "pagerDiv", 8, true, false, true, true, false)
</div>

<div id="divCompanyAccount" title="收支信息" style="display:none">
    <div id="divCompanyAccountContent" style="overflow-y: auto; height: 260px;">
        @using (Html.BeginForm())
        {
            <table class="font85 tableEdit">

                <tr>
                    <td class="label">科目</td>
                    <td>
                        @Html.Hidden("CompanyAccountNo")
                        @Html.DropDownList("AccountTitleNo", new SelectList(Model.DdlAccountTitle, "ItemValue", "ItemText"))
                    </td>
                </tr>
                <tr>
                    <td class="label">金额</td>
                    <td>
                        @Html.TextBox("Amount", null, new { maxlength = "10", @class = "money" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">记账日期</td>
                    <td>
                        @Html.TextBox("TransactionDate", null, new { maxlength = "50" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">备注</td>
                    <td>
                        @Html.TextArea("Memo", null, new { maxlength = "200", @style = "height:80px;width:90%;" })
                    </td>
                </tr>
            </table>
        }
    </div>
    <div style="text-align:right;">

        <div class="error-msg"></div>
        <button class="btn btn-primary" type="button" id="btnSave">保存</button>
        <button class="btn btn-default" type="button" id="btnCancel">取消</button>

    </div>
</div>  