@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>
                Reward Code Claim Records
            </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">Code</label>
                                <input type="text" class="form-control" name="code" value="{{ $code ?? '' }}" placeholder="Filter by Code">
                            </div>
                            <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="Filter by 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="Filter by GameID">
                            </div>
                            <div class="form-group mr-3">
                                <label class="mr-2">Start Date</label>
                                <input type="date" class="form-control" name="start_date" value="{{ $start_date ?? '' }}">
                            </div>
                            <div class="form-group mr-3">
                                <label class="mr-2">End Date</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">Search</button>
                            <button type="button" class="btn btn-sm btn-gradient-warning" onclick="resetSearch()">Reset</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">Claim Records List</h4>
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Code</th>
                                    <th>UserID</th>
                                    <th>GameID</th>
                                    <th>NickName</th>
                                    <th>Amount</th>
                                    <th>Client IP</th>
                                    <th>Created At</th>
                                </tr>
                                </thead>
                                <tbody>
                                @forelse($list as $item)
                                    <tr>
                                        <td>{{ $item->id }}</td>
                                        <td><strong>{{ $item->code }}</strong></td>
                                        <td>{{ $item->UserID }}</td>
                                        <td>{{ $item->GameID }}</td>
                                        <td>{{ $item->NickName }}</td>
                                        <td>{{ number_format($item->amount, 2) }}</td>
                                        <td>{{ $item->client_ip }}</td>
                                        <td>{{ $item->created_at }}</td>
                                    </tr>
                                @empty
                                    <tr>
                                        <td colspan="8" class="text-center text-muted">No records found</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
