ADD #143 (80%)
[cl7.git] / php / pages / inscrits.php
1 <?php # coding:utf-8
2
3 include_once("php/traitement_pre_affichage.php");
4
5 $participants = pg_query("
6 SELECT id, pseudo, nom, prenom, clan_nom, clan_tag, remarques
7 FROM participants
8 ORDER by clan_nom NULLS FIRST, clan_tag NULLS FIRST, pseudo
9 ");
10
11 $periodes = pg_query("SELECT nom_abrege FROM periodes ORDER BY id");
12 $debut_table = '
13 <tr>
14 <th>pseudo</th>
15 <th>nom</th>
16 <th>prénom</th>';
17 $nb_periode = 0;
18 while($periode = pg_fetch_object($periodes))
19 {
20 $debut_table .= '<th>'.$periode->nom_abrege.'</th>';
21 $nb_periode++;
22 }
23 $debut_table .= '<th>remarques</th>
24 </tr>';
25
26 $clan_courant = "PHP c'est du CACA";
27
28 echo '<table class="inscrits">';
29 while($participant = pg_fetch_object($participants))
30 {
31 if ($clan_courant !== $participant->clan_nom)
32 {
33 echo ($participant->clan_nom != '' ? '<tr><td colspan="'. ($nb_periode + 4) .'"><h1>'.traitement_pre_affichage($participant->clan_nom).'</h1></td></tr>' : ''), $debut_table;
34 $clan_courant = $participant->clan_nom;
35 }
36
37 $participations = pg_query_params("
38 SELECT periodes.nom, participations.participant_id FROM periodes
39 LEFT JOIN participations ON periodes.id = participations.periode_id AND participations.participant_id = $1
40 ORDER BY id
41 ", array($participant->id));
42
43 echo '<tr>';
44 echo '<td>', htmlentities($participant->clan_tag, ENT_QUOTES, "UTF-8"), traitement_pre_affichage($participant->pseudo), '</td>';
45 echo '<td>', traitement_pre_affichage($participant->nom), '</td>';
46 echo '<td>', traitement_pre_affichage($participant->prenom), '</td>';
47 while ($participation = pg_fetch_object($participations))
48 echo '<td '.($participation->participant_id == $participant->id ? 'class="participe"' : '').'></td>';
49
50 echo '<td>', traitement_pre_affichage($participant->remarques), '</td>';
51 echo '</tr>';
52 }
53 echo '</table>';
54 ?>
55