@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-chart-line"></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="">
                                <span style="padding-left: 10px">{{ __('auto.注册时间：') }}</span>
                                <input type="date" name="start_date" class="form-control" value="{{ $start_date }}" />
                                <span style="padding-left: 10px">{{ __('auto.至') }}</span>
                                <input type="date" name="end_date" class="form-control" value="{{ $end_date }}" />
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <a href="/admin/game_data/participation_statistics" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>
                            </form>
                            <br>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="25%">{{ __('auto.推荐进入的游戏') }}</th>
                                    <th width="15%">{{ __('auto.注册人数') }}</th>
                                    <th width="15%">{{ __('auto.参与游戏人数') }}</th>
                                    <th width="15%">{{ __('auto.参游率') }}</th>
                                    <th width="15%">{{ __('auto.付费人数') }}</th>
                                    <th width="15%">{{ __('auto.付费率') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($statistics as $stat)
                                    <tr>
                                        <td>{{ $stat['game_name'] }} <small class="text-muted">(ID: {{ $stat['game_id'] }})</small></td>
                                        <td>{{ $stat['register_count'] }}</td>
                                        <td>{{ $stat['played_count'] }}</td>
                                        <td>
                                            @if($stat['register_count'] > 0)
                                                <span class="badge badge-{{ $stat['participation_rate'] >= 50 ? 'success' : ($stat['participation_rate'] >= 30 ? 'warning' : 'danger') }}">
                                                    {{ $stat['participation_rate'] }}%
                                                </span>
                                            @else
                                                <span class="badge badge-secondary">-</span>
                                            @endif
                                        </td>
                                        <td>{{ $stat['paid_count'] }}</td>
                                        <td>
                                            @if($stat['register_count'] > 0)
                                                <span class="badge badge-{{ $stat['paid_rate'] >= 20 ? 'success' : ($stat['paid_rate'] >= 10 ? 'warning' : 'danger') }}">
                                                    {{ $stat['paid_rate'] }}%
                                                </span>
                                            @else
                                                <span class="badge badge-secondary">-</span>
                                            @endif
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            @if(count($statistics) == 0)
                                <div class="alert alert-info">
                                    <p>{{ __('auto.暂无统计数据，请选择其他时间范围。') }}</p>
                                </div>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
