2021-10-14 17:58:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'session_init.php';
|
|
|
|
require_once 'config.inc.php';
|
|
|
|
require_once 'db.class.php';
|
2022-09-14 13:05:25 +02:00
|
|
|
require_once 'entete.php';
|
2021-10-22 20:12:02 +02:00
|
|
|
require_once 'fonctions.inc.php';
|
|
|
|
print '<script type="text/javascript">
|
|
|
|
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"
|
|
|
|
}
|
2021-10-14 17:58:21 +02:00
|
|
|
|
2021-10-22 20:12:02 +02:00
|
|
|
}
|
|
|
|
</script>';
|
2021-10-14 17:58:21 +02:00
|
|
|
|
2022-09-14 13:05:25 +02:00
|
|
|
$db = new db();
|
|
|
|
print(' <br><br>
|
2021-10-14 17:58:21 +02:00
|
|
|
<!-- lalis Grid Section -->
|
|
|
|
|
|
|
|
<section id="content">
|
|
|
|
<div class="container">
|
|
|
|
<div class="row">
|
2022-09-14 13:05:25 +02:00
|
|
|
<div class="col-lg-12 text-center"><h3>LISTE DES VOTATIONS</h3>');
|
|
|
|
if ( empty( $_GET["id"]))
|
|
|
|
{
|
|
|
|
choixVotation('/vote.resultat.php');
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$idVotation = $_GET["id"];
|
|
|
|
print('
|
2021-10-14 17:58:21 +02:00
|
|
|
<h3>VOTE</h3>
|
|
|
|
<h4>');
|
2021-10-17 15:55:05 +02:00
|
|
|
$query = 'SELECT *, UNIX_TIMESTAMP(DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation);
|
2021-10-14 17:58:21 +02:00
|
|
|
$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');
|
2021-10-23 01:27:50 +02:00
|
|
|
if ( time() > $votation['tf'] )
|
2021-10-14 17:58:21 +02:00
|
|
|
{
|
|
|
|
echo $votation["libelle"] . "</h4>";
|
2021-10-22 20:12:02 +02:00
|
|
|
$listeAdherents = listeAdherents();
|
2021-10-14 17:58:21 +02:00
|
|
|
print (' <hr class="star-primary">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">');
|
|
|
|
|
|
|
|
$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)
|
|
|
|
{
|
2021-10-17 15:55:05 +02:00
|
|
|
$total = 0;
|
2021-10-14 17:58:21 +02:00
|
|
|
echo "<div><h5>" . $vote["libelle"] . "</h5><br>";
|
|
|
|
$query='SELECT * FROM liste_candidats WHERE idVotation=' . $idVotation . ' AND idVote=' . $vote["id"];
|
|
|
|
$result = $db->query($query);
|
|
|
|
$candidats = $db->result->fetch_all(MYSQLI_ASSOC);
|
|
|
|
echo "<pre>";
|
|
|
|
//$resultatCandidats = '';
|
2021-10-17 15:55:05 +02:00
|
|
|
|
|
|
|
$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 . '<br>';
|
2021-10-14 17:58:21 +02:00
|
|
|
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"] . '<br>';
|
|
|
|
$resultatCandidats[$candidat['candidat']] = $resultat["n"];
|
2021-10-17 15:55:05 +02:00
|
|
|
$total += $resultat["n"];
|
2021-10-14 17:58:21 +02:00
|
|
|
}
|
|
|
|
array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC);
|
|
|
|
reset($resultatCandidats);
|
2021-10-17 15:55:05 +02:00
|
|
|
if ($total >= $blanc)
|
|
|
|
{
|
|
|
|
print("<h5>Remporte le vote : " . key($resultatCandidats));
|
|
|
|
unset($resultatCandidats);
|
|
|
|
print("</h5>");
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
print("<h5>Aucun candidat n'emporte le vote, car il y a plus de 50% de votes blancs.</h5>");
|
|
|
|
}
|
2021-10-22 20:12:02 +02:00
|
|
|
listeVotants($idVotation, $vote["id"], $listeAdherents);
|
|
|
|
print("</pre></div><br>" . EOLH);
|
2021-10-14 17:58:21 +02:00
|
|
|
}
|
|
|
|
}else
|
|
|
|
{
|
2021-10-17 15:55:05 +02:00
|
|
|
print "Bonjour, vous pourrez consulter les résultats à partir du " . formattedate('fr', $votation['tf'] , "Europe/Paris") . "</h4>";
|
2021-10-14 17:58:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print (' <div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once 'footer.html';
|
|
|
|
?>
|