function show(object, idVote) { if (document.getElementById(object+idVote).style.display === "none") { document.getElementById(object+idVote).style.display = "block"; document.getElementById("button"+idVote).innerText = "Cacher la liste des votants" }else { document.getElementById(object+idVote).style.display = "none"; document.getElementById("button"+idVote).innerText = "Voir la liste des votants" } } '; $db = new db(); print('

LISTE DES VOTATIONS

'); if ( empty( $_GET["id"])) { choixVotation('/vote.resultat.php'); }else { $idVotation = $_GET["id"]; print('

VOTE

'); $query = 'SELECT *, UNIX_TIMESTAMP(DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation); $result = $db->query($query); $votation = $db->result->fetch_array(MYSQLI_ASSOC); if ($result === FALSE) { print "Votation non trouvée" . EOLH; }else { $now = date('Y-m-d'); if ( time() > $votation['tf'] ) { echo $votation["libelle"] . "

"; $listeAdherents = listeAdherents(); print ('
'); $query='SELECT * FROM liste_votes WHERE idVotation="' .$db->protect( $idVotation) .'"'; $result = $db->query($query); $votes = $db->result->fetch_all(MYSQLI_ASSOC); foreach ($votes as $vote) { $total = 0; echo "
" . $vote["libelle"] . "

"; $query='SELECT * FROM liste_candidats WHERE idVotation=' . $idVotation . ' AND idVote=' . $vote["id"]; $result = $db->query($query); $candidats = $db->result->fetch_all(MYSQLI_ASSOC); echo "
";
				//$resultatCandidats = '';

				$query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=0';
				$result = $db->query($query);
				$resultat = $db->result->fetch_array(MYSQLI_ASSOC);
				$blanc = $resultat["n"];
				echo 'Votes blancs : ' . $blanc . '
'; foreach($candidats as $candidat) { $query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=' . $candidat["id"]; $result = $db->query($query); $resultat = $db->result->fetch_array(MYSQLI_ASSOC); echo $candidat["candidat"] . ' :' . $resultat["n"] . '
'; $resultatCandidats[$candidat['candidat']] = $resultat["n"]; $total += $resultat["n"]; } array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC); reset($resultatCandidats); if ($total >= $blanc) { print("
Remporte le vote : " . key($resultatCandidats)); unset($resultatCandidats); print("
"); }else { print("
Aucun candidat n'emporte le vote, car il y a plus de 50% de votes blancs.
"); } listeVotants($idVotation, $vote["id"], $listeAdherents); print("

" . EOLH); } }else { print "Bonjour, vous pourrez consulter les résultats à partir du " . formattedate('fr', $votation['tf'] , "Europe/Paris") . ""; } } print ('
'); } require_once 'footer.html'; ?>