@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="post" action='/admin/global/userlist'>
                                <div>
                                    @csrf
                                </div>


                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="6%">
                                        <center>
                                            <button type="button" id="quan" onclick="checkbox()" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                                {{ __('auto.全选/全不选') }}
                                            </button>
                                        </center>
                                    </th>
                                    <th width="4%">{{ __('auto.玩家') }}id</th>
                                    <th width="6%">{{ __('auto.茶叶金额') }}</th>

                                </tr>
                                </thead>
                                <tbody class="search_checkbox">
                                @foreach($list as $k=>$item)
                                    <tr>
                                        @if (count($list) == 1)
                                            <td><input type="hidden" name="ids" value="{{$item->RecordID}}" class="only_one"></td>
                                        @else
                                            <td class="is_hidden">
                                                <input class="form-control" type="checkbox" name="checkbox" id="{{$item->RecordID}}" checked  value="">
                                            </td>
                                        @endif
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$item->UserID}}">
                                                {{$item->GameID}}
                                            </a>
                                        </td>
                                        <td>{{$item->WithDraw}}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="remark" style="margin: 50px 31px 22px 169px;width: 600px">
                                <span style="margin-left: 280px">{{ __('auto.请填写拒绝理由') }}</span>
                                <textarea class="form-control remarks" rows="3" name="remarks" required></textarea>
                            </div>
                            <div class="click_btn" style="clear: both;margin: 0 auto;width: 171px;">
                                <div style="margin-bottom: 10px">
                                    {{ __('auto.确定通过该订单吗？') }}
                                </div>

                                <button type="button" onclick="commit()" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                    {{ __('auto.提交') }}
                                </button>
                                <button type="button" onclick="cancel()" class="btn btn-sm btn-gradient-warning btn-icon-text">
                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
                                    {{ __('auto.取消') }}
                                </button>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        function checkbox(){
            var num=document.getElementsByName('checkbox');
            for(var i=0;i<num.length;i++){
                if(num[i].checked){
                    num[i].checked=false;
                }else{
                    num[i].checked=true;
                }
            }
        }


        function commit(){
            var ids

            // 获取单个值
            var only = $('.only_one').val()
            // 获取代付方值
            var remarks = $(".remarks").val()

            if (only !== undefined){
                ids = only;
            }else {
                // 获取多选框选中的值
                var num=document.getElementsByName('checkbox');
                var str = '';
                for(var i=0;i<num.length;i++){
                    if(num[i].checked){
                        str=str+num[i].id+',';
                    }
                }
                if (str==''){
                    alert('{{ __('auto.请选择要操作的数据') }}');return false;
                }

                 ids = str.substr(0,str.length-1);
            }

            var data = {
                'ids':ids,
                'remarks':remarks,
                'agree':false,
            }

            if (remarks == ''){
                layer.msg('{{ __('auto.请填写拒绝原因') }}')
                return false;
            }

            myConfirm("{{ __('auto.是否继续') }}?",function(){
                myRequest("/admin/withdrawal/verify","post",data,function(res){
                    layer.msg(res.msg)
                    if(res.code === 200){
                        setTimeout(function(){
                            parent.location.reload();
                        },1500)
                    }
                });
            });

        }




        function ban(ban){
            //1封号 2解封
            var num=document.getElementsByName('checkbox');

            var str='';
            for(var i=0;i<num.length;i++){
                if(num[i].checked){
                    str=str+num[i].id+',';
                }
            }

            if (str==''){
                alert('{{ __('auto.请选择要操作的数据') }}');return false;
            }
            var id=str.substr(0,str.length-1);
            console.log(id)
            // myConfirm("是否继续账户操作?",function(){
            //     myRequest("/admin/global/ban","post",{id:id,ban:ban},function(res){
            //         layer.msg(res.msg)
            //         setTimeout(function(){
            //             window.location.reload();
            //         },1500)
            //     });
            // });
            return false;
        }
    </script>
@endsection
