ajout de la liste des votants lors de l'affichage des résultats
This commit is contained in:
parent
7ae8c343ab
commit
5f6807b0dd
@ -25,7 +25,7 @@ if (empty($idVotation))
|
|||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
//chargement des données de la votation
|
//chargement des données de la votation
|
||||||
$db->query("SELECT *, UNIX_TIMESTAMP( DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf FROM liste_votations WHERE id=" . $idVotation);
|
$db->query("SELECT *, UNIX_TIMESTAMP( DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf, UNIX_TIMESTAMP(dateFin) as df, UNIX_TIMESTAMP(dateDebut) as dd FROM liste_votations WHERE id=" . $idVotation);
|
||||||
$votation = $db->result->fetch_array();
|
$votation = $db->result->fetch_array();
|
||||||
|
|
||||||
if(empty($_GET['status']))
|
if(empty($_GET['status']))
|
||||||
@ -51,7 +51,7 @@ if (empty($idVotation))
|
|||||||
$dolibarr->close();
|
$dolibarr->close();
|
||||||
|
|
||||||
$sujet = "[LALIS] Convocation à un vote";
|
$sujet = "[LALIS] Convocation à un vote";
|
||||||
$textDebut = "Bonjour,\nL'association Lalis vous invite à un vote.\nMotif du vote : " . $votation['libelle'] . "\n\nPour voter, cliquez sur le lien suivant :\nhttps://lalis69.ddns.net:10443/vote.form.php?v=" . $idVotation . "&id=";
|
$textDebut = "Bonjour,\nL'association Lalis vous invite à un vote du " . formatteDate('fr', $votation['dd'], 'Europe/Paris') . " 0h00 au " . formatteDate('fr', $votation['df'], 'Europe/Paris') . " minuit.\nMotif du vote : " . $votation['libelle'] . "\n\nPour voter, cliquez sur le lien suivant :\nhttps://lalis69.ddns.net:10443/vote.form.php?v=" . $idVotation . "&id=";
|
||||||
$textFin = "\n\nNous vous rappelons que pour pouvoir voter, vous devez être à jour de cotisation à la date du vote.\nLes résultats seront visibles dès le " . formatteDate('fr', $votation['tf'], 'Europe/Paris') . " par le lien suivant : https://lalis69.ddns.net:10443/vote.resultat.php?id=" . $idVotation . "\n\nPour Lalis, Le Président, David Larochette.";
|
$textFin = "\n\nNous vous rappelons que pour pouvoir voter, vous devez être à jour de cotisation à la date du vote.\nLes résultats seront visibles dès le " . formatteDate('fr', $votation['tf'], 'Europe/Paris') . " par le lien suivant : https://lalis69.ddns.net:10443/vote.resultat.php?id=" . $idVotation . "\n\nPour Lalis, Le Président, David Larochette.";
|
||||||
foreach($adherents as $adherent)
|
foreach($adherents as $adherent)
|
||||||
{
|
{
|
||||||
@ -59,9 +59,8 @@ if (empty($idVotation))
|
|||||||
print '<pre>' . $adherent['email'] . ' ' . $adherent['firstname'] . ' ' . $adherent['lastname'] . EOLH . nl2br($text) . '</pre>';
|
print '<pre>' . $adherent['email'] . ' ' . $adherent['firstname'] . ' ' . $adherent['lastname'] . EOLH . nl2br($text) . '</pre>';
|
||||||
if ( $_GET['status'] == 'Oui')
|
if ( $_GET['status'] == 'Oui')
|
||||||
{
|
{
|
||||||
//envoiMail($adherent['email'], $sujet, $text, $html=false, $cc='', $bcc='');
|
envoiMail($adherent['email'], $sujet, $text, $html=false, $cc='', $bcc='');
|
||||||
envoiMail('david@larochette.me', $sujet, $text, $html=false, $cc='', $bcc='');
|
//envoiMail('dtux@free.fr', $sujet, $text, $html=false, $cc='', $bcc='');
|
||||||
envoiMail('ric.libr4d@protonmail.com', $sujet, $text, $html=false, $cc='', $bcc='');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'log.php';
|
require_once 'log.php';
|
||||||
|
require 'PHPMailer/Exception.php';
|
||||||
|
require 'PHPMailer/PHPMailer.php';
|
||||||
|
require 'PHPMailer/SMTP.php';
|
||||||
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
use PHPMailer\PHPMailer\SMTP;
|
||||||
|
use PHPMailer\PHPMailer\Exception;
|
||||||
if ( !isset($site) )
|
if ( !isset($site) )
|
||||||
{
|
{
|
||||||
require_once( "config.inc.php" );
|
require_once( "config.inc.php" );
|
||||||
@ -94,7 +101,8 @@ function choixVotation($path, $methode=2) //2 = toutes les votations 1 = votat
|
|||||||
</form>';
|
</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
|
/*
|
||||||
|
function envoiMailold($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
|
||||||
{
|
{
|
||||||
require_once 'swiftmailer/autoload.php';
|
require_once 'swiftmailer/autoload.php';
|
||||||
//require_once 'include/swiftmailer/swiftmailer/lib/swift_init.php';
|
//require_once 'include/swiftmailer/swiftmailer/lib/swift_init.php';
|
||||||
@ -133,6 +141,64 @@ function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
|
||||||
|
{
|
||||||
|
|
||||||
|
//require 'vendor/autoload.php';
|
||||||
|
$mail = new PHPMailer(true);
|
||||||
|
try {
|
||||||
|
if ($html)
|
||||||
|
{
|
||||||
|
// setParameters() takes an associative array
|
||||||
|
$str = nl2br($text);
|
||||||
|
$text = "<html><head></head>\n<body>" . $str . "</body></html>";
|
||||||
|
log_write(__FILE__ . EOL . __LINE__ . EOL . wordwrap($text, 1000, "\r\n"), INFO);
|
||||||
|
$mail->isHTML(true);
|
||||||
|
$mail->AltBody = 'Ceci est un messssage HTML';
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
//$mail->isHTML(false);
|
||||||
|
|
||||||
|
$text = str_replace("\n","\r\n", $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Server settings
|
||||||
|
//$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
|
||||||
|
$mail->isSMTP(); //Send using SMTP
|
||||||
|
$mail->Host = 'mail.gandi.net'; //Set the SMTP server to send through
|
||||||
|
$mail->SMTPAuth = true; //Enable SMTP authentication
|
||||||
|
$mail->Username = 'contact@lalis.fr'; //SMTP username
|
||||||
|
$mail->Password = 'Gu>V$fiM{bQ^!x+FAHF+R.}bl'; //SMTP password
|
||||||
|
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit ssl encryption
|
||||||
|
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
|
||||||
|
$mail->MessageDate= '';
|
||||||
|
$mail->SMTPKeepAlive = true;
|
||||||
|
//Recipients
|
||||||
|
$mail->setFrom('contact@lalis.fr');
|
||||||
|
$mail->addAddress($destinataire); //Add a recipient
|
||||||
|
//$mail->addReplyTo('info@example.com', 'Information');
|
||||||
|
$mail->CharSet = PHPMailer::CHARSET_UTF8;
|
||||||
|
$mail->Body = $text;
|
||||||
|
//Attachments
|
||||||
|
//$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
|
||||||
|
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
|
||||||
|
|
||||||
|
//Content
|
||||||
|
//Set email format to HTML
|
||||||
|
$mail->Subject = $sujet;
|
||||||
|
$mail->send();
|
||||||
|
echo 'Message has been sent';
|
||||||
|
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel est parti:" . $destinataire . EOL . $sujet . EOL, INFO);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||||
|
log_error(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" . $destinataire . EOL . $sujet . EOL . print_r($mail->ErrorInfo, true) . EOL . wordwrap($text, 1000 , "\r\n"));
|
||||||
|
$mail->getSMTPInstance()->reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatteDate($locale, $date, $tz)
|
function formatteDate($locale, $date, $tz)
|
||||||
@ -146,4 +212,32 @@ function formatteDate($locale, $date, $tz)
|
|||||||
}
|
}
|
||||||
return $formatter->format($datetime );
|
return $formatter->format($datetime );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listeAdherents()
|
||||||
|
{
|
||||||
|
$dolibarr = new dbDolibarr();
|
||||||
|
$query = 'SELECT login, firstname, lastname FROM llx_adherent';
|
||||||
|
$dolibarr->query($query);
|
||||||
|
while ($adherent = $dolibarr->result->fetch_array())
|
||||||
|
{
|
||||||
|
$listeAdherents[$adherent['login']] = $adherent['firstname'] . ' ' . $adherent['lastname'];
|
||||||
|
}
|
||||||
|
$dolibarr->close();
|
||||||
|
return $listeAdherents;
|
||||||
|
}
|
||||||
|
|
||||||
|
function listeVotants($idVotation, $idVote, $listeAdherents)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
$query = "SELECT DISTINCT idVotant FROM votes WHERE idVotation=" . $idVotation . ' AND idVote=' . $idVote;
|
||||||
|
$result = $db->query($query);
|
||||||
|
print (EOLH . '<div id="listeVotants' . $idVote . '" style="display: none; line-height: 0.8;">');
|
||||||
|
while ($idVotants = $db->result->fetch_assoc())
|
||||||
|
{
|
||||||
|
|
||||||
|
print($listeAdherents[$idVotants['idVotant']] . EOLH);
|
||||||
|
}
|
||||||
|
print('</div><button id="button' . $idVote . '" onclick="show(\'listeVotants\',\'' . $idVote . '\')">Voir la liste des votants</button>' . EOLH);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -35,7 +35,7 @@ if ($dolibarr->result->num_rows == 0)
|
|||||||
{
|
{
|
||||||
$dolibarr->close();
|
$dolibarr->close();
|
||||||
$db = new db();
|
$db = new db();
|
||||||
$query = 'SELECT *, UNIX_TIMESTAMP(dateDebut) as td, UNIX_TIMESTAMP(dateFin) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation);
|
$query = 'SELECT *, UNIX_TIMESTAMP(dateDebut) as td, UNIX_TIMESTAMP( DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation);
|
||||||
$resultVotation = $db->query($query);
|
$resultVotation = $db->query($query);
|
||||||
$votation = $db->result->fetch_array();
|
$votation = $db->result->fetch_array();
|
||||||
$now = date('Y-m-d');
|
$now = date('Y-m-d');
|
||||||
|
@ -4,7 +4,22 @@ require_once 'session_init.php';
|
|||||||
require_once 'config.inc.php';
|
require_once 'config.inc.php';
|
||||||
require_once 'db.class.php';
|
require_once 'db.class.php';
|
||||||
require_once 'entete.html';
|
require_once 'entete.html';
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>';
|
||||||
$idVotation = $_GET["id"];
|
$idVotation = $_GET["id"];
|
||||||
$db = new db();
|
$db = new db();
|
||||||
|
|
||||||
@ -34,6 +49,7 @@ if ( empty($idVotation))
|
|||||||
if ( time() < $votation['tf'] )
|
if ( time() < $votation['tf'] )
|
||||||
{
|
{
|
||||||
echo $votation["libelle"] . "</h4>";
|
echo $votation["libelle"] . "</h4>";
|
||||||
|
$listeAdherents = listeAdherents();
|
||||||
print (' <hr class="star-primary">
|
print (' <hr class="star-primary">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -77,8 +93,8 @@ if ( empty($idVotation))
|
|||||||
{
|
{
|
||||||
print("<h5>Aucun candidat n'emporte le vote, car il y a plus de 50% de votes blancs.</h5>");
|
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>");
|
print("</pre></div><br>" . EOLH);
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user