2021-10-14 17:58:21 +02:00
< ? php
require_once 'session_init.php' ;
require_once 'config.inc.php' ;
require_once 'db.class.php' ;
require_once " log.php " ;
require_once 'entete.html' ;
$idVotant = trim ( base64_decode ( urldecode ( $_GET [ " id " ])), " \n \r " );
$idVotation = $_GET [ " v " ];
$dolibarr = new dbDolibarr ();
2021-10-17 15:55:05 +02:00
$query = " SELECT * FROM llx_adherent as a LEFT JOIN llx_adherent_type as t ON a.fk_adherent_type=t.rowid WHERE a.login=' " . $dolibarr -> protect ( $idVotant ) . " ' AND (DATE(a.datefin)>=CURDATE() OR t.subscription=0) AND t.vote=1 " ;
print $query . EOLH ;
2021-10-14 17:58:21 +02:00
$result = $dolibarr -> query ( $query );
2021-10-17 15:55:05 +02:00
print_r ( $dolibarr );
2021-10-14 17:58:21 +02:00
$votant = $dolibarr -> result -> fetch_array ();
print ( ' < br >< br >
<!-- lalis Grid Section -->
< section id = " content " >
< div class = " container " >
< form method = " get " action = " vote.php " >
< input type = " hidden " name = " id " value = " ' . $idVotant . ' " >
< input type = " hidden " name = " v " value = " ' . $idVotation . ' " > ' );
print ( ' < div class = " row " >
< div class = " col-lg-12 text-center " >
< h3 > VOTE </ h3 >
< h4 > ' );
if ( $dolibarr -> result -> num_rows == 0 )
{
2021-10-17 15:55:05 +02:00
print " Identifiant non autorisé.<br>Vous n'êtes probablement pas à jour de votre cotisation.<br>Si vous pensez qu'il s'agit d'une erreur, adressez vous à un responsable de l'association</h4>.<br><br><br><br> " ;
2021-10-14 17:58:21 +02:00
} else
{
$dolibarr -> close ();
$db = new db ();
$query = 'SELECT *, UNIX_TIMESTAMP(dateDebut) as td, UNIX_TIMESTAMP(dateFin) as tf FROM liste_votations WHERE id=' . $db -> protect ( $idVotation );
$resultVotation = $db -> query ( $query );
$votation = $db -> result -> fetch_array ();
$now = date ( 'Y-m-d' );
2021-10-17 15:55:05 +02:00
if ( $resultVotation === FALSE )
{
print " Votation non trouvée</h4> " . EOLH ;
} else
2021-10-14 17:58:21 +02:00
{
2021-10-17 15:55:05 +02:00
if ( time () >= $votation [ 'td' ] AND time () <= $votation [ 'tf' ] )
2021-10-14 17:58:21 +02:00
{
2021-10-17 15:55:05 +02:00
$query = " SELECT * FROM votes WHERE idVotant=' " . $db -> protect ( $idVotant ) . " ' " ;
$db -> query ( $query );
if ( $db -> result -> num_rows == 0 )
2021-10-14 17:58:21 +02:00
{
echo $votation [ " libelle " ] . " </h4> " ;
print ( ' < hr class = " star-primary " >
</ div >
</ div >
2021-10-17 15:55:05 +02:00
< div class = " row " >< h5 > Bonjour ' . $votant[' firstname '] . " " . $votant[' lastname ' ] . " </h5> " . EOLH . EOLH . " ATTENTION : " . EOLH . "
1 - les votes blancs sont comptés comme vote exprimés . Si plus de 50 % de vote blanc , alors le résultat du vote est nul . " . EOLH . " 2 - L ' absence de choix est compté comme abstention et donc non exprimés . " . EOLH . "
3 - Vérifiez bien votre vote avant de l ' envoyer , il est impossible de le modifier après . " );
2021-10-14 17:58:21 +02:00
$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 )
{
echo " <div><h5> " . $vote [ " libelle " ] . " </h5><br> " ;
$query = 'SELECT * FROM liste_candidats WHERE idVotation=' . $db -> protect ( $idVotation ) . ' AND idVote=' . $vote [ " id " ];
$result = $db -> query ( $query );
$candidats = $db -> result -> fetch_all ( MYSQLI_ASSOC );
echo " <pre> " ;
foreach ( $candidats as $candidat )
{
echo '<input type="radio" name="vote[' . $vote [ " id " ] . ']" value="' . $candidat [ " id " ] . '"> ' . $candidat [ " candidat " ] . ' <br>' ;
}
2021-10-17 15:55:05 +02:00
echo '<input type="radio" name="vote[' . $vote [ " id " ] . ']" value="0"> Vote blanc <br>' ;
2021-10-14 17:58:21 +02:00
print " </pre>
</ div >< br > " ;
}
print ( ' < div class = " text-center " >
< h4 >< input type = " submit " value = " Voter " ></ h4 > ' );
2021-10-17 15:55:05 +02:00
} else
{
print " Bonjour " . $votant [ 'firstname' ] . " " . $votant [ 'lastname' ] . ',' . EOLH . EOLH . " vous avez déjà voté, vous ne pouvez pas revoter ou modifier votre vote. " . EOLH . " Si vous pensez que c'est une erreur, veuillez prendre contact avec les responsables de l'association.</h4> " ;
2021-10-14 17:58:21 +02:00
}
} else
{
2021-10-17 15:55:05 +02:00
print " Bonjour " . $votant [ 'firstname' ] . " " . $votant [ 'lastname' ] . ',</h4>' . EOLH . EOLH . " Le vote ne sera ouvert qu'à partir du " . formattedate ( 'fr' , $votation [ 'td' ] , " Europe/Paris " ) . " et jusqu'au " . formattedate ( 'fr' , $votation [ 'tf' ] , " Europe/Paris " ) . '.' . EOLH . " Si vous pensez que ceci est une erreur, veuillez prendre contact avec les responsables de l'association.</h4> " ;
2021-10-14 17:58:21 +02:00
}
}
}
print ( ' </ div >
</ div >
</ form >
</ div >
</ section > ' );
require_once ( " footer.html " );
?>