@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="page-header">
                <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                        <i class="mdi mdi-settings"></i>
                    </span>
                    {{ __('auto.用户数据') }}
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">{{ __('auto.用户数据') }}</a></li>
                        <li class="breadcrumb-item active" aria-current="page">{{ __('auto.用户数据') }}</li>
                    </ol>
                </nav>
            </div>

            <div class="row">
                <div class="col-lg-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">

{{--                            @if ($user_tab != '')--}}
{{--                                <div>--}}
{{--                                    <a href="#" onclick="javascript:history.back(-1);">{{ __('auto.返回到上一页') }}</a>--}}
{{--                                </div>--}}
{{--                            @endif--}}

                            <h4 class="card-title">{{ __('auto.用户数据') }}</h4>
                            <form class="well form-inline margin-top-20" method="post" action='/admin/global/userlist'>
                                <div>
                                    @csrf
                                    <span style="padding-left: 10px" >{{ __('auto.会员ID：') }}</span>
                                    <input class="form-control" type="text" name="GameID" id="GameID"  value="{{$gameID}}" >
                                    <span style="padding-left: 10px" >{{ __('auto.设备ID：') }}</span>
                                    <input class="form-control" type="text" name="MachineID" id="MachineID" value="{{$MachineID}}" >
                                    <span style="padding-left: 10px" >{{ __('auto.手机号：') }}</span>
                                    <input class="form-control" type="text" name="PhoneNum" id="RegisterMobile" value="{{$phoneNum}}" >
                                    <span style="padding-left: 10px" >{{ __('auto.上级ID：') }}</span>
                                    <input class="form-control" type="text" name="SpreaderID" id="SpreaderID" value="{{$spreaderID}}" >
                                    <span style="padding-left: 10px" >{{ __('auto.昵称：') }}</span>
                                    <input class="form-control" type="text" name="NickName" id="Compellation" value="{{$nickName}}">
                                    <span style="padding-left: 10px" >{{ __('auto.手机型号：') }}</span>
                                    <select class="form-control" name="MobileModel" id="MobileModel" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                        @foreach(($mobileModelOptions ?? []) as $model)
                                            <option value="{{$model}}" @if(($mobileModel ?? '') === $model) selected @endif>{{$model}}</option>
                                        @endforeach
                                    </select>
                                    <span style="padding-left: 10px" >{{ __('auto.注册时间：') }}</span>
                                    <input type="datetime-local"  step="01" name="start_time" id="start_time" class="form-control" value="{{$startTime}}" onclick="start_times()"/>
                                    <input type="datetime-local"  step="01" name="end_time" id='end_time' class="form-control" value="{{$endTime}}" onclick="end_times()"/><br>

                                    <span style="padding-left: 10px" >{{ __('auto.上次离线时间') }}</span>
                                    <input type="datetime-local"  step="01" name="start_logintime" id="start_logintime" class="form-control" value="{{$startLoginTime}}" onclick="start_times('start_logintime')"/>
                                    <input type="datetime-local"  step="01" name="end_logintime" id='end_logintime' class="form-control" value="{{$endLoginTime}}" onclick="end_times('end_logintime')"/><br>


                                    <span style="padding-left: 10px" >{{ __('auto.渠道名称：') }}</span>
                                    <select class="form-control" name="channel" value="{{$channel}}" style="color: black">
                                        <option value="">{{ __('auto.全部渠道') }}</option>
                                        @foreach($channels as $key=>$val)
                                        <option value="{{$val}}" @if (  $channel == $val )
                                            selected
                                        @endif>{{$val}}</option>
                                        @endforeach

                                    </select> &nbsp;&nbsp;

                                    <input type="hidden" name="user_tab" value="{{$user_tab}}">
                                   <span style="padding-left: 10px" >VIP{{ __('auto.筛选：') }}</span>

                                    <select class="form-control" name="vip" value="{{$vip}}" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                        @for($i=1;$i<=6;$i++)
                                            @if($vip==$i)
                                                <option value="{{$i}}" selected>VIP {{$i}}</option>
                                            @else
                                                <option value="{{$i}}" >VIP {{$i}}</option>
                                            @endif

                                        @endfor
                                    </select> &nbsp;&nbsp;
                                    <span style="padding-left: 10px" >{{ __('auto.账号筛选：') }}</span>

                                    <select class="form-control" name="accounts_type" value="{{$accounts_type}}" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                        @foreach($webLogonTimes as $key=>$val)
                                            @if($accounts_type==$key)
                                                <option value="{{$key}}" selected>{{$val}}</option>
                                            @else
                                                <option value="{{$key}}" >{{$val}}</option>
                                            @endif

                                        @endforeach
                                    </select> &nbsp;&nbsp;

                                    <span style="padding-left: 10px" >{{ __('auto.包名筛选：') }}</span>

                                    <select class="form-control" name="PackgeName" value="{{$packgeName}}" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                       @foreach($ChannelPackageName as $val)
                                            @if($packgeName==$val)
                                                <option value="{{$val}}" selected>{{$val}}</option>
                                            @else
                                                <option value="{{$val}}" >{{$val}}</option>
                                            @endif

                                        @endforeach
                                    </select> &nbsp;&nbsp;

                                    <a href="/admin/global/userlist" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                                    <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                    <br>
                                    <input type="hidden" value="{{$quickSearch}}">

                                    @foreach($typeList as $key=>$val)
                                        <input class="form-control" type="checkbox" name="obj" id="radio" value="{{$key}}"  @if (strpos(','.$quickSearch.',', ','.$key.',') !== false)
                                            checked
                                        @endif onclick="quickSearchFun(this,{{$key}})">{{$val}}
                                    @endforeach


                                    <a href="/admin/global/userlist?excel=1
                                    &GameID={{$gameID}}
                                        &PhoneNum={{$phoneNum}}
                                        &SpreaderID={{$spreaderID}}
                                        &NickName={{$nickName}}
                                        &MobileModel={{$mobileModel ?? ''}}
                                        &start_time={{$startTime}}
                                        &end_time={{$endTime}}
                                        &vip={{$vip}}
                                        &channel={{$channel}}"
                                       class="btn btn-sm btn-gradient-light btn-icon-text">{{ __('auto.导出') }}</a>
                                    @if (!session()->has('hidden'))
                                        <input type="button" onclick="ban(1)" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.批量封号') }}"/>&nbsp;&nbsp;
                                        <input type="button" onclick="ban(2)" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.批量解封') }}"/>&nbsp;&nbsp;
                                    @endif
                                </div>


                            </form>

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="6%">
                                        <center>
                                            <button type="button" id="quan" onclick="checkboxFunc()" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                                {{ __('auto.反选') }}
                                            </button>
                                        </center>
                                    </th>
                                    <th width="6%">{{ __('auto.会员') }}ID</th>
                                    <th width="4%">{{ __('auto.昵称') }}</th>
                                    <th width="6%">{{ __('auto.手机号') }}</th>
                                    <th width="9%">
                                        <div class="sort_money">
                                            {{ __('auto.余额') }}
                                            <svg t="1611284352657" class="icon2" onclick="sort_money_func(this,'asc')"
                                                 viewBox="0 0 1024 1024" version="1.1"
                                                 xmlns="http://www.w3.org/2000/svg" p-id="4118" width="14">
                                                <path
                                                    d="M541.866667 285.866667l345.6 345.6c17.066667 17.066667 17.066667 42.666667 0 59.733333-8.533333 8.533333-19.2 12.8-29.866667 12.8H168.533333c-23.466667 0-42.666667-19.2-42.666666-42.666667 0-10.666667 4.266667-21.333333 12.8-29.866666l343.466666-345.6c17.066667-17.066667 42.666667-17.066667 59.733334 0z"
                                                    p-id="4119" fill="#707072">

                                                </path>
                                            </svg>

                                            <svg t="1611283709864" class="icon1" onclick="sort_money_func(this,'desc')"
                                                 viewBox="0 0 1024 1024" version="1.1"
                                                 xmlns="http://www.w3.org/2000/svg" p-id="3148" width="14">
                                                <path
                                                    d="M482.133333 738.133333L136.533333 392.533333c-17.066667-17.066667-17.066667-42.666667 0-59.733333 8.533333-8.533333 19.2-12.8 29.866667-12.8h689.066667c23.466667 0 42.666667 19.2 42.666666 42.666667 0 10.666667-4.266667 21.333333-12.8 29.866666L541.866667 738.133333c-17.066667 17.066667-42.666667 17.066667-59.733334 0z"
                                                    p-id="3149" fill="#707071">

                                                </path>
                                            </svg>
                                        </div>

                                    </th>
                                    <th width="6%">{{ __('auto.免费币') }}</th>
                                    <th width="6%">{{ __('auto.总输赢') }}</th>
                                    <th width="6%">{{ __('auto.最高分') }}</th>
                                    <th width="6%">{{ __('auto.最多赢分') }}</th>
                                    <th width="6%">{{ __('auto.今日/历史充值') }}</th>
                                    <th width="6%">{{ __('auto.今日/历史茶叶') }}</th>
                                    <th width="6%">{{ __('auto.今日/历史彩金') }}</th>
                                    <th width="6%">{{ __('auto.可茶叶金额') }}</th>
                                    <th width="6%">IP</th>

                                    <th width="6%">{{ __('auto.在线状态') }}</th>
                                    <th width="6%">{{ __('auto.上次离线时间') }}</th>
                                    <th width="6%">{{ __('auto.注册日期') }}({{ __('auto.当地') }})</th>
{{--                                    <th width="6%">{{ __('auto.注册日期') }}({{ __('auto.中国') }})</th>--}}
                                    <th width="6%">{{ __('auto.渠道名称') }}</th>
                                    <th width="6%">{{ __('auto.包名') }}</th>
                                    <th width="6%">{{ __('auto.账号') }}</th>
                                    <th width="8%">{{ __('auto.账号状态') }}</th>
                                    <th width="6%">{{ __('auto.设置') }}</th>
                                </tr>
                                </thead>
                                <tbody class="search_checkbox">
                                @foreach($list as $k=>$item)
                                    <tr>
                                        <td>
                                            <input class="form-control" type="checkbox" name="checkbox" id="{{$item->UserID}}"  value="" >
                                        </td>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$item->UserID}}">
                                                {{$item->GameID}}
                                            </a>
                                        </td>
                                        <td>{{$item->NickName}}{{ !empty($item->LastLogonMobile) ? '(' . $item->LastLogonMobile . ')' : '' }}</td>
                                        <td>{{$item->PhoneNum}}</td>
                                        <td>{{ $item->Score }}</td>
                                        <td>{{ $item->InsureScore }}</td>
                                        <td>{{ $item->totalScore ?? 0 }}</td>
                                        <td>{{ $item->MaxScore ?? 0 }}</td>
                                        <td>{{ $item->MaxWinScore ?? 0 }}</td>
                                        <td>{{$item->todayRecharge ?? 0}}/{{ $item->totalRecharge ?? 0 }}</td>
                                        <td>{{$item->todayWithdraw ?? 0}}/{{ $item->totalWithdraw ?? 0 }}</td>
                                        <td>{{$item->todayHandsel ?? 0}}/{{ $item->totalHandsel ?? 0 }}</td>

                                        <td>{{$item->CashAble}}</td>
                                        <td>
                                            <p>{{$item->RegisterIP}}({{ipAddress($item->RegisterIP)}})</p>
                                        </td>

                                        <td>
                                            @if($item->ServerName != null)
                                                {{ __('auto.游戏中') }}({{$item->ServerName}})
                                            @else
                                                {{ __('auto.离线') }}
                                            @endif
                                        </td>
                                        <td>{{ date('Y-m-d H:i:s',strtotime($item->LastLogonDate))}}</td>
                                        <td>{{ date('Y-m-d H:i:s',strtotime($item->RegisterDate))}}</td>
{{--                                        <td>{{ dateConvert($item->RegisterDate) }}</td>--}}
                                        <td>{{$item->Channel}}</td>
                                        <td></td>

                                        <td>
                                           @if ($item->WebLogonTimes == 2 || !empty($item->PhoneNum) )
                                                {{ __('auto.手机号') }}
                                            @elseif($item->WebLogonTimes == 0)
                                                facebook
                                            @elseif($item->WebLogonTimes == 1)
                                                {{ __('auto.游客') }}
                                            @endif
                                        </td>
                                        <td>{!! $item->Nullity !!}</td>
                                        <td>


                                        <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text" onclick="update({{$item->UserID}})">
                                            {{ __('auto.修改') }}
                                            <i class="mdi mdi-file-check btn-icon-append"></i>
                                        </button>

                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            </div>
                            <div class="box-footer clearfix" id = "pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,
                                        'PhoneNum'=>$phoneNum,
                                        'SpreaderID'=>$spreaderID,
                                        'NickName'=>$nickName,
                                        'MobileModel'=>$mobileModel ?? '',
                                        'start_time'=>$startTime,
                                        'end_time'=>$endTime,
                                        'start_logintime'=>$startLoginTime,
                                        'end_logintime'=>$endLoginTime,
                                        'vip'=>$vip,
                                        'accounts_type' => $accounts_type,

                                        'Score' => $score,
                                        'user_tab' => $user_tab,
                                        'channel' => $channel,
                                        'PackgeName'=>$packgeName,
                                        'quickSearch' => $quickSearch
                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">

        var quickSearch = '';

        function quickSearchFun(obj,key){

            if ($(obj).is(':checked')){

                quickSearch = quickSearch + key + ','

            }else {

                quickSearch = quickSearch.replace(key+',','')

            }

            $.ajax({
                type:"get",
                url:"/admin/global/userlist",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data:{quickSearch},
                success:function(msg){
                    if(msg){
                        $(".main-panel").html(msg)
                    }
                }
            })

        }

    </script>
    <script>
        var search_arr = [];
        var search_arr1 = [];
        var first_str = '';
        var data = {
            'GameID':"{{$gameID}}",
            'PhoneNum':"{{$phoneNum}}",
            'SpreaderID':"{{$spreaderID}}",
            'NickName':"{{$nickName}}",
            'MobileModel':"{{ $mobileModel ?? '' }}",
            'start_time':"{{$startTime}}",
            'end_time':"{{$endTime}}",
            'obj':"{{$obj}}",
            'vip':"{{$vip}}",
            'accounts_type':"{{$accounts_type}}",
            'Score':"{{$score}}",
            'channel':"{{$channel}}",
            'user_tab':"{{$user_tab}}",
            'PackgeName':"{{$packgeName}}",
            'quickSearch':"{{$quickSearch}}",
        };

        //同时获取该checkbox后面的值，以在后面的name属性为value的input里面的值，并且拼接成json字符串
        function start_times() {

            getFormat('00', '00', '00');

            document.getElementById("start_time").value = format
        }

        function end_times() {
            getFormat('23', '59', '59');
            document.getElementById("end_time").value = format
        }


        function update(id){
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/global/user_update?id='+id
            });
        }
        function del(id){
            myConfirm("{{ __('auto.删除操作不可逆,是否继续') }}?",function(){
                myRequest("/admin/accusation/del/"+id,"post",{},function(res){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                });
            });
        }
        function checkboxFunc(){
            var num=document.getElementsByName('checkbox');
            for(var i=0;i<num.length;i++){
                if(num[i].checked){
                    num[i].checked=false;
                }else{
                    num[i].checked=true;
                }
            }
        }
        function ban(ban){
            //1封号 2解封
            var num=document.getElementsByName('checkbox');
            var str='';
            for(var i=0;i<num.length;i++){
                if(num[i].checked){
                    str=str+num[i].id+',';
                }
            }
            if (str==''){
                alert('{{ __('auto.请选择要操作的数据') }}');return false;
            }
            var id=str.substr(0,str.length-1);
            myConfirm("{{ __('auto.是否继续账户操作') }}?",function(){
                myRequest("/admin/global/ban","post",{id:id,ban:ban},function(res){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                });
            });
            return false;
        }

        function sort_money_func(obj, val) {

            if (val == 'asc') {
                $(".sort_money svg:eq(1)").children('path').attr('fill', '#707071');
                $(obj).children('path').attr('fill', 'red')

            } else {
                $(obj).children('path').attr('fill', 'red')
                $(".sort_money svg:eq(0)").children('path').attr('fill', '#707071');
            }

            data.Score = val
            $.ajax({
                type: "post",
                url: "/admin/global/userlist",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: data,
                success: function (msg) {

                    if (msg) {
                        $(".main-panel").html(msg)

                    }
                }
            })
        }

    </script>
@endsection
