1
0
This commit is contained in:
2022-10-19 15:51:41 +02:00
parent e89dcf2cc7
commit 7422d5c89b
9 changed files with 173 additions and 119 deletions

View File

@ -17,7 +17,6 @@ print '<script type="text/javascript">
document.getElementById(object+idVote).style.display = "none";
document.getElementById("button"+idVote).innerText = "Voir la liste des votants"
}
}
</script>';
@ -40,80 +39,8 @@ if (empty($idVotation))
print('
<h3>VOTE</h3>
<h4>');
$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"] . "</h4>";
$listeAdherents = listeAdherents();
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)
{
switch ($vote["method"])
{
case 1:
$total = 0;
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 = '';
$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&nbsp;: ' . $blanc . '<br>';
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"] . '&nbsp;:' . $resultat["n"] . '<br>';
$resultatCandidats[$candidat['candidat']] = $resultat["n"];
$total += $resultat["n"];
}
array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC);
reset($resultatCandidats);
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>");
}
listeVotants($idVotation, $vote["id"], $listeAdherents);
print("</pre></div><br>" . EOLH);
break;
default:
break;
}
}
}else
{
print "Bonjour, vous pourrez consulter les résultats à partir du " . formattedate('fr', $votation['tf'] , "Europe/Paris") . "</h4>";
}
}
print (' <div>
$db->resultats($idVotation);
print (' <div>
</div>
</div>
</div>