
@{
    ViewData["Title"] = "LogisticWaitPayDetail";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
    ViewBag.Nav = new string[] { "财务报表", "资产负债表", "供应商应付账款" };
}

<div class="ibox-content m-b-sm border-bottom">
    <table id="tb" class="table table-hover table-bordered" style="width:100%;">
        <thead>
            <tr>
                <th>日期</th>
                <th>期初余额</th>
                <th>发生额</th>
                <th>发生额调整额</th>
                <th>付款额</th>
                <th>付款调整额</th>
                <th>期末余额</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>@(ViewBag.m.day.ToString("yyyy-MM-dd"))</td>
                <td>@(ViewBag.m.amount_start)</td>
                <td><input id="amount_happen" type="number" style="width:110px;height:24px;line-height:24px;" value="@(ViewBag.m.amount_happen)" /><button class="btn btn-success btn-xs" style="margin-left:3px" onclick="Save('amount_happen');">保存</button></td>
                <td><input id="amount_happen_adjust" type="number" style="width:110px;height:24px;line-height:24px;" value="@(ViewBag.m.amount_happen_adjust)" /><button class="btn btn-success btn-xs" style="margin-left:3px" onclick="Save('amount_happen_adjust');">保存</button></td>
                <td><a href="javascript:;" onclick="paydetail()">@(ViewBag.m.amount_payed)</a><button class="btn btn-warning btn-xs" style="margin-left:5px" onclick="updatePayed();">更新</button></td>
                <td><input id="amount_payed_adjust" type="number" style="width:110px;height:24px;line-height:24px;" value="@(ViewBag.m.amount_payed_adjust)" /><button class="btn btn-success btn-xs" style="margin-left:3px" onclick="Save('amount_payed_adjust');">保存</button></td>
                <td>@(ViewBag.m.amount_end)</td>
            </tr>
        </tbody>
    </table>
</div>

@section scripts{
    <script>
        function Save(id) {
            var val = $('#' + id).val();
            if (val == '') {
                layer.msg('调整额不能为空！');
                return;
            }

            var type = 0;
            if (id == 'amount_happen_adjust') {
                type = 1;
            }
            else if (id == 'amount_payed_adjust') {
                type = 2;
            }
            else if (id == 'amount_happen') {
                type = 3;
            }

            $.submit({
                type:'POST',
                url: '@Url.Content("~/Reports/Finance/UpdateLogisticWaitPay")',
                paramData: 'id=@(ViewBag.m.id)&type=' + type +'&amount='+val,
                func: function (result) {
                    if (result.success) {
                        layer.msg('提交成功！');

                        setTimeout(function () {
                            window.location = window.location;
                        }, 1.5 * 1000);
                    }
                    else {
                        layer.msg(result.msg);
                    }
                }
            })

        }

        function paydetail() {
            layer_show('@(ViewBag.m.day.ToString("yyyy-MM-dd")) 应付账款明细', '@Url.Content("~/Reports/Finance/ListHeadLogistic?start="+ ViewBag.m.day.ToString("yyyy-MM-dd"))' + '&end=@(ViewBag.m.day.ToString("yyyy-MM-dd"))', '95%', '95%');
        }

        function updatePayed() {
            $.submit({
                type:'POST',
                url: '@Url.Content("~/Reports/Finance/UpdateLogisticPayed")',
                paramData: 'day=@(ViewBag.m.day.ToString("yyyy-MM-dd"))',
                func: function (result) {
                    if (result.success) {
                        layer.msg('提交成功！');

                        setTimeout(function () {
                            window.location = window.location;
                        }, 1.5 * 1000);
                    }
                    else {
                        layer.msg(result.msg);
                    }
                }
            })
        }

    </script>
}


