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

                            <h4 class="card-title">{{ __('auto.用户数据') }}</h4>
                            <form class="well form-inline margin-top-20" method="post" action='/admin/custom/user_list'>
                                <div>
                                    @csrf
                                    <spen style="padding-left: 10px" >{{ __('auto.会员ID：') }}</spen>
                                    <input class="form-control" type="text" name="GameID" id="GameID" style="width: 10%; " value="{{$gameID}}" >

                                    <spen style="padding-left: 10px" >{{ __('auto.分配召回时间：') }}</spen>
                                    <input type="datetime-local"  step="01" name="cstart_time" id="cstart_time" class="form-control" value="{{$cstartTime}}" onclick="cstart_times()"/>
                                    <input type="datetime-local"  step="01" name="cend_time" id='cend_time' class="form-control" value="{{$cendTime}}" onclick="cend_times()"/>


                                    <spen style="padding-left: 10px" >{{ __('auto.召回时间：') }}</spen>
                                    <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()"/>


                                    <spen style="padding-left: 10px" >{{ __('auto.最后登录时间：') }}</spen>
                                    <input type="datetime-local"  step="01" name="lstart_time" id="lstart_time" class="form-control" value="{{$lstartTime}}" onclick="lstart_times()"/>
                                    <input type="datetime-local"  step="01" name="lend_time" id='lend_time' class="form-control" value="{{$lendTime}}" onclick="lend_times()"/>


                                    <spen style="padding-left: 10px" >{{ __('auto.召回状态：') }}</spen>
                                    <select class="form-control" name="state" value="{{$state}}" style="color: black">
                                        @foreach($callState as $key=>$val)
                                            <option value="{{$key}}" @if (  $state == $key )
                                                selected
                                                @endif>{{$val}}</option>
                                        @endforeach

                                    </select>

                                    <spen style="padding-left: 10px" >{{ __('auto.选择客服：') }}</spen>
                                    <select class="form-control" name="admin_id"  style="color: black">
                                        <option value="0">{{ __('auto.全部') }}</option>
                                        @foreach($adminName as $adminUid=>$nickname)
                                            <option value="{{$adminUid}}" @if (  $adminUid == $admin_id )
                                                selected
                                                @endif>{{$nickname}}</option>
                                        @endforeach

                                    </select>

                                    <a href="/admin/custom/user_list" 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;


                                </div>


                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>
                                        {{ __('auto.召回奖励：') }}{{$currentPrize}}
                                    </th>
                                    <th>
                                        {{ __('auto.召回总充值：') }}{{$currentPay/100}}
                                    </th>
                                    <th>
                                        {{ __('auto.召回总提现：') }}{{$currentWithdraw/100}}
                                    </th>
                                    <th>
                                        {{ __('auto.召回纯利：') }}{{($currentPay-$currentWithdraw)/100}}
                                    </th>
                                </tr>
                                <tr>
                                    <th width="6%">{{ __('auto.会员') }}ID</th>
                                    <th width="4%">{{ __('auto.昵称') }}</th>
                                    <th width="6%">{{ __('auto.手机号') }}</th>
                                    <th width="6%">{{ __('auto.邮箱') }}</th>
                                    <th width="9%">{{ __('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%">{{ __('auto.奖励') }}</th>

                                    <th width="6%">{{ __('auto.归属') }}</th>

                                    <th width="8%">{{ __('auto.操作') }}</th>

                                </tr>
                                </thead>
                                <tbody class="search_checkbox">
                                @foreach($list as $k=>$item)
                                    <tr>
                                        <td>

                                            <a href="/admin/global/id_find?UserID={{$item->UserID}}">
                                                {{$item->GameID}}
                                            </a>


                                        </td>
                                        <td>{{$item->NickName}}</td>
                                        <td>
                                            {{$item->PhoneNum}}
                                            <a  target="_blank"
                                                href="https://api.whatsapp.com/send?phone=55{{$item->PhoneNum}}">what's app</a>
                                        </td>
                                        <td>{{$item->Email}}</td>
                                        <td>{{ $item->Score }}</td>
                                        <td>{{ date('Y-m-d H:i:s',strtotime($item->RegisterDate))}}</td>
                                        <td>{{ date('Y-m-d H:i:s',strtotime($item->LastLogonDate))}}</td>

                                        <td>{{ date('Y-m-d H:i:s',strtotime($item->AddDate))}}</td>

                                        <td>
                                            {{$callState[$item->call_state]}}
                                        </td>



                                        <td>{{ $item->CallbackDate?date('Y-m-d H:i:s',strtotime($item->CallbackDate)):'--'}}</td>

                                        <td>{{ $item->recharge/100 }}</td>

                                        <td>{{ $item->withdraw/100 }}</td>

                                        <td>{{$item->call_state>0?($item->call_state==1?$prize:$prizeA):'--'}}</td>

                                        <td>
                                            {{$adminName[$item->admin_id]}}
                                        </td>

                                        <td>
                                            <a href="#" onclick="follow({{$item->UserID}})">{{ __('auto.跟进记录') }}</a>
                                        </td>

                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id = "pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,
                                        'GameID'=>$gameID,
                                        'start_time'=>$startTime,
                                        'end_time'=>$endTime,
                                        'lstart_time'=>$lstartTime,
                                        'lend_time'=>$lendTime,
                                        'cstartTime' => $cstartTime,
                                        'cendTime' => $cendTime,
                                        'state' => $state,
                                        'admin_id' => $admin_id
                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        var search_arr = [];
        var search_arr1 = [];
        var first_str = '';

        function callback() {
            myRequest("/admin/custom/callback", "post", {}, function (res) {
                layer.msg(res.msg)
            });
        }


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

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

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

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


        //同时获取该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
        }

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

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

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

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

        function follow(id){
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.召回跟进') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/custom/follow/'+id
            });
        }

    </script>
@endsection
