Location: PHPKode > projects > Pnyx : des lections virtuelles! > pnyx1.0.1/gen_rech_prog.php
<?php

	#########################################################################################
	# Recherche dans les propositions de Pnyx												#
	# Auteur : V. Blais																		#
	# Création : 2006-04-05																	#
	# Modification : 2008-09-08																#
	# 																						#
	# 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();
	
	#variables pour l'affichage graphique de la page
  	if(isset($HTTP_SESSION_VARS['RECH']["niveau_scol"])){
		if($HTTP_SESSION_VARS['RECH']["niveau_scol"] != ""){
			$titre = $HTTP_SESSION_VARS['RECH']["niveau_scol"];
		}
		else{
			$titre = "Voir les propositions";
		}
	}
	else{
		$titre = "Voir les propositions";
	}
	
	$lignes = 10;
	
	$HTTP_SESSION_VARS["TOUT"] = "y";
	//$HTTP_SESSION_VARS['RECH']['tous'] = "y";
	
	
if ($projet != 0){

	if (!session_is_registered("RES")){
		session_register("RES");
		
	} else {
		session_unregister("RES");
		session_register("RES");
	}
	
	$requete_sql = "SELECT * FROM projet WHERE statut = 'actif'";
	$reponse_projet = mysql_query($requete_sql);
	$ligne_projet = mysql_fetch_array($reponse_projet);
	
	$requete_sql = "SELECT * FROM categorie_prop WHERE actif = '1'";
	$reponse_catprop = mysql_query($requete_sql);
	
	if(isset($HTTP_SESSION_VARS["TOUT"])){
	
		if ($periode == "vote" && $HTTP_SESSION_VARS["TOUT"] != "y"){
			$requete_sql = "SELECT * FROM election
							WHERE projet_id = $projet
							";
			$reponse_prop = bd_executer_sql($requete_sql);
		
			$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;
		
		} else if ($periode != "fin_vote" || ($HTTP_SESSION_VARS["TOUT"]== "y")){
			
			#REQUETE POUR L'AFFICHAGE DE TOUTES LES PROPOSITIONS
			if (! session_is_registered("RECH") || $HTTP_SESSION_VARS['RECH']['tous']== "y") {
				$requete_sql = "SELECT *
								FROM fiche
								WHERE projet_id = $projet
								AND valide = 1
								ORDER BY date_valide DESC
								";
				$reponse_prop = bd_executer_sql($requete_sql);
				$reponse_res =  bd_executer_sql($requete_sql);
				$nb_prop = mysql_num_rows($reponse_prop);
				
				$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;
				
	
			#REQUETE POUR LA RECHERCHE DES PROPOSITIONS
			} else {
				
				if ($HTTP_SESSION_VARS['RECH']['cat'] != ""){
					$requete_sql = "SELECT cat_id FROM categorie_prop WHERE cat_id = " . $HTTP_SESSION_VARS['RECH']['cat'];
					$reponse_cat = mysql_query($requete_sql);
					$ligne_cat = mysql_fetch_array($reponse_cat);
					$cat = $ligne_cat["cat_id"];
					$clause_cat = "AND F.categorie = \"$cat\"";
				}else {
					$clause_cat = "";
				}
				
				if ($HTTP_SESSION_VARS['RECH']['niveau'] != ""){
					$niv = $HTTP_SESSION_VARS['RECH']['niveau'];
					$clause_niveau = "AND F.niveau = \"$niv\"";
				}else {
					$clause_niveau = "";
				}
				
				if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] != ""){
					$nivs = $HTTP_SESSION_VARS['RECH']['niveau_scol'];
					$clause_nscol = "AND G.niveau = \"$nivs\"";
				}else {
					$clause_nscol = "";
				}
				
				if ($HTTP_SESSION_VARS['RECH']['typegrp'] != ""){
					$type = $HTTP_SESSION_VARS['RECH']['typegrp'];
					$clause_typegrp = "AND G.type = \"$type\"";
				}else {
					$clause_typegrp = "";
				}
				
				if ($HTTP_SESSION_VARS['RECH']['groupe'] != ""){
					$grp = $HTTP_SESSION_VARS['RECH']['groupe'];
					$clause_groupe = "AND G.groupe_id = \"$grp\"";
				}else {
					$clause_groupe = "";
				}
				if ($HTTP_SESSION_VARS['RECH']['ecole'] != ""){
					$ecole = $HTTP_SESSION_VARS['RECH']['ecole'];
					$clause_ecole = "AND EC.ecole_id = \"$ecole\"";
				}else {
					$clause_ecole = "";
				}
				if ($HTTP_SESSION_VARS['RECH']['circons'] != ""){
					$cs = $HTTP_SESSION_VARS['RECH']['circons'];
					$clause_cs = "AND EC.ecole_id = \"$cs\"";
				}else {
					$clause_cs = "";
				}
				if ($HTTP_SESSION_VARS['RECH']['region'] != ""){
					$reg = $HTTP_SESSION_VARS['RECH']['region'];
					$clause_region = "AND RE.region_id = \"$reg\"";
				}else {
					$clause_region = "";
				}
						
				$ordre = "ORDER BY " . $HTTP_SESSION_VARS['RECH']['ordre'];
		#		echo $ordre;
		
		/*		ANCIENNE REQUETE
				$requete_sql = "SELECT F.*  
								FROM fiche F, ecole C, groupe G, eleve E, usager U, responsable R
								WHERE F.projet_id = $projet
								AND F.valide = 1
								$clause_niveau
								$clause_cat
								AND E.eleve_id = F.eleve_id
								AND G.groupe_id = E.groupe_id
								$clause_groupe
								$clause_nscol
								$clause_typegrp
								AND R.resp_id = G.resp_id
								AND C.ecole_id = R.ecole_id
								$clause_ecole
								AND U.usager_id = E.usager_id
								ORDER BY $ordre
								";
				$reponse_prop = bd_executer_sql($requete_sql);
				$nb_prop = mysql_num_rows($reponse_prop);
		*/		
				$requete_sql = "SELECT F.*
								FROM ((((((fiche AS F LEFT JOIN eleve AS E ON F.eleve_id = E.eleve_id)
											LEFT JOIN usager AS U ON E.usager_id = U.usager_id)
											LEFT JOIN groupe AS G ON E.groupe_id = G.groupe_id)
											LEFT JOIN responsable AS R ON G.resp_id = R.resp_id)
											LEFT JOIN ecole AS EC ON R.ecole_id = EC.ecole_id)
											LEFT JOIN commission_scolaire AS CS ON EC.comscol_id = CS.comscol_id)
											LEFT JOIN region AS RE ON CS.region_id = RE.region_id
								WHERE E.projet_id = $projet
								AND F.valide = 1
								$clause_niveau
								$clause_cat
								$clause_groupe
								$clause_nscol
								$clause_typegrp
								$clause_ecole
								$clause_cs
								$clause_region
								$ordre 
								";
				$reponse_prop = bd_executer_sql($requete_sql);
				$reponse_res =  bd_executer_sql($requete_sql);
				$nb_prop = mysql_num_rows($reponse_prop);
				
				$r = 0;
				$id = array();
				while ($ligne_res = mysql_fetch_array($reponse_res)){
					$id[$r] = $ligne_res['fiche_id'];
					$r++;
				}
				
				$HTTP_SESSION_VARS["RES"]= $id;
				
#				echo $requete_sql;
		
			}
		} else if ($HTTP_SESSION_VARS["TOUT"]!= "y"){
			$requete_sql = "SELECT * FROM election
							WHERE projet_id = $projet
							ORDER BY nb_votes DESC
							";
			$reponse_win = bd_executer_sql($requete_sql);
			$win = mysql_fetch_array($reponse_win);
			
			
	
			$requete_sql = "SELECT *
							FROM fiche
							WHERE fiche_id = \"$win[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);
	
			$requete_sql = "SELECT * FROM election
							WHERE projet_id = $projet
							AND finaliste_id != \"$win[finaliste_id]\"
							ORDER BY nb_votes DESC
							";
			$reponse_final = bd_executer_sql($requete_sql);
			
			$reponse_res = bd_executer_sql($requete_sql);
			$r = 1;
			$id = array();
			$id[0] =  $win['fiche_id'];
			while ($ligne_res = mysql_fetch_array($reponse_res)){
				$id[$r] = $ligne_res['fiche_id'];
				$r++;
			}
				
			$HTTP_SESSION_VARS["RES"]= $id;
		}
	}
	$requete_sql = "SELECT * FROM election
					WHERE projet_id = $projet
					";
	$reponse_prop = bd_executer_sql($requete_sql);
	$reponse_prop2 = bd_executer_sql($requete_sql);
	
	$position = 0;
	$tabFinaliste = array();
	while($ligne_prop2 = mysql_fetch_array($reponse_prop2)){
		$tabFinaliste[$position] = $ligne_prop2["fiche_id"];
		$position++;
	}
	$HTTP_SESSION_VARS['listeFinaliste'] = $tabFinaliste;
}
if($periode == "vote" || $periode == "fin_vote"){
	$nbonglet = 3;
}
else{
	$nbonglet = 2;
}
################################### FIN REQUETES BDD #########################################
#affichage graphique
require "entete.php";
if ($projet != 0){
	if($periode != "debut"){
?>
		<div id="panneauxOnglet1" class="panneauxOnglet">
		<ul class="ongletGroupe">
<?
		if ($periode == "vote"){
?>
			<li id="onglet1" class="onglets" onclick="selectionPanneaux('1','3')" onmouseover="overOnglet('1')" onmouseout="outOnglet('1')">Finalistes</li>
			<li id="onglet2" class="onglets" onclick="selectionPanneaux('2','3')" onmouseover="overOnglet('2')" onmouseout="outOnglet('2')">Toutes les propositions</li>
			<li id="onglet3" class="onglets" onclick="selectionPanneaux('3','3')" onmouseover="overOnglet('3')" onmouseout="outOnglet('3')">Explorer</li>
<?
		}
		else if($periode == "fin_vote"){
?>
			<li id="onglet1" class="onglets" onclick="selectionPanneaux('1','3')" onmouseover="overOnglet('1')" onmouseout="outOnglet('1')">Gagnant</li>
            <li id="onglet2" class="onglets" onclick="selectionPanneaux('2','3')" onmouseover="overOnglet('2')" onmouseout="outOnglet('2')">Résultats</li>
			<li id="onglet3" class="onglets" onclick="selectionPanneaux('3','3')" onmouseover="overOnglet('3')" onmouseout="outOnglet('3')">Explorer</li>
<?
		}
		else{
?>
			<li id="onglet1" class="onglets" onclick="selectionPanneaux('1','2')" onmouseover="overOnglet('1')" onmouseout="outOnglet('1')">Résultats</li>
			<li id="onglet2" class="onglets" onclick="selectionPanneaux('2','2')" onmouseover="overOnglet('2')" onmouseout="outOnglet('2')">Explorer</li>
<?
		}
?>
		</ul>
		<div class="panneauxGroupe">
<?
	}
}
######################################################## ONGLET FINALISTE ###########################################################
if ($periode == "vote"){
?>
	<div id="panelContenu1" class="panneaux">
	<p> La p&eacute;riode de vote est en cour. Voici les propositions qui ont &eacute;t&eacute; choisies comme finalistes : </p>

	<p><div align="center"><input type="button" value="Imprimer les finalistes" onclick="mod_projet_popup(605,480,0,'par','imp_fin.php')"></div></p><br />
<?
#			gen_variables_session();
#			$message = $HTTP_SESSION_VARS[SESSION][message];		
#			echo "<br /><h3 align=\"center\"><font color='#FF0000'>$message</font></h3>";
#			$HTTP_SESSION_VARS[SESSION][message]="";

	$i = 0;
	while ($ligne = mysql_fetch_array($reponse_prop)) {
		
		$requete_sql = "SELECT *
						FROM fiche
						WHERE fiche_id = \"$ligne[fiche_id]\"
						";
		$reponse_propos = bd_executer_sql($requete_sql);
		$ligne_prop = mysql_fetch_array($reponse_propos);
				
		$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);
?>
			
		<h4><a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$ligne['fiche_id']?>&amp;pos=<?=$i?>&amp;type=final"><?=$ligne_prop['slogan']?></a></h4>
		<table cellpadding="0" cellspacing="0" width="600" border="0" align="center">
		<tr valign="top">
		<td width="200" align="center">
    	<a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$ligne['fiche_id']?>&amp;pos=<?=$i?>&amp;type=final">
<?
		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."' alt='affiche' width='200' border='0'/>";
		} else {
?>
			<img src='<?=$affiche?>' alt='affiche' border="0"/>
<?	
		}
?>
		</a>
        <td align="center">
        <table cellpadding="0" cellspacing="0" width="95%" align="right">
        <tr>
        <td width="30%" valign="top">Auteur :</td>
        <td width="70%"><?=$ligne_eleve['login']?></td>
        </tr>
        <tr>
        <td valign="top">Niveau : </td>
        <td><?=$ligne_prop['niveau']?></td>
        </tr>
        <tr>
        <td valign="top">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 valign="top">École : </td>
        <td><?=$ligne_ecole['nom']?></td>
        </tr>
        <tr>
        <td valign="top">Niveau scolaire : </td>
        <td><?=$ligne_grp['niveau']?></td>
        </tr>
        <tr>
        <td valign="top">Groupe : </td>
        <td><?=$ligne_grp['nom']?></td>
        </tr>
        <tr>
        <td valign="top">Appr&eacute;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 valign="top">&nbsp;</td>
    	<td>
<?									
		if ($ligne_prop['app_nb'] > 1){
			echo "&nbsp;".$ligne_prop['app_nb']." appr&eacute;ciations";
		} else if ($ligne_prop['app_nb'] == 1){
			echo "&nbsp;".$ligne_prop['app_nb']." appr&eacute;ciation";
		}
?>
        <br />
        </td>
        </tr>
        </table>
        </td>
        </tr>
        </table>

		<hr align="center" width="400" /> 
	
<?
		$i++;
	}
?>
	<table cellpadding="0" cellspacing="0" width="100%" align="center" border="0">
	<tr>
	<td align="center">
	<a href="gen_rech_prog.php?onglet=2">
	<br />
	Voir toutes les propositions</a>
	<div align="right"><a href="#haut"><img src="images/haut.gif" alt="Retour au haut de la page" width="37" height="17" border="0" /></a></div>			</td>
	</tr>
	</table>
	</div>
<?
}

######################################################## ONGLET GAGNANT #############################################################
if ($periode == "fin_vote"){
			$requete_sql = "SELECT * FROM election
							WHERE projet_id = $projet
							ORDER BY nb_votes DESC
							";
			$reponse_win = bd_executer_sql($requete_sql);
			$win = mysql_fetch_array($reponse_win);
			
			
	
			$requete_sql = "SELECT *
							FROM fiche
							WHERE fiche_id = \"$win[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);
	
			$requete_sql = "SELECT * FROM election
							WHERE projet_id = $projet
							AND finaliste_id != \"$win[finaliste_id]\"
							ORDER BY nb_votes DESC
							";
			$reponse_final = bd_executer_sql($requete_sql);
			
			$reponse_res = bd_executer_sql($requete_sql);
			$r = 1;
			$id = array();
			$id[0] =  $win['fiche_id'];
			while ($ligne_res = mysql_fetch_array($reponse_res)){
				$id[$r] = $ligne_res['fiche_id'];
				$r++;
			}
				
			$HTTP_SESSION_VARS["RES"]= $id;
?>
	<div id="panelContenu1" class="panneaux">
	
	<h4><a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$win['fiche_id']?>&amp;pos=0"><?=$ligne_prop['slogan']?></a></h4>
	<table cellpadding="0" cellspacing="0" width="600" border="0" align="center">
	<tr>
	<td align="center" width="200">
    <a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$win['fiche_id']?>&amp;pos=0">
<?
	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."' alt='affiche' width='200' border='0'/>";
	} else {
?>
		<img src='<?=$affiche?>' alt='affiche' border="0"/>
<?	
	}
?>
	</a>
	<td align="center">
	<table cellpadding="0" cellspacing="0" width="95%" align="right">
	<tr>
	<td width="30%" valign="top">Auteur :</td>
	<td width="70%"><?=$ligne_eleve['login']?></td>
	</tr>
	<tr>
	<td valign="top">Niveau : </td>
	<td><?=$ligne_prop['niveau']?></td>
	</tr>
	<tr>
	<td valign="top">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 valign="top">École : </td>
	<td><?=$ligne_ecole['nom']?></td>
	</tr>
	<tr>
	<td valign="top">Niveau scolaire : </td>
	<td><?=$ligne_grp['niveau']?></td>
	</tr>
	<tr>
	<td valign="top">Groupe : </td>
	<td><?=$ligne_grp['nom']?></td>
	</tr>
	<tr>
	<td colspan="2" align="center" valign="top">&nbsp;		
	</td>
	</tr>
	<tr>
	<td valign="top">Nombre de votes : </td>
	<td><?=$win['nb_votes']?></td>
	</tr>
	</table>
	</td>
	</tr>
	<tr><td colspan="2">
	<br />
	<p><strong>Explication</strong> : 
	<?=nl2br($ligne_prop['proposition'])?>
	</p>
	</td></tr>
	</table>
	<p><div align="center"><input type="button" value="Imprimer les résultats" onclick="mod_projet_popup(650,550,0,'par','imp_fin.php')"></div></p><br />
	</div>
<?
}

if ($projet == 0){
?>
		<p>Il n’y a présentement aucun projet actif en cours. Nous vous invitons à consulter les nouvelles sur la page d’accueil pour prendre connaissance des projets futurs de la <em>Pnyx!</em> Merci!</p></td></tr></table></td></tr></table>
<?		
} else if ($periode == "debut"){
?>
		<p>La période de candidature n'est pas encore commencée. Aucune proposition ne peut donc être disponible. Nous vous invitons à consulter les nouvelles sur la page d’accueil pour prendre connaissance de la date de début de la période de candidature. Merci!</p></td></tr></table></td></tr></table>
<?
} else {
#		gen_variables_session();
#			$message = $HTTP_SESSION_VARS[SESSION][message];		
#			echo "<br /><h3 align=\"center\"><font color='#FF0000'>$message</font></h3>";
#			$HTTP_SESSION_VARS[SESSION][message]="";
######################################################## ONGLET RECHERCHE ###########################################################
	if ($periode == "vote" || $periode == "fin_vote"){
?>
			<div id="panelContenu3" class="panneaux">
<?
	}
	else{
?>
			<div id="panelContenu2" class="panneaux">
<?
	}
?>
		<table cellpadding="0" cellspacing="0" width="100%" align="center" border="0">
<?
if (isset($HTTP_SESSION_VARS["TOUT"])){
	if ($HTTP_SESSION_VARS["TOUT"] == "y"){
		if ($periode == "vote"){
			/*
?>
			<tr>
			<td colspan="4">&nbsp;</td>
			</tr>
			<tr>
			<td colspan="2" align="center">&nbsp;</td>
			<td align="center"><a href="gen_rech_prog2.php?type_action=voir_fin">Voir les finalistes</a></td>
			<td align="center">&nbsp;</td>
			</tr>
<?	
			*/
		} else if ($periode == "fin_vote"){
			/*
?>
			<tr>
			<td colspan="4">&nbsp;</td>
			</tr>
			<tr>
			<td colspan="2" align="center">&nbsp;</td>
			<td align="center"><a href="gen_rech_prog2.php?type_action=voir_fin">Voir les résultats</a></td>
			<td align="center">&nbsp;</td>
			</tr>
<?	
			*/
		}
	}
}
?>
			</table>		
			<form name="form_crit" method="post" action="gen_rech_prog2.php">
			<table cellpadding="0" cellspacing="0" width="100%" align="center" border="0">
			<tr>
			<td colspan="2"><h4>Explorer les résultats par:</h4></td>
			</tr>
			<tr>
			<td ><p><strong>Niveau de la proposition :</strong>
				<select name="niveau" size="1">
<?
if ($HTTP_SESSION_VARS['RECH']['niveau'] == ""){
				echo "<option value=\"\" selected=\"selected\">Tous</option>";
} else {
				echo "<option value=\"\">Tous</option>";
}
			
if($ligne_projet['international'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau'] == "international"){
					echo "<option value=\"international\" selected=\"selected\">International</option>";
	} else {
					echo "<option value=\"international\">International</option>";
	}
}
			
if($ligne_projet['national'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau'] == "national"){
					echo "<option value=\"national\" selected=\"selected\">National</option>";
	} else {
					echo "<option value=\"national\">National</option>";
	}
}
			
if($ligne_projet['local'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau'] == "local"){
					echo "<option value=\"local\" selected=\"selected\">Local</option>";
	} else {
					echo "<option value=\"local\">Local</option>";
	}
}
?>
			</select></p>
			</td>
			<td>
			<p><strong>Niveau scolaire :</strong>
			  <select name="niveau_scol" size="1">
<?
if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] == ""){
				echo "<option value=\"\" selected=\"selected\">Tous</option>";
} else {
				echo "<option value=\"\">Tous</option>";
}
			
if($ligne_projet['cycle1p'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] == "1er cycle primaire"){
					echo "<option value=\"1er cycle primaire\" selected=\"selected\">1er cycle primaire (6-7 ans)</option>";
	} else {
					echo "<option value=\"1er cycle primaire\">1er cycle primaire (6-7 ans)</option>";
	}
}
			
if($ligne_projet['cycle2p'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] == "2e cycle primaire"){
					echo "<option value=\"2e cycle primaire\" selected=\"selected\">2e cycle primaire (8-9 ans)</option>";
	} else {
					echo "<option value=\"2e cycle primaire\">2e cycle primaire (8-9 ans)</option>";
	}
}
			
if($ligne_projet['cycle3p'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] == "3e cycle primaire"){
					echo "<option value=\"3e cycle primaire\" selected=\"selected\">3e cycle primaire (10-11 ans)</option>";
	} else {
					echo "<option value=\"3e cycle primaire\">3e cycle primaire (10-11 ans)</option>";
	}
}
			
if($ligne_projet['cycle1s'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] == "1er cycle secondaire"){
					echo "<option value=\"1er cycle secondaire\" selected=\"selected\">1er cycle secondaire (12-13 ans)</option>";
	} else {
					echo "<option value=\"1er cycle secondaire\">1er cycle secondaire (12-13 ans)</option>";
	}
}
			
if($ligne_projet['cycle2s'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] == "2e cycle secondaire"){
					echo "<option value=\"2e cycle secondaire\" selected=\"selected\">2e cycle secondaire (14-16 ans)</option>";
	} else {
					echo "<option value=\"2e cycle secondaire\">2e cycle secondaire (14-16 ans)</option>";
	}
}
?>
			</select></p>
			</td>
			</tr>
			<tr>
			<td>
			<p><strong>Catégorie de la proposition :</strong>
			  <select name="cat" size="1">
<?
if ($HTTP_SESSION_VARS['RECH']['cat'] == ""){
				echo "<option value=\"\" selected=\"selected\">Tous</option>";
} else {
				echo "<option value=\"\">Tous</option>";
}
			
while($ligne_catprop = mysql_fetch_array($reponse_catprop)){
				$cat = $ligne_catprop['nom'];
				$catid = $ligne_catprop['cat_id'];
	if($HTTP_SESSION_VARS['RECH']['cat'] == $catid){
				echo "<option value='" . $catid . "' selected=\"selected\">" . $cat . "</option>";
	} else {
					echo "<option value='" . $catid . "'>" . $cat . "</option>";
	}
}			
?>				
			</select></p>
			</td>
			<td>
			<p><strong>Type de groupe :</strong>
			  <select name="typegrp" size="1">
<?
if ($HTTP_SESSION_VARS['RECH']['typegrp'] == ""){
				echo "<option value=\"\" selected=\"selected\">Tous</option>";
} else {
				echo "<option value=\"\">Tous</option>";
}
			
if($ligne_projet['classe_reg'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['typegrp'] == "classe  régulière"){
					echo "<option value=\"classe  régulière\" selected=\"selected\">Classe régulière</option>";
	} else {
					echo "<option value=\"classe  régulière\">Classe régulière</option>";
	}
}
			
if($ligne_projet['conseil'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['typegrp'] == "conseil d'élèves"){
					echo "<option value=\"conseil d\'élèves\" selected=\"selected\">Conseil d'élèves</option>";
	} else {
					echo "<option value=\"conseil d\'élèves\">Conseil d'élèves</option>";
	}
}
			
if($ligne_projet['parasco'] == 1){
	if ($HTTP_SESSION_VARS['RECH']['typegrp'] == "groupe parascolaire"){
					echo "<option value=\"groupe parascolaire\" selected=\"selected\">Groupe parascolaire</option>";
	} else {
					echo "<option value=\"groupe parascolaire\">Groupe parascolaire</option>";
	}
}
			
if($ligne_projet['autre'] == 1){
	if($HTTP_SESSION_VARS['RECH']['typegrp'] == "autre"){
					echo "<option value=\"autre\" selected=\"selected\">Autre</option>";
	} else {
					echo "<option value=\"autre\">Autre</option>";
	}
}
?>			
			</select></p>
			</td>
			</tr>
			<tr>
			<td colspan="2" align="center"><input type="hidden" name="type_action" value="rech_crit" />
				<input type="submit" value="Envoyer" /></td>
			</tr>
			</table>
			</form>
</div>
<?
}

if(isset($HTTP_SESSION_VARS["TOUT"])){
	if (($periode == "cand" || $periode == "fin_cand") && $projet != 0 || ($HTTP_SESSION_VARS["TOUT"]== "y")){
######################################################## ONGLET RESULTAT ###########################################################
				$ordre="";
				$cat = "";
				if(isset($HTTP_SESSION_VARS['RECH']['cat'])){
					if ($HTTP_SESSION_VARS['RECH']['cat'] != ""){
						$requete_sql = "SELECT cat_id FROM categorie_prop WHERE cat_id = " . $HTTP_SESSION_VARS['RECH']['cat'];
						$reponse_cat = mysql_query($requete_sql);
						$ligne_cat = mysql_fetch_array($reponse_cat);
						$cat = $ligne_cat["cat_id"];
						$clause_cat = "AND F.categorie = '" . $cat . "'";
					}else {
						$clause_cat = "";
					}
				}else {
					$clause_cat = "";
				}
					
				
				$niv = "";
				if(isset($HTTP_SESSION_VARS['RECH']['niveau'])){
					if ($HTTP_SESSION_VARS['RECH']['niveau'] != ""){
						$niv = $HTTP_SESSION_VARS['RECH']['niveau'];
						$clause_niveau = "AND F.niveau = '" . $niv . "'";
					}else {
						$clause_niveau = "";
					}
				}else {
					$clause_niveau = "";
				}
				
				$nivs = "";
				if(isset($HTTP_SESSION_VARS['RECH']['niveau_scol'])){
					if ($HTTP_SESSION_VARS['RECH']['niveau_scol'] != ""){
						$nivs = $HTTP_SESSION_VARS['RECH']['niveau_scol'];
						$clause_nscol = "AND G.niveau = '" . $nivs . "'";
					}else {
						$clause_nscol = "";
					}
				}else {
					$clause_nscol = "";
				}
				
				$type = "";
				if(isset($HTTP_SESSION_VARS['RECH']['typegrp'])){
					if ($HTTP_SESSION_VARS['RECH']['typegrp'] != ""){
						$type = $HTTP_SESSION_VARS['RECH']['typegrp'];
						$clause_typegrp = "AND G.type = '" . $type . "'";
					}else {
						$clause_typegrp = "";
					}
				}else {
					$clause_typegrp = "";
				}
				
				$grp = "";
				if(isset($HTTP_SESSION_VARS['RECH']['groupe'])){
					if ($HTTP_SESSION_VARS['RECH']['groupe'] != ""){
						$grp = $HTTP_SESSION_VARS['RECH']['groupe'];
						$clause_groupe = "AND G.groupe_id = '" . $grp . "'";
					}else {
						$clause_groupe = "";
					}
				}else {
					$clause_groupe = "";
				}
				
				$ecole = "";
				if(isset($HTTP_SESSION_VARS['RECH']['ecole'])){
					if ($HTTP_SESSION_VARS['RECH']['ecole'] != ""){
						$ecole = $HTTP_SESSION_VARS['RECH']['ecole'];
						$clause_ecole = "AND EC.ecole_id = '" . $ecole . "'";
					}else {
						$clause_ecole = "";
					}
				}else {
					$clause_ecole = "";
				}
				
				$cs = "";
				if(isset($HTTP_SESSION_VARS['RECH']['circons'])){
					if ($HTTP_SESSION_VARS['RECH']['circons'] != ""){
						$cs = $HTTP_SESSION_VARS['RECH']['circons'];
						$requete_sql = "SELECT circonscription FROM ecole WHERE ecole_id = '" . $cs . "'";
						$reponse_circon = mysql_query($requete_sql);
						$ligne_circon = mysql_fetch_array($reponse_circon);
						$clause_cs = "AND EC.circonscription = '" . $ligne_circon['circonscription'] . "'";
					}else {
						$clause_cs = "";
					}
				}else {
					$clause_cs = "";
				}
				
				$reg = "";
				if(isset($HTTP_SESSION_VARS['RECH']['region'])){
					if ($HTTP_SESSION_VARS['RECH']['region'] != ""){
						$reg = $HTTP_SESSION_VARS['RECH']['region'];
						$clause_region = "AND RE.region_id = '" . $reg . "'";
					}else {
						$clause_region = "";
					}
				}else {
					$clause_region = "";
				}
		
		if ($periode == "vote" || $periode == "fin_vote"){
?>
			<div id="panelContenu2" class="panneaux">
<?
		}
		else{
?>
			<div id="panelContenu1" class="panneaux">			
<?
		}
		$requete_sql = "SELECT F.*
							FROM ((((((fiche AS F LEFT JOIN eleve AS E ON F.eleve_id = E.eleve_id)
												  LEFT JOIN usager AS U ON E.usager_id = U.usager_id)
												  LEFT JOIN groupe AS G ON E.groupe_id = G.groupe_id)
												  LEFT JOIN responsable AS R ON G.resp_id = R.resp_id)
											  	  LEFT JOIN ecole AS EC ON R.ecole_id = EC.ecole_id)
												  LEFT JOIN commission_scolaire AS CS ON EC.comscol_id = CS.comscol_id)
												  LEFT JOIN region AS RE ON CS.region_id = RE.region_id
							WHERE E.projet_id = $projet
							AND F.valide = 1
							$clause_niveau
							$clause_cat
							$clause_groupe
							$clause_nscol
							$clause_typegrp
							$clause_ecole
							$clause_cs
							$clause_region
							$ordre 
							";
		$reponse_propid = bd_executer_sql($requete_sql);
		$reponse_propid2 = bd_executer_sql($requete_sql);
		$nb_prop = mysql_num_rows($reponse_propid);
?>
			<table width="664" cellpadding="0" cellspacing="0">
			<tr>
			<td colspan="2"><a name="resultats" id="resultats"></a></td>
			</tr>
			<tr>
			<td colspan="2">
            <table>
			<tr>
			<td>
<?
			if ($nb_prop == 0){
				echo "<h3 align=\"center\"><font color='#FF0000'>Aucune proposition n'a été trouvée.</font></h3></td></tr></table>";
			} else {
				if (isset($HTTP_GET_VARS['debut'])){
					$debut = $HTTP_GET_VARS['debut'];
				} else {
					$debut =0;
				}
				
				if($debut != 0){
					mysql_data_seek($reponse_prop, $debut);
				}
				$debut_display = $debut +1; # $debut commence a 0, usager part de 1
				if ($debut + $lignes < $nb_prop) {
					$fin = $debut + $lignes -1;
					$fin_display = $debut + $lignes;
				} else {
					$fin = $nb_prop;
					$fin_display = $nb_prop;
				}
				
				echo "<p><strong>".$nb_prop." proposition(s) trouvée(s).</strong></p>";
				
				if ($nb_prop>1){
			?>
            </td>
            <td width="71%" align="right">
		<form name="form_ordre" method="post" action="gen_rech_prog2.php">
        <h4 style="display:inline">&nbsp;&nbsp;Ordonner les résultats par :&nbsp;</h4>
        <select name="ordre" id="ordre" size="1" onchange="trieResultat()">
		<option value="">Choisir</option>
        <option value="date_asc">Date d'affichage (ancien-récent)</option>
		<option value="date_desc">Date d'affichage (récent - ancien)</option>
        <option value="prop_asc">Titre de proposition (A-Z)</option>
		<option value="prop_desc">Titre de proposition (Z-A)</option>
		<option value="auteur_asc">Auteur (A-Z)</option>
		<option value="auteur_desc">Auteur (Z-A)</option>
        <option value="cat_asc">Catégorie (A-Z)</option>
        <option value="cat_desc">Catégorie (Z-A)</option>
        <option value="ecole_asc">École (A-Z)</option>
		<option value="ecole_desc">École (Z-A)</option>
        <option value="groupe_asc">Groupe (A-Z)</option>
		<option value="groupe_desc">Groupe (Z-A)</option>
        <option value="app_asc">Popularité croissante</option>
        <option value="app_desc">Popularité décroissante</option>
		</select>
        <input type="hidden" id="cat" value="<?= $cat ?>" />
        <input type="hidden" id="niv" value="<?= $niv ?>" />
        <input type="hidden" id="nivs" value="<?= $nivs ?>" />
        <input type="hidden" id="type" value="<?= $type ?>" />
        <input type="hidden" id="grp" value="<?= $grp ?>" />
        <input type="hidden" id="ecole" value="<?= $ecole ?>" />
        <input type="hidden" id="cs" value="<?= $cs ?>" />
        <input type="hidden" id="region" value="<?= $region ?>" />
<?
	if(isset($_GET['debut'])){
		$debut = $_GET['debut'];
	}
	else{
		$debut = 0;
	}
?>
        <input type="hidden" id="debut" value="<?= $debut ?>" />
		</form>
        </td>
        </tr>
        <tr>
        <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
        <td>Liste des propositions <?=$debut_display?>  &agrave; <?=$fin_display?></td>
		<td align="right">
			<?
			#$d pour debut
			#$j pour le chiffre de la page
			#$i pour l'indice	
			$blocs_reponses = intval($nb_prop / $lignes);
			if (($nb_prop % $lignes) > 0) {
				$blocs_reponses = $blocs_reponses + 1;
			}
			$ongletP = "";
			if($periode == "vote" || $periode == "fin_vote"){
				$ongletP = "&onglet=2";	
			}
			if ($blocs_reponses > 1) {

				if ($debut - $lignes >= 0) {
					echo "<a href=\"gen_rech_prog.php?debut=";
					echo $debut - $lignes . $ongletP;
					echo "\">Pr&eacute;c&eacute;dent</a>&nbsp;&nbsp;&nbsp;";
				}
				for ($i=1; $i<=$blocs_reponses; $i++) {
					$d = $i * $lignes - $lignes;
					if ($debut == $d) {
						$lim = $i;
						$bas = $i-3;
						if($bas < 1){
							$bas = 1;
						}						
						for ($j=$bas; $j<=$blocs_reponses; $j++) {
							if ($j < $lim){
								$d = $j * $lignes - $lignes . $ongletP;
								echo "<a href=\"gen_rech_prog.php?debut=$d\">" . $j . "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
							}#if
						}#for
						echo "$i&nbsp;&nbsp;&nbsp;&nbsp;";
						$i ++;
						$lim = $i + 3;
						for ($j=$i; $j<=$blocs_reponses; $j++) {
							if ($j < $lim){
								$d = $j * $lignes - $lignes . $ongletP;
								echo "<a href=\"gen_rech_prog.php?debut=$d\">$j</a>&nbsp;&nbsp;&nbsp;&nbsp;";
							}#if
						}#for
					
					}#if
				}#for
									if ($debut + $lignes <+ $nb_prop) {
					echo "<a href=\"gen_rech_prog.php?debut=";
					echo $debut + $lignes . $ongletP;
					echo "\">Suivant</a>&nbsp;&nbsp;&nbsp;";
				}
			}
			?>
				</td>
				</tr>
				</table>
				<br />
			<?
			}
						
			$ordre = "ORDER BY " . $HTTP_SESSION_VARS['RECH']['ordre'];
			$compteur = $debut;
			$tabProp = array();
			while($ligne_propid = mysql_fetch_array($reponse_propid)){
				$position = "";
				do {
					$position = rand(0,($nb_prop - 1));
				}
				while(isset($tabProp[$position]));
					$tabProp[$position] = $ligne_propid["fiche_id"];
			}
			ksort($tabProp);
			
			if(isset($HTTP_SESSION_VARS['listeProp'])){
				if(($clause_niveau != "" || $clause_cat != "" || $clause_groupe != "" || $clause_nscol != "" || $clause_typegrp != "" || $clause_ecole != "" || $clause_cs != "" || $clause_region != "")){
					$position = 0;
					$tabProp = array();
					while($ligne_propid = mysql_fetch_array($reponse_propid2)){
						$tabProp[$position] = $ligne_propid["fiche_id"];
						$position++;
					}	
				}
				else{
					$tabProp = $HTTP_SESSION_VARS['listeProp'];
				}
			}
			else{
				if(($clause_niveau != "" || $clause_cat != "" || $clause_groupe != "" || $clause_nscol != "" || $clause_typegrp != "" || $clause_ecole != "" || $clause_cs != "" || $clause_region != "")){
					$position = 0;
					$tabProp = array();
					while($ligne_propid = mysql_fetch_array($reponse_propid2)){
						$tabProp[$position] = $ligne_propid["fiche_id"];
						$position++;
					}	
				}
				else{
					$HTTP_SESSION_VARS['listeProp'] = $tabProp;
				}
			}
?>
			<div id="resultatProp">
<?		
			foreach($tabProp as $position => $fiche_id) {
				if(isset($_GET['debut'])){
					$debut = $_GET['debut'];
				}
				else{
					$debut = 0;
				}
				if($position < ($debut + 10) && $position >= $debut){
					$requete_sql = "SELECT *
									FROM fiche
									WHERE fiche_id = $fiche_id
									";
					$reponse_fiche = bd_executer_sql($requete_sql);
					$ligne_fiche = mysql_fetch_array($reponse_fiche);
							
					$requete_sql = "SELECT *
									FROM eleve E, usager U
									WHERE E.eleve_id = \"$ligne_fiche[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);
			
?>
			
						<h4><a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$ligne_fiche['fiche_id']?>&amp;pos=<?=$position?>"><?=$ligne_fiche['slogan']?></a></h4>
						<table cellpadding="0" cellspacing="0" width="600" border="0" align="center">
						<tr>
						<td width="200" align="center" valign="top">
            			<a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$ligne_fiche['fiche_id']?>&amp;pos=<?=$position?>">
<?
						if ($ligne_fiche['affiche'] == ""){
							$affiche = "images/gen_affiche.jpg";
						} else {
							$affiche = $ligne_fiche['affiche'];
						}
	
						list($width) = getimagesize($affiche);
						if ($width > 200){
							echo "<img src='".$affiche."' alt='affiche' width='200' border='0'/>";
						} else {
?>
							<img src='<?=$affiche?>' alt='affiche' border="0"/>
<?	
						}
?>
						</a>
                        </td>
                        <td align="center">
                        <table cellpadding="0" cellspacing="0" width="95%" align="right">
                        <tr>
                        <td width="30%" valign="top">Auteur :</td>
                        <td width="70%"><?=$ligne_eleve['login']?></td>
                        </tr>
                        <tr>
                        <td valign="top">Niveau : </td>
                        <td><?=$ligne_fiche['niveau']?></td>
                        </tr>
                        <tr>
                        <td valign="top">Catégorie : </td>
                        <td>
<?
						$requete_sql = "SELECT nom
										FROM categorie_prop
										WHERE cat_id = \"$ligne_fiche[categorie]\"
										";
						$reponse_catNom = mysql_query($requete_sql);
						$ligne_catNom = mysql_fetch_array($reponse_catNom);
?>
		  				<?= $ligne_catNom['nom']?>		
                        </td>
                        </tr>
                        <tr>
                        <td valign="top">École : </td>
                        <td><?=$ligne_ecole['nom']?></td>
                        </tr>
                        <tr>
                        <td valign="top">Niveau scolaire : </td>
                        <td><?=$ligne_grp['niveau']?></td>
                        </tr>
                        <tr>
                        <td valign="top">Groupe : </td>
                        <td><?=$ligne_grp['nom']?></td>
                        </tr>
                        <tr>
                        <td valign="top">Appréciation : </td>
                        <td>
<?
						if ($ligne_fiche['app_moyenne'] < 0.50){
							echo "<img src='images/etoile_0.jpg' alt='0' />";
						} else if ($ligne_fiche['app_moyenne'] < 0.99){
							echo "<img src='images/etoile_0_5.jpg' alt='0,5' />";
						} else if ($ligne_fiche['app_moyenne'] < 1.50){
							echo "<img src='images/etoile_1.jpg' alt='1' />";
						} else if ($ligne_fiche['app_moyenne'] < 2.00){
							echo "<img src='images/etoile_1_5.jpg' alt='1,5' />";
						} else if ($ligne_fiche['app_moyenne'] < 2.50){
							echo "<img src='images/etoile_2.jpg' alt='2' />";
						} else if ($ligne_fiche['app_moyenne'] < 3.00){
							echo "<img src='images/etoile_2_5.jpg' alt='2,5' />";
						} else if ($ligne_fiche['app_moyenne'] < 3.50){
							echo "<img src='images/etoile_3.jpg' alt='3' />";
						} else if ($ligne_fiche['app_moyenne'] < 4.00){
							echo "<img src='images/etoile_3_5.jpg' alt='3,5' />";
						} else if ($ligne_fiche['app_moyenne'] < 4.50){
							echo "<img src='images/etoile_4.jpg' alt='4' />";
						} else if ($ligne_fiche['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 valign="top">&nbsp;</td>
                        <td>
<?									
						if ($ligne_fiche['app_nb'] > 1){
							echo "&nbsp;".$ligne_fiche['app_nb']." appréciations";
						} else if ($ligne_fiche['app_nb'] == 1){
							echo "&nbsp;".$ligne_fiche['app_nb']." appréciation";
						}
?>
                        <br />
                        </td>
                        </tr>
                        </table>
                        </td>
                        </tr>
                        </table>
                        <hr align="center" width="400" />
<?
					}
				}
				$compteur++;
?>
</div>
<?
			
			
				if ($compteur > $fin) {
					break;
				}
			}
			$blocs_reponses = intval($nb_prop / $lignes);
			if (($nb_prop % $lignes) > 0) {
				$blocs_reponses = $blocs_reponses + 1;
			}
			$ongletP = "";
			if($periode == "vote" || $periode == "fin_vote"){
				$ongletP = "&onglet=2";	
			}
			if ($blocs_reponses > 1) {
   	           	echo "<br />
				<table width='90%' align='center'><tr>
				<td align='right'>";

				if ($debut - $lignes >= 0) {
					echo "<a href=\"gen_rech_prog.php?debut=";
					echo $debut - $lignes . $ongletP;
					echo "\">Pr&eacute;c&eacute;dent</a>&nbsp;&nbsp;&nbsp;";
				}
				for ($i=1; $i<=$blocs_reponses; $i++) {
					$d = $i * $lignes - $lignes;
					if ($debut == $d) {
						$lim = $i;
						$bas = $i-3;
						if($bas < 1){
							$bas = 1;
						}						
						for ($j=$bas; $j<=$blocs_reponses; $j++) {
							if ($j < $lim){
								$d = $j * $lignes - $lignes . $ongletP;
								echo "<a href=\"gen_rech_prog.php?debut=$d\">" . $j . "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
							}#if
						}#for
						echo "$i&nbsp;&nbsp;&nbsp;&nbsp;";
						$i ++;
						$lim = $i + 3;
						for ($j=$i; $j<=$blocs_reponses; $j++) {
							if ($j < $lim){
								$d = $j * $lignes - $lignes . $ongletP;
								echo "<a href=\"gen_rech_prog.php?debut=$d\">$j</a>&nbsp;&nbsp;&nbsp;&nbsp;";
							}#if
						}#for
					
					}#if
				}#for
				if ($debut + $lignes <+ $nb_prop) {
					echo "<a href=\"gen_rech_prog.php?debut=";
					echo $debut + $lignes . $ongletP;
					echo "\">Suivant</a>&nbsp;&nbsp;&nbsp;";
				}
			}
			echo "</td></tr></table>";
		}
?>
			
			
<?
	} else if ($periode == "fin_vote"){
?>

	
			<table width="664" cellpadding="0" cellspacing="0">
			<tr>
			<td colspan="2"><h3>Résultats des élections</h3></td>
			</tr>
			<tr>
			<td colspan="2"><p>Voici les autres propositions finalistes : </p>
              <?
			$i = 1;
			while ($ligne = mysql_fetch_array($reponse_final)) {
			
			$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);
?>
			
			<h4><a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$ligne['fiche_id']?>&amp;pos=<?=$i?>"><?=$ligne_prop['slogan']?></a></h4>
			<table cellpadding="0" cellspacing="0" width="600" border="0" align="center">
			<tr>
			<td align="center" width="200">
            <a href="gen_rech_prog2.php?type_action=aff_prop&amp;id_prop=<?=$ligne['fiche_id']?>&amp;pos=<?=$i?>">
<?
		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."' alt='affiche' width='200' border='0'/>";
	} else {
?>
		<img src='<?=$affiche?>' alt='affiche' border="0"/>
<?	
	}
?>
</a>
			<td align="center">
			<table cellpadding="0" cellspacing="0" width="95%" align="right">
			<tr>
			<td width="31%" valign="top">Auteur :</td>
			<td width="69%"><?=$ligne_eleve['login']?></td>
			</tr>
			<tr>
			<td valign="top">Niveau : </td>
			<td><?=$ligne_prop['niveau']?></td>
			</tr>
			<tr>
			<td valign="top">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 valign="top">École : </td>
			<td><?=$ligne_ecole['nom']?></td>
			</tr>
			<tr>
			<td valign="top">Niveau scolaire : </td>
			<td><?=$ligne_grp['niveau']?></td>
			</tr>
			<tr>
			<td valign="top">Groupe : </td>
			<td><?=$ligne_grp['nom']?></td>
			</tr>
		<tr>
		<td valign="top"><br />
		  Nombre de votes : </td>
		<td><br />		  <?=$ligne['app_nb']?></td>
		</tr>
			</table>
			</td>
			</tr>
			</table>
			<hr align="center" width="400" />
<?
	$i++;
	}
?>
			<table cellpadding="0" cellspacing="0" width="100%" align="center" border="0">
			<tr>
			<td align="center"><a href="gen_rech_prog2.php?type_action=voir_tout">Voir les propositions non finalistes</a>
			<div align="right"><a href="#haut"><img src="images/haut.gif" alt="Retour au haut de la page" width="37" height="17" border="0" /></a></div>
			</td>
			</tr>
			</table>
			</div>
<?
	}
?>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
	require "pied_page.php";
?>
Return current item: Pnyx : des lections virtuelles!