@extends('vip.layouts') @section('content')
<style>



</style>
<script type="text/html" id="userdetail">
    <a href="/admin/GameOrder/Index?name=@{{d.account_name}}&star_time=&end_time=&seo_title=@{{d.account_name}}的全部注单">@{{  d.account_name }}</a>
    </script>
<script type="text/html" id="usergetmoney">
<!-- @{{1*d.get_money}} -->
@{{#if(1*d.get_money>0){ }}
<p style="color:red;">@{{1*d.get_money}}</p>
@{{#}else{ }}
 <p style="color:green;">@{{1*d.get_money}}</p>
@{{#} }}

</script>

    <div class="layui-row">

        <div class="layui-col-xs12">


            <form class="layui-form rewrite" action="" eventType=eventForm>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('user_buy.type') }}</label>
                        <div class="layui-input-inline">
                            <select name="type" id="type" lay-verify="" autocomplete="off" class="layui-input" eventType="event-query">
                                <option value="-1"> {{ trans('common.pls') }} </option>
                                @isset($options)
                                    @isset($options['type'])
                                        @foreach($options['type'] as $k =>$v)
                                            @if($k == $type)
                                                <option selected = "selected" value="{{$k}}">{{$v}}</option>
                                            @else
                                                <option value="{{ $k }}"> {{ $v }} </option>
                                            @endif

                                        @endforeach
                                    @endisset
                                @endisset
                            </select>
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('user_buy.time') }}</label>

                        <div class="layui-input-inline">
                            <input type="text" name="time_start"  id="form_time_start" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item"
                            value="{{$time_start}}" eventType=event-query>
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" name="time_end" id="form_time_end"  placeholder=" - " lay-verify="" autocomplete="off" class="layui-input test-item"
                            value="{{$time_end}}" eventType=event-query>
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('user_buy.account') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="account" id="form_account" lay-verify="" autocomplete="off"
                                   eventType=event-query class="layui-input" value="{{Request::get('name')?Request::get('name'):$account}}">
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('user_buy.game_no') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="game_no" id="form_game_no" lay-verify="" autocomplete="off"
                                   eventType=event-query class="layui-input" value="{{Request::get('no')?Request::get('no'):$game_no}}">
                        </div>
                    </div>

                    <div class="layui-inline" style="display: none;">
                        <label class="layui-form-label">游戏</label>
                        <div class="layui-input-inline">
                            <select name="game" id="form_game"  autocomplete="off" eventType="event-query">
                                <option value="">{{ trans('report.all_sixgame') }}</option>
                                @foreach($gameList as $k=>$v):
                                    @if($game==$v['table_name'])
                                        <option value="{{$v['table_name']}}" selected="selected">{{$v['name']}}</option>
                                    @else
                                        <option value="{{$v['table_name']}}">{{$v['name']}}</option>
                                    @endif
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">

                        <div class="layui-inline">
                        <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" style="opacity: 1; pointer-events: auto;" eventType=event-query-submit>提交</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;"><i class="layui-icon">ဂ</i></a>
                        </div>

                    </div>
                </div>
            </form>
        </div>
    </div>
    @push('dataTableJS')
        /*var active = {
        reload: function() {
        table.reload('{{ $dataId }}',
        {
        page:{
        curr: 1 //重新从第 1 页开始
        },
        where: {
        time_start: $("#form_time_start").val(),
        time_end: $("#form_time_end").val(),
        account: $("#form_account").val(),
        game_no: $("#form_game_no").val(),
        type: $("#type").val(),
        rtoken: ''
        }
        });
        }
        };*/

        //重置表单
          $('.reset').on('click',function(){
              $('input').val('');
              $('#status').val('');
              $('#game').val('');
              $('#type').val('');
//              var type = $(this).data('type');
//              active[type] ? active[type].call(this) : '';
          });


        function dataTableLoadFinished(res,curr,count){
            var str='';
            if(document.getElementById("statistics")){
            }else{
                $('.layui-table-page').after('<div id="statistics"></div>');
            }
            var data=res.data;
            var count= 0;//总注数
            var count_money=0;
            var count_prize_money=0;//总中奖
            var count_profit=0;//总中奖
            for(var i=0; i < data.length;i++){
               count+=parseFloat(data[i].num);
               count_money+=parseFloat(data[i].money);
                count_prize_money+=parseFloat(data[i].prize_money);
                count_profit+=parseFloat(data[i].get_money);
            }
        $.ajax({
        type: 'get',
        url: '/admin/sixmoney_buy/total',
        data: {where:res.extras},
        dataType: 'json',
        //async: false,
        success: function (data) {
        console.log(data);
        var val=data.data
        str+='<p>当页总笔数：<span class="blue" style="color: red;">'+count+'</span> ,总笔数：<span class="blue" style="color: green;">'+val.num+'</span> ,</p>';

        str+='<p>当页总投注金额：<span class="blue" style="color: red;">'+Math.floor(count_money*100)/100+'</span> ,总投注金额：<span class="blue" style="color: green;">'+Math.floor(val.money*100)/100+'</span> ,</p>';

        str+='<p>当页总派奖金额：<span class="blue" style="color: red;">'+Math.floor(count_prize_money*100)/100+'</span> ,总派奖金额：<span class="blue" style="color: green;">'+Math.floor(val.prize_money*100)/100+'</span> ,</p>';
        str+='<p>当页平台盈利金额：'
            if(count_profit<0){
                str+='<span class="blue" style="color: red;">'+ Math.floor(-100*count_profit)/100+'</span>';
            }else{
                str+='<span class="blue" style="color: green;">'+ Math.floor(-100*count_profit)/100+'</span>';
            }
            str+=',平台总盈利金额：';
            if(val.get_money>0){
                str+='<span class="blue" style="color: red;">'+ Math.floor(val.get_money*100)/100+'</span></p>';
            }else{
                str+='<span class="blue" style="color: green;">'+ Math.floor(val.get_money*100)/100+'</span></p>';
            }
            $('#statistics').html(str);
            var height1=$('.layui-table-view').height();
            var height2=$('#statistics').height();
            $('.layui-table-view').css({height:(height1+height2)});
        }
        });
    }
    @endpush
    @include('vip.datatable')
@endsection