@extends('vip.layouts')
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }

        .layui-form-switch em {
            width: auto;
        }

        .layui-form-switch {
            width: 44px;
            line-height: 23px;
        }

        .layui-form-item .checkbox {
            width: auto;
        }

        .statistics{
            margin: 0 auto;
            text-align: center;
            margin-bottom: 5px;
        }

        .red{
            color: red;
            font-weight: bold;
        }
    </style>
    <!---注单管理-->
    <div class="layui-row">
        <div class="layui-col-sm12 layui-col-md12 text" >
            <form class="layui-form rewrite" eventType=eventForm>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">开始时间：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="start_time" id="start_time"  lay-verify=""
                                   autocomplete="off" class="layui-input test-item" eventType=event-query
                                   value="{{ $start_time }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">结束时间：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_time" id="end_time" placeholder=" - " lay-verify=""
                                   autocomplete="off" class="layui-input test-item" eventType=event-query
                                   value="{{ $end_time }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">本站用户名：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="account_name" id="account_name" lay-verify="" autocomplete="off" eventType=event-query
                                   class="layui-input" value="{{ $account_name }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">真人用户名：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="Accounts" id="Accounts" lay-verify="" autocomplete="off" eventType=event-query
                                   class="layui-input" value="{{ $Accounts }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload"  eventType=event-query-submit
                           style="opacity: 1; pointer-events: auto;">提交</a>
                        <a class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload"
                           style="opacity: 1; pointer-events: auto;">重置</a>
                        <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload"
                           style="opacity: 1; pointer-events: auto;" href="javascript:window.location.reload()">
                            <i class="layui-icon">ဂ</i>
                        </a>
                        <a class="layui-btn layui-btn-sm" id="get_rec" data-type="reload" style="opacity: 1; pointer-events: auto;">获取最新流水</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    @push('dataTableJS')
        $('.layui-table-page').after('<div id="statistics" class="statistics"></div>');
        function dataTableLoadFinished(res,curr,count)
        {
        console.log('res：',res);
        console.log('curr：',curr);
        console.log('count：',count);
        console.log('length：',res.data.length);
        console.log('length：',res.data);

        var str = '';
        var bettingamount_limit = 0;
        var winLoseamount_limit = 0;
        var validamount_limit = 0;
        for(var i = 0; i < res.data.length; i++)
        {
        bettingamount_limit += parseFloat(res.data[i]['bet_amount']);
        winLoseamount_limit += parseFloat(res.data[i]['profit']);
        validamount_limit += res.data[i]['state']=='正常开奖'?parseFloat(res.data[i]['bet_amount']):0;
        }

        $('#statistics').html('');

        str = '<p>本页共'+ res.data.length +'条注单；总投注金额：<span class="red">'+ bettingamount_limit.toFixed(2) +'RMB</span>；总盈亏金额：<span class="red">'+ winLoseamount_limit.toFixed(2) +'RMB</span>；总有效投注额：<span class="red">'+ validamount_limit.toFixed(2) +'RMB</span></p>';
        str += '<p>本类共{{ $co }}条注单；总投注金额：<span class="red">{{ $bettingamount }}RMB</span>；总盈亏金额：<span class="red">{{ $winLoseamount }}RMB</span>；总有效投注额：<span class="red">{{ $validamount }}RMB</span></p>';

        $('#statistics').html(str);
        }



    @endpush
    @include('vip.datatable')
    <script>
/*        $('#get_rec').on('click',function(){
            layer.confirm('开始获取并添加最新流水到本站？', {
                btn: ['确认', '取消'] //按钮
            }, function() {
                $.ajax({
                    type: 'get',
                    url: '/admin/HjGame/getBettingRecordByVendorNew',
                    data: {},
                    dataType: 'json',
                    success: function (data) {
                        layer.msg(data.msg);
                        setTimeout(function(){
                            window.location.reload();
                        },2500);
                    }
                });
            }, function() {
            });

        });*/
$('#get_rec').on('click',function(){
    layer.open({
        type: 2,
        title: '获取最新流水',
        shadeClose: true,
        shade: 0.8,
        area: ['1000px', '70%'],
        content: '/admin/HjGame/getDetailRecord?vendorId=0&num=0&repeat=0',
        end: function(){ //此处用于演示
            location.reload();
        }
    });
});
    </script>
@endsection
