214 lines
7.8 KiB
PHP
214 lines
7.8 KiB
PHP
<?php
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\Exception;
|
|
?>
|
|
<?php
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
ini_set('display_errors', '1');
|
|
ini_set('display_startup_errors', '1');
|
|
error_reporting(E_ALL);
|
|
include('Connections/bkngstm.php');
|
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
?>
|
|
<?php
|
|
// teacher notification
|
|
|
|
// Calcola la data del giorno successivo
|
|
$today = date('Y-m-d');
|
|
$nextDay = date('Y-m-d', strtotime($today . ' + 1 day'));
|
|
|
|
// Query SQL per recuperare gli eventi
|
|
$sql = "SELECT serviceschedule.dateschedule, serviceschedule.dateschedule, service.servicename, serviceschedule.idserviceschedule, service.maxcapacity
|
|
FROM serviceschedule
|
|
LEFT JOIN service ON serviceschedule.idservice = service.idservice
|
|
WHERE DATE(serviceschedule.dateschedule) = '$nextDay'
|
|
ORDER BY serviceschedule.dateschedule";
|
|
|
|
$result = $conn->query($sql);
|
|
|
|
//send email to teacher
|
|
|
|
require 'phpmailer/src/Exception.php';
|
|
require 'phpmailer/src/PHPMailer.php';
|
|
require 'phpmailer/src/SMTP.php';
|
|
|
|
|
|
//mail to client
|
|
|
|
$mail = new PHPMailer(true);
|
|
|
|
$mail->isSMTP(); // Set mailer to use SMTP
|
|
$mail->Host = 'mail.yogasoul.it'; // Specify main and backup server
|
|
$mail->SMTPAuth = true; // Enable SMTP authentication
|
|
$mail->Username = 'info@yogasoul.it'; // SMTP username
|
|
$mail->Password = '!Testolina88'; // SMTP password
|
|
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
|
|
$mail->Port = '587';
|
|
|
|
|
|
|
|
//mail sent
|
|
|
|
$messageedit=" <p style='font-size: 14px; line-height: 190%;'><span style='font-size: 18px; line-height: 34.2px;'><strong><span style='line-height: 34.2px; font-size: 18px;'> Ciao Aurora , </span></strong></span></p>
|
|
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Di seguito riepilogo delle tue lezioni di domani $nextDay</span></p>";
|
|
if ($result->num_rows > 0) {
|
|
// Ci sono record, inizializza la variabile $buttonedit
|
|
$buttonedit = "";
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
|
$date = date('d-M-Y H:i', strtotime($row["dateschedule"]));
|
|
$buttonedit .= "<strong>Classe: " . $row["servicename"] . ", Data: " . $date . "</strong><br>";
|
|
|
|
// Query per recuperare i partecipanti alla classe
|
|
$idserviceschedule = $row["idserviceschedule"];
|
|
$participantQuery = "SELECT auth_users.first_name, auth_users.last_name
|
|
FROM bookingclass
|
|
LEFT JOIN auth_users ON bookingclass.iduser = auth_users.id
|
|
WHERE bookingclass.idserviceschedule = '$idserviceschedule'";
|
|
|
|
$participantResult = $conn->query($participantQuery);
|
|
|
|
if ($participantResult->num_rows > 0) {
|
|
// Ci sono partecipanti, aggiungi i nomi e cognomi a $buttonedit
|
|
$buttonedit .= "<table>";
|
|
while ($participantRow = $participantResult->fetch_assoc()) {
|
|
$buttonedit .= "<tr>";
|
|
$buttonedit .= "<td>" . $participantRow["first_name"] . "</td>";
|
|
$buttonedit .= "<td>" . $participantRow["last_name"] . "</td>";
|
|
$buttonedit .= "</tr>";
|
|
}
|
|
$buttonedit .= "</table>";
|
|
|
|
// Conta il numero di partecipanti
|
|
$numPartecipanti = $participantResult->num_rows;
|
|
|
|
// Aggiungi l'ultima riga con il numero di posti e maxcapacity
|
|
$buttonedit .= "<em>Partecipanti: $numPartecipanti / " . $row["maxcapacity"] . "</em><br><br>";
|
|
|
|
|
|
|
|
} else {
|
|
// Nessun partecipante trovato
|
|
$buttonedit .= "Nessun partecipante per questa classe.";
|
|
}
|
|
}
|
|
|
|
include('mail/emailtemplate2.php');
|
|
// Email body content
|
|
|
|
//$trfnmbmail=$appformn.'r'.$revnumb;
|
|
$htmlContent = $mailmessage1;
|
|
|
|
|
|
$mail->From = 'info@yogasoul.it';
|
|
$mail->FromName = 'YogiBook [YogaSoul]';
|
|
$mail->addAddress('info@yogasoul.it'); // Add a recipient
|
|
|
|
|
|
|
|
|
|
$mail->Subject = "YogiBook - Lezioni di domani $nextDay";
|
|
$mail->Body = $htmlContent;
|
|
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
|
|
|
$mail->send();
|
|
} else {
|
|
// Nessun record trovato
|
|
$buttonedit = "Non ci sono record per il giorno successivo.";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Chiudi la connessione al database
|
|
$conn->close();
|
|
?>
|
|
<?php
|
|
// email notification to users
|
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
|
// Calcolo della data successiva
|
|
|
|
$today = date("Y-m-d");
|
|
$nextDay = date('Y-m-d', strtotime($today . ' + 1 day'));
|
|
|
|
// Query SQL
|
|
$sql = "SELECT s.servicename,
|
|
DATE_FORMAT(ss.dateschedule, '%d-%m-%Y %H:%i') AS formatted_date,
|
|
au.first_name,
|
|
au.email
|
|
FROM serviceschedule ss
|
|
LEFT JOIN service s ON ss.idservice = s.idservice
|
|
LEFT JOIN bookingclass bc ON ss.idserviceschedule = bc.idserviceschedule
|
|
LEFT JOIN auth_users au ON bc.iduser = au.id
|
|
WHERE DATE(ss.dateschedule) = '$nextDay'";
|
|
|
|
$result = $conn->query($sql);
|
|
|
|
if ($result->num_rows > 0) {
|
|
// Stampa dei risultati
|
|
while ($row = $result->fetch_assoc()) {
|
|
$servicename = $row["servicename"];
|
|
$formatted_date = $row["formatted_date"];
|
|
$first_name = $row["first_name"];
|
|
$email = $row["email"];
|
|
//send email to users
|
|
|
|
|
|
|
|
|
|
//mail to client
|
|
|
|
$mail = new PHPMailer(true);
|
|
|
|
$mail->isSMTP(); // Set mailer to use SMTP
|
|
$mail->Host = 'premium60.web-hosting.com'; // Specify main and backup server
|
|
$mail->SMTPAuth = true; // Enable SMTP authentication
|
|
$mail->Username = 'info@yogasoul.it'; // SMTP username
|
|
$mail->Password = '!Testolina88'; // SMTP password
|
|
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
|
|
$mail->Port = '587';
|
|
|
|
|
|
$messageedit=" <p style='font-size: 14px; line-height: 190%;'><span style='font-size: 18px; line-height: 34.2px;'><strong><span style='line-height: 34.2px; font-size: 18px;'> Ciao $first_name , </span></strong></span></p>
|
|
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Eccoti un promemoria per ricordarti la tua prossima lezione di '$servicename' del $formatted_date .</span></p>";
|
|
|
|
$buttonedit="<a href='https://yogibook.yogasoul.it/' target='_blank' class='v-button v-font-size' style='box-sizing: border-box;display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #FFFFFF; background-color: #3AAEE0; border-radius: 4px;-webkit-border-radius: 4px; -moz-border-radius: 4px; width:auto; max-width:100%; overflow-wrap: break-word; word-break: break-word; word-wrap:break-word; mso-border-alt: none;font-size: 14px;'>
|
|
<span style='display:block;padding:10px 20px;line-height:120%;'><span style='line-height: 16.8px;'>YogiBook - YogaSoul</span></span>
|
|
</a>";
|
|
|
|
include('mail/emailtemplate2.php');
|
|
// Email body content
|
|
|
|
//$trfnmbmail=$appformn.'r'.$revnumb;
|
|
$htmlContent = $mailmessage1;
|
|
|
|
|
|
$mail->From = 'info@yogasoul.it';
|
|
$mail->FromName = 'YogiBook [YogaSoul]';
|
|
$mail->addAddress($email); // Add a recipient
|
|
|
|
|
|
|
|
|
|
$mail->Subject = "YogiBook - Promemoria lezione di domani $nextDay";
|
|
$mail->Body = $htmlContent;
|
|
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
|
|
|
$mail->send();
|
|
|
|
|
|
echo "Nome evento: " . $servicename . "<br>";
|
|
echo "Data e ora: " . $formatted_date . "<br>";
|
|
echo "Nome allievo: " . $first_name . "<br>";
|
|
echo "Email: " . $email . "<br><br>";
|
|
}
|
|
} else {
|
|
echo "Nessun risultato trovato.";
|
|
}
|
|
|
|
$conn->close();
|
|
|
|
|
|
?>
|