<?php
#########################################################################################
# Gestion des enregistrements de Pnyx #
# Auteur : V. Blais #
# Création : 2006-04-05 #
# Modification : 2008-09-03 #
# #
# Pnyx - une application Web (PHP/MySQL) d'élections virtuelles conçue pour des élèves #
# du primaire et du secondaire, dans lequel ils sont amenés à faire des propositions #
# en ligne et voter pour leur favorite, sous la supervision d'un enseignant. #
# #
# Copyright (C) <2008 - 2009> #
# <Service national du RÉCIT de l'univers social de la Commission scolaire de la #
# Pointe-de-l'Île> #
# #
# This program is free software; you can redistribute it and/or modify it under the #
# terms of the GNU General Public License as published by the Free Software Foundation. #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License along with this #
# program as the file LICENSE.txt; if not, please see #
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. #
# #
# Service national du RÉCIT de l'univers social #
# http://www.recitus.qc.ca #
# Contact e-mail : steve-hide@address.com #
#########################################################################################
require "entete_php.php";
#gen_variables_session();
#vérifier si l'usager peut accéder à cette page
acces_admin("adm_enregistrement.php");
#affichage d'un projet archivé
if ($projet_admin != 0){
$projet = $projet_admin;
#variables pour l'affichage du titre
$titre = "Gestion des enregistrements (projet archivé)";
}else{
$projet = $HTTP_SESSION_VARS['SESSION']['projet'];
#variables pour l'affichage du titre
$titre = "Gestion des enregistrements";
}
# gen_variables_session();
# if (isset($HTTP_GET_VARS['id_projet'])){
# $projet = $HTTP_GET_VARS['id_projet'];
# }
################################### REQUETES BDD #########################################
#si un ordre a été spécifié
if (isset($HTTP_GET_VARS['ordre'])){
$ordre = $HTTP_GET_VARS['ordre'];
}else{
$ordre = "R.nom ASC";
}
if ($projet != 0){
#requete nom du projet à afficher
$requete_sql = "SELECT nom
FROM projet
WHERE projet_id = $projet
";
$reponse_projet = bd_executer_sql($requete_sql);
$ligne_projet = mysql_fetch_array($reponse_projet);
#requete pour afficher les enregistrements
$requete_sql = "SELECT R.resp_id, R.nom, R.prenom, E.nom,
L.date_valide, L.nb_groupe, L.valide, R.nouveau
FROM (((responsable AS R LEFT JOIN lien_resp_projet AS L ON R. resp_id = L.resp_id)
LEFT JOIN ecole AS E ON R.ecole_id = E.ecole_id)
LEFT JOIN commission_scolaire AS CS ON E.comscol_id = CS.comscol_id)
LEFT JOIN region AS RE ON CS.region_id = RE.region_id
WHERE L.projet_id = \"$projet\"
ORDER BY $ordre
";
$reponse_enr = bd_executer_sql($requete_sql);
$nb_enr = mysql_num_rows($reponse_enr);
#requete pour afficher les enregistrements
$requete_sql = "SELECT R.resp_id, R.nom, R.prenom, E.nom,
L.date_valide, L.nb_groupe, L.valide, R.nouveau
FROM (((responsable AS R LEFT JOIN lien_resp_projet AS L ON R. resp_id = L.resp_id)
LEFT JOIN ecole AS E ON R.ecole_id = E.ecole_id)
LEFT JOIN commission_scolaire AS CS ON E.comscol_id = CS.comscol_id)
LEFT JOIN region AS RE ON CS.region_id = RE.region_id
WHERE L.projet_id = $projet
ORDER BY $ordre
";
$reponse_enrv = bd_executer_sql($requete_sql);
$nb_enr = mysql_num_rows($reponse_enrv);
} else {
#requete pour afficher les enregistrements
$requete_sql = "SELECT R.resp_id, R.nom, R.prenom, E.nom,
L.date_valide, L.nb_groupe, L.valide, R.nouveau
FROM (((responsable AS R LEFT JOIN lien_resp_projet AS L ON R. resp_id = L.resp_id)
LEFT JOIN ecole AS E ON R.ecole_id = E.ecole_id)
LEFT JOIN commission_scolaire AS CS ON E.comscol_id = CS.comscol_id)
LEFT JOIN region AS RE ON CS.region_id = RE.region_id
ORDER BY $ordre
";
$reponse_enrv = bd_executer_sql($requete_sql);
$nb_enr = mysql_num_rows($reponse_enrv);
}
################################### FIN REQUETES BDD #########################################
#affichage graphique
require "entete.php";
$message = $HTTP_SESSION_VARS['SESSION']['message'];
echo "<br /><h3 align=\"center\"><font color='#FF0000'>$message</font></h3>";
$HTTP_SESSION_VARS['SESSION']['message']="";
?>
<!-- ############################## TABLE LIENS ######################################################## -->
<?
if ($projet_admin != 0){
?>
<div align='right'><a href="adm_enregistrement2.php?type_action=retour_projCour">Revenir au projet en cours</a></div>
<?
}else {
?>
<div align='right'><a href='adm_resp.php'>Faire une recherche</a></div>
<?
}
?>
<!-- ############################## FIN TABLE LIENS ######################################################## -->
<?
if ($projet == 0){
?>
<p> Nom du projet : Il n'y a pas encore de projet en cours</p>
<?
}else{
?>
<p> Nom du projet :
<?=$ligne_projet['nom']?>
</p>
<?
}
?>
<div align="right"><input type="button" value="Afficher les courriels" onclick="mod_projet_popup(510,600,0,'par','courriel_resp.php')" /></div>
<div id="panneauxOnglet1" class="panneauxOnglet">
<ul class="ongletGroupe">
<?
if ($projet != 0){
?>
<li id="onglet1" class="onglets" onclick="selectionPanneaux('1','2')" onmouseover="overOnglet('1')" onmouseout="outOnglet('1')">Validés</li>
<li id="onglet2" class="onglets" onclick="selectionPanneaux('2','2')" onmouseover="overOnglet('2')" onmouseout="outOnglet('2')">Non validés</li>
<?
}
else{
?>
<li id="onglet1" class="onglets" onclick="selectionPanneaux('1','1')" onmouseover="overOnglet('1')" onmouseout="outOnglet('1')">Non validés</li>
<?
}
?>
</ul>
<div class="panneauxGroupe">
<?
################################################ ONGLET ENREGISTREMENTS VALIDÉS #################################################
if ($projet != 0){
?>
<div id="panelContenu1" class="panneaux">
<form action="adm_enregistrement2.php" method="post">
<table>
<tr>
<td valign="top"><p><strong>Afficher en ordre de :</strong></p></td>
<td><select name="ordre" size="1">
<option value="alpha_asc">Nom de responsable (A-Z)</option>
<option value="alpha_desc">Nom de responsable (Z-A)</option>
<option value="region_asc">Région (A-Z)</option>
<option value="region_desc">Région (Z-A)</option>
<option value="com_scol_asc">Commission scolaire (A-Z)</option>
<option value="com_scol_desc">Commission scolaire (Z-A)</option>
<option value="ecole_asc">Nom de l'école (A-Z)</option>
<option value="ecole_desc">Nom de l'école (Z-A)</option>
<option value="nb_groupe_asc">Nombre de groupe croissant</option>
<option value="nb_groupe_desc">Nombre de groupe décroissant</option>
</select>
</td>
<td><input type="submit" value="Afficher" />
<input type="hidden" name="type_action" value="ordonner_val" />
</td>
</tr>
</table>
</form>
<!-- ############# TABLE AFFICHAGE ENREGISTREMENTS ######################################################## -->
<table cellpadding="0" cellspacing="0" width="100%" border="1">
<tr>
<td width="108" align="center"><strong>Responsable</strong></td>
<td width="108" align="center"><strong>Région</strong></td>
<td width="89" align="center"><strong>Commission scolaire</strong></td>
<td width="200" align="center"><strong>École</strong></td>
<td width="98" align="center"><strong>Date de validation</strong></td>
<td width="50" align="center"><strong>Nb de groupe</strong></td>
</tr>
<?
$nb_respv = 0;
$tot_groupe = 0;
while ($ligne_enr = mysql_fetch_array($reponse_enrv)){
if ($ligne_enr['valide'] == 1){
$requete_sql = "SELECT comscol_id
FROM ecole E, responsable R, lien_resp_projet L
WHERE E.ecole_id = R.ecole_id
AND R.resp_id = '" . $ligne_enr['resp_id'] . "'
";
$reponse_ecole = mysql_query($requete_sql);
$ligne_ecole = mysql_fetch_array($reponse_ecole);
$requete_sql = "SELECT nom, region_id
FROM commission_scolaire
WHERE comscol_id = '" . $ligne_ecole['comscol_id'] . "'
";
$reponse_cs = mysql_query($requete_sql);
$ligne_cs = mysql_fetch_array($reponse_cs);
$requete_sql = "SELECT nom
FROM region
WHERE region_id = '" . $ligne_cs['region_id'] . "'
";
$reponse_region = mysql_query($requete_sql);
$ligne_region = mysql_fetch_array($reponse_region);
$nb_respv ++;
$tot_groupe += $ligne_enr['nb_groupe'];
$nom = $ligne_enr[2]." ".$ligne_enr[1];
$date = date_fr($ligne_enr['date_valide']);
echo "<tr>
<td><a href=\"adm_resp.php?id_resp=".$ligne_enr[0]."\"><font size='-1'>".$nom."</font></a></td>
<td><font size='-1'>".$ligne_region['nom']."</font></td>
<td><font size='-1'>".$ligne_cs['nom']."</font></td>
<td><font size='-1'>".$ligne_enr['nom']."</font></td>
<td><font size='-1'>".$date."</font></td>
<td align='center'><font size='-1'>".$ligne_enr['nb_groupe']."</font></td>
</tr>";
}
}
?>
<tr>
<td align="center"><font size='-1'><strong><?=$nb_respv?></strong></font></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td align="center"><font size='-1'><strong><?=$tot_groupe?></strong></font></td>
</tr>
</table>
<!-- ############# FIN TABLE AFFICHAGE ENREGISTREMENTS ######################################################## -->
<?
}
?>
</div>
<?
################################################ ONGLET ENREGISTREMENTS NON VALIDÉS #################################################
if ($projet != 0){
?>
<div id="panelContenu2" class="panneaux">
<?
}
else{
?>
<div id="panelContenu1" class="panneaux">
<?
}
?>
<form action="adm_enregistrement2.php" method="post">
<table>
<tr>
<td valign="top"><p><strong>Afficher en ordre de :</strong></p></td>
<td><select name="ordre" size="1">
<option value="alpha_asc">Nom de responsable (A-Z)</option>
<option value="alpha_desc">Nom de responsable (Z-A)</option>
<option value="region_asc">Région (A-Z)</option>
<option value="region_desc">Région (Z-A)</option>
<option value="com_scol_asc">Commission scolaire (A-Z)</option>
<option value="com_scol_desc">Commission scolaire (Z-A)</option>
<option value="ecole_asc">Nom de l'école (A-Z)</option>
<option value="ecole_desc">Nom de l'école (Z-A)</option>
<option value="nb_groupe_asc">Nombre de groupe croissant</option>
<option value="nb_groupe_desc">Nombre de groupe décroissant</option>
</select>
</td>
<td><input type="submit" value="Afficher" />
<input type="hidden" name="type_action" value="ordonner_nval" />
</td>
</tr>
</table>
</form>
<br />
<img src="images/message_eleve.gif" alt="Nouvelle inscription" width="15" height="15" /> Nouvelle inscription
<!-- ############# TABLE AFFICHAGE ENREGISTREMENTS ######################################################## -->
<table cellpadding="0" cellspacing="0" width="100%" border="1">
<tr>
<td width="108" align="center"><strong>Responsable</strong></td>
<td width="108" align="center"><strong>Région</strong></td>
<td width="89" align="center"><strong>Commission scolaire</strong></td>
<td width="200" align="center"><strong>École</strong></td>
<td width="50" align="center"><strong>Nb de groupes</strong></td>
</tr>
<?
$nb_resp =0;
$tot_groupe = 0;
while ($ligne_enr = mysql_fetch_array($reponse_enr)){
if ($ligne_enr['valide'] == 0){
$nb_resp++;
$nb_grp = $ligne_enr['nb_groupe'];
$tot_groupe += $ligne_enr['nb_groupe'];
$nom = $ligne_enr[2]." ".$ligne_enr[1];
$requete_sql = "SELECT E.comscol_id, E.ecole_id
FROM ecole E, responsable R, lien_resp_projet L
WHERE E.ecole_id = R.ecole_id
AND R.resp_id = '" . $ligne_enr['resp_id'] . "'
";
$reponse_ecole = mysql_query($requete_sql);
$ligne_ecole = mysql_fetch_array($reponse_ecole);
$requete_sql = "SELECT nom, region_id
FROM commission_scolaire
WHERE comscol_id = '" . $ligne_ecole['comscol_id'] . "'
";
$reponse_cs = mysql_query($requete_sql);
$ligne_cs = mysql_fetch_array($reponse_cs);
$requete_sql = "SELECT nom
FROM region
WHERE region_id = '" . $ligne_cs['region_id'] . "'
";
$reponse_region = mysql_query($requete_sql);
$ligne_region = mysql_fetch_array($reponse_region);
if ($ligne_enr['nouveau'] == 0){
echo "<tr>
<td><a href=\"adm_resp.php?id_resp=".$ligne_enr[0]."\"><font size='-1'>".$nom."</font></a></td>
<td><font size='-1'>".$ligne_region['nom']."</font></td>
<td><font size='-1'>".$ligne_cs['nom']."</font></td>";
if ($ligne_ecole['ecole_id'] != 0){
echo "<td><font size='-1'>".$ligne_enr['nom']."</font></td>";
}else {
echo "<td><font size='-1'> Autre </font></td>";
}
echo "<td align='center'><font size='-1'>".$nb_grp."</font></td>
</tr>";
}else {
echo "<tr>
<td bgcolor='#99CCFF'><a href=\"adm_resp.php?id_resp=".$ligne_enr[0]."\"><font size='-1'>".$nom."</font></a></td>
<td bgcolor='#99CCFF'><font size='-1'>".$ligne_region['nom']."</font></td>
<td bgcolor='#99CCFF'><font size='-1'>".$ligne_cs['nom']."</font></td>";
if ($ligne_ecole['ecole_id'] != 0){
echo "<td bgcolor='#99CCFF'><font size='-1'>".$ligne_enr['nom']."</font></td>";
}else {
echo "<td bgcolor='#99CCFF'><font size='-1'> Autre </font></td>";
}
echo "<td align='center' bgcolor='#99CCFF'><font size='-1'>".$nb_grp."</font></td>
</tr>";
}
}
}
?>
<tr>
<td align="center"><font size='-1'><strong><?=$nb_resp?></strong></font></td>
<td> </td>
<td> </td>
<td> </td>
<td align="center"><font size='-1'><strong><?=$tot_groupe?></strong></font></td>
</tr>
</table>
</div>
</div>
</div>
<!-- ############# FIN TABLE AFFICHAGE ENREGISTREMENTS ######################################################## -->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
require "pied_page.php";
?>