
@{
    ViewData["Title"] = "Paypal收入流水";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
    ViewBag.Nav = new string[] { "财务报表", "Paypal分录信息" };
}

<div class="row">
    <div class="col-sm-12">
        <div class="ibox-content m-b-sm border-bottom">
            <form id="toolbar">
                <div class="form-inline" style="line-height:40px;">
                    <div class="form-group">
                        <label>Paypal帐号：</label>
                        <select id="account" name="account" class="form-control" style="width:160px;">
                            <option value="">选择Paypal帐号</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>分录月份</label>
                        <input id="month" name="month" type="text" class="form-control" style="width:130px;" value="@(DateTime.Now.ToString("yyyy-MM"))" />
                    </div>
                    <div class="form-group">
                        <label>币种：</label>
                        <select id="currency" name="currency" class="form-control" style="width:100px;">
                            <option value="">选择币种</option>
                            <option value="USD">USD</option>
                            <option value="EUR">EUR</option>
                            <option value="GBP">GBP</option>
                            <option value="HKD">HKD</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
                    </div>
                </div>
            </form>
        </div>

        <div class="ibox-content m-b-sm border-bottom">
            <table id="roletable" style="table-layout:fixed;"></table>
        </div>
    </div>
</div>
@section css{
    <link href="~/css/bootstrap-table-fixed-columns.css" rel="stylesheet" />
    <style>
        .mules {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
}
@section scripts{
    <script src="~/js/bootstrap-table-fixed-columns.js" type="text/javascript"></script>

    <script type="text/javascript">
        var tb;
        var companyid = 0;
        $(document).ready(function () {
            laydate.render({ elem: '#month', type: 'month' });

            var height = document.body.clientHeight;
            $("#roletable").attr("data-height", (height - 170));

            list();

            listAccount();
        })

        function list() {
            var columns = [
                { field: 'recordtime', title: '月份', width: '100', sortable: true },
                { field: 'paypal_account', title: '帐号', width: '150' },
                { field: 'note', title: '摘要', width: '150'},
                { field: 'account_subject', title: '会计科目', width: '230', iscount: true},
                { field: 'platform_bank', title: '平台|银行', width: '150'},
                { field: 'receive_account', title: '帐号', width: '130' },
                { field: 'currency', title: '币种', width: '80' },
                { field: 'balance_impact', title: '方向', width: '80' },
                { field: 'amount', title: '金额', width: '100' },
                { field: 'createtime', title: '创建时间', width: '130' }
            ];

            var url = '@Url.Content("~/Reports/Finance/ListPaypalIncomeAnalyzeJson")' + '?' + $("#toolbar").serialize();

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "", {
                    showfooter: true, loadsuccess: function (d) {
                        //替换汇总行的相关列值
                        var tr = $('.fixed-table-footer').find('tr');
                        for (var c in columns) {
                            var key = columns[c].field;
                            if (columns[c].iscount) {
                                for (var v in d.count_row) {
                                    if (key == v) {
                                        tr.find('td').eq(c).children('div').first().html(d.count_row[v]);
                                        break;
                                    }
                                }
                            }
                        }
                        companyid = d.companyid;
                    }
                }, {
                        fixedcol: true,
                        fixedcolnum:2
                    });
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }

        function listAccount() {
            $.submit({
                url: '@Url.Content("~/Reports/Orders/ListPaypalAccount")',
                type:'POST',
                paramData: '',
                func: function (result) {
                    if (result != null && result != undefined) {
                        $('#account').html('<option value="">选择Paypal帐号</option>');
                        for (var i = 0; i < result.length; i++) {
                            $('#account').append('<option value="' + result[i] + '">' + result[i]+'</option>');
                        }
                    }
                }
            })
        }

        function exportlist() {
            if (confirm("确定要导出吗?")) {
                window.open('@Url.Content("~/Reports/Orders/ExportEbayOrders")' + '?' + $("#toolbar").serialize(), '_blank');
            }
        }

    </script>
}


