@extends('layouts.app', ['pageSlug' => 'dashboard'])

@section('content')
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header ">
                    <div class="row">

                            <div class="small-col-sm-6 text-left">
                                <h5 class="card-category">Club Stats for</h5>
                                <h2 class="card-title">{{ $club_info['club_name'] }}</h2>
                            </div>
                            <div class="stat-point">
                                <h4 class='stat-point-title'>League</h4>
                                <h3>Beginner</h3>
                            </div>
                            <div class="stat-point">
                                <h4 class='stat-point-title'>Members</h4>
                                <h3>17</h3>
                            </div>
                            <div class="stat-point">
                                <h4 class='stat-point-title'>Owner Id</h4>
                                <h3> {{ $club_info['owner_id'] }} </h3>
                            </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    @if(count($club_groups))
        @foreach($club_groups as $group)
            <div class="row">
                <div class="col-lg-12">
                    <div class="card ">
                        <div class="card-header">
                            <h5 class="card-category">{{ $group->group_desc }} </h5>
                            <h4 class="card-title">{{ $group->group_name }}</h4>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table tablesorter" id="">
                                    <thead class=" text-primary">
                                        <tr>
                                            <th>
                                                Club Member
                                            </th>
                                            <th>
                                                Player Id
                                            </th>
                                            <th>
                                                Rating
                                            </th>
                                            <th>
                                            <!-- <th class="text-center"> -->
                                                Percentile
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if(count($group->players))
                                            @foreach($group->players as $player)
                                                <tr>
                                                    <td>
                                                        <a href='{{ action("PlayerController@index", ["playerid" => $player->player_id]) }}'>
                                                            {{ $player->first_name }} {{ $player->last_name }}
                                                        </a>
                                                    </td>
                                                    <td>
                                                        {{ $player->player_id }}
                                                    </td>
                                                    <td>
                                                        {{$player->rating}}
                                                    </td>
                                                    <td>
                                                    <!-- <td class="text-center"> -->
                                                        Top {{ $player->percentile }}%
                                                    </td>
                                                </tr>
                                            @endforeach
                                        @else
                                            <tr>
                                                <td>
                                                    No Players in Group
                                                </td>
                                            </tr>
                                        @endif
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        @endforeach
    @else
        <h1>No Players in Club</h1>
    @endif


    <script> var dashboardData = {club_players: "{{$club_groups}}"}; </script>
@endsection

@push('js')
    <script src="{{ asset('black') }}/js/plugins/chartjs.min.js"></script>
    <script src="{{ asset('black') }}/js/clubtheme.js"></script>
    <script>
        $(document).ready(function() {
          demo.initDashboardPageCharts();
        });
    </script>
@endpush
