MOD Petit refactoring #137
[cl7.git] / php / pages / inscrits.php
diff --git a/php/pages/inscrits.php b/php/pages/inscrits.php
new file mode 100644 (file)
index 0000000..b5df9b2
--- /dev/null
@@ -0,0 +1,55 @@
+<?php # coding:utf-8
+
+include_once("traitement_pre_affichage.php");
+
+$participants = mysql_query("
+   SELECT id, pseudo, nom, prenom, clan_nom, clan_tag, remarques
+   FROM participants
+   ORDER by clan_nom, clan_tag, pseudo
+");
+
+$periodes = mysql_query("SELECT nom_abrege FROM periodes ORDER BY id");
+$debut_table = '
+ <tr>
+  <th>pseudo</th>
+  <th>nom</th>
+  <th>prĂ©nom</th>';
+$nb_periode = 0;
+while($periode = mysql_fetch_object($periodes))
+{
+   $debut_table .= '<th>'.$periode->nom_abrege.'</th>';
+   $nb_periode++;
+}
+$debut_table .= '<th>remarques</th>
+ </tr>';
+$clan_courant = null;
+
+echo '<table class="inscrits">';
+while($participant = mysql_fetch_object($participants))
+{  
+   if ($clan_courant !== $participant->clan_nom)
+   {
+      echo ($participant->clan_nom != '' ? '<tr><td colspan="'. ($nb_periode + 4) .'"><h1>'.traitement_pre_affichage($participant->clan_nom).'</h1></td></tr>' : ''), $debut_table;
+      $clan_courant = $participant->clan_nom;
+   }
+   
+   $participations = mysql_query("
+      SELECT periodes.nom, participations.participant_id FROM periodes
+      LEFT JOIN participations ON periodes.id = participations.periode_id AND participations.participant_id = ".$participant->id."
+      ORDER BY id
+   ");
+   
+   echo '<tr>';
+   echo '<td>', htmlentities($participant->clan_tag, ENT_QUOTES, "UTF-8"), traitement_pre_affichage($participant->pseudo), '</td>';
+   echo '<td>', traitement_pre_affichage($participant->nom), '</td>';
+   echo '<td>', traitement_pre_affichage($participant->prenom), '</td>';
+   while ($participation = mysql_fetch_object($participations))
+     echo '<td '.($participation->participant_id == $participant->id ? 'class="participe"' : '').'></td>';
+   
+   echo '<td>', traitement_pre_affichage($participant->remarques), '</td>';
+   echo '</tr>';
+}
+echo '</table>';
+?>
+