@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-gift"></i>
                    </span>
                    PWA Bonus Log
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">Log Management</a></li>
                        <li class="breadcrumb-item active" aria-current="page">PWA Bonus Log</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">PWA Bonus Receive Records</h4>
                            <form class="well form-inline margin-top-20" method="get" action='/admin/pwa_bonus_log'>
                                <div>
                                    <span style="padding-left: 10px">Date:</span>
                                    <input type="date" name="log_date" class="form-control" value="{{$log_date}}" />
                                    <span style="padding-left: 10px">GameID:</span>
                                    <input class="form-control" type="text" name="game_id" style="width: 12%;" value="{{$game_id}}" placeholder="GameID">
                                </div>
                                <div style="margin-top: 10px;">
                                    <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="Search"/>&nbsp;&nbsp;
                                    <a href="/admin/pwa_bonus_log" class="btn btn-sm btn-gradient-warning btn-icon-text">Clear</a>
                                </div>
                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>GameID</th>
                                    <th>UserID</th>
                                    <th>Channel</th>
                                    <th>Bonus</th>
                                    <th>Org Score</th>
                                    <th>Now Score</th>
                                    <th>IP</th>
                                    <th>Log Date</th>
                                    <th>Created At</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $v)
                                    <tr>
                                        <td>{{ $v->id }}</td>
                                        <td>
                                            @if(!empty($v->userID) && !empty($v->GameID))
                                                <a href="javascript:void(0)" onclick="idFindFunc({{ $v->userID }})">{{ $v->GameID }}</a>
                                            @else
                                                {{ $v->GameID ?? '-' }}
                                            @endif
                                        </td>
                                        <td>{{ $v->userID ?? '-' }}</td>
                                        <td>{{ $v->Channel ?? '-' }}</td>
                                        <td>{{ number_format(($v->bonus_amount ?? 0) / 100, 2, '.', '') }}</td>
                                        <td>{{ number_format(($v->org_score ?? 0) / 100, 2, '.', '') }}</td>
                                        <td>{{ number_format(($v->now_score ?? 0) / 100, 2, '.', '') }}</td>
                                        <td>{{ $v->ip ?? '-' }}</td>
                                        <td>{{ $v->log_date }}</td>
                                        <td>{{ $v->created_at }}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">
                                Total <b>{{ $list->appends(['log_date'=>$log_date,'game_id'=>$game_id])->total() }}</b> records, divided into <b>{{ $list->lastPage() }}</b> pages
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function idFindFunc(UserID) {
            layer.open({
                type: 2,
                title: '用户控制面板',
                shadeClose: true,
                shade: 0.8,
                area: ['100%', '100%'],
                content: '/admin/global/id_find?UserID=' + UserID + '&OpenPage=1'
            });
        }
    </script>
@endsection
