@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-trophy"></i>
                    </span>
                    充值排行榜
                </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">充值排行榜</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">充值排行榜 <small style="color:#999">(总充值 &gt; 100 且 提现/充值 &lt; 35%)</small></h4>
                            <form class="well form-inline margin-top-20" method="get" action="/admin/global/recharge_rank">
                                <div>
                                    <span style="padding-left: 10px">{{ __('auto.渠道名称：') }}</span>
                                    <select class="form-control" name="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="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                    <a href="/admin/global/recharge_rank" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                                </div>
                            </form>

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="6%">{{ __('auto.会员') }}ID</th>
                                    <th width="5%">{{ __('auto.渠道') }}</th>
                                    <th width="7%">{{ __('auto.余额') }}</th>
                                    <th width="7%">今日充值</th>
                                    <th width="7%">今日提现</th>
                                    <th width="8%">总充值</th>
                                    <th width="8%">总提现</th>
                                    <th width="6%">提/充比</th>
                                    <th width="10%">
                                        <div class="sort_register">
                                            {{ __('auto.注册时间') }}
                                            <svg t="1611284352657" class="icon2" onclick="sortFunc('sortRegister','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="{{ ($sortRegister ?? '') === 'asc' ? 'red' : '#707072' }}"></path>
                                            </svg>
                                            <svg t="1611283709864" class="icon1" onclick="sortFunc('sortRegister','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="{{ ($sortRegister ?? '') === 'desc' ? 'red' : '#707071' }}"></path>
                                            </svg>
                                        </div>
                                    </th>
                                    <th width="10%">
                                        <div class="sort_login">
                                            最后登录时间
                                            <svg t="1611284352657" class="icon2" onclick="sortFunc('sortLogin','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="{{ ($sortLogin ?? '') === 'asc' ? 'red' : '#707072' }}"></path>
                                            </svg>
                                            <svg t="1611283709864" class="icon1" onclick="sortFunc('sortLogin','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="{{ ($sortLogin ?? '') === 'desc' ? 'red' : '#707071' }}"></path>
                                            </svg>
                                        </div>
                                    </th>
                                    <th width="10%">{{ __('auto.控制状态') }}</th>
                                    <th width="8%">{{ __('auto.用户控制') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $item)
                                    <tr>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$item->UserID}}">
                                                {{$item->GameID}}
                                            </a>
                                        </td>
                                        <td>{{$item->Channel}}</td>
                                        <td>{{$item->Score}}</td>
                                        <td>{{$item->todayRecharge ?? 0}}</td>
                                        <td>{{$item->todayWithdraw ?? 0}}</td>
                                        <td>{{$item->Recharge}}</td>
                                        <td>{{$item->Withdraw}}</td>
                                        <td>{{$item->withdrawRate}}%</td>
                                        <td>{{ $item->RegisterDate ? date('Y-m-d H:i:s', strtotime($item->RegisterDate)) : '' }}</td>
                                        <td>{{ $item->LastLogonDate ? date('Y-m-d H:i:s', strtotime($item->LastLogonDate)) : '' }}</td>
                                        <td>
                                            @if ($item->RecordRechargeControl == 1)
                                                {{ __('auto.自动控制') }} <br>
                                            @endif

                                            @empty($item->ControlScore)
                                                {{ __('auto.无') }}
                                            @elseif ($item->ControlScore < 0)
                                                {{ __('auto.单控中') }} {{$item->EffectiveScore}} / {{$item->ControlScore}}
                                                / {{$item->control_record}} {{ __('auto.输') }}
                                            @elseif ($item->ControlScore > 0)
                                                {{ __('auto.单控中') }} {{ __('auto.赢') }}{{$item->EffectiveScore}} / {{$item->ControlScore}}
                                                {{$item->control_record}}
                                            @endempty
                                        </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([
                                    'channel' => $channel,
                                    'sortRegister' => $sortRegister ?? '',
                                    'sortLogin' => $sortLogin ?? '',
                                ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                            {!! $list->links() !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var currentSort = {
            sortRegister: '{{ $sortRegister ?? '' }}',
            sortLogin: '{{ $sortLogin ?? '' }}'
        };

        function sortFunc(field, dir) {
            var params = new URLSearchParams(window.location.search);
            params.delete('sortRegister');
            params.delete('sortLogin');
            params.delete('page');

            if (currentSort[field] === dir) {
                // already active => cancel sort
            } else {
                params.set(field, dir);
            }

            window.location.href = '/admin/global/recharge_rank?' + params.toString();
        }

        function update(id) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改配置') }}',
                shadeClose: true,
                shade: 0.8,
                offset: '180px',
                scrollbar: false,
                maxmin: true,
                area: ['70%', '60%'],
                fixed: false,
                content: '/admin/global/dk_userlist_edit?UserID=' + id,
                end: function () {
                    window.location.reload();
                },
            });
        }
    </script>
@endsection
