@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/shop'>
                                {{ __('auto.玩家ID：') }}
                                <input class="form-control" type="text" name="id" style="width: 8%; " value="{{ $id }}" placeholder="{{ __('auto.请输入玩家') }}ID">
                                <spen style="padding-left: 10px" >{{ __('auto.商品名称：') }}</spen>
                                <input class="form-control" type="text" name="reward" style="width: 8%; " value="{{ $reward }}" placeholder="{{ __('auto.请输入商品名称') }}">
                                <spen style="padding-left: 10px" >{{ __('auto.奖品种类：') }}</spen>
                                <select class="form-control" name="type" value="{{$type}}">
                                    <option value="">{{ __('auto.请选择种类') }}</option>
                                    @foreach($prop_type as $k=>$v)
                                        <option value="{{$k}}" @if($k===$type) selected @endif>{{$v}}</option>
                                    @endforeach
                                </select>
                                <spen style="padding-left: 10px" >{{ __('auto.状态：') }}</spen>
                                <select class="form-control" name="status" value="{{$status}}">
                                    <option value="">{{ __('auto.请选择状态') }}</option>
                                    @foreach($order_status as $k=>$v)
                                        <option value="{{$k}}" @if($k===$status) selected @endif>{{$v}}</option>
                                    @endforeach
                                </select>
                                <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;
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>
                                <a href="/admin/exchange/shop" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                                <a href="/admin/exchange/shop?excel=1&id={{$id}}&type={{$type}}&status={{$status}}&reward={{$reward}}&start_time={{$start_time}}&end_time={{$end_time}}" class="btn btn-sm btn-gradient-info btn-icon-text">{{ __('auto.导出') }}</a>
                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.兑换时间') }}</th>
                                    <th>{{ __('auto.奖品名称') }}</th>
                                    <th>{{ __('auto.奖品价格（元）') }}</th>
                                    <th>{{ __('auto.奖品种类') }}</th>
                                    <th>{{ __('auto.玩家') }}ID</th>
                                    <th>{{ __('auto.玩家昵称') }}</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: 13%">{{ $v->CreateDate}}</td>
                                        <td style="width: 10%">{{ $v->GoodsTitle}}</td>
                                        <td style="width: 10%">{{ $v->Money}}</td>
                                        <td style="width: 10%">{{ $v->Type}}</td>
                                        <td style="width: 6%">{{ $v->GameID }}</td>
                                        <td style="width: 12%">{{ $v->NickName}}</td>
                                        <td style="width: 10%">{{ $v->Compellation}}</td>
                                        <td style="width: 8%">{{ $v->MobilePhone}}</td>
                                        <td style="width: 15%">{{ $v->UserNote}}</td>
                                        <td style="width: 10%">
                                            <select id="state{{$v->RecordID}}">
                                                @foreach($select as $key=>$vl)
                                                    <option value="{{$vl}}" @if($v->Cause==$vl){echo selected=selected} @endif>@if($vl==null){{ __('auto.待发货') }}@else{{$vl}}@endif</option>
                                                @endforeach
                                            </select>
                                        </td>
                                        <td style="width: 5%">
                                            @if($v->PropType==0 || $v->PropType==1)
                                            <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text" onclick="publish({{ $v->RecordID }})">
                                                {{ __('auto.修改') }}
                                                <i class="mdi mdi-file-check btn-icon-append"></i>
                                            </button>
                                            @else
                                            @endif
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">
                                {{ __('auto.总共') }} <b>{{ $list->appends(["id"=>$id,"reward"=>$reward,"type"=>$type,"status"=>$status,"id"=>$id,"start_time"=>$start_time,"end_time"=>$end_time])->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/shop/update/"+id,"post",data,function(res){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                });
            });
        }
    </script>
@endsection
