@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/channel/list'>
                                <span style="padding-left: 5px">{{ __('auto.包名：') }}</span>
                                <input type="text" name="Name" value="{{$Name}}"
                                       class="form-control">&nbsp;&nbsp;
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <a href="/admin/channel/list"
                                   class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}&{{ __('auto.刷新') }}</a>&nbsp;&nbsp;

                            </form>
                            <br>
                            <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>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="5%">{{ __('auto.渠道名称') }}</th>
                                    <th width="8%">{{ __('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 $k=>$v)
                                    <tr>
                                        <td>{{$v->Name}}</td>
                                        <td>
                                            @if ($v->ReviewState == 1)
                                                InReview
                                            @else
                                                {{ __('auto.正常') }}
                                            @endif
                                        </td>

                                        <td>
                                            @if ($v->ReviewState == 1)
                                                <button type="button" class="btn btn-sm btn-danger"
                                                        onclick="switch_control({{$v->ChannelType}},{{$v->ChannelIndex}},{{$v->AndroidVersion}},'off')">
                                                    {{ __('auto.关闭') }}
                                                </button>
                                            @elseif ($v->ReviewState == 0)
                                                <button type="button" class="btn btn-sm btn-primary"
                                                        onclick="switch_control({{$v->ChannelType}},{{$v->ChannelIndex}},{{$v->AndroidVersion}},'on')">
                                                    {{ __('auto.开启') }}
                                                </button>
                                            @endif

                                        </td>
                                        <td>{{$v->AndroidVersion}}</td>
                                        <td>{{$v->remarks}}</td>
                                        <td>
                                            <button class="btn btn-sm btn-gradient-dark"
                                                    onclick="update({{$v->ChannelType}},{{$v->ChannelIndex}},{{$v->AndroidVersion}},'{{$v->Name}}')">
                                                {{ __('auto.添加备注') }}
                                            </button>

                                            <button class="btn btn-sm btn-gradient-dark"
                                                    onclick="edit({{$v->ChannelType}},{{$v->ChannelIndex}},{{$v->AndroidVersion}},'{{$v->Name}}')">
                                                {{ __('auto.修改') }}
                                            </button>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,
                                        'Name' => $Name

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

        function switch_control(id, ChannelIndex, AndroidVersion, type) {

            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?", function () {
                myRequest("/admin/channel/switch/" + id, "post", {ChannelIndex, AndroidVersion, type}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 2000)
                });
            });
        }


        function add() {
            layer.open({
                type: 2,
                title: '{{ __('auto.添加渠道包') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '70%'],
                content: '/admin/channel/channel_add'
            });
        }

        function update(ChannelType, ChannelIndex, AndroidVersion, ChannelName) {
            layer.open({
                type: 2,
                title: '{{ __('auto.添加备注') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/channel/update/' + ChannelType + '?ChannelIndex=' + ChannelIndex + '&ChannelName=' + ChannelName + '&AndroidVersion=' + AndroidVersion
            });
        }

        function edit(ChannelType, ChannelIndex, AndroidVersion, ChannelName) {
            layer.open({
                type: 2,
                title: '{{ __('auto.修改渠道配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/channel/channel_edit/' + ChannelType + '?ChannelIndex=' + ChannelIndex + '&ChannelName=' + ChannelName + '&AndroidVersion=' + AndroidVersion
            });
        }


    </script>
@endsection
