<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="description" content="Educas est une application de gestion d'ecole dans son ensemble">
    <meta name="author" content="Jean-Marius Yao">
    <title>{{$evaluated->evaluated->libelle.' '.$class->libelle}}</title>
</head>
<style>
  @page {
    margin: 60px 10px 60px 10px; /* Supprime toutes les marges */
  }

  body {
    margin: 0cm;
    padding: 0cm;
    font-size: .875em;
    overflow-x: hidden;
    color: #353c4e;
    font-family: sans-serif;
  }

  th, td {
    white-space: nowrap;
  }

  #header {
    /* position: fixed; */
    border-bottom: 2px solid gray;
    left: 0;
    right: 0;
    top: -20px;
    text-align: center;
    font-size: 12px;
    color: #555;
  }

  #footer {
    position: fixed;
    bottom: -50px;
    border-top: 2px solid gray;
    left: 0;
    right: 0;
    height: 50px;
    text-align: center;
    font-size: 12px;
    color: #555;
  }
</style>
<body>
  <header id="header">
    <table style="width: 100%; margin: 0px auto; padding:0%">
      <tbody>
        <tr>
          <td style="width: 50%">
            <table style="width: 100%">
              <tbody>
                <tr>
                  <td>
                    <div style="text-align: center; font-size: 12px">Ministère de l'Education Nationale, de l'Enseignement <br> Technique et de la   Formation Professionnelle</div>
                  </td>
                </tr>
                <tr>
                  <td>
                    <div style="text-align: center;">
                      <b style="font-size: 15px;">{{mb_strtoupper($school->school->name_school)}}</b><br>
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </td>
          <td style="width: 50%">
            <table style="width: 100%">
              <tbody>
                <tr>
                  <td>
                    <div style="text-align: center; font-size: 12px;">
                      <b >REPUBLIQUEDE COTE D'IVOIRE</b><br>
                      <i>Union - Discipline - Travail</i>
                    </div>
                  </td>
                </tr>
                <tr>
                  <td>
                    <div style="text-align: center;">
                      <b style="font-size: 15px;">Année Scolaire : <b>{{$class->schoolYear->school_year}}</b>
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
      </tbody>
    </table>
  </header>

  <section style="padding: 0%; margin-top: 5%">
    <div style="width: 100%; height: 17px; text-align: center; margin-top: 20px; margin-bottom: 30px">
      <span style="font-size: 20px; text-decoration: underline; font-weight: 700;">
        {{ strtoupper($evaluated->evaluated->libelle).' '.$class->libelle }}
      </span>
    </div>
    <div style="margin-top: 5%">
      <table border="2" cellpadding="10" cellspacing="0" style="border-collapse: collapse; width: 100%; margin: 0px auto; border: 1px solid black;">
        <thead>
          <tr>
            <th style="width: 3%; text-align:center">N°</th>
            <th style="width: 25%; text-align:left">Nom & Prénoms</th>
            <th style="width: 5%; text-align:center">Sexe</th>
            @foreach ($matters as $matter)
            <th style="text-align: center">{{ ucwords($matter->primary_matter->abbreviated) }}</th>
            @endforeach
            <th style="width: 7%; text-align:center">Point</th>
            <th style="width: 7%; text-align:center">Moy</th>
            <th style="width: 7%; text-align:center">Rang</th>
          </tr>
        </thead>
        <tbody>
          @php $i = 1; @endphp
          @foreach ($datas as $item)
          <tr>
            <th style="text-align: center">{{$i <= 9 ? '0'.$i++:$i++}}</th>
            <td style="text-align: left">{{ Str::limit($item['name'], '40', '...') }}</td>
            <td style="text-align: center">{{$item['sexe']}}</td>
            @foreach ($item['notes'] as $note)
            <td style="text-align: center"> <b>{{ $note['note'] ? ($note['note']['note'] == 'nc' ? 'nc':$note['note']['note']):'--' }}</b>{{ $note['note'] ? ($note['note']['note'] != 'nc' ? ' / '.$note['valeur']:''):'' }}</td>
            @endforeach
            <td style="text-align: center">{{ $item['resultat'] ? ($item['resultat']['point'] == 'nc' ? 'nc':$item['resultat']['point'].' / '.calculTotatPoint($item['notes'])):'--' }}</td>
            <td style="text-align: center"><b>{{ $item['resultat'] ? ($item['resultat']['moyenne'] == 'nc' ? 'nc':$item['resultat']['moyenne']):'--' }}</b> {{ $item['resultat'] ? ($item['resultat']['moyenne'] != 'nc' ? ' / 10':''):'' }}</td>
            <th style="text-align: center">{{ $item['resultat'] ? ($item['resultat']['rang'] ?? 'nc'):'--' }}</th>
          </tr>
          @endforeach
        </tbody>
      </table>
    </div>
  </section>

  <footer id="footer">
    <table style="width: 100%">
      <tbody>
        <tr>
          <td style="width: 50%">
            <i style="text-align: left; font-size: 12px; margin:0%">{{ $school->address_email }} / {{ $school->phon_school }}</i>
          </td>
          <td style="width: 25%">
            <i style="text-align: center; font-size: 12px; margin:0%">{{ strtoupper($class->libelle).' -- '.random_int(1000, 5000).' - 0'.$school->school_id }}</i>
          </td>
          <td style="width: 25%">
            <i style="text-align: right; float:right; font-size: 12px; margin:0%">Imprimé le {{date('Y-m-d H:i:s')}}</i>
          </td>
        </tr>
      </tbody>
    </table>
  </footer>
</body>
</html>