@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/exchange/cost'>
                                <spen style="padding-left: 10px" >{{ __('auto.用户ID：') }}</spen>
                                <input class="form-control" type="text" name="user_id" style="width: 10%; " value="{{$user_id}}" placeholder="{{ __('auto.请输入中奖者') }}ID">&nbsp;&nbsp;
                                <spen style="padding-left: 10px" >{{ __('auto.奖品名称：') }}</spen>
                                <input class="form-control" type="text" name="prop_name" style="width: 10%; " value="{{$prop_name}}" placeholder="{{ __('auto.请输入奖品名称') }}">&nbsp;&nbsp;
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}" />
                                <a href="/admin/exchange/cost" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.用户') }}ID</th>
                                    <th>{{ __('auto.联系电话') }}</th>
                                    <th>{{ __('auto.时间') }}</th>
                                    <th>{{ __('auto.名称') }}</th>
                                    <th>{{ __('auto.状态') }}</th>
                                    <th>{{ __('auto.操作') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td style="width: 8%">{{ $v->UseId }}</td>
                                        <td style="width: 15%">{{ $v->Phone}}</td>
                                        <td style="width: 15%">{{ date('Y-m-d H:i:s',strtotime($v->CreateTime)) }}</td>
                                        <td style="width: 10%">{{ $v->PropName}}</td>
                                        <td style="width: 10%">
                                            <select id="state{{$v->UniqueCode}}">
                                                @foreach($select as $key=>$vl)
                                                    <option value="{{$vl}}" @if($v->State==$vl){echo selected=selected} @endif>@if($vl==null){{ __('auto.选择订单状态') }}@else{{$vl}}@endif</option>
                                                @endforeach
                                            </select>
                                        </td>
                                        <td style="width: 5%">
                                            <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text" onclick="publish('{{$v->UniqueCode}}')">
                                                {{ __('auto.修改') }}
                                                <i class="mdi mdi-file-check btn-icon-append"></i>
                                            </button>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">
                                {{ __('auto.总共') }} <b>{{ $list->appends(["user_id"=>$user_id,"prop_name"=>$prop_name])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        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/cost/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
