@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>
{{--                            <p class="card-description">--}}
{{--                                <button type="button" class="btn btn-sm btn-gradient-success btn-icon-text"--}}
{{--                                        onclick="add()">--}}
{{--                                    <i class="mdi mdi-plus btn-icon-prepend"></i>--}}
{{--                                    {{ __('auto.茶叶审核档位添加') }}--}}
{{--                                </button>--}}
{{--                            </p>--}}
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.菜单名称') }}</th>
                                    <th>{{ __('auto.代付方') }}</th>
                                    <th>{{ __('auto.累计咖啡额度范围设置') }}</th>
                                    <th>{{ __('auto.单个玩家可免审核茶叶额度') }}</th>
                                    <th>{{ __('auto.每日日累计消耗申请额度') }} / {{ __('auto.每日申请总额度') }}</th>
                                    <th>{{ __('auto.操作') }}</th>
                                    <th>{{ __('auto.开关状态') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $val)
                                    <tr>
                                        <td>{{ $val->name }}</td>
                                        <td>{{ $val->agent_name }}</td>
                                        <td>{{$val->recharge_min}} - {{$val->recharge_max}}</td>
                                        <td>
                                            @if ($val->type == 1)
                                                {{$val->quota}}
                                            @elseif($val->type == 2)
                                                {{$val->quota}} {{ __('auto.倍') }}
                                            @endif
                                        </td>
                                        <td>{{$val->useQuota}} / {{ $val->total_quota }}</td>
                                        <td>
                                            <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text"
                                                    onclick="update({{ $val->id }})">
                                                {{ __('auto.修改') }}
                                                <i class="mdi mdi-file-check btn-icon-append"></i>
                                            </button>
                                        </td>
                                        <td>
                                            @if ($val->status == 1)
                                                {{ __('auto.开启中') }}
                                                <button class="btn btn-sm btn-gradient-danger"
                                                        onclick="block({{$val->id}},2)">{{ __('auto.关闭') }}
                                                </button>
                                            @else
                                                {{ __('auto.关闭中') }}
                                                <button class="btn btn-sm btn-gradient-success"
                                                        onclick="block({{$val->id}},1)">{{ __('auto.开启') }}
                                                </button>
                                            @endif
                                        </td>

                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([

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

    </div>

    <script>

        function add() {
            layer.open({
                type: 2,
                title: '{{ __('auto.添加免审配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['60%', '80%'],
                content: '/admin/withdrawal/exempt_review_add'
            });
        }

        function update(id) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改免审配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/withdrawal/exempt_review_update/' + id
            });
        }


        function block(id,status) {
            myConfirm("{{ __('auto.是否继续') }}?", function () {
                myRequest("/admin/withdrawal/block/" + id, "post", {status}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                });
            });
        }

    </script>

@endsection
