query($sql); //send email to teacher //mail to client $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = $_ENV['MAIL_HOST']; $mail->SMTPAuth = true; $mail->Username = $_ENV['MAIL_USERNAME']; $mail->Password = $_ENV['MAIL_PASSWORD']; $mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION']; $mail->Port = (int) $_ENV['MAIL_PORT']; $mail->CharSet = 'UTF-8'; //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 .= ""; $buttonedit .= ""; $buttonedit .= ""; } $buttonedit .= "
" . $participantRow["first_name"] . "" . $participantRow["last_name"] . "
"; // 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 = $_ENV['MAIL_FROM_ADDRESS']; $mail->FromName = $_ENV['MAIL_FROM_NAME']; $mail->addAddress('info@yogasoul.it'); // riepilogo alla teacher $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."; } // Connessione $bkngstm condivisa: non la chiudiamo qui ?> 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(); $mail->Host = $_ENV['MAIL_HOST']; $mail->SMTPAuth = true; $mail->Username = $_ENV['MAIL_USERNAME']; $mail->Password = $_ENV['MAIL_PASSWORD']; $mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION']; $mail->Port = (int) $_ENV['MAIL_PORT']; $mail->CharSet = 'UTF-8'; $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 = $_ENV['MAIL_FROM_ADDRESS']; $mail->FromName = $_ENV['MAIL_FROM_NAME']; $mail->addAddress($email); // promemoria all'utente $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."; } ?>