@extends('layouts.admin')

@section('title')

  Risultati

@stop

@section('content')

	   <div class="row">
        <div class="col-xs-12">
          <div class="box">
          <div class="row">
            <div class="col-xs-12">
              @php
              $capo = false;
              @endphp
              @foreach($games as $idx => $g)
                @php
                $color = "red";
                foreach($g as $_g)
                {
                  if ($_g->played)
                    $color = "blue";
                  
                }
                if ($g[0]->type == 'RITORNO' && !$capo)
                {
                  $capo = true;
                  print "<br><br><br>";
                }
                  
                @endphp                
                <div style="padding:10px;background-color:{{$color}};color:white;margin:5px;float:left;"><a href="#{{$idx}}" style="color:white">{{str_replace('ANDATA', '', str_replace('RITORNO', '', $idx))}}&ordf;</a></div>
              @endforeach
            </div>
            <div class="col-xs-12" style="padding:20px;">
              <a href="{{ route('calendars.index') }}" class="btn btn-info">Indietro</a>
            </div>
          </div>
          
          </div>
          
          <div class="box">
            
            <div class="row">
              <div class="col-xs-10">
                <h3>Classifica</h3>
              </div>
            </div>
            <div class="box-body table-responsive no-padding">
              <table class="table table-striped table-hover">
                <tr>
                  <th>Squadra</th>
                  <th>Punti</th>
                  <th>PG</th>
                  <th>V</th>
                  <th>N</th>                  
                  <th>P</th>                  
                  <th>GF</th>                  
                  <th>GS</th>                  
                  <th>DR</th>                  
                </tr>
                @foreach($aRates as $r)
                  <tr>
                    <td>{{$r["team"]}}</td>
                    <td>{{$r["POINTS"]}}</td>
                    <td>{{$r["PG"]}}</td>
                    <td>{{$r["V"]}}</td>
                    <td>{{$r["N"]}}</td>
                    <td>{{$r["P"]}}</td>
                    <td>{{$r["GF"]}}</td>
                    <td>{{$r["GS"]}}</td>
                    <td>{{$r["DR"]}}</td>
                  </tr>
                @endforeach
              </table>
              
            </div>
            <br>
            @foreach($aRates as $idx => $r)
                @if($r["penality"] != '')
                  <span style="margin-left: 10px">
                    {{$r["penality"]}}<br>
                  </span>
                @endif
            @endforeach
                  <br>
          </div>
          
          <div class="box">
            @php
            $old = '';
            @endphp
            @foreach($games as $idx => $g)
            
            @if($old == '' || $old != $g[0]->type)
              <div class="col-xs-10"><h1>{{$g[0]->type}}</h1></div>
            @endif

            <div class="row">

              
              <a name="{{$idx}}"></a>
              <div class="col-xs-10">
                <h3>&nbsp;&nbsp;&nbsp;{!!str_replace('ANDATA', '&ordf; A', str_replace('RITORNO', '&ordf; R', $idx))!!}</h3>
              </div>
              <div class="col-xs-2">
                <br><a href="/admin/calendars/games/{{$g[0]->calendar_id}}/{{$g[0]->day}}/{{$g[0]->type}}" class="btn btn-info text-right">Modifica</a><br><br>
              </div>
            </div>
            
              <div class="box-body table-responsive no-padding">
                <table class="table table-striped table-hover">
                  <tr>
                    <th>Data</th>
                    <th>In casa</th>
                    <th>Trasferta</th>
                    <th>Risultato</th>                  
                  </tr>
                  @foreach($g as $gg)
                    <tr>
                      <td>{{date("d/m/Y", strtotime($gg->date))}}</td>
                      <td>{!!$gg->getHomeTeam()->name!!}</td>
                      <td>{!!$gg->getAwayTeam()->name!!}</td>
                      <td>
                        @if($gg->played)
                          {{$gg->home_goals}} - {{$gg->away_goals}}
                        @endif
                      </td>
                    </tr>
                  @endforeach
                </table>
              </div>
              <br>

              @php
              $old = $g[0]->type;
              @endphp
            
            @endforeach

          </div>

        </div>
        <div class="col-xs-2">
          <a href="{{ route('calendars.index') }}" class="btn btn-info">Indietro</a>
        </div>
        
      </div>
@stop
