@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-history"></i>
                </span>
                圣诞大转盘抽奖记录
            </h3>
        </div>

        <div class="row mb-3">
            <div class="col-12 grid-margin stretch-card">
                <div class="card">
                    <div class="card-body">
                        <form class="form-inline" id="search-form" method="get" action="">
                            <div class="form-group mr-3">
                                <label class="mr-2">UserID</label>
                                <input type="text" class="form-control" name="user_id" value="{{ $user_id ?? '' }}" placeholder="按 UserID 筛选">
                            </div>
                            <div class="form-group mr-3">
                                <label class="mr-2">GameID</label>
                                <input type="text" class="form-control" name="game_id" value="{{ $game_id ?? '' }}" placeholder="按 GameID 筛选">
                            </div>
                            <div class="form-group mr-3">
                                <label class="mr-2">开始日期</label>
                                <input type="date" class="form-control" name="start_date" value="{{ $start_date ?? '' }}">
                            </div>
                            <div class="form-group mr-3">
                                <label class="mr-2">结束日期</label>
                                <input type="date" class="form-control" name="end_date" value="{{ $end_date ?? '' }}">
                            </div>
                            <button type="submit" class="btn btn-sm btn-gradient-primary mr-2">筛选</button>
                            <button type="button" class="btn btn-sm btn-gradient-warning" onclick="resetSearch()">重置</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12 grid-margin stretch-card">
                <div class="card">
                    <div class="card-body">
                        <h4 class="card-title">抽奖记录列表</h4>
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>UserID</th>
                                    <th>GameID</th>
                                    <th>昵称</th>
                                    <th>档位索引 (slot_index)</th>
                                    <th>奖励值 (reward)</th>
                                    <th>抽奖时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                @forelse($list as $item)
                                    <tr>
                                        <td>{{ $item->id }}</td>
                                        <td>{{ $item->UserID }}</td>
                                        <td>{{ $item->GameID }}</td>
                                        <td>{{ $item->NickName }}</td>
                                        <td>{{ $item->slot_index }}</td>
                                        <td>{{ number_format($item->reward, 2) }}</td>
                                        <td>{{ $item->created_at }}</td>
                                    </tr>
                                @empty
                                    <tr>
                                        <td colspan="7" class="text-center text-muted">暂无记录</td>
                                    </tr>
                                @endforelse
                                </tbody>
                            </table>
                        </div>
                        <div class="mt-3">
                            {{ $list->appends(request()->all())->links() }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function resetSearch() {
        window.location.href = window.location.pathname;
    }
</script>
@endsection
