@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <style type="text/css">
        .table th {
            padding: 0.5375rem;
            vertical-align: top;
            border-top: 1px solid #ebedf2;
        }
    </style>
    <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/gold/update_stock_log'>
                                <span style="padding-left: 5px">{{ __('auto.游戏：') }}</span>
                                <select class="form-control" name="kind_id" value="{{$kind_id}}" id="select"
                                        onchange="gradeChange(this.options[this.options.selectedIndex].value)">
                                    <option value="">{{ __('auto.选择游戏') }}</option>
                                    @foreach($game_name as $k=>$v)
                                        <option value="{{$k}}" @if($k==$kind_id) selected @endif >{{$v}}</option>
                                    @endforeach
                                </select>
                                <span style="padding-left: 5px">{{ __('auto.房间：') }}</span>
                                <select class="form-control" name="ServerID" value="" id="game_level">
                                    <option value="">{{ __('auto.选择房间') }}</option>
                                    @foreach($room_list as $k=>$v)
                                        <option value="{{$v->ServerID}}"
                                                @if($v->ServerID==$ServerID) selected @endif>{{$v->ServerName}}</option>
                                    @endforeach
                                </select> &nbsp;&nbsp;
                                <spen style="padding-left: 10px" >{{ __('auto.选择时间：') }}</spen>
                                <input type="datetime-local" step="01" name="start_time" id="start_time"
                                       class="form-control" value="{{$start_time}}" onclick="start_times()"/>
                                <input type="datetime-local" step="01" name="end_time" id='end_time'
                                       class="form-control" value="{{$end_time}}" onclick="end_times()"/>
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <a href="/admin/gold/update_stock_log" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="6%">{{ __('auto.操作房间') }}</th>
                                    <th width="6%">{{ __('auto.最后操作人') }}</th>
                                    <th width="6%">{{ __('auto.操作生效时间') }}</th>
                                    <th width="6%">{{ __('auto.单控操作内容') }}</th>
                                    <th width="6%">{{ __('auto.操作生效之前库存') }}</th>
                                    <th width="6%">{{ __('auto.操作生效之后库存') }}</th>
                                </tr>
                                </thead>
                                <tbody>

                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td>{{ $v->ServerName }}</td>
                                        <td>{{$v->account}}</td>
                                        <td>{{ $v->create_time }}</td>
                                        <td>{{ $v->content}}</td>
                                        <td>{{ $v->BeforeStock}}</td>
                                        <td>{{ $v->AfterStock }}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
    'kind_id'=>$kind_id,
    'start_time' => $start_time,
    'end_time' => $end_time,
    'ServerID' => $ServerID,
    'kind_id' => $kind_id,

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

        function start_times() {

            getFormat('00', '00', '00');

            document.getElementById("start_time").value = format
        }

        function end_times() {
            getFormat('23', '59', '59');
            document.getElementById("end_time").value = format
        }

        function edit(id) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.配置修改') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '90%'],
                content: '/admin/gold/gameconfig/update/' + id
            });
        }

        function show(value) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.查看配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '60%'],
                content: '/admin/global/show_config/' + value
            });
        }

        // 修改库存
        function update_stock(serverID) {

            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改库存') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '80%'],
                content: '/admin/gold/update_stock/' + serverID
            });

        }

        // 更新库存
        function sync_stock(obj, serverID) {

            // 库存
            var stock = $(obj).parents('tr').find('td').eq(6);
            // 税收
            // var revenue = $(obj).parents('tr').find('td').eq(3);

            myRequest("/admin/gold/sync_stock/" + serverID, "post", {}, function (res) {

                layer.msg(res.msg)
                if (res.code == 200) {
                    stock.text(res.data.data.stock);
                    // revenue.text(res.data.data.revenue);
                }

            });

        }

        function gradeChange(value) {

            myRequest("/admin/gold/roomlist", "post", {'GameID': value}, function (res) {
                // layer.msg(res.msg)
                var data = res.data
                var html = ''
                for (var i of data) {
                    html += '<option value=' + i['ServerID'] + '>' + i['ServerName'] + '</option>'
                }
                $("#game_level").html(html)
            });
        }

    </script>
@endsection
