fixed multiple things
This commit is contained in:
+140
-82
@@ -1,107 +1,165 @@
|
||||
<?php
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
?>
|
||||
<?php
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
require_once('include/headscript.php');
|
||||
if (isset($_GET['idorder'])) { $idorder = $_GET['idorder']; }
|
||||
if (isset($_GET['idnewbooking'])) { $idnewbooking = $_GET['idnewbooking']; }
|
||||
if (isset($_GET['iduser'])) { $iduser = $_GET['iduser']; }
|
||||
if (isset($_GET['idservicenew'])) { $idservicenew = $_GET['idservicenew']; }
|
||||
// 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;
|
||||
|
||||
// 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
|
||||
// Valida i parametri richiesti
|
||||
if ($idorder === 0 || $idnewbooking === 0 || $iduser === 0 || $idservicenew === 0) {
|
||||
die("Errore: Parametri mancanti.");
|
||||
}
|
||||
|
||||
// Recupera i valori di bookingstart e idserviceschedule dalla tabella bookingclass
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
|
||||
$sqlnewbook = "SELECT dateschedule FROM serviceschedule WHERE idserviceschedule = $idnewbooking";
|
||||
$resultnew = $conn->query($sqlnewbook);
|
||||
// Recupera dateschedule e servicename
|
||||
$query = "SELECT serviceschedule.dateschedule, service.servicename
|
||||
FROM serviceschedule
|
||||
LEFT JOIN service ON service.idservice = ?
|
||||
WHERE serviceschedule.idserviceschedule = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("ii", $idservicenew, $idnewbooking);
|
||||
$stmt->execute();
|
||||
$resultnew = $stmt->get_result();
|
||||
|
||||
// Estrai il risultato e memorizzalo in $newtime
|
||||
if ($resultnew->num_rows > 0) {
|
||||
$rownew = $resultnew->fetch_assoc();
|
||||
$newtime = $rownew["dateschedule"];
|
||||
$newtime = $rownew['dateschedule'];
|
||||
$servicename = $rownew['servicename'] ?? 'N/D';
|
||||
} else {
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
die("Errore: Nessun orario trovato per idserviceschedule = $idnewbooking.");
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
// Formatta la data per l'email
|
||||
$newtimeformat = date("d-m-Y H:i", strtotime($newtime));
|
||||
|
||||
// Inserisce la nuova prenotazione in bookingclass
|
||||
$insertQuery = "INSERT INTO bookingclass (idserviceschedule, iduser, prevbookingstart, idprevserviceschedule, idservice, idorder, bookingstart, status)
|
||||
VALUES (?, ?, '0', '0', ?, ?, ?, 'pending')";
|
||||
$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();
|
||||
|
||||
// Effettua l'inserimento del nuovo record nella tabella bookingclass
|
||||
$insertQuery = "INSERT INTO bookingclass (idserviceschedule, iduser, prevbookingstart, idprevserviceschedule, idservice, idorder, bookingstart, status)
|
||||
VALUES ($idnewbooking, $iduser, '0', '0', $idservicenew, $idorder, '$newtime', 'pending')";
|
||||
$conn->query($insertQuery);
|
||||
// Aggiorna una prenotazione cancellata a pending (se esiste)
|
||||
$updateQuery = "UPDATE bookingclass
|
||||
SET status = 'pending'
|
||||
WHERE iduser = ? AND idorder = ? AND status = 'cancelled'
|
||||
LIMIT 1";
|
||||
$stmt = $conn->prepare($updateQuery);
|
||||
$stmt->bind_param("ii", $iduser, $idorder);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
// 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>
|
||||
<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>
|
||||
<br>
|
||||
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Per vedere e gestire le tue lezioni clicca qui: https://yogibook.yogasoul.it </span></p>
|
||||
<br>
|
||||
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Per il primo accesso devi per prima cosa resettare la password cliccando di seguito</span></p>
|
||||
<br>
|
||||
<a href='https://yogibook.yogasoul.it/public/password/reset' 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;'>Reset Password</span></span>
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
|
||||
// Configura il contenuto dell'email
|
||||
$messageedit = "
|
||||
<p style='font-size: 14px; line-height: 190%;'>
|
||||
<span style='font-size: 18px; line-height: 34.2px;'>
|
||||
<strong>Ciao $firstname,</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 per il servizio <strong>$servicename</strong>.
|
||||
</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/o se la riprogrammazione è stata accettata.
|
||||
</span>
|
||||
</p>
|
||||
<br>
|
||||
<p style='font-size: 14px; line-height: 190%;'>
|
||||
<span style='font-size: 16px; line-height: 30.4px;'>
|
||||
Per vedere e gestire le tue lezioni clicca qui:
|
||||
<a href='https://yogibook.yogasoul.it'>YogiBook</a>
|
||||
</span>
|
||||
</p>
|
||||
<br>
|
||||
<p style='font-size: 14px; line-height: 190%;'>
|
||||
<span style='font-size: 16px; line-height: 30.4px;'>
|
||||
Per il primo accesso devi prima resettare la password cliccando qui:
|
||||
</span>
|
||||
</p>
|
||||
<br>
|
||||
<a href='https://yogibook.yogasoul.it/public/password/reset' target='_blank' style='box-sizing: border-box; display: inline-block; text-decoration: none; text-align: center; color: #FFFFFF; background-color: #3AAEE0; border-radius: 4px; width: auto; max-width: 100%; font-size: 14px;'>
|
||||
<span style='display: block; padding: 10px 20px; line-height: 120%;'>Reset Password</span>
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
<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>";
|
||||
<br>
|
||||
<br>
|
||||
<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;'>
|
||||
<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';
|
||||
|
||||
$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; text-align: center; color: #FFFFFF; background-color: #3AAEE0; border-radius: 4px; width: auto; max-width: 100%; font-size: 14px;'>
|
||||
<span style='display: block; padding: 10px 20px; line-height: 120%;'>YogiBook - YogaSoul</span>
|
||||
</a>";
|
||||
|
||||
// Integra $messageedit in $mailmessage1
|
||||
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
|
||||
|
||||
// Configura l'email
|
||||
$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->setFrom('info@yogasoul.it', 'YogiBook [YogaSoul]');
|
||||
$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 = $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();
|
||||
|
||||
//mail sent
|
||||
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
die("Errore durante l'invio dell'email: " . $mail->ErrorInfo);
|
||||
}
|
||||
|
||||
// Esegui il reindirizzamento
|
||||
header("Location: userpanel.php?reprogram=Y");
|
||||
exit();
|
||||
|
||||
?>
|
||||
// Esegui il reindirizzamento
|
||||
header("Location: userpanel.php?reprogram=Y");
|
||||
exit();
|
||||
|
||||
Reference in New Issue
Block a user