@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-wrench"></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/user/score_change'>
                                <spen style="padding-left: 10px">{{ __('auto.变化原因：') }}</spen>
                                {{--                                <input class="form-control" type="text" name="describe" style="width: 10%; " value="{{$describe}}" placeholder="{{ __('auto.输入变化原因') }}">--}}
                                <select name="describe" id="" class="form-control">
                                    <option value="">{{ __('auto.请选择原因') }}</option>
                                    <option value="-1" @if (-1 == $describe)
                                    selected
                                        @endif>{{ __('auto.全部彩金') }}
                                    </option>
                                    @foreach($Reason as $v)
                                        <option value="{{$v->Reason}}" @if ($v->Reason == $describe)
                                        selected
                                            @endif>{{$v->Describe}}</option>
                                    @endforeach
                                </select>


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

                                <spen style="padding-left: 10px">{{ __('auto.选择时间：') }}</spen>
                                <input type="date" step="01" name="start_time" class="form-control"
                                       value="{{$start_time}}"/>&nbsp;&nbsp;
                                <input type="date" step="01" name="end_time" class="form-control"
                                       value="{{$end_time}}"/>&nbsp;&nbsp;
                                <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="hidden" name="ChangeScoreSort" value="{{$ChangeScoreSort}}">
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <a href="/admin/user/score_change"
                                   class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.重置') }}</a>&nbsp;&nbsp;

                                <!-- <a href="/admin/user/list/" class="btn btn-sm btn-gradient-info btn-icon-text">返回</a> -->
                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.会员') }}ID</th>
                                    <th>{{ __('auto.金额变化时间') }}</th>
                                    <th>{{ __('auto.变化原因') }}</th>
                                    <th>{{ __('auto.变化前金豆') }}</th>
                                    <th>
                                        <div class="ChangeScore">
                                            {{ __('auto.变化金豆') }}
                                            <svg t="1611284352657" class="icon2" onclick="ChangeScoreSort(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="ChangeScoreSort(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>{{ __('auto.变化后金豆') }}</th>
                                    <th>{{ __('auto.操作人') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td style="width: 13%">
{{--                                            <a href="/admin/global/id_find?UserID={{$v->UserID}}">--}}
{{--                                                {{$v->GameID}}--}}
{{--                                            </a>--}}
                                            <a href="javascript:void(0)" onclick="idFindFunc({{$v->UserID}})">{{$v->GameID}}</a>
                                        </td>
                                        <td style="width: 13%">{{ $v->UpdateTime }}</td>
                                        <td style="width: 10%">
                                            {{ $v->Describe}} <br>
                                            {{$v->ServerName}}
                                        </td>

                                        <td style="width: 10%">{{ $v->BeforeScore}}</td>
                                        <td style="width: 10%">{{ $v->ChangeScore}}</td>
                                        <td style="width: 10%">{{ $v->AfterScore}}</td>
                                        <td style="width: 10%">{{ __('auto.系统') }}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">
                                {{ __('auto.总共') }}
                                <b>{{ $list->appends([
    'describe'=>$describe,
    'UserID'=>$UserID,
    'start_time'=>$start_time,
    'end_time'=>$end_time,
    'ChangeScoreMin' => $ChangeScoreMin,
    'ChangeScoreMax' => $ChangeScoreMax,
    'ChangeScoreSort' => $ChangeScoreSort


])->total() }}</b>
                                {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        var data_obj = {
            'describe': "{{$describe}}",
            'UserID':"{{$UserID}}",
            'start_time':"{{$start_time}}",
            'end_time':"{{$end_time}}",
            'ChangeScoreMax':"{{$ChangeScoreMax}}",
            'ChangeScoreMin':"{{$ChangeScoreMin}}"
        }

        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'
            });
        }

        var that = this
        function ChangeScoreSort(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: "get",
                url: "/admin/user/score_change",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: that.data_obj,
                success: function (msg) {

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

                    }
                }
            })
        }


        function publish(id) {
            myConfirm("{{ __('auto.是否继续') }}?", function () {
                var myselect = document.getElementById("state" + id);
                var index = myselect.selectedIndex;
                var data = {state: myselect.options[index].value}
                myRequest("/admin/shop/update/" + id, "post", data, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                });
            });
        }

        $('.menu-switch').click(function () {
            id = $(this).attr('id');
            state = $(this).attr('state');
            if (state == "on") {
                $('.pid-' + id).hide();
                $(this).attr("state", "off")
                $(this).removeClass('mdi-menu-down').addClass('mdi-menu-right');
            } else {
                $('.pid-' + id).show();
                $(this).attr("state", "on")
                $(this).removeClass('mdi-menu-right').addClass('mdi-menu-down');
            }
        })


    </script>
@endsection
