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 = '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';
//mail sent
$messageedit="
Ciao Aurora ,
Di seguito riepilogo delle tue lezioni di domani $nextDay
";
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 .= "Classe: " . $row["servicename"] . ", Data: " . $date . "
";
// 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 .= "";
while ($participantRow = $participantResult->fetch_assoc()) {
$buttonedit .= "";
$buttonedit .= "| " . $participantRow["first_name"] . " | ";
$buttonedit .= "" . $participantRow["last_name"] . " | ";
$buttonedit .= "
";
}
$buttonedit .= "
";
// Conta il numero di partecipanti
$numPartecipanti = $participantResult->num_rows;
// Aggiungi l'ultima riga con il numero di posti e maxcapacity
$buttonedit .= "Partecipanti: $numPartecipanti / " . $row["maxcapacity"] . "
";
} 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();
?>
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=" Ciao $first_name ,
Eccoti un promemoria per ricordarti la tua prossima lezione di '$servicename' del $formatted_date .
";
$buttonedit="
YogiBook - YogaSoul
";
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 . "
";
echo "Data e ora: " . $formatted_date . "
";
echo "Nome allievo: " . $first_name . "
";
echo "Email: " . $email . "
";
}
} else {
echo "Nessun risultato trovato.";
}
$conn->close();
?>