<?php 
$this->title = '交易管理';
?>

<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">

    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">

                <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>SL</th>
                                <th>TP</th>
                                <th>手数</th>
                                <th>开仓价格</th>
                                <th>开仓时间</th>
                                <th>平仓价格</th>
                                <th>平仓时间</th>
                                <th>利息</th>
                                <th>佣金</th>
                                <th>获利</th>
                            </tr>
                            </thead>
                            <tfoot>
                            <tr>
                                <th>订单号</th>
                                <th>账户</th>
                                <th>类型</th>
                                <th>品种</th>
                                <th>SL</th>
                                <th>TP</th>
                                <th>手数</th>
                                <th>开仓价格</th>
                                <th>开仓时间</th>
                                <th>平仓价格</th>
                                <th>平仓时间</th>
                                <th>利息</th>
                                <th>佣金</th>
                                <th>获利</th>
                            </tr>
                            </tfoot>
                        </table>
                    </div>

                </div>
            </div>
        </div>
    </div>

</div>

<?php $this->beginBlock('footer_script'); ?>
<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": '/admin/trades/ajax?type=<?= $type ?>',
        "order": [[0, "desc"]],
        "columns": [{
            "data": "TICKET"
        },
            {
                "data": "LOGIN"
            },
            {
                "data": "CMD"
            },
            {
                "data": "SYMBOL"
            },
            {
                "data": "SL"
            },
            {
                "data": "TP"
            },
            {
                "data": "VOLUME"
            },
            {
                "data": "OPEN_PRICE"
            },
            {
                "data": "OPEN_TIME"
            },
            {
                "data": "CLOSE_PRICE"
            },
            {
                "data": "CLOSE_TIME"
            },
            {
                "data": "SWAPS"
            },
            {
                "data": "COMMISSION"
            },
            {
                "data": "PROFIT"
            }],
        columnDefs: [{
            targets: 2,
            render: function(data, type, row, meta) {
                if(data==0){
                    return 'BUY';
                }else if (data==1){
                    return 'SELL';
                }else if (data==2){
                    return 'BUY LIMIT';
                }else if (data==3){
                    return 'SELL LIMIT';
                }else if (data==4){
                    return 'BUY STOP';
                }else if (data==5){
                    return 'SELL STOP';
                }else if (data==6){
                    return 'BALANCE';
                }else if (data==7){
                    return 'CREDIT';
                }else{
                    return '';
                }
            },
            "orderable": true
        },{
            targets: 6,
            render: function(data, type, row, meta) {
                return data/100;
            },
            "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');
                }
            }]

    });

});

$('.data').datepicker({
    startView: 1,
    todayBtn: "linked",
    keyboardNavigation: true,
    forceParse: false,
    autoclose: true,
    format: "yyyy-mm-dd"
});

</script>
<?php $this->endBlock(); ?>