version 0.1
This commit is contained in:
@ -22,7 +22,7 @@ if ( empty($idVotation))
|
||||
<div class="col-lg-12 text-center">
|
||||
<h3>VOTE</h3>
|
||||
<h4>');
|
||||
$query = 'SELECT *, UNIX_TIMESTAMP(dateFin) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation);
|
||||
$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)
|
||||
@ -44,12 +44,19 @@ if ( empty($idVotation))
|
||||
$votes = $db->result->fetch_all(MYSQLI_ASSOC);
|
||||
foreach ($votes as $vote)
|
||||
{
|
||||
$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 : ' . $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"];
|
||||
@ -57,17 +64,25 @@ if ( empty($idVotation))
|
||||
$resultat = $db->result->fetch_array(MYSQLI_ASSOC);
|
||||
echo $candidat["candidat"] . ' :' . $resultat["n"] . '<br>';
|
||||
$resultatCandidats[$candidat['candidat']] = $resultat["n"];
|
||||
$total += $resultat["n"];
|
||||
}
|
||||
array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC);
|
||||
reset($resultatCandidats);
|
||||
print("<h5>Remporte le vote : " . key($resultatCandidats));
|
||||
unset($resultatCandidats);
|
||||
print "</h5></pre>
|
||||
</div><br>";
|
||||
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>");
|
||||
}
|
||||
|
||||
print("</pre></div><br>");
|
||||
}
|
||||
}else
|
||||
{
|
||||
print "Bonjour, vous pourrez consulter les résultats après la clôture du vote le " . formattedate('fr', $votation['tf'] , "Europe/Paris") . "</h4>";
|
||||
print "Bonjour, vous pourrez consulter les résultats à partir du " . formattedate('fr', $votation['tf'] , "Europe/Paris") . "</h4>";
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user