@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/treasure'>
                                {{ __('auto.期号：') }}
                                <input class="form-control" type="text" name="id" style="width: 10%; " value="{{$id}}" placeholder="{{ __('auto.请输入期号') }}">
                                <spen style="padding-left: 10px" >{{ __('auto.中奖者ID：') }}</spen>
                                <input class="form-control" type="text" name="gameid" style="width: 10%; " value="{{$gameid}}" placeholder="{{ __('auto.请输入中奖者') }}ID">&nbsp;&nbsp;
                                <spen style="padding-left: 10px" >{{ __('auto.奖品名称：') }}</spen>
                                <input class="form-control" type="text" name="bonus_name" style="width: 10%; " value="{{$bonus_name}}" placeholder="{{ __('auto.请输入奖品名称') }}">&nbsp;&nbsp;
                                <select class="form-control" name="ratio" value="{{$ratio}}" style="color: black">
                                    <option value="">{{ __('auto.选择种类') }}</option>
                                    @foreach($ratio_name as $k=>$v)
                                        <option value="{{$k}}" @if($k==$ratio) selected @endif>{{$v}}</option>
                                    @endforeach
                                </select>
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}" />
                                <a href="/admin/exchange/treasure" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <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: 6%">{{ $v->ID }}</td>
                                        <td style="width: 15%">{{ date('Y-m-d H:i:s',strtotime($v->LuckyTime)) }}</td>
                                        <td style="width: 10%">{{ $v->BonusName}}</td>
                                        <td style="width: 8%">{{ $v->GameID }}</td>
                                        <td style="width: 15%">{{ $v->NickName}}</td>
                                        <td style="width: 10%">{{ $v->Compellation}}</td>
                                        <td style="width: 10%">{{ $v->MobilePhone}}</td>
                                        <td style="width: 15%">{{ $v->UserNote}}</td>
                                        <td style="width: 10%">
                                            <select id="state{{$v->ID}}">
                                                @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%">
                                            <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text" onclick="publish({{ $v->ID }})">
                                                {{ __('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(["id"=>$id,"gameid"=>$gameid,"ratio"=>$ratio])->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/treasure/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
