<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">
                        <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="UserID" id="UserID" style="width: 10%; "
                                       value="{{$UserID}}">
                                <span style="padding-left: 10px">{{ __('auto.设备ID：') }}</span>
                                <input class="form-control" type="text" name="MachineID" id="MachineID" style="width: 10%; "
                                       value="{{$MachineID}}">
                                <span style="padding-left: 10px">{{ __('auto.手机号：') }}</span>
                                <input class="form-control" type="text" name="RegisterMobile" id="RegisterMobile"
                                       style="width: 10%; " value="{{$RegisterMobile}}">
                                <span style="padding-left: 10px">{{ __('auto.上级ID：') }}</span>
                                <input class="form-control" type="text" name="SpreaderID" id="SpreaderID"
                                       style="width: 10%; " value="{{$SpreaderID}}">
                                <span style="padding-left: 10px">{{ __('auto.姓名：') }}</span>
                                <input class="form-control" type="text" name="Compellation" id="Compellation"
                                       style="width: 10%; " value="{{$Compellation}}">
                                <span style="padding-left: 10px">{{ __('auto.注册时间：') }}</span>
                                <input type="datetime-local" step="01" name="start_time" id="start_time"
                                       class="form-control" value="{{$start_time}}" onclick="start_times()" />
                                <input type="datetime-local" step="01" name="end_time" id='end_time'
                                       class="form-control" value="{{$end_time}}" onclick="end_times()"/><br>
                                <span style="padding-left: 10px">{{ __('auto.渠道名称：') }}</span>
                                <input class="form-control" type="text" name="mobile" style="width: 10%; "
                                       value="{{ __('auto.暂时无法使用') }}" disabled>
                                <span style="padding-left: 10px">{{ __('auto.当前在线状态：') }}</span>
                                <input class="form-control" type="text" name="mobile" style="width: 10%; "
                                       value="{{ __('auto.暂时无法使用') }}" disabled>
                                <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>
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <br>

                                <input class="form-control" type="checkbox" name="obj" id="radio" value="1"
                                       onclick="search(1)">{{ __('auto.当前在线') }}
                                <input class="form-control" type="checkbox" name="obj" id="radio" value="2"
                                       onclick="search(2)">{{ __('auto.未实名') }}
                                <input class="form-control" type="checkbox" name="obj" id="radio" value="3"
                                       onclick="search(3)">{{ __('auto.无手机号') }}
                                <input class="form-control" type="checkbox" name="obj" id="radio" value="4"
                                       onclick="search(4)">{{ __('auto.同') }}IP
                                <input class="form-control" type="checkbox" name="obj" id="radio" value="5"
                                       onclick="search(5)">{{ __('auto.无渠道') }}
                                <input class="form-control" type="checkbox" name="obj" id="radio" value="6"
                                       onclick="search(6)">{{ __('auto.未充值') }}
                                <input class="form-control" type="checkbox" name="obj" id="radio" value="7"
                                       onclick="search(7)">{{ __('auto.无上级') }}
                                <input class="form-control" type="checkbox" name="obj" id="radio" value="8"
                                       onclick="search(8)">{{ __('auto.封号中') }}


                                <a href="/admin/global/userlist?excel=1
                                    &UserID={{$UserID}}
                                    &RegisterMobile={{$RegisterMobile}}
                                    &SpreaderID={{$SpreaderID}}
                                    &Compellation={{$Compellation}}
                                    &start_time={{$start_time}}
                                    &end_time={{$end_time}}
                                    &obj={{$obj}}
                                    &vip={{$vip}}"
                                   class="btn btn-sm btn-gradient-light btn-icon-text">{{ __('auto.导出') }}</a>
                                <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;
                            </div>


                        </form>
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th width="6%">
                                    <center>
                                        <button type="button" id="quan" onclick="checkbox()"
                                                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="6%">IP</th>
                                <th width="6%">{{ __('auto.金豆余额') }}</th>
{{--                                <th width="6%">{{ __('auto.上级') }}ID</th>--}}
{{--                                <th width="6%">VIP{{ __('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="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->UserID}}
                                        </a>
                                    </td>
                                    <td>{{$item->Compellation}}</td>
                                    <td>{{$item->RegisterMobile}}</td>
                                    <td>{{$item->RegisterIP}}</td>
                                    <td>{{$item->Score}}</td>
{{--                                    <td>{{$item->SpreaderID}}</td>--}}
{{--                                    <td>{{$item->MemberOrder}}</td>--}}
                                    {{--                                        <td>{{ __('auto.无法统计') }}</td>--}}

                                    <td>
                                        @if($item->ServerName != null)
                                            {{ __('auto.在线') }}($item->ServerName)
                                        @elseif($item->LastLogonDate >= now())
                                            {{ __('auto.在线') }}({{ __('auto.大厅') }})
                                        @else
                                            {{ __('auto.离线') }}
                                        @endif
                                    </td>

                                    <td>{{ date('Y-m-d H:i:s',strtotime($item->RegisterDate))}}</td>
{{--                                    <td>{{ dateConvert($item->RegisterDate) }}</td>--}}
                                    <td>{{$item->Channel}}</td>
                                    <td>{{$item->Accounts}}</td>
                                    <td>
                                        @if($item->Nullity==0)
                                            {{ __('auto.正常') }}
                                        @else
                                            {{ __('auto.封禁') }}
                                        @endif
                                    </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 class="box-footer clearfix" id="pages">
                            {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,
                                        'UserID'=>$UserID,
                                        'RegisterMobile'=>$RegisterMobile,
                                        'SpreaderID'=>$SpreaderID,
                                        'Compellation'=>$Compellation,
                                        'start_time'=>$start_time,
                                        'end_time'=>$end_time,
                                        'obj'=>$obj,
                                        'vip'=>$vip
                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                            {!! $list->links() !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var search_arr = [];

    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 checkbox() {
        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 search(value) {

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

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

</script>
