ajout de la liste des votants lors de l'affichage des résultats
This commit is contained in:
@ -1,5 +1,12 @@
|
||||
<?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) )
|
||||
{
|
||||
require_once( "config.inc.php" );
|
||||
@ -94,7 +101,8 @@ function choixVotation($path, $methode=2) //2 = toutes les votations 1 = votat
|
||||
</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 'include/swiftmailer/swiftmailer/lib/swift_init.php';
|
||||
@ -133,6 +141,64 @@ function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
@ -146,4 +212,32 @@ function formatteDate($locale, $date, $tz)
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user