fixed mailer class

This commit is contained in:
2026-09-04 10:03:38 +02:00
parent 83af2e2d17
commit b8957a8a24
15 changed files with 479 additions and 631 deletions
+19 -23
View File
@@ -1,17 +1,18 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
?>
<?php
// Connessione al database (adattare le informazioni di connessione)
include('include/headscript.php');
require_once __DIR__ . '/class/mailer.php';
$conn = new mysqli($servername, $username, $password, $dbname);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
$conn = $bkngstm; // riusa la connessione già aperta da bkngstm.php
// Recupera il parametro "idbookingclass" dalla richiesta GET
// Recupera il parametro "idbookingclass" dalla richiesta GET
if (isset($_GET['idbookingclass'])) {
$idbookingclass = $_GET['idbookingclass'];
$idbookingclass = (int) $_GET['idbookingclass'];
// Aggiorna lo status a "booked" e is_reprogrammed a "Y" nella tabella "bookingclass"
$query = "UPDATE bookingclass SET status = 'booked', is_reprogrammed = 'Y' WHERE idbookingclass = ?";
@@ -38,9 +39,7 @@ if (isset($_GET['idbookingclass'])) {
$firstname = $row['first_name'];
$newtimeformat = date("d-m-Y H:i", strtotime($newtime));
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
// Mail to client
$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 $firstname , </span></strong></span></p>
@@ -65,20 +64,21 @@ if (isset($_GET['idbookingclass'])) {
$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->isSMTP();
$mail->Host = $_ENV['MAIL_HOST'];
$mail->SMTPAuth = true;
$mail->Username = $_ENV['MAIL_USERNAME'];
$mail->Password = $_ENV['MAIL_PASSWORD'];
$mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION']; // ssl
$mail->Port = (int) $_ENV['MAIL_PORT']; // 465
$mail->CharSet = 'UTF-8';
include('mail/emailtemplate2.php');
// Email body content
$htmlContent = $mailmessage1;
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->From = $_ENV['MAIL_FROM_ADDRESS'];
$mail->FromName = $_ENV['MAIL_FROM_NAME'];
$mail->addAddress($emailuser); // Add a recipient
$mail->Subject = "YogiBook - Lezione riprogrammata con successo!";
@@ -104,7 +104,3 @@ if (isset($_GET['idbookingclass'])) {
} else {
echo "Parametro 'idbookingclass' non trovato nella richiesta GET.";
}
// Chiudi la connessione al database
$conn->close();
?>
+38 -31
View File
@@ -1,33 +1,23 @@
<?php
require_once('include/headscript.php');
require_once __DIR__ . '/class/mailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once('include/headscript.php');
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
// Abilita il reporting degli errori per il debug
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Recupera i parametri GET
$idorder = isset($_GET['idorder']) ? (int)$_GET['idorder'] : 0;
$idnewbooking = isset($_GET['idnewbooking']) ? (int)$_GET['idnewbooking'] : 0;
$iduser = isset($_GET['iduser']) ? (int)$_GET['iduser'] : 0;
$idservicenew = isset($_GET['idservicenew']) ? (int)$_GET['idservicenew'] : 0;
$idorder = isset($_GET['idorder']) ? (int) $_GET['idorder'] : 0;
$idnewbooking = isset($_GET['idnewbooking']) ? (int) $_GET['idnewbooking'] : 0;
$iduser = isset($_GET['iduser']) ? (int) $_GET['iduser'] : 0;
$idservicenew = isset($_GET['idservicenew']) ? (int) $_GET['idservicenew'] : 0;
// Valida i parametri richiesti
if ($idorder === 0 || $idnewbooking === 0 || $iduser === 0 || $idservicenew === 0) {
die("Errore: Parametri mancanti.");
}
// Crea la connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connessione al database fallita: " . $conn->connect_error);
}
// Riusa la connessione già aperta da bkngstm.php
$conn = $bkngstm;
// Recupera dateschedule e servicename
$query = "SELECT serviceschedule.dateschedule, service.servicename
@@ -45,7 +35,6 @@ if ($resultnew->num_rows > 0) {
$servicename = $rownew['servicename'] ?? 'N/D';
} else {
$stmt->close();
$conn->close();
die("Errore: Nessun orario trovato per idserviceschedule = $idnewbooking.");
}
$stmt->close();
@@ -53,6 +42,19 @@ $stmt->close();
// Formatta la data per l'email
$newtimeformat = date("d-m-Y H:i", strtotime($newtime));
// Recupera nome ed email dell'utente per la mail
$firstname = '';
$emailuser = '';
$stmtUser = $conn->prepare("SELECT first_name, email FROM auth_users WHERE id = ?");
$stmtUser->bind_param("i", $iduser);
$stmtUser->execute();
$resUser = $stmtUser->get_result();
if ($rowUser = $resUser->fetch_assoc()) {
$firstname = $rowUser['first_name'] ?? '';
$emailuser = $rowUser['email'] ?? '';
}
$stmtUser->close();
// Inserisce la nuova prenotazione in bookingclass
$insertQuery = "INSERT INTO bookingclass (idserviceschedule, iduser, prevbookingstart, idprevserviceschedule, idservice, idorder, bookingstart, status)
VALUES (?, ?, '0', '0', ?, ?, ?, 'pending')";
@@ -60,7 +62,6 @@ $stmt = $conn->prepare($insertQuery);
$stmt->bind_param("iiiis", $idnewbooking, $iduser, $idservicenew, $idorder, $newtime);
if (!$stmt->execute()) {
$stmt->close();
$conn->close();
die("Errore durante l'inserimento della nuova prenotazione: " . $conn->error);
}
$stmt->close();
@@ -75,8 +76,13 @@ $stmt->bind_param("ii", $iduser, $idorder);
$stmt->execute();
$stmt->close();
// Chiudi la connessione al database
$conn->close();
// Connessione $bkngstm gestita globalmente: non la chiudiamo qui
// Se non abbiamo un'email valida, salta l'invio ma completa comunque il flusso
if ($emailuser === '') {
header("Location: userpanel.php?reprogram=Y");
exit();
}
// Configura il contenuto dell'email
$messageedit = "
@@ -141,23 +147,24 @@ include('mail/emailtemplate2.php');
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'mail.yogasoul.it';
$mail->SMTPAuth = true;
$mail->Username = 'info@yogasoul.it';
$mail->Password = '!Testolina88';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$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->setFrom('info@yogasoul.it', 'YogiBook [YogaSoul]');
$mail->setFrom($_ENV['MAIL_FROM_ADDRESS'], $_ENV['MAIL_FROM_NAME']);
$mail->addAddress($emailuser);
$mail->Subject = "Proposta di riprogrammazione!";
$mail->Body = $mailmessage1;
$mail->Body = $mailmessage1;
$mail->AltBody = 'Hai inviato una richiesta di riprogrammazione della tua lezione per il servizio ' . $servicename . ' il ' . $newtimeformat . '. La tua richiesta è in fase di accettazione.';
$mail->send();
} catch (Exception $e) {
die("Errore durante l'invio dell'email: " . $mail->ErrorInfo);
// La prenotazione è già salvata: logghiamo l'errore mail ma non blocchiamo l'utente
error_log("Errore invio mail riprogrammazione (iduser $iduser): " . $mail->ErrorInfo);
}
// Esegui il reindirizzamento
+15 -26
View File
@@ -1,20 +1,13 @@
<?php
// Abilita visualizzazione errori PHP (solo per debug)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Connessione al database
include('include/headscript.php');
require_once __DIR__ . '/class/mailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Connessione al database
include('include/headscript.php');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connessione al database fallita: " . $conn->connect_error);
}
// Riusa la connessione già aperta da bkngstm.php
$conn = $bkngstm;
// Inizializza log
$logFile = 'cancella_prenotazione_log.txt';
$logMessage = "Esecuzione cancellazione: " . date('Y-m-d H:i:s') . "\n";
@@ -47,7 +40,7 @@ if (!$idbookingclass) {
// Verifica validità: token corrisponde, lezione futura
$query = "SELECT bc.*, ob.expireon, au.email, au.first_name, s.servicename
FROM bookingclass bc
LEFT JOIN orderbook ob ON bc.idorder = ob.order_id
LEFT JOIN orderbook ob ON bc.idorder = ob.idorderbook
LEFT JOIN auth_users au ON bc.iduser = au.id
LEFT JOIN service s ON bc.idservice = s.idservice
WHERE bc.idbookingclass = ?
@@ -176,19 +169,15 @@ if (isset($_GET['action']) && $_GET['action'] === 'cancel') {
<span style='display:block;padding:10px 20px;line-height:120%;'><span style='line-height: 16.8px;'>YogiBook - YogaSoul</span></span>
</a>";
require_once 'phpmailer/src/Exception.php';
require_once 'phpmailer/src/PHPMailer.php';
require_once 'phpmailer/src/SMTP.php';
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'mail.yogasoul.it';
$mail->SMTPAuth = true;
$mail->Username = 'info@yogasoul.it';
$mail->Password = '!Testolina88';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$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'];
if (!file_exists('mail/emailtemplate2.php')) {
throw new Exception("File emailtemplate2.php non trovato.");
@@ -201,8 +190,8 @@ if (isset($_GET['action']) && $_GET['action'] === 'cancel') {
$htmlContent = str_replace('{message}', $messagecancel, $mailmessage1);
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->From = $_ENV['MAIL_FROM_ADDRESS'];
$mail->FromName = $_ENV['MAIL_FROM_NAME'];
$mail->addAddress($emailuser);
$mail->Subject = "YogiBook - Lezione cancellata con successo!";
$mail->Body = $htmlContent;
@@ -314,5 +303,5 @@ file_put_contents($logFile, $logMessage, FILE_APPEND);
</html>
<?php
$stmt->close();
$conn->close();
// Connessione $bkngstm gestita globalmente: non la chiudiamo qui
?>
-6
View File
@@ -1,14 +1,10 @@
<?php
// Debug iniziale
error_log("== Inizio mailer.php ==");
// Percorso assoluto alla root (es. /home/wnunknek/yogibook.yogasoul.it/)
$rootPath = dirname(__DIR__, 2);
error_log("Root path: $rootPath");
// Percorso al vendor
$vendorPath = $rootPath . '/vendor/autoload.php';
error_log("Vendor path: $vendorPath");
if (!file_exists($vendorPath)) {
die("❌ vendor/autoload.php non trovato in $vendorPath");
@@ -24,5 +20,3 @@ use PHPMailer\PHPMailer\Exception;
// ✅ Caricamento variabili .env
$dotenv = Dotenv::createImmutable($rootPath);
$dotenv->load();
error_log("✅ Variabili .env caricate: " . print_r($_ENV, true));
+2 -7
View File
@@ -30,10 +30,7 @@ $userId = (int)$iduserlogin;
/***********************
* DB
***********************/
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connessione fallita: " . $conn->connect_error);
}
$conn = $bkngstm;
/***********************
* 1) USER INFO (auth_users)
@@ -69,7 +66,6 @@ $bk = $res->fetch_assoc();
$stmt->close();
if (!$bk) {
$conn->close();
header("Location: userpanel.php?deleted=0&err=notfound");
exit();
}
@@ -89,12 +85,11 @@ $stmt->bind_param("ii", $id, $userId);
if (!$stmt->execute()) {
$err = $stmt->error;
$stmt->close();
$conn->close();
die("Errore durante la cancellazione del record: " . htmlspecialchars($err));
}
$stmt->close();
$conn->close();
// Connessione $bkngstm gestita globalmente: non la chiudiamo qui
/***********************
* 4) EMAIL (TO utente + CC info@yogasoul.it)
+25 -40
View File
@@ -1,51 +1,36 @@
<?php
require_once __DIR__ . '/class/mailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
ini_set ('display_errors', 1);
ini_set ('display_startup_errors', 1);
error_reporting (E_ALL);
//Now include the following following files based
//on the correct file path. Third file is required only if you want to enable SMTP.
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
$name="Claudio";
//mail to client
$name = "Claudio";
$mail = new PHPMailer(true);
try {
$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->isHTML(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';
include('mail/emailtemplate2.php');
$htmlContent = $mailmessage1;
include('mail/emailtemplate2.php');
// Email body content
$mail->setFrom($_ENV['MAIL_FROM_ADDRESS'], $_ENV['MAIL_FROM_NAME']);
$mail->addAddress('info@claudiosironi.com');
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->addAddress('info@claudiosironi.com'); // Add a recipient
$mail->Subject = 'Comunicazione YogiBook';
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->Subject = 'Comunicazione YogiBook';
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
// echo 'Message has been sent';
?>
echo 'Message has been sent';
} catch (Exception $e) {
error_log("Errore invio mail (emailsend): " . $mail->ErrorInfo);
echo 'Invio non riuscito';
}
+14 -78
View File
@@ -1,4 +1,4 @@
<?php $mailmessage1="<!DOCTYPE HTML PUBLIC '-//W3C//DTD XHTML 1.0 Transitional //EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<?php $mailmessage1 = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD XHTML 1.0 Transitional //EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'>
<head>
<!--[if gte mso 9]>
@@ -81,7 +81,7 @@ a[x-apple-data-detectors='true'] {
text-decoration: none !important;
}
table, td { color: #000000; } #u_body a { color: #0000ee; text-decoration: underline; } @media (max-width: 480px) { #u_content_image_1 .v-src-width { width: auto !important; } #u_content_image_1 .v-src-max-width { max-width: 40% !important; } #u_content_heading_1 .v-font-size { font-size: 38px !important; } #u_content_image_3 .v-src-width { width: 100% !important; } #u_content_image_3 .v-src-max-width { max-width: 100% !important; } #u_content_text_5 .v-container-padding-padding { padding: 10px 30px 11px 10px !important; } }
table, td { color: #000000; } #u_body a { color: #0000ee; text-decoration: underline; } @media (max-width: 480px) { #u_content_image_1 .v-src-width { width: auto !important; } #u_content_image_1 .v-src-max-width { max-width: 40% !important; } #u_content_heading_1 .v-font-size { font-size: 38px !important; } #u_content_text_5 .v-container-padding-padding { padding: 10px 30px 11px 10px !important; } }
</style>
@@ -90,14 +90,14 @@ table, td { color: #000000; } #u_body a { color: #0000ee; text-decoration: under
</head>
<body class='clean-body u_body' style='margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #fceae9;color: #000000'>
<body class='clean-body u_body' style='margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #f2f3f5;color: #000000'>
<!--[if IE]><div class='ie-container'><![endif]-->
<!--[if mso]><div class='mso-container'><![endif]-->
<table id='u_body' style='border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color: #fceae9;width:100%' cellpadding='0' cellspacing='0'>
<table id='u_body' style='border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color: #f2f3f5;width:100%' cellpadding='0' cellspacing='0'>
<tbody>
<tr style='vertical-align: top'>
<td style='word-break: break-word;border-collapse: collapse !important;vertical-align: top'>
<!--[if (mso)|(IE)]><table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td align='center' style='background-color: #fceae9;'><![endif]-->
<!--[if (mso)|(IE)]><table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td align='center' style='background-color: #f2f3f5;'><![endif]-->
@@ -120,7 +120,7 @@ table, td { color: #000000; } #u_body a { color: #0000ee; text-decoration: under
<tr>
<td style='padding-right: 0px;padding-left: 0px;' align='center'>
<img align='center' border='0' src='https://yogibook.yogasoul.it/public/mail/images/image-5.png' alt='Logo' title='Logo' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 24%;max-width: 139.2px;' width='139.2' class='v-src-width v-src-max-width'/>
<img align='center' border='0' src='https://yogibook.yogasoul.it/mail/images/image-5.png' alt='Logo' title='Logo' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 24%;max-width: 139.2px;' width='139.2' class='v-src-width v-src-max-width'/>
</td>
</tr>
@@ -157,7 +157,7 @@ table, td { color: #000000; } #u_body a { color: #0000ee; text-decoration: under
<table id='u_content_heading_1' style='font-family:'Montserrat',sans-serif;' role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'>
<tbody>
<tr>
<td class='v-container-padding-padding' style='overflow-wrap:break-word;word-break:break-word;padding:50px 10px 30px;font-family:'Montserrat',sans-serif;' align='left'>
<td class='v-container-padding-padding' style='overflow-wrap:break-word;word-break:break-word;padding:50px 10px 40px;font-family:'Montserrat',sans-serif;' align='left'>
<h1 class='v-font-size' style='margin: 0px; color: #27187e; line-height: 140%; text-align: center; word-wrap: break-word; font-family: 'Montserrat',sans-serif; font-size: 36px; font-weight: 400;'><strong>Comunicazione da YogiBook</strong></h1>
@@ -166,26 +166,6 @@ table, td { color: #000000; } #u_body a { color: #0000ee; text-decoration: under
</tbody>
</table>
<table id='u_content_image_3' style='font-family:'Montserrat',sans-serif;' role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'>
<tbody>
<tr>
<td class='v-container-padding-padding' style='overflow-wrap:break-word;word-break:break-word;padding:15px 10px 40px;font-family:'Montserrat',sans-serif;' align='left'>
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td style='padding-right: 0px;padding-left: 0px;' align='center'>
<img align='center' border='0' src='https://yogibook.yogasoul.it/public/mail/images/image-6.png' alt='Hero Image' title='Hero Image' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 55%;max-width: 319px;' width='319' class='v-src-width v-src-max-width'/>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
</div>
</div>
@@ -272,7 +252,7 @@ $messageedit
<tr>
<td style='padding-right: 0px;padding-left: 0px;' align='center'>
<img align='center' border='0' src='https://yogibook.yogasoul.it/public/mail/images/image-3.png' alt='border' title='border' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 100%;max-width: 600px;' width='600' class='v-src-width v-src-max-width'/>
<img align='center' border='0' src='https://yogibook.yogasoul.it/mail/images/image-3.png' alt='border' title='border' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 100%;max-width: 600px;' width='600' class='v-src-width v-src-max-width'/>
</td>
</tr>
@@ -320,7 +300,7 @@ $messageedit
<table align='left' border='0' cellspacing='0' cellpadding='0' width='32' height='32' style='width: 32px !important;height: 32px !important;display: inline-block;border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;margin-right: 16px'>
<tbody><tr style='vertical-align: top'><td align='left' valign='middle' style='word-break: break-word;border-collapse: collapse !important;vertical-align: top'>
<a href='https://www.instagram.com/aura_yogasoul/' title='Instagram' target='_blank'>
<img src='https://yogibook.yogasoul.it/public/mail/images/image-1.png' alt='Instagram' title='Instagram' width='32' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: none;height: auto;float: none;max-width: 32px !important'>
<img src='https://yogibook.yogasoul.it/mail/images/image-1.png' alt='Instagram' title='Instagram' width='32' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: none;height: auto;float: none;max-width: 32px !important'>
</a>
</td></tr>
</tbody></table>
@@ -330,7 +310,7 @@ $messageedit
<table align='left' border='0' cellspacing='0' cellpadding='0' width='32' height='32' style='width: 32px !important;height: 32px !important;display: inline-block;border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;margin-right: 0px'>
<tbody><tr style='vertical-align: top'><td align='left' valign='middle' style='word-break: break-word;border-collapse: collapse !important;vertical-align: top'>
<a href='https://www.facebook.com/yogasoul.it' title='Facebook' target='_blank'>
<img src='https://yogibook.yogasoul.it/public/mail/images/image-2.png' alt='Facebook' title='Facebook' width='32' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: none;height: auto;float: none;max-width: 32px !important'>
<img src='https://yogibook.yogasoul.it/mail/images/image-2.png' alt='Facebook' title='Facebook' width='32' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: none;height: auto;float: none;max-width: 32px !important'>
</a>
</td></tr>
</tbody></table>
@@ -372,10 +352,9 @@ $messageedit
<td class='v-container-padding-padding' style='overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:'Montserrat',sans-serif;' align='left'>
<div class='v-font-size' style='font-size: 14px; color: #908f8f; line-height: 190%; text-align: center; word-wrap: break-word;'>
<p style='font-size: 14px; line-height: 190%;'>Queste mail ti sono inviate solo come promemoria <br />delle lezioni da te acquistate su Yogasoul.it</p>
<p style='font-size: 14px; line-height: 190%;'>Puoi comunque decidere di cancellarti cliccando qui.</p>
<p style='font-size: 14px; line-height: 190%;'> </p>
<p style='font-size: 14px; line-height: 190%;'>© 2023 YogaSoul  All Rights Reserved.<br /><a rel='noopener' href='http://www.yogasoul.it' target='_blank'>www.yogasoul.it</a> - <a rel='noopener' href='mailto:info@yogasoul.it' target='_blank'>info@yogasoul.it</a></p>
<p style='font-size: 14px; line-height: 190%;'>Questa è una email di servizio relativa alle lezioni acquistate su Yogasoul.it e alla gestione delle tue prenotazioni.</p>
<p style='font-size: 14px; line-height: 190%;'> </p>
<p style='font-size: 14px; line-height: 190%;'>© 2023 YogaSoul All Rights Reserved.<br /><a rel='noopener' href='http://www.yogasoul.it' target='_blank'>www.yogasoul.it</a> - <a rel='noopener' href='mailto:info@yogasoul.it' target='_blank'>info@yogasoul.it</a></p>
</div>
</td>
@@ -396,49 +375,6 @@ $messageedit
<div class='u-row-container' style='padding: 0px;background-color: transparent'>
<div class='u-row' style='margin: 0 auto;min-width: 320px;max-width: 600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;'>
<div style='border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: transparent;'>
<!--[if (mso)|(IE)]><table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td style='padding: 0px;background-color: transparent;' align='center'><table cellpadding='0' cellspacing='0' border='0' style='width:600px;'><tr style='background-color: transparent;'><![endif]-->
<!--[if (mso)|(IE)]><td align='center' width='600' style='width: 600px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;' valign='top'><![endif]-->
<div class='u-col u-col-100' style='max-width: 320px;min-width: 600px;display: table-cell;vertical-align: top;'>
<div style='height: 100%;width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;'>
<!--[if (!mso)&(!IE)]><!--><div style='box-sizing: border-box; height: 100%; padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;'><!--<![endif]-->
<table style='font-family:'Montserrat',sans-serif;' role='presentation' cellpadding='0' cellspacing='0' width='100%' border='0'>
<tbody>
<tr>
<td class='v-container-padding-padding' style='overflow-wrap:break-word;word-break:break-word;padding:0px;font-family:'Montserrat',sans-serif;' align='left'>
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td style='padding-right: 0px;padding-left: 0px;' align='center'>
<img align='center' border='0' src='https://yogibook.yogasoul.it/public/mail/images/image-4.png' alt='border' title='border' style='outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 100%;max-width: 600px;' width='600' class='v-src-width v-src-max-width'/>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
<div class='u-row-container' style='padding: 0px;background-color: transparent'>
<div class='u-row' style='margin: 0 auto;min-width: 320px;max-width: 600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;'>
<div style='border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: transparent;'>
@@ -489,4 +425,4 @@ $messageedit
<!--[if IE]></div><![endif]-->
</body>
</html>"; ?>
</html>";
+73 -84
View File
@@ -1,14 +1,12 @@
<?php
header('Content-Type: text/html; charset=utf-8');
include('Connections/bkngstm.php');
require_once __DIR__ . '/class/mailer.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);
$conn = $bkngstm;
?>
<?php
// teacher notification
@@ -26,30 +24,25 @@ $sql = "SELECT serviceschedule.dateschedule, serviceschedule.dateschedule, servi
$result = $conn->query($sql);
//send email to teacher
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
//send email to teacher
//mail to client
//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->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
//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>
$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
@@ -65,7 +58,7 @@ if ($result->num_rows > 0) {
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) {
@@ -78,40 +71,37 @@ if ($result->num_rows > 0) {
$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>";
$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
include('mail/emailtemplate2.php');
// Email body content
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$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();
$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.";
@@ -119,14 +109,13 @@ $mail->send();
// Chiudi la connessione al database
$conn->close();
// Connessione $bkngstm condivisa: non la chiudiamo qui
?>
<?php
// email notification to users
$conn = new mysqli($servername, $username, $password, $dbname);
$conn = $bkngstm;
// Calcolo della data successiva
$today = date("Y-m-d");
@@ -148,56 +137,57 @@ $result = $conn->query($sql);
if ($result->num_rows > 0) {
// Stampa dei risultati
while ($row = $result->fetch_assoc()) {
$servicename = $row["servicename"];
$servicename = $row["servicename"];
$formatted_date = $row["formatted_date"];
$first_name = $row["first_name"];
$email = $row["email"];
//send email to users
//send email to users
//mail to client
$mail = new PHPMailer(true);
//mail to client
$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 = new PHPMailer(true);
$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>
$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 = " <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;'>
$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
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
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$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->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();
$mail->send();
echo "Nome evento: " . $servicename . "<br>";
echo "Data e ora: " . $formatted_date . "<br>";
echo "Nome allievo: " . $first_name . "<br>";
@@ -207,7 +197,6 @@ $mail->send();
echo "Nessun risultato trovato.";
}
$conn->close();
?>
+93 -108
View File
@@ -1,25 +1,13 @@
<?php
header('Content-Type: text/html; charset=utf-8');
include('Connections/bkngstm.php');
require_once __DIR__ . '/class/mailer.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');
//require_once('include/headscript.php'); ?>
<?php
// from email to ID auth_users
// Crea la connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
// Verifica la connessione
if ($conn->connect_error) {
die("Connessione fallita: " . $conn->connect_error);
}
// Riusa la connessione già aperta da bkngstm.php
$conn = $bkngstm;
// Seleziona i record con status 'pending' dalla tabella orderbook
$select_query = "SELECT * FROM orderbook WHERE status = 'pending'";
@@ -34,9 +22,9 @@ if ($result->num_rows > 0) {
$service_id = $row["idservice"];
$quantity_class = $row["quantityclass"];
$ordern = $row["order_id"];
echo "Elaborazione record con ID: $order_id, Service ID: $service_id\n";
$user_query = "SELECT id FROM auth_users WHERE email = '$billing_email'";
$user_result = $conn->query($user_query);
@@ -47,7 +35,7 @@ if ($result->num_rows > 0) {
$update_query = "UPDATE orderbook SET iduser = '$user_id' WHERE idorderbook = '$order_id'";
$conn->query($update_query);
} else {
// Genera una password casuale e crea l'hash
// Genera una password casuale e crea l'hash
$password = "YogiBook159"; // La password casuale
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Inserisci un nuovo utente in auth_users
@@ -80,73 +68,73 @@ $service_schedule_result = $conn->query($service_schedule_query);
if ($service_schedule_result->num_rows > 0) {
echo "Record per l'ordine ID: $order_id\n";
$inserted_count = 0; // Numero di inserimenti effettuati con successo
$inserted_count = 0; // Numero di inserimenti effettuati con successo
while ($schedule_row = $service_schedule_result->fetch_assoc()) {
if ($inserted_count >= $quantity_class) {
break; // Se il numero di inserimenti riusciti è sufficiente, esci dal ciclo
if ($inserted_count >= $quantity_class) {
break; // Se il numero di inserimenti riusciti è sufficiente, esci dal ciclo
}
$date_schedule = $schedule_row["dateschedule"];
$selected_user_id = isset($new_user_id) ? $new_user_id : $user_id;
$idservice = $schedule_row["idservice"];
//recover number of booking
$idserviceschedule = $schedule_row["idserviceschedule"];
//recover number of booking
$idserviceschedule = $schedule_row["idserviceschedule"];
//check if already booked
$querychk = "SELECT * FROM bookingclass WHERE iduser = '$user_id' AND idserviceschedule = '$idserviceschedule'";
$result = mysqli_query($conn, $querychk);
//check if already booked
$querychk = "SELECT * FROM bookingclass WHERE iduser = '$user_id' AND idserviceschedule = '$idserviceschedule'";
$result = mysqli_query($conn, $querychk);
if ($result) {
// Verifica se esiste almeno una riga nella query
if (mysqli_num_rows($result) == 0) {
if ($result) {
// Verifica se esiste almeno una riga nella query
if (mysqli_num_rows($result) == 0) {
//recover maxcapacity
$service_maxcapacity_query = "SELECT maxcapacity FROM service WHERE idservice = '$idservice'";
$service_maxcapacity_result = $conn->query($service_maxcapacity_query);
//recover maxcapacity
$service_maxcapacity_query = "SELECT maxcapacity FROM service WHERE idservice = '$idservice'";
$service_maxcapacity_result = $conn->query($service_maxcapacity_query);
$row = $service_maxcapacity_result->fetch_assoc();
$maxcapacity = $row['maxcapacity'];
$row = $service_maxcapacity_result->fetch_assoc();
$maxcapacity = $row['maxcapacity'];
$bookingclass_count_query = "SELECT COUNT(*) as total_records FROM bookingclass WHERE idserviceschedule = '$idserviceschedule'";
$bookingclass_count_result = $conn->query($bookingclass_count_query);
if ($bookingclass_count_result) {
$rowcount= $bookingclass_count_result->fetch_assoc();
$total_records = $rowcount['total_records'];
$bookingclass_count_query = "SELECT COUNT(*) as total_records FROM bookingclass WHERE idserviceschedule = '$idserviceschedule'";
$bookingclass_count_result = $conn->query($bookingclass_count_query);
// Ora hai il numero totale di record con l'idserviceschedule specificato
} else {
$total_records='0';
}
if ($bookingclass_count_result) {
$rowcount = $bookingclass_count_result->fetch_assoc();
$total_records = $rowcount['total_records'];
// Check if maxcapacity is greater than total_records before inserting
if ($maxcapacity > $total_records) {
// Ora hai il numero totale di record con l'idserviceschedule specificato
} else {
$total_records = '0';
}
// Inserisci il nuovo record in bookingclass
$insert_booking_query = "INSERT INTO bookingclass (idserviceschedule, idservice, iduser, bookingstart,idorder)
// Check if maxcapacity is greater than total_records before inserting
if ($maxcapacity > $total_records) {
// Inserisci il nuovo record in bookingclass
$insert_booking_query = "INSERT INTO bookingclass (idserviceschedule, idservice, iduser, bookingstart,idorder)
VALUES ('{$schedule_row['idserviceschedule']}', '$service_id', '$selected_user_id', '$date_schedule', '$order_id')";
if ($conn->query($insert_booking_query)) {
echo "Inserito record in bookingclass per l'ordine ID: $order_id\n";
$inserted_count++;
} else {
echo "Errore durante l'inserimento: " . $conn->error . "\n";
if ($conn->query($insert_booking_query)) {
echo "Inserito record in bookingclass per l'ordine ID: $order_id\n";
$inserted_count++;
} else {
echo "Errore durante l'inserimento: " . $conn->error . "\n";
}
} else {
echo "La capacità massima è stata raggiunta. Impossibile effettuare la prenotazione.\n";
}
}
} else {
echo "La capacità massima è stata raggiunta. Impossibile effettuare la prenotazione.\n";
}
}}
//brackets of while
//brackets of while
}
// Aggiorna lo status a 'booked' nella tabella orderbook
@@ -154,15 +142,12 @@ if ($bookingclass_count_result) {
$conn->query($update_order_status_query);
echo "Aggiornato lo status a 'booked' per l'ordine ID: $order_id\n";
//send email to user
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
$name=$first_name;
$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 $name , </span></strong></span></p>
//send email to user
$name = $first_name;
$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 $name , </span></strong></span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Le prenotazioni relative al tuo ultimo ordine n. $ordern sono state inserite con successo!</span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Puoi vederle e riprogrammarle dall'indirizzo https://yogibook.yogasoul.it </span></p>
<br>
@@ -176,47 +161,49 @@ $messageedit=" <p style='font-size: 14px; line-height: 190%;'><span style='fo
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Ci vediamo sul tappetino!</span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Il Team Yogasoul</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;'>
$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>";
//mail to client
$mail = new PHPMailer(true);
$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->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';
include('mail/emailtemplate2.php');
// Email body content
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->addAddress($billing_email); // Add a recipient
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($billing_email); // Add a recipient
$mail->Subject = "YogiBook - Prenotazioni effettuate per il tuo ordine $ordern";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
try {
$mail->send();
} catch (Exception $e) {
error_log("Errore invio mail ordine $order_id: " . $mail->ErrorInfo);
}
$mail->Subject = "YogiBook - Prenotazioni effettuate per il tuo ordine $ordern";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
//mail sent
// ... (il resto del codice come prima)
} else {
@@ -224,7 +211,7 @@ $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
}
// Recupera il numero di settimane da expiryparameter
// Recupera il numero di settimane da expiryparameter
$expiry_class_query = "SELECT quantityclass FROM orderbook WHERE idorderbook = '$order_id'";
$expiry_class_result = $conn->query($expiry_class_query);
@@ -243,7 +230,7 @@ if ($expiry_class_result && $expiry_class_result->num_rows > 0) {
$update_expiry_query = "UPDATE orderbook SET expireon = DATE_ADD(order_date_created, INTERVAL $expiry_weeks WEEK) WHERE idorderbook = '$order_id'";
$conn->query($update_expiry_query);
echo "Aggiornata la colonna expireon per l'ordine ID: $order_id\n";
echo "Aggiornata la colonna expireon per l'ordine ID: $order_id\n";
} else {
echo "Nessun record trovato in expiryparameter per quantityclass: $quantity_class\n";
}
@@ -268,6 +255,4 @@ if ($reschedule_number_result && $reschedule_number_result->num_rows > 0) {
echo "Nessun record trovato in expiryparameter per quantityclass: $quantity_class\n";
}
// Chiudi la connessione al database
$conn->close();
?>
// Connessione $bkngstm gestita globalmente: non la chiudiamo qui
+14 -25
View File
@@ -1,24 +1,12 @@
<?php
// Abilita visualizzazione errori PHP (solo per debug)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include('include/headscript.php');
require_once __DIR__ . '/class/mailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
include('include/headscript.php');
// Includi PHPMailer una sola volta, all'inizio dello script
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
// Verifica connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connessione al database fallita: " . $conn->connect_error);
}
// Riusa la connessione già aperta da bkngstm.php
$conn = $bkngstm;
// Inizializza contatore e log
$emailCount = 0;
@@ -127,12 +115,13 @@ while ($row = $result->fetch_assoc()) {
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'mail.yogasoul.it';
$mail->SMTPAuth = true;
$mail->Username = 'info@yogasoul.it';
$mail->Password = '!Testolina88';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$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';
if (!file_exists('mail/emailtemplate2.php')) {
throw new Exception("File emailtemplate2.php non trovato.");
@@ -145,8 +134,8 @@ while ($row = $result->fetch_assoc()) {
$htmlContent = str_replace('{message}', $message, $mailmessage1);
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->From = $_ENV['MAIL_FROM_ADDRESS'];
$mail->FromName = $_ENV['MAIL_FROM_NAME'];
$mail->addAddress($emailuser);
$mail->Subject = "YogiBook - Promemoria lezione!";
$mail->Body = $htmlContent;
@@ -178,4 +167,4 @@ if (!empty($errors)) {
}
echo "Dettagli nel file di log: $logFile\n";
$conn->close();
// Connessione $bkngstm gestita globalmente: non la chiudiamo qui
+14 -26
View File
@@ -1,26 +1,18 @@
<?php
header('Content-Type: text/html; charset=utf-8');
include('Connections/bkngstm.php');
require_once __DIR__ . '/class/mailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
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');
// take idorder
if (isset($_GET['idorder'])) {
$idorder = $_GET['idorder'];
}
// Crea la connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
// Verifica la connessione
if ($conn->connect_error) {
die("Connessione fallita: " . $conn->connect_error);
}
// Riusa la connessione già aperta da bkngstm.php
$conn = $bkngstm;
// Seleziona i record con status 'pending' dalla tabella orderbook
$select_query = "SELECT * FROM orderbook WHERE idorderbook = ?";
@@ -227,9 +219,6 @@ if ($is_openflexy || $service_schedule_result->num_rows > 0) {
$stmt_reschedule->close();
// Invia la mail (modificata per includere la scadenza)
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
$name = $first_name;
$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 $name , </span></strong></span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Le prenotazioni relative al tuo ultimo ordine n. $ordern sono state inserite con successo!</span></p>
@@ -250,16 +239,17 @@ if ($is_openflexy || $service_schedule_result->num_rows > 0) {
</a>";
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'mail.yogasoul.it';
$mail->SMTPAuth = true;
$mail->Username = 'info@yogasoul.it';
$mail->Password = '!Testolina88';
$mail->SMTPSecure = 'tls';
$mail->Port = '587';
$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';
include('mail/emailtemplate2.php');
$htmlContent = $mailmessage1; // Assumo che $mailmessage1 sia il template; se devi integrare $messageedit qui, dimmelo
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->From = $_ENV['MAIL_FROM_ADDRESS'];
$mail->FromName = $_ENV['MAIL_FROM_NAME'];
$mail->addAddress($billing_email);
$mail->Subject = "YogiBook - Prenotazioni effettuate per il tuo ordine $ordern";
$mail->Body = str_replace(['{messageedit}', '{buttonedit}'], [$messageedit, $buttonedit], $htmlContent); // Se il template ha placeholders, altrimenti usa direttamente $messageedit come Body
@@ -277,5 +267,3 @@ if ($is_openflexy || $service_schedule_result->num_rows > 0) {
echo "Nessun record di schedule futuro trovato per l'ordine ID: $order_id a partire dalla data della prima lezione: $first_lesson_date\n";
}
$stmt_schedule->close();
$conn->close();
+106 -88
View File
@@ -1,65 +1,96 @@
<?php
require_once('include/headscript.php');
require_once __DIR__ . '/class/mailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
?>
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once('include/headscript.php');
if (isset($_GET['idpreviousbooking'])) { $idpreviousbooking = $_GET['idpreviousbooking']; }
if (isset($_GET['idnewbooking'])) { $idnewbooking = $_GET['idnewbooking']; }
if (isset($_GET['iduser'])) { $iduser = $_GET['iduser']; }
if (isset($_GET['idservicenew'])) { $idservicenew = $_GET['idservicenew']; }
// Effettua la cancellazione del record nella tabella bookingclass
// Sostituisci questi passaggi con il codice reale per connettersi al database e eseguire la query di cancellazione
$idpreviousbooking = isset($_GET['idpreviousbooking']) ? (int) $_GET['idpreviousbooking'] : 0;
$idnewbooking = isset($_GET['idnewbooking']) ? (int) $_GET['idnewbooking'] : 0;
$iduser = isset($_GET['iduser']) ? (int) $_GET['iduser'] : 0;
$idservicenew = isset($_GET['idservicenew']) ? (int) $_GET['idservicenew'] : 0;
// Recupera i valori di bookingstart e idserviceschedule dalla tabella bookingclass
$conn = new mysqli($servername, $username, $password, $dbname);
$selectQuery = "SELECT bookingstart, idserviceschedule, idorder FROM bookingclass WHERE idbookingclass = $idpreviousbooking";
$result = $conn->query($selectQuery);
$sqlnewbook = "SELECT dateschedule FROM serviceschedule WHERE idserviceschedule = $idnewbooking";
$resultnew = $conn->query($sqlnewbook);
if ($idpreviousbooking === 0 || $idnewbooking === 0 || $iduser === 0 || $idservicenew === 0) {
die("Errore: Parametri mancanti.");
}
// Estrai il risultato e memorizzalo in $newtime
$rownew = $resultnew->fetch_assoc();
$newtime = $rownew["dateschedule"];
// Riusa la connessione già aperta da bkngstm.php
$conn = $bkngstm;
if ($result && $result->num_rows > 0) {
$row = $result->fetch_assoc();
$prevBookingStart = $row['bookingstart'];
$idPrevServiceSchedule = $row['idserviceschedule'];
$globalidorder = $row['idorder'];
// Nuovo orario della lezione scelta
$stmt = $conn->prepare("SELECT dateschedule FROM serviceschedule WHERE idserviceschedule = ?");
$stmt->bind_param("i", $idnewbooking);
$stmt->execute();
$resultnew = $stmt->get_result();
$rownew = $resultnew->fetch_assoc();
$newtime = $rownew['dateschedule'] ?? null;
$stmt->close();
// Effettua la cancellazione del record nella tabella bookingclass
$deleteQuery = "DELETE FROM bookingclass WHERE idbookingclass = $idpreviousbooking";
$conn->query($deleteQuery);
if (!$newtime) {
die("Errore: orario della nuova lezione non trovato.");
}
// Effettua l'inserimento del nuovo record nella tabella bookingclass
$insertQuery = "INSERT INTO bookingclass (idserviceschedule, iduser, prevbookingstart, idprevserviceschedule, idservice, idorder, bookingstart, status)
VALUES ($idnewbooking, $iduser, '$prevBookingStart', $idPrevServiceSchedule, $idservicenew, $globalidorder, '$newtime', 'pending')";
$conn->query($insertQuery);
// Dati della prenotazione precedente
$stmt = $conn->prepare("SELECT bookingstart, idserviceschedule, idorder FROM bookingclass WHERE idbookingclass = ?");
$stmt->bind_param("i", $idpreviousbooking);
$stmt->execute();
$result = $stmt->get_result();
// Aggiorna la tabella orderbook
echo $globalidorder;
echo 'ciao';
if ($result->num_rows === 0) {
$stmt->close();
die("Errore: prenotazione precedente non trovata.");
}
$updateQuery = "UPDATE orderbook SET reprogrammed = reprogrammed + 1 WHERE idorderbook = $globalidorder";
$conn->query($updateQuery);
echo "Query di aggiornamento: " . $updateQuery;
// Chiudi la connessione al database
$conn->close();
$newtimeformat = date("d-m-Y H:i", strtotime($newtime));
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
//mail to client
$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 $firstname , </span></strong></span></p>
$row = $result->fetch_assoc();
$prevBookingStart = $row['bookingstart'];
$idPrevServiceSchedule = (int) $row['idserviceschedule'];
$globalidorder = (int) $row['idorder'];
$stmt->close();
// Cancella la prenotazione precedente
$stmt = $conn->prepare("DELETE FROM bookingclass WHERE idbookingclass = ?");
$stmt->bind_param("i", $idpreviousbooking);
$stmt->execute();
$stmt->close();
// Inserisci la nuova prenotazione (pending)
$stmt = $conn->prepare(
"INSERT INTO bookingclass (idserviceschedule, iduser, prevbookingstart, idprevserviceschedule, idservice, idorder, bookingstart, status)
VALUES (?, ?, ?, ?, ?, ?, ?, 'pending')"
);
$stmt->bind_param("iisiiss", $idnewbooking, $iduser, $prevBookingStart, $idPrevServiceSchedule, $idservicenew, $globalidorder, $newtime);
$stmt->execute();
$stmt->close();
// Incrementa il contatore riprogrammazioni sull'ordine
$stmt = $conn->prepare("UPDATE orderbook SET reprogrammed = reprogrammed + 1 WHERE idorderbook = ?");
$stmt->bind_param("i", $globalidorder);
$stmt->execute();
$stmt->close();
// Recupera nome ed email dell'utente per la mail
$firstname = '';
$emailuser = '';
$stmtUser = $conn->prepare("SELECT first_name, email FROM auth_users WHERE id = ?");
$stmtUser->bind_param("i", $iduser);
$stmtUser->execute();
$resUser = $stmtUser->get_result();
if ($rowUser = $resUser->fetch_assoc()) {
$firstname = $rowUser['first_name'] ?? '';
$emailuser = $rowUser['email'] ?? '';
}
$stmtUser->close();
$newtimeformat = date("d-m-Y H:i", strtotime($newtime));
// Se manca l'email, completa comunque il flusso senza inviare
if ($emailuser === '') {
header("Location: userpanel.php?reprogram=Y");
exit();
}
// Contenuto mail
$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 $firstname , </span></strong></span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Hai inviato una richiesta di riprogrammazione della tua lezione </span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Ecco il dettaglio della riprogrammazione $newtimeformat</span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>La tua richiesta è in fase di accettazione! Verrai avvisata se la riprogrammazione è stata accettata</span></p>
@@ -76,49 +107,36 @@ $messageedit=" <p style='font-size: 14px; line-height: 190%;'><span style='fo
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Ci vediamo sul tappetino!</span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Il Team Yogasoul</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;'>
$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>";
$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';
</a>";
include('mail/emailtemplate2.php');
// Email body content
$htmlContent = $mailmessage1;
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->addAddress($emailuser); // Add a recipient
$mail = new PHPMailer(true);
try {
$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->isHTML(true);
$mail->setFrom($_ENV['MAIL_FROM_ADDRESS'], $_ENV['MAIL_FROM_NAME']);
$mail->addAddress($emailuser);
$mail->Subject = "Proposta di riprogrammazione!";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->Subject = "Proposta di riprogrammazione!";
$mail->Body = $htmlContent;
$mail->AltBody = 'Hai inviato una richiesta di riprogrammazione. La tua richiesta è in fase di accettazione.';
$mail->send();
//mail sent
} catch (Exception $e) {
error_log("Errore invio mail riprogrammazione (iduser $iduser): " . $mail->ErrorInfo);
}
// Esegui il reindirizzamento
header("Location: userpanel.php?reprogram=Y");
exit();
}
?>
header("Location: userpanel.php?reprogram=Y");
exit();
+56 -67
View File
@@ -1,15 +1,15 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
?>
<?php
include('include/headscript.php');
require_once __DIR__ . '/class/mailer.php';
$conn = new mysqli($servername, $username, $password, $dbname);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Riusa la connessione già aperta da bkngstm.php
$conn = $bkngstm;
if (isset($_GET['idbookingclass'])) {
$idbookingclass = $_GET['idbookingclass'];
$idbookingclass = (int) $_GET['idbookingclass'];
// Recupera i dettagli della prenotazione per inviare la mail prima di cancellare il record
$query = "SELECT bookingclass.*, auth_users.*, service.*
@@ -24,14 +24,11 @@ if (isset($_GET['idbookingclass'])) {
while ($row = $result->fetch_assoc()) {
$emailuser = $row['email'];
$firstname = $row['first_name'];
$newtime = $row['bookingstart'];
$newtime = $row['bookingstart'];
$newtimeformat = date("d-m-Y H:i", strtotime($newtime));
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
//mail to client
$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 $firstname , </span></strong></span></p>
$newtimeformat = date("d-m-Y H:i", strtotime($newtime));
//mail to client
$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 $firstname , </span></strong></span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Ci dispiace ma la tua richiesta di rirpogrammazione è stata rifiutata! </span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Ecco la riprogrammazione rifiutata $newtimeformat</span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Puoi collegarti al portale YogiBook come sotto riportato per programmare la tua lezione</span></p>
@@ -48,63 +45,66 @@ $messageedit=" <p style='font-size: 14px; line-height: 190%;'><span style='fo
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Ci vediamo sul tappetino!</span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Il Team Yogasoul</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;'>
$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>";
</a>";
$mail = new PHPMailer(true);
$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->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';
include('mail/emailtemplate2.php');
// Email body content
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->addAddress($emailuser); // Add a recipient
include('mail/emailtemplate2.php');
// Email body content
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->Subject = "YogiBook - Riprogrammazione rifiutata!";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->From = $_ENV['MAIL_FROM_ADDRESS'];
$mail->FromName = $_ENV['MAIL_FROM_NAME'];
$mail->addAddress($emailuser); // Add a recipient
if ($mail->send()) {
// Mail inviata con successo, ora cancella il record
$deleteQuery = "DELETE FROM bookingclass WHERE idbookingclass = ?";
$stmt = $conn->prepare($deleteQuery);
if ($stmt) {
$stmt->bind_param("i", $idbookingclass);
if ($stmt->execute()) {
// Reindirizza alla pagina "pendingbookedclass.php" dopo la cancellazione
header("Location: pendingbookedclass.php");
exit();
} else {
echo "Errore durante l'esecuzione della query di cancellazione: " . $stmt->error;
}
$stmt->close();
} else {
echo "Errore nella preparazione della query di cancellazione: " . $conn->error;
$mail->Subject = "YogiBook - Riprogrammazione rifiutata!";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
// Cancella comunque il record (il rifiuto va registrato a prescindere dalla mail)
$deleteQuery = "DELETE FROM bookingclass WHERE idbookingclass = ?";
$stmt = $conn->prepare($deleteQuery);
if ($stmt) {
$stmt->bind_param("i", $idbookingclass);
if (!$stmt->execute()) {
error_log("Errore cancellazione booking $idbookingclass: " . $stmt->error);
}
$stmt->close();
} else {
echo "Errore nell'invio della mail: " . $mail->ErrorInfo;
error_log("Errore preparazione delete booking: " . $conn->error);
}
// Prova a inviare la mail di rifiuto: se fallisce, logga ma non bloccare
try {
$mail->send();
} catch (Exception $e) {
error_log("Errore invio mail rifiuto (booking $idbookingclass): " . $mail->ErrorInfo);
}
// Reindirizza comunque
header("Location: pendingbookedclass.php");
exit();
}
} else {
echo "Errore durante l'esecuzione della query di recupero dei dettagli: " . $conn->error;
@@ -112,14 +112,3 @@ $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
} else {
echo "Parametro 'idbookingclass' non trovato nella richiesta GET.";
}
$conn->close();
?>
+9 -21
View File
@@ -10,7 +10,8 @@ use PHPMailer\PHPMailer\Exception;
header('Content-Type: application/json');
// Funzione per generare il template HTML dell'email
function generateEmailTemplate($message) {
function generateEmailTemplate($message)
{
return <<<HTML
<!DOCTYPE html>
<html lang="it">
@@ -108,12 +109,12 @@ try {
throw new Exception('Dati mancanti.');
}
// Prepara tutti gli indirizzi email ricevuti
$to = array_column($recipients, 'email');
// Prepara tutti gli indirizzi email ricevuti
$to = array_column($recipients, 'email');
if (empty($to)) {
throw new Exception('Nessun destinatario valido trovato.');
}
if (empty($to)) {
throw new Exception('Nessun destinatario valido trovato.');
}
// Sostituisci i newline con <br> per l'HTML
@@ -130,23 +131,10 @@ if (empty($to)) {
$mail->Username = $_ENV['MAIL_USERNAME'];
$mail->Password = $_ENV['MAIL_PASSWORD'];
$mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION'];
$mail->Port = $_ENV['MAIL_PORT'];
$mail->Port = (int) $_ENV['MAIL_PORT'];
$mail->Timeout = 5; // Timeout di 5 secondi
$mail->SMTPKeepAlive = false; // Disabilita la connessione persistente
// Abilita debug SMTP per diagnosticare problemi
$mail->SMTPDebug = 2; // 2 = Mostra messaggi di debug dettagliati
$mail->Debugoutput = function($str, $level) {
error_log("PHPMailer Debug [$level]: $str");
};
// Debug: verifica i valori SMTP
error_log('SMTP Host: ' . $mail->Host);
error_log('SMTP Username: ' . $mail->Username);
error_log('SMTP Password: ' . $mail->Password);
error_log('SMTP Secure: ' . $mail->SMTPSecure);
error_log('SMTP Port: ' . $mail->Port);
// Mittente
$mail->setFrom($_ENV['MAIL_FROM_ADDRESS'], $_ENV['MAIL_FROM_NAME']);
@@ -169,4 +157,4 @@ if (empty($to)) {
// Log dell'errore completo
error_log('Errore in send_email.php: ' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine());
echo json_encode(['success' => false, 'message' => "Errore nell'invio dell'email: " . $e->getMessage()]);
}
}
+1 -1
View File
@@ -526,7 +526,7 @@ $italianMonths = [
</div>
<div class="alert alert-warning alert-dismissible fade show" role="alert" style="text-align: center;">
<i class="mdi mdi-alert-outline me-2"></i>
Car* Yogi, ti ricordiamo che il pacchetto 4 lezioni ha validità entro le 5 settimane dall'acquisto e il pacchetto da 12 lezioni entro il <strong>20 dicembre 2025</strong> 🙏
Car* Yogi, ti ricordiamo che il pacchetto 4 lezioni ha validità entro <strong>5 settimane</strong> e il pacchetto da 12 lezioni entro <strong>15 settimane</strong> dalla prima lezione 🙏
</div>
</div>
</div>