@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="get" action='/admin/extension/verify_final'>

                                <spen style="padding-left: 10px">{{ __('auto.会员ID：') }}</spen>
                                <input class="form-control" type="text" name="GameID" style="width: 10%; "
                                       value="{{$GameID}}">

                                <spen style="padding-left: 10px">{{ __('auto.手机号：') }}</spen>
                                <input class="form-control" type="text" name="mobile" style="width: 10%; "
                                       value="{{$mobile}}">
                                <spen style="padding-left: 10px">{{ __('auto.上级ID：') }}</spen>
                                <input class="form-control" type="text" name="SpreaderID" style="width: 10%; "
                                       value="{{$SpreaderID}}">
                                <spen style="padding-left: 10px">{{ __('auto.昵称：') }}</spen>
                                <input class="form-control" type="text" name="NickName" style="width: 10%; "
                                       value="{{$NickName}}">

                                <spen style="padding-left: 10px">{{ __('auto.选择注册时间：') }}</spen>
                                <input type="datetime-local" step="01" name="start_time" class="form-control"
                                       value="{{$start_time}}" id="start_time" onclick="start_times()"/>&nbsp;&nbsp;
                                <input type="datetime-local" step="01" name="end_time" class="form-control"
                                       value="{{$end_time}}" id="end_time" onclick="end_times()"/>&nbsp;&nbsp;

                                <spen style="padding-left: 10px">{{ __('auto.审核通过时间：') }}</spen>
                                <input type="datetime-local" step="01" name="CreateTimeStart" class="form-control"
                                       value="{{$CreateTimeStart}}" id="CreateTimeStart" onclick="CreateTimeStarts()"/>&nbsp;&nbsp;
                                <input type="datetime-local" step="01" name="CreateTimeEnd" class="form-control"
                                       value="{{$CreateTimeEnd}}" id="CreateTimeEnd" onclick="CreateTimeEnds()"/>&nbsp;&nbsp;

                                <span style="padding-left: 10px">{{ __('auto.类型：') }}</span>
                                <select name="Type" id="" class="form-control">
                                    <option>{{ __('auto.请选择') }}</option>
                                    <option value="1" @if ($Type == 1)
                                        selected
                                    @endif>{{ __('auto.邀请好友注册') }}</option>
                                    <option value="2" @if ($Type == 2)
                                        selected
                                    @endif>{{ __('auto.邀请好友对局') }}</option>
                                </select>
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <a href="/admin/extension/verify_final"
                                   class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>&nbsp;&nbsp;

                            </form>


                            <br>


                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.会员') }}ID</th>
                                    <th>TA{{ __('auto.的上级') }}ID</th>
                                    <th>{{ __('auto.总奖励') }}</th>
                                    <th>{{ __('auto.历史通过审核金') }}</th>
                                    <th>{{ __('auto.可领金额') }}</th>
                                    <th>{{ __('auto.账号创建时间') }}</th>
                                    <th>{{ __('auto.通过时金额') }}</th>
                                    <th>{{ __('auto.金额类型') }}</th>
                                    <th>{{ __('auto.是否达成额度') }}</th>
                                    <th>{{ __('auto.来源玩家') }}</th>
                                    <th>{{ __('auto.所有下级人数') }}</th>
                                    <th>{{ __('auto.直属下级') }}</th>
                                    <th>{{ __('auto.下下级') }}</th>
                                    <th>{{ __('auto.审核通过时间') }}</th>
                                    <th>{{ __('auto.用户额度达成时间') }}</th>
                                    <th>{{ __('auto.备注') }}</th>
                                </tr>
                                </thead>
                                <tbody>

                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$v->UserID}}">
                                                {{$v->GameID}}
                                            </a>
                                        </td>
                                        <td>{{ $v->SpreaderID }}</td>
                                        <td>{{$v->Total}}</td>
                                        <td>{{ $v->FinalScore }}</td>
                                        <td>{{CollectableScore($v->UserID,$v->Type)}}</td>
                                        <td>{{$v->RegisterDate}}</td>
                                        <td>{{$v->AgreeScore}}</td>
                                        <td>
                                            @if ($v->Type == 1)
                                                {{ __('auto.注册') }}
                                            @elseif($v->Type == 2)
                                                {{ __('auto.对局') }}
                                            @endif
                                        </td>
                                        <td>{{$v->logFinalScore}}</td>
                                        <td>
                                            @if ($v->count > 0)
                                                <a href="javascript:void(0)"
                                                   onclick="userSourceFunc({{$v->OrderID}},{{$v->UserID}},{{$v->Type}})">{{$v->count}}</a>
                                            @else
                                                {{$v->count}}
                                            @endif
                                        </td>

                                        <td>{{$v->downCount1 + $v->downCount2}}</td>
                                        <td>
                                            @if ($v->downCount1 > 0)
                                                <a href="/admin/user/bind_list?Higher1ID={{$v->UserID}}&source=2&start_time={{$start_time}}&end_time={{$end_time}}&GameID={{$GameID}}&SpreaderID={{$SpreaderID}}&NickName={{$NickName}}&Type={{$Type}}&Sort={{$Sort}}">
                                                    {{$v->downCount1}}
                                                </a>
                                            @else
                                                {{$v->downCount1}}
                                            @endif

                                        </td>
                                        <td>
                                            @if ($v->downCount2 > 0)
                                                <a href="/admin/user/bind_list?Higher2ID={{$v->UserID}}&source=2&start_time={{$start_time}}&end_time={{$end_time}}&GameID={{$GameID}}&SpreaderID={{$SpreaderID}}&NickName={{$NickName}}&Type={{$Type}}&Sort={{$Sort}}">
                                                    {{$v->downCount2}}
                                                </a>
                                            @else
                                                {{$v->downCount2}}
                                            @endif

                                        </td>
                                        <td>{{$v->CreateTime}}</td>
                                        <td>{{$v->UpdateTime}}</td>

                                        <td  contentEditable="true"
                                             onblur="remarks(this,{{$v->id}})" style="vertical-align: top">{{$v->Remarks}}
                                        </td>

                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">

                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'start_time' => $start_time,
                                        'end_time' => $end_time,
                                        'GameID' => $GameID,
                                        'SpreaderID' => $SpreaderID,
                                        'NickName' => $NickName,
                                        'Type' => $Type,
                                        'Sort' => $Sort,
                                        'mobile'=>$mobile,
                                        'CreateTimeStart' => $CreateTimeStart,
                                        'CreateTimeEnd' => $CreateTimeEnd

                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var dataObj = {
            'GameID': '{{$GameID}}',
            'mobile': '{{$mobile}}',
            'SpreaderID': '{{$SpreaderID}}',
            'NickName': '{{$NickName}}',
            'start_time': '{{$start_time}}',
            'end_time': '{{$end_time}}',
            'Sort':'{{$Sort}}'
        }

        // 类型搜索
        function typeFunc() {

            //这样获取的是一个数组
            var ci = document.getElementsByName("Type");

            var type = ''

            // 遍历复选框数组  如果被选中ci[i].checked的值就是true
            for (var i = 0; i < ci.length; i++) {
                if (ci[i].checked == true) {
                    type += ci[i].value + ','
                }
            }

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

            console.log(type)
        }

        // 奖励来源
        function userSourceFunc(OrderID, UserID,Type) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.奖金来源') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '80%'],
                content: '/admin/extension/user_source?OrderID=' + OrderID + '&UserID=' + UserID+'&Type='+Type
            });
        }

        // 上下排序
        function totalScoreFunc(obj, val) {

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

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

            dataObj.Sort = val

            $.ajax({
                type: "get",
                url: "/admin/extension/verify",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: dataObj,
                success: function (msg) {

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

                    }
                }
            })
        }

        function remarks(obj, id) {
            var Remarks = $(obj).html();
            myRequest("/admin/extension/verify_final_remarks/" + id, "post", {Remarks}, function (res) {
                layer.msg(res.msg)
                // setTimeout(function () {
                //     window.location.reload();
                // }, 1500)
            });
        }

        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 CreateTimeStarts() {

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

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

        function CreateTimeEnds() {
            getFormat('23', '59', '59');
            document.getElementById("CreateTimeEnd").value = format
        }
    </script>
@endsection
