@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">
                            <form class="well form-inline margin-top-20" method="post" action='/admin/global/reward'>
                                <div>
                                    @csrf
                                    <spen style="padding-left: 10px">{{ __('auto.会员ID：') }}</spen>
                                    <input class="form-control" type="text" name="UserID" id="UserID"
                                           value="{{$UserID}}">
                                    <spen style="padding-left: 10px">{{ __('auto.上级id：') }}</spen>
                                    <input class="form-control" type="text" name="SpreaderID" id="SpreaderID"
                                           value="{{$SpreaderID}}">
                                    <spen style="padding-left: 10px">{{ __('auto.选择类型：') }}</spen>
                                    <select class="form-control" name="Type" value="" style="color: black">
                                        <option value="1" @if ($Type == 1)
                                            selected
                                        @endif>{{ __('auto.注册') }}</option>
                                        <option value="2" @if ($Type == 2)
                                            selected
                                        @endif>{{ __('auto.对局') }}</option>
                                        <option value="3" @if ($Type == 3)
                                            selected
                                        @endif>{{ __('auto.咖啡') }}</option>
                                    </select>
                                    <spen style="padding-left: 10px">{{ __('auto.发放时间：') }}</spen>
                                    <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()"/>
                                    <a href="/admin/global/reward"
                                       class="btn btn-sm btn-gradient-primary btn-icon-text">{{ __('auto.重置') }}</a>
                                    <input type="submit" class="btn btn-sm btn-gradient-primary btn-icon-text"
                                           value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp
                                </div>

                                {{ __('auto.自动审核：') }}
                                @if ($AutoVerify == 1)
                                    {{ __('auto.已开启') }} <button class="btn btn-sm btn-gradient-dark" onclick="autoVerify(0)">{{ __('auto.关闭') }}</button>
                                @else
                                    {{ __('auto.已关闭') }} <button class="btn btn-sm btn-gradient-dark" onclick="autoVerify(1)">{{ __('auto.开启') }}</button>
                                @endif

                            </form>

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="5%">{{ __('auto.发放会员') }}id</th>
                                    <th width="4%">{{ __('auto.上级') }}id</th>
                                    <th width="6%">{{ __('auto.系统发放时间') }}</th>
                                    <th width="8%">{{ __('auto.发放奖励') }}</th>
                                    <th width="8%">{{ __('auto.发放状态') }}</th>
                                    <th width="8%">{{ __('auto.奖励来源玩家') }}</th>

                                    <th width="8%">{{ __('auto.类型') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $value)
                                    <tr>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$value->UserID}}">{{$value->GameID}}</a>
                                        </td>
                                        <td>{{$value->SpreaderID}}</td>
                                        <td>{{date("Y-m-d H:i:s" ,strtotime($value->SendTime))}}</td>
                                        <td>{{$value->DirectRebate}}</td>
                                        <td>{{ __('auto.已发放') }}</td>

                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$value->SourceUserID}}">{{$value->SourceGameID}}</a>

                                        </td>

                                        <td>
                                            @if ($value->Type == 1)
                                                {{ __('auto.注册') }}
                                            @elseif($value->Type == 2)
                                                {{ __('auto.对局') }}
                                            @elseif($value->Type == 3)
                                                {{ __('auto.咖啡') }}
                                            @endif
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,
                                        'UserID' => $UserID,
                                        'SpreaderID' => $SpreaderID,
                                        'start_time' => $start_time,
                                        'end_time' => $end_time,
                                        'Type' => $Type
                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        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 autoVerify(StatusValue) {
            myRequest("/admin/extension/auto_verify", "post", {StatusValue}, function (res) {
                layer.msg(res.msg)
                setTimeout(function () {
                    window.location.reload();
                }, 1500)
            });
        }

        function userSourceFunc(orderIds, Type, Id, GameID) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.奖金来源') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '80%'],
                content: '/admin/global/user_source?orderIds=' + orderIds + '&Type=' + Type + '&Id=' + Id + '&GameID=' + GameID
            });
        }
    </script>
@endsection
