
@{
    ViewData["Title"] = "Ebay Paypal费";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
    ViewBag.Nav = new string[] { "统计", "Ebay", "Paypal流水" };
}

<div class="row">
    <div class="col-sm-12">
        <div id="rightcontain">
            <div class="ibox-content m-b-sm border-bottom">
                <form id="toolbar">
                    <div class="form-inline" style="line-height:40px;">
                        <div class="form-group" style="display:none;">
                            <label>&nbsp;</label>
                            <select id="account" name="account" class="form-control">
                                <option value="">请选择帐号</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>时间</label>
                            <input id="start" name="start" type="text" class="form-control" style="width:130px;" value="@(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"))" />
                            <span>至</span>
                            <input id="end" name="end" type="text" class="form-control" style="width:130px;" value="@(DateTime.Now.ToString("yyyy-MM-dd"))" />
                        </div>
                        <div class="form-group">
                            <label>&nbsp;</label>
                            <input id="orderno" name="orderno" class="form-control" style="width:130px;" placeholder="平台订单号" />
                        </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>
                            <button type="button" class="btn btn-success" onclick="exportxls();">导出</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>
</div>
@section css{
    <link href="~/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/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/jquery.ztree.core.min.js"></script>
    <script src="~/js/jquery.ztree.excheck.min.js"></script>
    <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: '#start' });
            laydate.render({ elem: '#end' });

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

            list();

            listAccount();

            //listWebsite();

            //listcategory12();
        })

        function list() {
            var columns = [
                {
                    field: 'transaction_id', title: '交易号', width: '160', formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.transaction_id + '">' + data.transaction_id + '</div>';
                    }
                },
                { field: 'receipt_id', title: 'receipt_id', width: '120' },
                { field: 'transaction_type', title: '交易类型', width: '120' },
                { field: 'payment_type', title: '支付类型', width: '130', iscount: true },
                { field: 'currency', title: '币种', width: '130' },
                { field: 'gross_amount', title: '订单金额', width: '100', sortable: true, iscount: true },
                { field: 'gross_amount_rmb', title: '订单金额RMB', width: '130', iscount: true },
                { field: 'payment_status', title: '交易状态', width: '110' },
                { field: 'receiver', title: '接收帐号', width: '110' },
                { field: 'payment_date', title: '时间', width: '130', sortable: true }
            ];
            
            var url = '@Url.Content("~/Reports/Orders/ListPaypalJson")' + '?' + $("#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: 1
                    });
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }

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

        function listWebsite() {
            $.submit({
                url: '@Url.Content("~/Reports/Orders/ListWebSite")',
                type:'POST',
                paramData: 'platform=@(ViewBag.platform)',
                func: function (result) {
                    if (result != null && result != undefined) {
                        $('#website').html('<option value="">选择站点</option>');
                        for (var i = 0; i < result.length; i++) {
                            $('#website').append('<option value="' + result[i] + '">' + result[i]+'</option>');
                        }
                    }
                }
            })
        }

        function exportxls() {
            window.open('@Url.Content("~/Reports/Orders/ExportPaypal")' + '?' + $("#toolbar").serialize() + '&companyid=' + companyid, '_blank');
        }
        

    </script>

}



