<?php 
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\helpers\Url;

?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-12">
        <h2>入金管理</h2>
        <ol class="breadcrumb">
            <li>
                <a href="/admin/dashboard">管理首页</a>
            </li>
            <li class="active">
                <strong>入金管理</strong>
            </li>
        </ol>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <!--
    <div class="row">
        <div class="col-lg-6">
            <div class="widget style1 red-bg">
                <div class="row">
                    <div class="col-xs-4">
                        <i class="fa fa-cny fa-5x"></i>
                    </div>
                    <div class="col-xs-8 text-right">
                        <span> 待入金 </span>
                        <h2 class="font-bold">${sum0?string(",##0.00#")}</h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="widget style1 navy-bg">
                <div class="row">
                    <div class="col-xs-4">
                        <i class="fa fa-cny fa-5x"></i>
                    </div>
                    <div class="col-xs-8 text-right">
                        <span> 成功入金 </span>
                        <h2 class="font-bold">${sum1?string(",##0.00#")}</h2>
                    </div>
                </div>
            </div>
        </div>
    </div>
    -->
    <form>
        <input type="hidden" name="type" value="<?= $type ?>">
        <div class="ibox-content m-b-sm border-bottom">
            <div class="row">
                <div class="col-sm-3">
                    <div class="form-group">
                        <label class="control-label">客户姓名</label>
                        <input type="text" id="name" name="name" value="<?= Yii::$app->getRequest()->get('name') ?>" placeholder="客户姓名" class="form-control">
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="form-group">
                        <label class="control-label" for="price">开始时间</label>
                        <input readonly="readonly" type="text" id="sTime" name="sTime" value="<?= Yii::$app->getRequest()->get('sTime') ?>" placeholder="开始时间" class="datetime form-control">
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="form-group">
                        <label class="control-label" for="quantity">结束时间</label>
                        <input readonly="readonly" type="text" id="eTime" name="eTime" value="<?= Yii::$app->getRequest()->get('eTime') ?>" placeholder="结束时间" class="datetime form-control">
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="form-group">
                        <label class="control-label" for="quantity">操作</label>
                        <input type="submit" class="btn btn-primary form-control" value="搜索">
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5 style="line-height:30px;">
                        <?php if ($type == 0) : ?>待入金<?php elseif ($type == 1): ?>成功入金<?php endif; ?>明细
                    </h5>
                    <?php if($type == 0) :?>
                        <div class="btn-group pull-right">
                            <button id="patchIntoGold" class="btn btn-primary">补单</button>
                        </div>
                    <?php endif;?>
                    <div class="clearfix"></div>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
                        <table id="datatables" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>状态</th>
                                <th>代理商</th>
                                <th>账户</th>
                                <th>姓名</th>
                                <th>手机</th>
                                <th>金额</th>
                                <th>人民币</th>
                                <th>汇率</th>
                                <th>入金方式</th>
                                <th>MT4入金状态</th>
                                <th>支付单号</th>
                                <th>入金时间</th>
                                <th>操作人</th>
                            </tr>
                            </thead>
                            <tfoot>
                            <tr>
                                <th>编号</th>
                                <th>状态</th>
                                <th>代理商</th>
                                <th>账户</th>
                                <th>姓名</th>
                                <th>手机</th>
                                <th>金额</th>
                                <th>人民币</th>
                                <th>汇率</th>
                                <th>入金方式</th>
                                <th>MT4入金状态</th>
                                <th>支付单号</th>
                                <th>入金时间</th>
                                <th>操作人</th>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $this->beginBlock('footer_script');?>
<script>
    KindEditor.ready(function (K) {
    });
</script>
<!-- Page-Level Scripts -->
<script>
    var table;
    $(document).ready(function () {
        table = $('#datatables').DataTable({
            "aLengthMenu": [[20, 50, 100, 500, 999999999], [20, 50, 100, 500, "ALL"]],
            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            },
            "processing": true,
            "serverSide": true,
            "ajax": '<?= Url::to(['ajax', 'type' => $type, 'name'=>Yii::$app->getRequest()->get('name'), 'sTime' => Yii::$app->getRequest()->get('sTime'), 'eTime' => Yii::$app->getRequest()->get('eTime')]) ?>',
            "order": [[0, "desc"]],
            "columns": [{
                "data": "id"
            }, {
                "data": "type"
            }, {
                "data": "IBNAME"
            }, {
                "data": "login"
            }, {
                "data": "name"
            }, {
                "data": "mobile"
            }, {
                "data": "amount"
            }, {
                "data": "rmb"
            }, {
                "data": "rate"
            }, {
                "data": "pay_name"
            }, {
                "data": "mt4_status"
            }, {
                "data": "order_sn"
            }, {
                "data": "in_time"
            }, {
                "data": "admin_name"
            }],
            columnDefs: [{
                targets: 1,
                render: function (data, type, row, meta) {
                    if (data == 0) {
                        return '<span class="label label-danger">等待</span>';
                    } else if (data == 1) {
                        return '<span class="label label-primary">成功</span>';
                    }
                },
                "orderable": true
            }, {
                targets: 12,
                render: function (data, type, row, meta) {
                    return timeStamp2String(data);
                },
                "orderable": true
            }, {
                targets: 10,
                render: function (data, type, row, meta) {
                    if (data == 0) {
                        return '<span class="label label-danger">未入金</span>';
                    } else if (data == 1) {
                        return '<span class="label label-primary">已入金</span>';
                    }
                },
                "orderable": true
            }],
            "sPaginationType": "full_numbers",
            dom: '<"html5buttons"B>lTfgitp',
            buttons: [{
                extend: 'copy'
            },
                {
                    extend: 'csv'
                },
                {
                    extend: 'excel'
                },
                {
                    extend: 'pdf'
                },
                {
                    extend: 'print',
                    customize: function (win) {
                        $(win.document.body).addClass('white-bg');
                        $(win.document.body).css('font-size', '10px');
                        $(win.document.body).find('table').addClass('compact').css('font-size', 'inherit');
                    }
                }]
        });
        $('#datatables tbody').on('click', 'tr',
            function () {
                if ($(this).hasClass('selected')) {
                    $(this).removeClass('selected');
                } else {
                    table.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                }
            });
        $("#modal").on("hidden.bs.modal", function () {
            $(this).removeData("bs.modal");
            KindEditor.remove('#kindeditor');
        });
        $('.data').datepicker({
            startView: 1,
            todayBtn: "linked",
            keyboardNavigation: true,
            forceParse: false,
            autoclose: true,
            format: "yyyy-mm-dd"
        });
    });
    $('#patchIntoGold').click(function () {
        var data = table.row('.selected').data();
        if (data != undefined) {
            swal({
                title: "您确定吗?",
                text: "请确定已收到客户款项!",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true
            }, function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        type: "POST",
                        url: "<?= Url::to(['patch-into-gold']) ?>",
                        data: {
                            id: data.id
                        },
                        dataType: "json",
                        beforeSend: function () {
                        },
                        success: function (data) {
                            if (data.isSuccess) {
                                table.ajax.reload();
                            } else {
                                toastr.error(data.msg, "提示");
                            }
                        },
                        complete: function (XMLHttpRequest, textStatus) {
                        },
                        error: function () {
                        }
                    });
                }
            });
        }
    });
</script>
<?php $this->endBlock();?>

