<?php
#########################################################################################
# Gestion des élections 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_election.php");
#variables pour l'affichage du titre
$titre = "Gestion des élections";
if (!session_is_registered("RES")){
session_register("RES");
} else {
session_unregister("RES");
session_register("RES");
}
################################### REQUETES BDD #########################################
$requete_sql = "SELECT *
FROM election
WHERE projet_id = $projet
ORDER BY nb_votes DESC
";
$reponse_elect = bd_executer_sql($requete_sql);
$nb_elect = mysql_num_rows($reponse_elect);
$reponse_res = bd_executer_sql($requete_sql);
$r = 0;
$id = array();
while ($ligne_res = mysql_fetch_array($reponse_res)){
$id[$r] = $ligne_res['fiche_id'];
$r++;
}
$HTTP_SESSION_VARS["RES"]= $id;
################################### 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']="";
if ($nb_elect == "0"){
?>
<h4>Il n'y a aucune proposition dans la liste des finalistes.</h4>
<p>Pour ajouter une proposition à la liste, vous devez aller dans "Voir les propositions" et choisir la proposition de votre choix.
Cliquez ensuite sur le bouton "Ajouter" situé sous la fiche.</p>
<?
}else{
if ($periode == "vote"){
?>
<h4>Liste des propositions finalistes.</h4>
<p>La période de vote est activée.</p>
<br />
<?
} else if ($periode == "fin_vote" || (isset($HTTP_GET_VARS['id_projet']) && $HTTP_GET_VARS['id_projet'] != $projet )){
?>
<h4>Résultats de l'élection.</h4>
<br />
<?
} else {
?>
<h4>Liste des finalistes.</h4>
<p>La liste sera offcielle et ne pourra pas être modifiée lorsque la période de vote sera activée.</p>
<br />
<?
}
$i =0;
while ($ligne = mysql_fetch_array($reponse_elect)) {
$requete_sql = "SELECT *
FROM fiche
WHERE fiche_id = '" . $ligne['fiche_id'] . "'
";
$reponse_prop = bd_executer_sql($requete_sql);
$ligne_prop = mysql_fetch_array($reponse_prop);
$requete_sql = "SELECT *
FROM eleve E, usager U
WHERE E.eleve_id = '" . $ligne_prop['eleve_id'] . "'
AND U.usager_id = E.usager_id
";
$reponse_eleve = bd_executer_sql($requete_sql);
$ligne_eleve = mysql_fetch_array($reponse_eleve);
$requete_sql = "SELECT *
FROM groupe
WHERE groupe_id = '" . $ligne_eleve['groupe_id'] . "'
";
$reponse_grp = bd_executer_sql($requete_sql);
$ligne_grp = mysql_fetch_array($reponse_grp);
$requete_sql = "SELECT E.nom
FROM ecole E, responsable R
WHERE R.resp_id = '" . $ligne_grp['resp_id'] . "'
AND E.ecole_id = R.ecole_id
";
$reponse_ecole = bd_executer_sql($requete_sql);
$ligne_ecole = mysql_fetch_array($reponse_ecole);
?>
<table cellpadding="0" cellspacing="0" width="600" border="1" align="center">
<tr>
<td align="center" width="200">
<?
if ($ligne_prop['affiche'] == ""){
$affiche = "images/gen_affiche.jpg";
} else {
$affiche = $ligne_prop['affiche'];
}
list($width) = getimagesize($affiche);
if ($width > 200){
echo "<img src='".$affiche."' width='200' alt=\"affiche\" />";
} else {
?>
<img src='<?=$affiche?>' alt="affiche"/>
<?
}
?>
<td align="center">
<table cellpadding="0" cellspacing="0" width="95%" align="right">
<tr>
<td colspan="2"><strong><a href="adm_election2.php?type_action=aff_fiche&page=adm_election.php&id_prop=<?=$ligne['fiche_id']?>&pos=<?=$i?>"><?=$ligne_prop['slogan']?></a></div></strong></td>
</tr>
<tr>
<td width="30%">Auteur :</td>
<td width="70%"><?=$ligne_eleve['login']?></td>
</tr>
<tr>
<td>Niveau : </td>
<td><?=$ligne_prop['niveau']?></td>
</tr>
<tr>
<td>Catégorie : </td>
<td>
<?
$requete_sql = "SELECT nom
FROM categorie_prop
WHERE cat_id = \"$ligne_prop[categorie]\"
";
$reponse_catNom = mysql_query($requete_sql);
$ligne_catNom = mysql_fetch_array($reponse_catNom);
?>
<?= $ligne_catNom['nom']?></td>
</tr>
<tr>
<td>École : </td>
<td><?=$ligne_ecole['nom']?></td>
</tr>
<tr>
<td>Niveau scolaire : </td>
<td><?=$ligne_grp['niveau']?></td>
</tr>
<tr>
<td>Groupe : </td>
<td><?=$ligne_grp['nom']?></td>
</tr>
<tr>
<td>Type de groupe : </td>
<td><?=$ligne_grp['type']?></td>
</tr>
<tr>
<td>Appréciation : </td>
<td>
<?
if ($ligne_prop['app_moyenne'] < 0.50){
echo "<img src='images/etoile_0.jpg' alt=\"0\" />";
} else if ($ligne_prop['app_moyenne'] < 0.99){
echo "<img src='images/etoile_0_5.jpg' alt=\"0,5\" />";
} else if ($ligne_prop['app_moyenne'] < 1.50){
echo "<img src='images/etoile_1.jpg' alt=\"1\" />";
} else if ($ligne_prop['app_moyenne'] < 2.00){
echo "<img src='images/etoile_1_5.jpg' alt=\"1,5\" />";
} else if ($ligne_prop['app_moyenne'] < 2.50){
echo "<img src='images/etoile_2.jpg' alt=\"2\" />";
} else if ($ligne_prop['app_moyenne'] < 3.00){
echo "<img src='images/etoile_2_5.jpg' alt=\"2,5\" />";
} else if ($ligne_prop['app_moyenne'] < 3.50){
echo "<img src='images/etoile_3.jpg' alt=\"3\" />";
} else if ($ligne_prop['app_moyenne'] < 4.00){
echo "<img src='images/etoile_3_5.jpg' alt=\"3,5\" />";
} else if ($ligne_prop['app_moyenne'] < 4.50){
echo "<img src='images/etoile_4.jpg' alt=\"4\" />";
} else if ($ligne_prop['app_moyenne'] < 5.00){
echo "<img src='images/etoile_4_5.jpg' alt=\"4,5\" />";
} else {
echo "<img src='images/etoile_5.jpg' alt=\"5\" />";
}
?>
<br />
</td>
</tr>
<tr>
<td> </td>
<td>
<?
if ($ligne_prop['app_nb'] > 1){
echo " ".$ligne_prop['app_nb']." appréciations";
} else if ($ligne_prop['app_nb'] == 1){
echo " ".$ligne_prop['app_nb']." appréciation";
}
?>
<br />
</td>
</tr>
<tr>
<td colspan="2" align="center">
</td>
</tr>
<?
$i++;
if ($periode == "vote" || $periode == "fin_vote" || isset($HTTP_GET_VARS['id_projet'])){
?>
<tr>
<td>Nombre de votes : </td>
<td><?=$ligne['nb_votes']?></td>
</tr>
<?
} else {
?>
<tr>
<td colspan="2">
<form name="form_supp" method="post" action="adm_election2.php">
<input type="submit" name="supp" value="Retirer de la liste" onclick="return confirm('Voulez-vous retirer la proposition de la liste des finalistes?')"/>
<input type="hidden" name="type_action" value="ret_fin">
<input type="hidden" name="id_final" value="<?= $ligne['finaliste_id'] ?>">
</form>
</td>
</tr>
<?
}
?>
</table>
</td>
</tr>
</table>
<p> </p>
<?
}
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
require "pied_page.php";
?>