@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">
                        @if ($id_list != '')
                            <div>
{{--                                <a href="/admin/global/id_find?UserID={{$UserID}}" onclick="javascript:history.back(-1);">{{ __('auto.返回到上一页') }}</a>&nbsp;&nbsp;--}}
                                <a href="#" onClick="javascript :history.go(-{{$Jump}});">{{ __('auto.返回上一页') }}</a>
                            </div>
                        @endif
                        <div class="card-body">
                            <span>
                                <button class="btn btn-sm btn-gradient-danger"
                                        onclick="change_date()">6{{ __('auto.月17日') }}</button>
                            </span>
                            <form class="well form-inline margin-top-20" method="post"
                                  action='/admin/global/winloser?id_list={{$id_list}}'>
                                <div>
                                    @csrf
                                    <input type="hidden" name="Jump" value="{{$Jump}}">
                                    <spen style="padding-left: 10px">{{ __('auto.会员ID：') }}</spen>
                                    <input class="form-control" type="text" name="UserID" id="UserID"
                                           value="{{$GameID}}">
                                    <spen style="padding-left: 10px">{{ __('auto.战绩搜索：') }}</spen>
                                    <input class="form-control" type="text" name="UniqueCode" id="UniqueCode"
                                           value="{{$UniqueCode}}">
                                    <spen style="padding-left: 10px">{{ __('auto.游戏选择：') }}</spen>
                                    <select class="form-control" name="searchGame" value="" style="color: black">
                                        <option value="">{{ __('auto.全部') }}</option>
                                        @foreach($games as $key=>$value)
                                            <option value="{{$key}}" @if ($searchGame == $key) selected @endif>
                                                {{$value}}
                                            </option>
                                        @endforeach

                                    </select>

                                    <spen style="padding-left: 10px">{{ __('auto.房间选择：') }}</spen>
                                    <select class="form-control" name="room" value="" style="color: black">
                                        <option value="">{{ __('auto.全部') }}</option>
                                        @foreach($rooms as $key=>$value)
                                            <option value="{{$key}}" @if ($room == $key) selected @endif>
                                                {{$value}}
                                            </option>
                                        @endforeach

                                    </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}}"/>
                                    <input type="datetime-local" step="01" name="end_time" id='end_time'
                                           class="form-control" value="{{$end_time}}"/> <br>

                                    <spen style="padding-left: 10px">{{ __('auto.输赢金额范围：') }}</spen>
                                    <input type="number"  value="{{$ChangeScoreMin}}" style="color: black;width: 10%;"
                                           class="form-control required" name="ChangeScoreMin">-
                                    <input type="number"  value="{{$ChangeScoreMax}}" style="color: black;width: 10%;"
                                           class="form-control required" name="ChangeScoreMax">

                                    <input type="submit" class="btn btn-sm btn-gradient-primary btn-icon-text"
                                           value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp

                                    <input type="hidden" name="afterScoreSort" value="{{$afterScoreSort}}">
                                    <input type="hidden" name="ChangeScoreSort" value="{{$ChangeScoreSort}}">

                                    <a href="/admin/global/winloser"
                                       class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                                    <a href="/admin/global/winloser?excel=1
                                    &UserID={{$GameID}}
                                        &UniqueCode={{$UniqueCode}}
                                        &room={{$room}}
                                        &start_time={{$start_time}}
                                        &end_time={{$end_time}}
                                        &searchGame={{$searchGame}}
                                        &ChangeScoreMin={{$ChangeScoreMin}}
                                        &ChangeScoreMax={{$ChangeScoreMax}}
                                        "
                                       class="btn btn-sm btn-gradient-light btn-icon-text">{{ __('auto.导出') }}</a>

                                </div>
                            </form>

                            <div class="row">
                                @if (hidden() != 'service')
                                    <div class="card">
                                        <div class="card-body">
                                            <table class="table table-bordered">
                                                <thead>
                                                <tr>
                                                    <th>{{ __('auto.平台总输赢：') }}{{$data['ChangeScore']}}</th>
                                                    <th>{{ __('auto.流水：') }}{{$data['liushui']}}</th>
                                                    <th>{{ __('auto.税收：') }}{{$data['Revenue']}}</th>
                                                    <th>{{ __('auto.人数：') }}{{$data['UserID']}}</th>
                                                </tr>
                                                </thead>
                                            </table>
                                        </div>
                                    </div>
                                @endif

                            </div>

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="5%">{{ __('auto.会员') }}ID</th>
                                    <th width="4%">{{ __('auto.游戏时间') }}</th>
                                    <th width="6%">{{ __('auto.房间名称') }}</th>
                                    <th width="6%">{{ __('auto.变化前金豆') }}</th>

                                    <th width="6%">
                                        <div class="ChangeScore">
                                            {{ __('auto.输赢变化金豆') }}
                                            <svg t="1611284352657" class="icon2" onclick="ChangeScore(this,'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="#707072">

                                                </path>
                                            </svg>

                                            <svg t="1611283709864" class="icon1" onclick="ChangeScore(this,'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="#707071">

                                                </path>
                                            </svg>
                                        </div>

                                    </th>
                                    <th width="8%">
                                        <div class="afterScore">
                                            {{ __('auto.变化后输赢金豆') }}
                                            <svg t="1611284352657" class="icon2" onclick="afterScore(this,'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="#707072">

                                                </path>
                                            </svg>

                                            <svg t="1611283709864" class="icon1" onclick="afterScore(this,'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="#707071">

                                                </path>
                                            </svg>
                                        </div>

                                    </th>
                                    <th width="8%">{{ __('auto.累计税收') }}</th>
                                    <th width="6%">{{ __('auto.游戏战绩') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $value)
                                    <tr>
                                        <td>
{{--                                            <a href="/admin/global/id_find?UserID={{$value->UserID}}">{{$value->GameID}}</a>--}}
                                            <a href="javascript:void(0)" onclick="idFindFunc({{$value->UserID}})">{{$value->GameID}}</a>
                                        </td>
                                        <td>{{$value->UpdateTime}}</td>
                                        <td>{{$value->thirdRoom?? $rooms[$value->ServerID] ?? ''}}</td>
                                        <td>{{$value->BeforeScore}}</td>
                                        <td>{{$value->ChangeScore}}</td>
                                        <td>{{$value->afterScore}}</td>
                                        <td>{{$value->Revenue}}</td>
                                        <td>
                                            @if($value->UniqueCode)
                                            <a href="/admin/global/game_record?UniqueCode={{$value->UniqueCode}}&gameId={{$value->GameID}}&month={{date('Ym',strtotime($value->UpdateTime))}}">{{ __('auto.点击查询') }}</a>
                                            @endif
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,
                                        'UserID' => $GameID,
                                        'UniqueCode' => $UniqueCode,
                                        'room' => $room,
                                        'start_time' => $start_time,
                                        'end_time' => $end_time,
                                        'id_list' => $id_list,
                                        'ChangeScoreMin'=>$ChangeScoreMin,
                                        'ChangeScoreMax'=>$ChangeScoreMax,
                                        'afterScoreSort'=>$afterScoreSort,
                                        'ChangeScoreSort'=>$ChangeScoreSort,
                                        'searchGame' => $searchGame
                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        var data_obj = {
            'UserID':"{{$GameID}}",
            'UniqueCode':"{{$UniqueCode}}",
            'room':"{{$room}}",
            'start_time':"{{$start_time}}",
            'end_time': "{{$end_time}}",
            'id_list':"{{$id_list}}",
            'ChangeScoreMin':"{{$ChangeScoreMin}}",
            'ChangeScoreMax':"{{$ChangeScoreMax}}",
            'afterScoreSort':"{{$afterScoreSort}}",
            'ChangeScoreSort':"{{$ChangeScoreSort}}",
            'searchGame':"{{$searchGame}}",
        }
        var that = this

        function change_date() {
            $('#start_time').val('2021-06-17T00:00:00');
        }

        function idFindFunc(UserID) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.用户控制面板') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['100%', '100%'],
                content: '/admin/global/id_find?UserID=' + UserID+'&OpenPage=1'
            });
        }

        function ChangeScore(obj, val) {

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

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

            that.data_obj.ChangeScoreSort = val

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

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

                    }
                }
            })
        }

        function afterScore(obj, val) {

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

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

            that.data_obj.afterScoreSort = val

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

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

                    }
                }
            })
        }
    </script>
@endsection

