Compare commits
22 Commits
2d83c9da13
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2392a267d1 | |||
| 9fdb56c7ed | |||
| aff67bc496 | |||
| 754c5f93f0 | |||
| 26fb165c98 | |||
| 8c3c3982ac | |||
| f1d9b8d31e | |||
| 318191cc31 | |||
| a061db1e87 | |||
| 8a86787501 | |||
| 10ef6db5c5 | |||
| 9447d62c27 | |||
| 77c938e8de | |||
| edc6bda47f | |||
| 3c8d8b9fab | |||
| eb7c0ff531 | |||
| 4b41240fea | |||
| 3b4718b6d2 | |||
| 26d5788278 | |||
| 653cc3e2c4 | |||
| e54668b960 | |||
| ef9ba730fc |
@@ -1,5 +1,5 @@
|
||||
APP_ENV=production
|
||||
APP_DEBUG=false
|
||||
APP_DEBUG=true
|
||||
APP_KEY=base64:aj3bR0zA9I8nZ1Rm5alncE4QFTPNoHVkd8YSRJEImwY=
|
||||
APP_URL=https://yogibook.yogasoul.it
|
||||
|
||||
@@ -31,7 +31,6 @@ MAIL_USERNAME=info@yogasoul.it
|
||||
MAIL_PASSWORD=!Testolina88
|
||||
MAIL_ENCRYPTION=ssl
|
||||
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<?php phpinfo();
|
||||
@@ -9,10 +9,10 @@ $dotenv = Dotenv::createImmutable(__DIR__ . '/../../');
|
||||
$dotenv->load();
|
||||
|
||||
// Prende i valori dal .env
|
||||
$hostname_bkngstm = $_ENV['DB_HOST'] ?? 'localhost';
|
||||
$database_bkngstm = $_ENV['DB_DATABASE'] ?? 'yogibookaury';
|
||||
$username_bkngstm = $_ENV['DB_USERNAME'] ?? 'root';
|
||||
$password_bkngstm = $_ENV['DB_PASSWORD'] ?? '';
|
||||
$hostname_bkngstm = $_ENV['DB_HOST'];
|
||||
$database_bkngstm = $_ENV['DB_DATABASE'];
|
||||
$username_bkngstm = $_ENV['DB_USERNAME'];
|
||||
$password_bkngstm = $_ENV['DB_PASSWORD'];
|
||||
|
||||
$servername = $hostname_bkngstm;
|
||||
$username = $username_bkngstm;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
?>
|
||||
@@ -8,106 +9,95 @@ include('include/headscript.php');
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
|
||||
// Recupera il parametro "idbookingclass" dalla richiesta GET
|
||||
if (isset($_GET['idbookingclass'])) {
|
||||
$idbookingclass = $_GET['idbookingclass'];
|
||||
|
||||
// Aggiorna lo status a "booked" nella tabella "bookingclass"
|
||||
$query = "UPDATE bookingclass SET status = 'booked' WHERE 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 = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
|
||||
|
||||
if ($stmt) {
|
||||
$stmt->bind_param("i", $idbookingclass);
|
||||
if ($stmt->execute())
|
||||
|
||||
//query
|
||||
$query = "SELECT bookingclass.*, auth_users.*, service.*
|
||||
FROM bookingclass
|
||||
LEFT JOIN auth_users ON bookingclass.iduser = auth_users.id
|
||||
LEFT JOIN service ON bookingclass.idservice = service.idservice
|
||||
WHERE bookingclass.idbookingclass = $idbookingclass";
|
||||
if ($stmt->execute()) {
|
||||
// Query per recuperare i dettagli della prenotazione
|
||||
$query = "SELECT bookingclass.*, auth_users.*, service.*
|
||||
FROM bookingclass
|
||||
LEFT JOIN auth_users ON bookingclass.iduser = auth_users.id
|
||||
LEFT JOIN service ON bookingclass.idservice = service.idservice
|
||||
WHERE bookingclass.idbookingclass = $idbookingclass";
|
||||
|
||||
$result = $conn->query($query);
|
||||
$result = $conn->query($query);
|
||||
|
||||
if ($result) {
|
||||
// Elabora i risultati
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
// Ora puoi accedere ai dati delle tabelle
|
||||
$newtime = $row['bookingstart'];
|
||||
$emailuser = $row['email'];
|
||||
$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>
|
||||
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>La tua richiesta di riprogrammazione è stata accettata! </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>
|
||||
<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>
|
||||
</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>";
|
||||
if ($result) {
|
||||
// Elabora i risultati
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
// Ora puoi accedere ai dati delle tabelle
|
||||
$newtime = $row['bookingstart'];
|
||||
$emailuser = $row['email'];
|
||||
$firstname = $row['first_name'];
|
||||
|
||||
$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>";
|
||||
$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;'>La tua richiesta di riprogrammazione è stata accettata! </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>
|
||||
<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>
|
||||
</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>";
|
||||
|
||||
$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 = 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(); // 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');
|
||||
// Email body content
|
||||
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->From = 'info@yogasoul.it';
|
||||
$mail->FromName = 'YogiBook [YogaSoul]';
|
||||
$mail->addAddress($emailuser); // Add a recipient
|
||||
|
||||
|
||||
$mail->Subject = "YogiBook - Lezione riprogrammata con successo!";
|
||||
$mail->Body = $htmlContent;
|
||||
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
||||
|
||||
$mail->Subject = "YogiBook - Lezione riprogrammata con successo!";
|
||||
$mail->Body = $htmlContent;
|
||||
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
||||
$mail->send();
|
||||
}
|
||||
|
||||
$mail->send();
|
||||
|
||||
//mail sent
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Reindirizza alla pagina "pendingbookedclass.php" dopo l'aggiornamento
|
||||
header("Location: pendingbookedclass.php");
|
||||
exit(); // Assicura che il codice successivo non venga eseguito dopo il reindirizzamento
|
||||
// Reindirizza alla pagina "pendingbookedclass.php" dopo l'aggiornamento
|
||||
header("Location: pendingbookedclass.php");
|
||||
exit(); // Assicura che il codice successivo non venga eseguito dopo il reindirizzamento
|
||||
} else {
|
||||
echo "Errore durante l'esecuzione della query: " . $conn->error;
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo "Errore durante l'esecuzione della query: " . $stmt->error;
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo "Errore nella preparazione della query: " . $conn->error;
|
||||
}
|
||||
@@ -117,10 +107,4 @@ $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
||||
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
+478
-515
File diff suppressed because it is too large
Load Diff
+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();
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
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);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die(json_encode(['error' => 'Connessione al database fallita']));
|
||||
}
|
||||
|
||||
if (isset($_GET['idorder'])) {
|
||||
$idorder = $_GET['idorder'];
|
||||
|
||||
// Recupera i dati necessari dall'ordine
|
||||
$order_query = "SELECT idservice, quantityclass, first_lesson_date FROM orderbook WHERE idorderbook = ?";
|
||||
$stmt_order = $conn->prepare($order_query);
|
||||
$stmt_order->bind_param("i", $idorder);
|
||||
$stmt_order->execute();
|
||||
$order_result = $stmt_order->get_result();
|
||||
|
||||
if ($order_result->num_rows > 0) {
|
||||
$order_row = $order_result->fetch_assoc();
|
||||
$service_id = $order_row['idservice'];
|
||||
$quantity_class = $order_row['quantityclass'];
|
||||
$first_lesson_date = $order_row['first_lesson_date'];
|
||||
|
||||
// Recupera expirylessons da expiryparameter
|
||||
$expiry_lessons_query = "SELECT expirylessons FROM expiryparameter WHERE quantityclass = ?";
|
||||
$stmt_expiry_lessons = $conn->prepare($expiry_lessons_query);
|
||||
$stmt_expiry_lessons->bind_param("i", $quantity_class);
|
||||
$stmt_expiry_lessons->execute();
|
||||
$expiry_lessons_result = $stmt_expiry_lessons->get_result();
|
||||
|
||||
if ($expiry_lessons_result->num_rows > 0) {
|
||||
$expiry_row = $expiry_lessons_result->fetch_assoc();
|
||||
$expirylessons = $expiry_row['expirylessons'];
|
||||
|
||||
// Calcola la data della expirylessons-esima lezione
|
||||
$expiry_date_query = "SELECT dateschedule FROM serviceschedule WHERE idservice = ? AND dateschedule >= ? ORDER BY dateschedule LIMIT ?, 1";
|
||||
$stmt_expiry_date = $conn->prepare($expiry_date_query);
|
||||
$offset = $expirylessons - 1;
|
||||
$stmt_expiry_date->bind_param("isi", $service_id, $first_lesson_date, $offset);
|
||||
$stmt_expiry_date->execute();
|
||||
$expiry_date_result = $stmt_expiry_date->get_result();
|
||||
|
||||
if ($expiry_date_result->num_rows > 0) {
|
||||
$date_row = $expiry_date_result->fetch_assoc();
|
||||
$expireon = $date_row['dateschedule'];
|
||||
echo json_encode(['expiry_date' => $expireon]);
|
||||
} else {
|
||||
echo json_encode(['error' => 'Non abbastanza lezioni disponibili per calcolare la scadenza']);
|
||||
}
|
||||
$stmt_expiry_date->close();
|
||||
} else {
|
||||
echo json_encode(['error' => 'Nessun record in expiryparameter per quantityclass: ' . $quantity_class]);
|
||||
}
|
||||
$stmt_expiry_lessons->close();
|
||||
} else {
|
||||
echo json_encode(['error' => 'Ordine non trovato']);
|
||||
}
|
||||
$stmt_order->close();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
// Abilita visualizzazione errori PHP (solo per debug)
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Inizializza log
|
||||
$logFile = 'cancella_prenotazione_log.txt';
|
||||
$logMessage = "Esecuzione cancellazione: " . date('Y-m-d H:i:s') . "\n";
|
||||
|
||||
// Recupera parametri GET: idbookingclass e token
|
||||
if (!isset($_GET['idbookingclass']) || !isset($_GET['token'])) {
|
||||
$logMessage .= "Parametri mancanti: idbookingclass o token\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Cancellazione non possibile</h1>";
|
||||
echo "<p>Parametri mancanti.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Sanitizza idbookingclass
|
||||
$idbookingclass = filter_var($_GET['idbookingclass'], FILTER_VALIDATE_INT);
|
||||
$token = $_GET['token'];
|
||||
|
||||
if (!$idbookingclass) {
|
||||
$logMessage .= "Errore: idbookingclass non valido: " . $_GET['idbookingclass'] . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Cancellazione non possibile</h1>";
|
||||
echo "<p>Parametro idbookingclass non valido.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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 auth_users au ON bc.iduser = au.id
|
||||
LEFT JOIN service s ON bc.idservice = s.idservice
|
||||
WHERE bc.idbookingclass = ?
|
||||
AND bc.cancellation_token = ?
|
||||
AND bc.status = 'booked'
|
||||
AND bc.bookingstart > NOW()";
|
||||
$stmt = $conn->prepare($query);
|
||||
|
||||
if (!$stmt) {
|
||||
$logMessage .= "Errore preparazione query per ID $idbookingclass: " . $conn->error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Cancellazione non possibile</h1>";
|
||||
echo "<p>Errore nella preparazione della query.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->bind_param("is", $idbookingclass, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows === 0) {
|
||||
$checkQuery = "SELECT * FROM bookingclass
|
||||
WHERE idbookingclass = ?
|
||||
AND cancellation_token = ?
|
||||
AND status = 'booked'
|
||||
AND bookingstart > NOW()";
|
||||
$checkStmt = $conn->prepare($checkQuery);
|
||||
$checkStmt->bind_param("is", $idbookingclass, $token);
|
||||
$checkStmt->execute();
|
||||
$checkResult = $checkStmt->get_result();
|
||||
|
||||
if ($checkResult->num_rows > 0) {
|
||||
$row = $checkResult->fetch_assoc();
|
||||
$bookingstart = $row['bookingstart'];
|
||||
$lessonTime = new DateTime($bookingstart);
|
||||
$hour = (int)$lessonTime->format('H');
|
||||
$minute = (int)$lessonTime->format('i');
|
||||
$isBefore1700 = ($hour < 17) || ($hour === 17 && $minute === 0);
|
||||
$logMessage .= "Tentativo di cancellazione fallito per ID $idbookingclass: orario oltre il limite (" . ($isBefore1700 ? "00:01" : "12:00") . ")\n";
|
||||
echo "<h1>Cancellazione non possibile</h1>";
|
||||
echo "<p>Non è possibile cancellare la lezione dopo le " . ($isBefore1700 ? "00:01" : "12:00") . " del giorno della lezione.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
} else {
|
||||
$logMessage .= "Tentativo di cancellazione fallito per ID $idbookingclass: link non valido o lezione non prenotata\n";
|
||||
echo "<h1>Cancellazione non possibile</h1>";
|
||||
echo "<p>Il link non è valido o la lezione non è prenotata.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
}
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
$checkStmt->close();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$bookingstart = $row['bookingstart'];
|
||||
$newtimeformat = date("d-m-Y H:i", strtotime($bookingstart));
|
||||
$expireon = $row['expireon'] ? date("d-m-Y", strtotime($row['expireon'])) : "sconosciuta";
|
||||
$emailuser = $row['email'];
|
||||
$firstname = $row['first_name'] ?? 'Utente';
|
||||
$servicename = $row['servicename'] ?? 'Sconosciuta';
|
||||
$iduser = $row['iduser'];
|
||||
$idservice = $row['idservice'];
|
||||
$idorderbook = $row['idorder'];
|
||||
|
||||
// Verifica il limite di cancellazione
|
||||
$lessonTime = new DateTime($bookingstart);
|
||||
$hour = (int)$lessonTime->format('H');
|
||||
$minute = (int)$lessonTime->format('i');
|
||||
$isBefore1700 = ($hour < 17) || ($hour === 17 && $minute === 0);
|
||||
$currentTime = new DateTime();
|
||||
$lessonDate = $lessonTime->format('Y-m-d');
|
||||
|
||||
if ($isBefore1700) {
|
||||
$deadline = new DateTime("$lessonDate 00:01:00");
|
||||
} else {
|
||||
$deadline = new DateTime("$lessonDate 12:00:00");
|
||||
}
|
||||
|
||||
if ($currentTime > $deadline) {
|
||||
$logMessage .= "Tentativo di cancellazione fallito per ID $idbookingclass: orario oltre il limite (" . $deadline->format('Y-m-d H:i:s') . ")\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Cancellazione non possibile</h1>";
|
||||
echo "<p>Non è possibile cancellare la lezione dopo le " . ($isBefore1700 ? "00:01" : "12:00") . " del giorno della lezione.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Gestisci azione di cancellazione
|
||||
if (isset($_GET['action']) && $_GET['action'] === 'cancel') {
|
||||
$updateQuery = "UPDATE bookingclass
|
||||
SET status = 'cancelled'
|
||||
WHERE idbookingclass = ? AND cancellation_token = ?";
|
||||
$updateStmt = $conn->prepare($updateQuery);
|
||||
$updateStmt->bind_param("is", $idbookingclass, $token);
|
||||
$updateStmt->execute();
|
||||
|
||||
if (!filter_var($emailuser, FILTER_VALIDATE_EMAIL)) {
|
||||
$logMessage .= "Email non valida per ID $idbookingclass: $emailuser\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Cancellazione confermata</h1>";
|
||||
echo "<p>La lezione del $newtimeformat è stata cancellata con successo, ma non è stato possibile inviare l'email di conferma.</p>";
|
||||
echo "<p>Ricordati di riprenotare entro la scadenza del tuo abbonamento ($expireon).</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$cancellationDeadline = $isBefore1700 ? "00:01" : "12:00";
|
||||
$messagecancel = "<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;'>La tua lezione ($servicename) del $newtimeformat è stata cancellata con successo!</span></p>
|
||||
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Hai cancellato la lezione entro il limite delle $cancellationDeadline del giorno della lezione.</span></p>
|
||||
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Ricordati di riprenotare entro la scadenza del tuo abbonamento ($expireon).</span></p>
|
||||
<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>
|
||||
<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>";
|
||||
|
||||
$messageedit = $messagecancel;
|
||||
$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>";
|
||||
|
||||
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;
|
||||
|
||||
if (!file_exists('mail/emailtemplate2.php')) {
|
||||
throw new Exception("File emailtemplate2.php non trovato.");
|
||||
}
|
||||
include('mail/emailtemplate2.php');
|
||||
|
||||
if (!isset($mailmessage1)) {
|
||||
throw new Exception("Variabile \$mailmessage1 non definita in emailtemplate2.php.");
|
||||
}
|
||||
|
||||
$htmlContent = str_replace('{message}', $messagecancel, $mailmessage1);
|
||||
|
||||
$mail->From = 'info@yogasoul.it';
|
||||
$mail->FromName = 'YogiBook [YogaSoul]';
|
||||
$mail->addAddress($emailuser);
|
||||
$mail->Subject = "YogiBook - Lezione cancellata con successo!";
|
||||
$mail->Body = $htmlContent;
|
||||
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
||||
|
||||
$mail->send();
|
||||
$logMessage .= "Cancellazione confermata per ID $idbookingclass ($newtimeformat), email inviata a $emailuser\n";
|
||||
|
||||
echo "<h1>Cancellazione confermata</h1>";
|
||||
echo "<p>La lezione del $newtimeformat è stata cancellata con successo.</p>";
|
||||
echo "<p>Ricordati di riprenotare entro la scadenza del tuo abbonamento ($expireon).</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
} catch (Exception $e) {
|
||||
$logMessage .= "Cancellazione confermata per ID $idbookingclass ($newtimeformat), ma errore invio email a $emailuser: " . $mail->ErrorInfo . "\n";
|
||||
echo "<h1>Cancellazione confermata</h1>";
|
||||
echo "<p>La lezione del $newtimeformat è stata cancellata con successo, ma non è stato possibile inviare l'email di conferma.</p>";
|
||||
echo "<p>Ricordati di riprenotare entro la scadenza del tuo abbonamento ($expireon).</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
}
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
$updateStmt->close();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$logMessage .= "Accesso a modale per ID $idbookingclass, token: $token, opzione riprogrammazione: rebook-from-cancel.php?idbookingclass=$idbookingclass&token=" . urlencode($token) . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Cancellazione Lezione</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Gestione Lezione</h1>
|
||||
<p>Lezione: <?php echo htmlspecialchars($servicename); ?> del <?php echo htmlspecialchars($newtimeformat); ?></p>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log("Modale SweetAlert2 avviato per ID <?php echo $idbookingclass; ?>, token: <?php echo urlencode($token); ?>");
|
||||
Swal.fire({
|
||||
title: "Cosa vuoi fare?",
|
||||
html: "Puoi cancellare la lezione del <?php echo htmlspecialchars($newtimeformat); ?> o riprogrammarla.<br>Scadenza abbonamento: <?php echo htmlspecialchars($expireon); ?><br><br><strong>Debug:</strong> Reindirizzamento previsto: rebook-from-cancel.php?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>",
|
||||
icon: "question",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Cancella Lezione",
|
||||
cancelButtonText: "Riprogramma Lezione",
|
||||
showDenyButton: true,
|
||||
denyButtonText: "Riprogramma Lezione",
|
||||
denyButtonColor: "#e47c06ff"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
console.log("Cliccato 'Cancella Lezione' per ID <?php echo $idbookingclass; ?>");
|
||||
Swal.fire({
|
||||
title: "Attenzione!",
|
||||
text: "La lezione sarà cancellata. Ricordati di riprenotare entro la scadenza del tuo abbonamento (<?php echo htmlspecialchars($expireon); ?>)!",
|
||||
icon: "warning",
|
||||
confirmButtonText: "Conferma Cancellazione",
|
||||
showCancelButton: true,
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((confirmResult) => {
|
||||
if (confirmResult.isConfirmed) {
|
||||
console.log("Conferma cancellazione, reindirizzamento a: ?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&action=cancel");
|
||||
window.location.replace("?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&action=cancel");
|
||||
} else {
|
||||
console.log("Cancellazione annullata");
|
||||
}
|
||||
});
|
||||
} else if (result.isCancel) {
|
||||
console.log("Cliccato 'Riprogramma Lezione' per ID <?php echo $idbookingclass; ?>, reindirizzamento a: rebook-from-cancel.php?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>");
|
||||
try {
|
||||
window.location.replace("rebook-from-cancel.php?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>");
|
||||
} catch (e) {
|
||||
console.error("Errore durante il reindirizzamento: ", e);
|
||||
alert("Errore: impossibile reindirizzare a rebook-from-cancel.php. Controlla la console del browser.");
|
||||
}
|
||||
} else if (result.isDenied) {
|
||||
console.log("Cliccato 'Riprogramma Lezione', reindirizzamento a: https://yogibook.yogasoul.it");
|
||||
window.location.replace("rebook-from-cancel.php?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,6 @@
|
||||
Esecuzione cancellazione: 2025-10-13 14:36:02
|
||||
Accesso a modale per ID 4, token: f596e67a-a517-11f0-afe1-145afc4aef92, opzione riprogrammazione: rebook-from-cancel.php?idbookingclass=4&token=f596e67a-a517-11f0-afe1-145afc4aef92
|
||||
Esecuzione cancellazione: 2025-10-13 14:37:22
|
||||
Accesso a modale per ID 4, token: f596e67a-a517-11f0-afe1-145afc4aef92, opzione riprogrammazione: rebook-from-cancel.php?idbookingclass=4&token=f596e67a-a517-11f0-afe1-145afc4aef92
|
||||
Esecuzione cancellazione: 2025-10-13 14:38:20
|
||||
Accesso a modale per ID 4, token: f596e67a-a517-11f0-afe1-145afc4aef92, opzione riprogrammazione: rebook-from-cancel.php?idbookingclass=4&token=f596e67a-a517-11f0-afe1-145afc4aef92
|
||||
+244
-284
@@ -1,7 +1,5 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
|
||||
<?php
|
||||
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
@@ -9,19 +7,19 @@ $conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message']; } else { $message='n'; }
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message'];
|
||||
} else {
|
||||
$message = 'n';
|
||||
}
|
||||
// ID dell'insegnante
|
||||
$idTeacher = 1;
|
||||
|
||||
|
||||
// Controlla se il form è stato inviato
|
||||
if (isset($_POST['submit'])) {
|
||||
// Recupera la data dal form
|
||||
$dayoffdate = $_POST['dayoff'];
|
||||
|
||||
|
||||
|
||||
// Query SQL per l'inserimento del day off
|
||||
$insertQuery = "INSERT INTO dayoff (idteacher, dayoffdate) VALUES ($idTeacher, '$dayoffdate')";
|
||||
|
||||
@@ -33,8 +31,6 @@ if (isset($_POST['submit'])) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Query SQL
|
||||
$query = "SELECT * FROM certificateuserprofile LEFT JOIN auth_users ON certificateuserprofile.iduser=auth_users.id ORDER BY auth_users.last_name";
|
||||
|
||||
@@ -50,321 +46,285 @@ if ($result->num_rows > 0) {
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Prenotazioni YogaSoul</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Prenotazioni YogaSoul</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<!-- DataTables CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap5.min.css">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd", // Formato della data
|
||||
minDate: 0, // Impedisce la selezione di date passate
|
||||
// Altre opzioni del datepicker se necessario
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- DataTables JS -->
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#dayoff").datepicker({ dateFormat: "yy-mm-dd" });
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: 0,
|
||||
});
|
||||
$("#dayoff").datepicker({
|
||||
dateFormat: "yy-mm-dd"
|
||||
});
|
||||
// Initialize DataTables
|
||||
$('#certificateTable').DataTable({
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.11.5/i18n/it-IT.json"
|
||||
},
|
||||
"pageLength": 100,
|
||||
"order": [
|
||||
[0, "asc"]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function confirmDelete(id) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questo certificato verrà cancellato definitivamente!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `deletecertificate.php?id=${id}&source=admin`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box, .custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<!-- <body data-layout="horizontal"> -->
|
||||
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
<body>
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-flex">
|
||||
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start right Content here -->
|
||||
<!-- ============================================================== -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if ($message=='success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
DayOff rimosso con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<!-- Start right Content here -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if ($message == 'success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
Certificato rimosso con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?> </h5>
|
||||
<p>Certificati</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Documento</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document["first_name"]; ?> <?php echo $document["last_name"]; ?></td>
|
||||
<td><?php echo $document["expirydatedocument"]; ?></td>
|
||||
<td><a href="user/document/<?php echo $document["filenamedocument"]; ?>" target="_blank">DOC</a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="certificateTable" class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Data Caricamento</th>
|
||||
<th>Documento</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document["first_name"]; ?> <?php echo $document["last_name"]; ?></td>
|
||||
<td><?php echo $document["expirydatedocument"]; ?></td>
|
||||
<td><?php echo $document["uploaded_at"] ?? 'N/D'; ?></td>
|
||||
<td><a href="user/document/<?php echo $document["filenamedocument"]; ?>" target="_blank">DOC</a></td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm" onclick="confirmDelete(<?php echo $document['idcertificateuserprofile']; ?>)">
|
||||
<i class="fas fa-trash"></i> Cancella
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- End Page-content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
|
||||
<!-- End Page-content -->
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- JAVASCRIPT -->
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
|
||||
</body>
|
||||
<!-- end main content-->
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
<!-- JAVASCRIPT -->
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
<script src="assets/js/app.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
require_once('Connections/bkngstm.php');
|
||||
require_once('webassist/mysqli/rsobj.php');
|
||||
include('include/headscript.php'); // $iduserlogin
|
||||
|
||||
/***********************
|
||||
* LOG (mail + debug)
|
||||
***********************/
|
||||
$logDir = __DIR__ . '/logs';
|
||||
if (!is_dir($logDir)) {
|
||||
@mkdir($logDir, 0755, true);
|
||||
}
|
||||
$mailLogFile = $logDir . '/mail_cancel.log';
|
||||
|
||||
function mail_log($file, $msg)
|
||||
{
|
||||
@file_put_contents($file, "[" . date("Y-m-d H:i:s") . "] " . $msg . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
/***********************
|
||||
* INPUT
|
||||
***********************/
|
||||
if (!isset($_GET['id'])) {
|
||||
die("ID non fornito.");
|
||||
}
|
||||
|
||||
$id = (int)$_GET['id'];
|
||||
$userId = (int)$iduserlogin;
|
||||
|
||||
/***********************
|
||||
* DB
|
||||
***********************/
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
/***********************
|
||||
* 1) USER INFO (auth_users)
|
||||
***********************/
|
||||
$stmt = $conn->prepare("SELECT email, first_name, last_name FROM auth_users WHERE id = ? LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
$u = $res->fetch_assoc();
|
||||
$stmt->close();
|
||||
|
||||
$userEmail = $u['email'] ?? '';
|
||||
$userName = trim(($u['first_name'] ?? '') . ' ' . ($u['last_name'] ?? ''));
|
||||
|
||||
/***********************
|
||||
* 2) BOOKING INFO (nome classe + data) + ownership check
|
||||
***********************/
|
||||
$stmt = $conn->prepare("
|
||||
SELECT
|
||||
bc.idbookingclass,
|
||||
s.servicename,
|
||||
ss.dateschedule
|
||||
FROM bookingclass bc
|
||||
LEFT JOIN service s ON bc.idservice = s.idservice
|
||||
LEFT JOIN serviceschedule ss ON bc.idserviceschedule = ss.idserviceschedule
|
||||
WHERE bc.idbookingclass = ? AND bc.iduser = ?
|
||||
LIMIT 1
|
||||
");
|
||||
$stmt->bind_param("ii", $id, $userId);
|
||||
$stmt->execute();
|
||||
$res = $stmt->get_result();
|
||||
$bk = $res->fetch_assoc();
|
||||
$stmt->close();
|
||||
|
||||
if (!$bk) {
|
||||
$conn->close();
|
||||
header("Location: userpanel.php?deleted=0&err=notfound");
|
||||
exit();
|
||||
}
|
||||
|
||||
$className = $bk['servicename'] ?? 'Lezione';
|
||||
$classDateRaw = $bk['dateschedule'] ?? null;
|
||||
|
||||
$classDateTxt = $classDateRaw ? date("d-m-Y H:i", strtotime($classDateRaw)) : 'N/D';
|
||||
$cancelDateTxt = date("d-m-Y H:i");
|
||||
|
||||
/***********************
|
||||
* 3) DELETE (safe)
|
||||
***********************/
|
||||
$stmt = $conn->prepare("DELETE FROM bookingclass WHERE idbookingclass = ? AND iduser = ?");
|
||||
$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();
|
||||
|
||||
/***********************
|
||||
* 4) EMAIL (TO utente + CC info@yogasoul.it)
|
||||
* Usa le chiavi del tuo .env: MAIL_HOST, MAIL_PORT, MAIL_USERNAME, ...
|
||||
***********************/
|
||||
try {
|
||||
// Carica vendor/autoload + dotenv (il tuo file esistente)
|
||||
require_once(__DIR__ . '/class/mailer.php');
|
||||
|
||||
$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
|
||||
|
||||
// Legge le variabili in stile Laravel (con trim per eventuali virgolette)
|
||||
$host = trim($_ENV['MAIL_HOST'] ?? 'mail.yogasoul.it', "\" \t\n\r\0\x0B");
|
||||
$port = (int)($_ENV['MAIL_PORT'] ?? 465);
|
||||
$user = $_ENV['MAIL_USERNAME'] ?? '';
|
||||
$pass = $_ENV['MAIL_PASSWORD'] ?? '';
|
||||
$enc = strtolower(trim($_ENV['MAIL_ENCRYPTION'] ?? 'ssl', "\" \t\n\r\0\x0B"));
|
||||
|
||||
$fromEmail = trim($_ENV['MAIL_FROM_ADDRESS'] ?? 'info@yogasoul.it', "\" \t\n\r\0\x0B");
|
||||
$fromName = trim($_ENV['MAIL_FROM_NAME'] ?? 'YogiBook', "\" \t\n\r\0\x0B");
|
||||
|
||||
// Config SMTP
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $host;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $user;
|
||||
$mail->Password = $pass;
|
||||
$mail->Port = $port;
|
||||
|
||||
if (in_array($enc, ['tls', 'ssl'], true)) {
|
||||
$mail->SMTPSecure = $enc;
|
||||
}
|
||||
|
||||
// Timeout (utile su SMTP hosting)
|
||||
$mail->Timeout = 20;
|
||||
|
||||
$mail->setFrom($fromEmail, $fromName);
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->isHTML(true);
|
||||
|
||||
// Destinatari
|
||||
if (!empty($userEmail)) {
|
||||
$mail->addAddress($userEmail, $userName ?: '');
|
||||
}
|
||||
$mail->addCC('info@yogasoul.it');
|
||||
|
||||
// Log impostazioni usate (senza password)
|
||||
mail_log($mailLogFile, "SMTP in uso host={$host} porta={$port} enc={$enc} user={$user}");
|
||||
|
||||
// Contenuto (ITALIANO)
|
||||
$mail->Subject = "Lezione cancellata - {$className}";
|
||||
$mail->Body = "
|
||||
<div style='font-family:Arial,sans-serif;font-size:14px;color:#222'>
|
||||
<p>Ciao " . htmlspecialchars($userName ?: 'Yogi') . ",</p>
|
||||
<p>La tua lezione è stata <b>cancellata</b>.</p>
|
||||
<p>
|
||||
<b>Lezione:</b> " . htmlspecialchars($className) . "<br>
|
||||
<b>Data/ora prevista:</b> " . htmlspecialchars($classDateTxt) . "<br>
|
||||
<b>Data/ora cancellazione:</b> " . htmlspecialchars($cancelDateTxt) . "<br>
|
||||
<b>ID prenotazione:</b> #{$id}
|
||||
</p>
|
||||
<p>Grazie,<br>— " . htmlspecialchars($fromName) . "</p>
|
||||
</div>
|
||||
";
|
||||
|
||||
$mail->send();
|
||||
|
||||
mail_log($mailLogFile, "OK inviata. booking_id={$id} user_id={$userId} to={$userEmail} lezione='" . $className . "' prevista='{$classDateTxt}' cancellata='{$cancelDateTxt}'");
|
||||
} catch (Throwable $e) {
|
||||
mail_log($mailLogFile, "ERRORE invio. booking_id={$id} user_id={$userId} to={$userEmail} :: " . $e->getMessage());
|
||||
error_log("Mailer error (delete booking #{$id}, user #{$userId}): " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Redirect
|
||||
header("Location: userpanel.php?deleted=1");
|
||||
exit();
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require_once('include/headscript.php');
|
||||
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
if (isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']); // Sanitize input
|
||||
// Optional: Verify user ownership for security (uncomment if needed)
|
||||
/*
|
||||
$iduserlogin = $_SESSION['iduserlogin']; // Assumes user ID is stored in session
|
||||
$deleteQuery = "DELETE FROM certificateuserprofile WHERE idcertificateuserprofile = ? AND iduser = ?";
|
||||
$stmt = $conn->prepare($deleteQuery);
|
||||
$stmt->bind_param("ii", $id, $iduserlogin);
|
||||
*/
|
||||
$deleteQuery = "DELETE FROM certificateuserprofile WHERE idcertificateuserprofile = ?";
|
||||
$stmt = $conn->prepare($deleteQuery);
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
// Determine redirect based on source
|
||||
$source = isset($_GET['source']) ? $_GET['source'] : 'user';
|
||||
if ($source === 'admin') {
|
||||
header("Location: certificati.php?message=success");
|
||||
} else {
|
||||
header("Location: userprofiledoc.php?message=success");
|
||||
}
|
||||
} else {
|
||||
echo "Errore nella cancellazione: " . $conn->error;
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo "ID non fornito.";
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once('include/headscript.php');
|
||||
|
||||
$conn = mysqli_connect($servername, $username, $password, $dbname);
|
||||
|
||||
if (!$conn) {
|
||||
die(json_encode(['error' => 'Connessione al database fallita']));
|
||||
}
|
||||
|
||||
// Query per ottenere tutte le classi disponibili
|
||||
$sql = "SELECT id, servicename, day, time FROM classes ORDER BY servicename, day, time";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
|
||||
$classes = [];
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$classes[] = [
|
||||
'id' => $row['id'],
|
||||
'servicename' => $row['servicename'],
|
||||
'day' => $row['day'],
|
||||
'time' => $row['time']
|
||||
];
|
||||
}
|
||||
|
||||
mysqli_close($conn);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($classes);
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once('include/headscript.php');
|
||||
|
||||
$conn = mysqli_connect($servername, $username, $password, $dbname);
|
||||
|
||||
if (!$conn) {
|
||||
die(json_encode(['error' => 'Connessione al database fallita']));
|
||||
}
|
||||
|
||||
$class_id = isset($_POST['class_id']) ? intval($_POST['class_id']) : 0;
|
||||
|
||||
if ($class_id <= 0) {
|
||||
die(json_encode(['error' => 'ID classe non valido']));
|
||||
}
|
||||
|
||||
// Query per ottenere le date disponibili per la classe specificata
|
||||
// Supponiamo che ci sia una tabella 'class_schedule' con le date disponibili
|
||||
$sql = "SELECT DISTINCT DATE(bookingstart) as available_date
|
||||
FROM class_schedule
|
||||
WHERE class_id = ?
|
||||
ORDER BY available_date";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
mysqli_stmt_bind_param($stmt, 'i', $class_id);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
|
||||
$availableDates = [];
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$availableDates[] = $row['available_date'];
|
||||
}
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($conn);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['availableDates' => $availableDates]);
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
ob_start();
|
||||
require_once('include/headscript.php');
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
ob_end_clean();
|
||||
echo json_encode(['error' => 'Connessione al database fallita: ' . $conn->connect_error]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = "SELECT
|
||||
ss.idserviceschedule,
|
||||
s.servicename,
|
||||
COALESCE(s.maxcapacity, 0) AS maxcapacity,
|
||||
DATE_FORMAT(ss.dateschedule, '%d %M %Y %H:%i') AS display_dateschedule,
|
||||
DATE_FORMAT(ss.dateschedule, '%Y-%m-%d %H:%i') AS iso_dateschedule,
|
||||
(SELECT COUNT(*)
|
||||
FROM bookingclass bc
|
||||
WHERE bc.idserviceschedule = ss.idserviceschedule
|
||||
AND bc.status != 'cancelled') AS occupied_seats
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
ORDER BY ss.dateschedule ASC";
|
||||
|
||||
$result = $conn->query($query);
|
||||
|
||||
$classes = [];
|
||||
if ($result) {
|
||||
$italianMonths = [
|
||||
'January' => 'Gennaio',
|
||||
'February' => 'Febbraio',
|
||||
'March' => 'Marzo',
|
||||
'April' => 'Aprile',
|
||||
'May' => 'Maggio',
|
||||
'June' => 'Giugno',
|
||||
'July' => 'Luglio',
|
||||
'August' => 'Agosto',
|
||||
'September' => 'Settembre',
|
||||
'October' => 'Ottobre',
|
||||
'November' => 'Novembre',
|
||||
'December' => 'Dicembre'
|
||||
];
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
// Traduci il mese in italiano
|
||||
foreach ($italianMonths as $en => $it) {
|
||||
$row['display_dateschedule'] = str_replace($en, $it, $row['display_dateschedule']);
|
||||
}
|
||||
|
||||
// Assicura che maxcapacity sia positivo
|
||||
if ($row['maxcapacity'] <= 0) {
|
||||
$row['maxcapacity'] = 1; // Valore positivo di fallback, cambialo se necessario
|
||||
}
|
||||
|
||||
$classes[] = $row;
|
||||
}
|
||||
ob_end_clean();
|
||||
echo json_encode(['classes' => $classes]);
|
||||
} else {
|
||||
ob_end_clean();
|
||||
echo json_encode(['error' => 'Errore nella query: ' . $conn->error]);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// ID dell'utente (esempio, da sostituire con l'utente loggato)
|
||||
$userid = 1; // Sostituisci con l'ID utente corrente, ad esempio da sessione
|
||||
|
||||
// Query per ottenere il valore di lessonnotification
|
||||
$query = "SELECT lessonnotification FROM auth_users WHERE id = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("i", $userid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$lessonnotification = $row['lessonnotification'];
|
||||
} else {
|
||||
$lessonnotification = 'Y'; // Valore di default se l'utente non esiste
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Opzioni</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Opzioni YogaSoul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 20px auto;
|
||||
max-width: 600px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.custom-card h2 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-check {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-check-label {
|
||||
margin-left: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.save-button {
|
||||
background-color: #1ebf73;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.save-button:hover {
|
||||
background-color: #18a060;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#lessonnotification').on('change', function() {
|
||||
var isChecked = $(this).is(':checked') ? 'Y' : 'N';
|
||||
|
||||
$.ajax({
|
||||
url: 'update_lessonnotification.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
userid: <?php echo $userid; ?>,
|
||||
lessonnotification: isChecked
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
Swal.fire({
|
||||
title: 'Successo!',
|
||||
text: 'Impostazione notifiche lezione aggiornata con successo.',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Errore!',
|
||||
text: 'Errore durante l\'aggiornamento: ' + response.error,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
Swal.fire({
|
||||
title: 'Errore!',
|
||||
text: 'Errore durante la richiesta AJAX.',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="layout-wrapper">
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Opzioni</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="custom-card">
|
||||
<h2>Impostazioni Notifiche</h2>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="lessonnotification" <?php echo $lessonnotification === 'Y' ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label" for="lessonnotification">
|
||||
Abilita notifiche per le lezioni
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
<script src="assets/js/app.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+165
-151
@@ -1,171 +1,185 @@
|
||||
<!-- ========== Left Sidebar Start ========== -->
|
||||
<div class="vertical-menu">
|
||||
<div class="vertical-menu">
|
||||
|
||||
<!-- LOGO -->
|
||||
<div class="navbar-brand-box">
|
||||
<a href="index.html" class="logo logo-dark">
|
||||
<span class="logo-sm">
|
||||
<img src="assets/images/logo-dark-sm.png" alt="" height="30">
|
||||
</span>
|
||||
<span class="logo-lg">
|
||||
<img src="assets/images/logo-dark.png" alt="" height="32">
|
||||
</span>
|
||||
</a>
|
||||
<!-- LOGO -->
|
||||
<div class="navbar-brand-box">
|
||||
<a href="index.html" class="logo logo-dark">
|
||||
<span class="logo-sm">
|
||||
<img src="assets/images/logo-dark-sm.png" alt="" height="30">
|
||||
</span>
|
||||
<span class="logo-lg">
|
||||
<img src="assets/images/logo-dark.png" alt="" height="32">
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<a href="index.html" class="logo logo-light">
|
||||
<span class="logo-lg">
|
||||
<img src="assets/images/logo-light.png" alt="" height="30">
|
||||
</span>
|
||||
<span class="logo-sm">
|
||||
<img src="assets/images/logo-light-sm.png" alt="" height="26">
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<a href="index.html" class="logo logo-light">
|
||||
<span class="logo-lg">
|
||||
<img src="assets/images/logo-light.png" alt="" height="30">
|
||||
</span>
|
||||
<span class="logo-sm">
|
||||
<img src="assets/images/logo-light-sm.png" alt="" height="26">
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
|
||||
<div data-simplebar class="sidebar-menu-scroll">
|
||||
<div data-simplebar class="sidebar-menu-scroll">
|
||||
|
||||
<!--- Sidemenu -->
|
||||
<div id="sidebar-menu">
|
||||
<!-- Left Menu Start -->
|
||||
<ul class="metismenu list-unstyled" id="side-menu">
|
||||
<li class="menu-title" data-key="t-menu">Dashboard</li>
|
||||
|
||||
|
||||
<!--- Sidemenu -->
|
||||
<div id="sidebar-menu">
|
||||
<!-- Left Menu Start -->
|
||||
<ul class="metismenu list-unstyled" id="side-menu">
|
||||
<li class="menu-title" data-key="t-menu">Dashboard</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li>
|
||||
<a href="userpanel.php" class="">
|
||||
<i class="bx bx-calendar-event icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Prenotazioni</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="orders.php" class="">
|
||||
<i class="bx bx-detail icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Ordini</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="menu-title" data-key="t-applications">Profilo Utente</li>
|
||||
|
||||
<li>
|
||||
<a href="userprofile.php" class="">
|
||||
<i class="bx bx-user-circle icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Profilo utente</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="userprofiledoc.php" class="">
|
||||
<i class="bx bxs-file-doc icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Certificati</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
<?php if (Auth::user()->hasRole('Admin')): ?>
|
||||
<li class="menu-title" data-key="t-applications">Amministrazione</li>
|
||||
|
||||
<li>
|
||||
<a href="admin-services.php" class="">
|
||||
<i class="bx bx-edit-alt icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Servizi</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="adminpanel.php" class="">
|
||||
<i class="bx bxs-school icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Classi</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="pendingbookedclass.php" class="">
|
||||
<i class="bx bx-skip-next icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Pending/Waiting</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li>
|
||||
<a href="dayoff.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Day Off</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="orderbooklist.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Order Pending</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="certificati.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Certificati</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="situationusers.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Siutazione</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li class="menu-title" data-key="t-applications">Template</li>
|
||||
<li>
|
||||
<a href="userpanel.php" class="">
|
||||
<i class="bx bx-calendar-event icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Prenotazioni</span>
|
||||
</a>
|
||||
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="orders.php" class="">
|
||||
<i class="bx bx-detail icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Ordini</span>
|
||||
</a>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="javascript: void(0);" class="has-arrow">
|
||||
<i class="bx bx-table icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-tables">Tables</span>
|
||||
</a>
|
||||
<ul class="sub-menu" aria-expanded="false">
|
||||
<li><a href="copiaintegra/dist/tables-basic.html" data-key="t-basic-tables">Basic Tables</a></li>
|
||||
<li><a href="copiaintegra/dist/tables-advanced.html" data-key="t-advanced-tables">Advance Tables</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="menu-title" data-key="t-applications">Profilo Utente</li>
|
||||
|
||||
<?php endif; ?>
|
||||
<li>
|
||||
<a href="userprofile.php" class="">
|
||||
<i class="bx bx-user-circle icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Profilo utente</span>
|
||||
</a>
|
||||
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="options.php" class="">
|
||||
<i class="bx bx-user-circle icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Opzioni</span>
|
||||
</a>
|
||||
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="userprofiledoc.php" class="">
|
||||
<i class="bx bxs-file-doc icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Certificati</span>
|
||||
</a>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</li>
|
||||
<?php if (Auth::user()->hasRole('Admin')): ?>
|
||||
<li class="menu-title" data-key="t-applications">Amministrazione</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Sidebar -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- Left Sidebar End -->
|
||||
|
||||
<li>
|
||||
<a href="admin-services.php" class="">
|
||||
<i class="bx bx-edit-alt icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Servizi</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="adminpanel.php" class="">
|
||||
<i class="bx bxs-school icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Classi</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="pendingbookedclass.php" class="">
|
||||
<i class="bx bx-skip-next icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Pending/Waiting</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li>
|
||||
<a href="dayoff.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Day Off</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="orderbooklist.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Order Pending</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="certificati.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Certificati</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="situationusers.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Situazione</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="ordersummary.php" class="">
|
||||
<i class="bx bx-power-off icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-email">Sommario Ordini</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li class="menu-title" data-key="t-applications">Template</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li>
|
||||
<a href="javascript: void(0);" class="has-arrow">
|
||||
<i class="bx bx-table icon nav-icon"></i>
|
||||
<span class="menu-item" data-key="t-tables">Tables</span>
|
||||
</a>
|
||||
<ul class="sub-menu" aria-expanded="false">
|
||||
<li><a href="copiaintegra/dist/tables-basic.html" data-key="t-basic-tables">Basic Tables</a></li>
|
||||
<li><a href="copiaintegra/dist/tables-advanced.html" data-key="t-advanced-tables">Advance Tables</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Sidebar -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- Left Sidebar End -->
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once('Connections/bkngstm.php');
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die(json_encode(['success' => false, 'error' => 'Connessione fallita: ' . $conn->connect_error]));
|
||||
}
|
||||
|
||||
if (isset($_POST['userid']) && isset($_POST['lessonnotification'])) {
|
||||
$userid = $_POST['userid'];
|
||||
$lessonnotification = $_POST['lessonnotification'];
|
||||
|
||||
// Validate lessonnotification value
|
||||
if (!in_array($lessonnotification, ['Y', 'N'])) {
|
||||
echo json_encode(['success' => false, 'error' => 'Valore lessonnotification non valido']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = "UPDATE auth_users SET lessonnotification = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("si", $lessonnotification, $userid);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => $conn->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'Parametri mancanti']);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
@@ -0,0 +1,2 @@
|
||||
[2026-02-18 13:43:57] ERROR sending. booking_id=29 user_id=2 to=info@claudiosironi.com :: SMTP Error: Could not connect to SMTP host. Failed to connect to server
|
||||
[2026-02-18 13:46:10] ERROR sending. booking_id=30 user_id=2 to=info@claudiosironi.com :: SMTP Error: Could not connect to SMTP host. Failed to connect to server
|
||||
@@ -0,0 +1,379 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
|
||||
<?php
|
||||
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message'];
|
||||
} else {
|
||||
$message = 'n';
|
||||
}
|
||||
|
||||
// Gestione del filtro
|
||||
$filter = isset($_GET['filter']) ? $_GET['filter'] : 'all';
|
||||
$today = date("Y-m-d");
|
||||
$whereClause = "";
|
||||
if ($filter == 'active') {
|
||||
$whereClause = "WHERE expireon > '$today'";
|
||||
} elseif ($filter == 'expired') {
|
||||
$whereClause = "WHERE expireon <= '$today'";
|
||||
}
|
||||
|
||||
// Query SQL per recuperare tutti gli ordini con join su service
|
||||
$query = "SELECT o.order_id, o.first_name, o.last_name, s.servicename, o.expireon, o.status
|
||||
FROM orderbook o
|
||||
LEFT JOIN service s ON o.idservice = s.idservice
|
||||
$whereClause
|
||||
ORDER BY o.order_id DESC";
|
||||
|
||||
// Esecuzione della query
|
||||
$result = $conn->query($query);
|
||||
|
||||
// Recupero dei records
|
||||
$orders = [];
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$orders[] = $row;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Riepilogo Ordini</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd", // Formato della data
|
||||
minDate: 0, // Impedisce la selezione di date passate
|
||||
// Altre opzioni del datepicker se necessario
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- <body data-layout="horizontal"> -->
|
||||
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Riepilogo Ordini</h4>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-flex">
|
||||
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start right Content here -->
|
||||
<!-- ============================================================== -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if ($message == 'success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
Operazione completata con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<h5>Riepilogo Ordini (Amministratore)</h5>
|
||||
<p>Tutti gli ordini registrati</p>
|
||||
|
||||
<!-- Filtri -->
|
||||
<div class="mb-3">
|
||||
<a href="?filter=all" class="btn btn-secondary <?php echo $filter == 'all' ? 'active' : ''; ?>">Tutti</a>
|
||||
<a href="?filter=active" class="btn btn-success <?php echo $filter == 'active' ? 'active' : ''; ?>">Attivi</a>
|
||||
<a href="?filter=expired" class="btn btn-danger <?php echo $filter == 'expired' ? 'active' : ''; ?>">Scaduti</a>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Stato</th>
|
||||
<th>Numero Ordine</th>
|
||||
<th>Nome</th>
|
||||
<th>Cognome</th>
|
||||
<th>Nome Classe</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($orders as $order) {
|
||||
$isActive = ($order["expireon"] > $today);
|
||||
$badgeClass = $isActive ? 'badge bg-success' : 'badge bg-danger';
|
||||
$badgeText = $isActive ? 'Attivo' : 'Scaduto';
|
||||
?>
|
||||
<tr>
|
||||
<td><span class="<?php echo $badgeClass; ?>"><?php echo $badgeText; ?></span></td>
|
||||
<td><?php echo $order["order_id"]; ?></td>
|
||||
<td><?php echo $order["first_name"]; ?></td>
|
||||
<td><?php echo $order["last_name"]; ?></td>
|
||||
<td><?php echo $order["servicename"]; ?></td>
|
||||
<td><?php echo $order["expireon"]; ?></td>
|
||||
<td><?php echo $order["status"]; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- End Page-content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- JAVASCRIPT -->
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,379 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
|
||||
<?php
|
||||
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message'];
|
||||
} else {
|
||||
$message = 'n';
|
||||
}
|
||||
|
||||
// Gestione del filtro
|
||||
$filter = isset($_GET['filter']) ? $_GET['filter'] : 'all';
|
||||
$today = date("Y-m-d");
|
||||
$whereClause = "";
|
||||
if ($filter == 'active') {
|
||||
$whereClause = "WHERE expireon > '$today'";
|
||||
} elseif ($filter == 'expired') {
|
||||
$whereClause = "WHERE expireon <= '$today'";
|
||||
}
|
||||
|
||||
// Query SQL per recuperare tutti gli ordini con join su service
|
||||
$query = "SELECT o.order_id, o.first_name, o.last_name, s.servicename, o.expireon, o.status
|
||||
FROM orderbook o
|
||||
LEFT JOIN service s ON o.idservice = s.idservice
|
||||
$whereClause
|
||||
ORDER BY o.order_id DESC";
|
||||
|
||||
// Esecuzione della query
|
||||
$result = $conn->query($query);
|
||||
|
||||
// Recupero dei records
|
||||
$orders = [];
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$orders[] = $row;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Riepilogo Ordini</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd", // Formato della data
|
||||
minDate: 0, // Impedisce la selezione di date passate
|
||||
// Altre opzioni del datepicker se necessario
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- <body data-layout="horizontal"> -->
|
||||
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Riepilogo Ordini</h4>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-flex">
|
||||
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start right Content here -->
|
||||
<!-- ============================================================== -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if ($message == 'success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
Operazione completata con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<h5>Riepilogo Ordini (Amministratore)</h5>
|
||||
<p>Tutti gli ordini registrati</p>
|
||||
|
||||
<!-- Filtri -->
|
||||
<div class="mb-3">
|
||||
<a href="?filter=all" class="btn btn-secondary <?php echo $filter == 'all' ? 'active' : ''; ?>">Tutti</a>
|
||||
<a href="?filter=active" class="btn btn-success <?php echo $filter == 'active' ? 'active' : ''; ?>">Attivi</a>
|
||||
<a href="?filter=expired" class="btn btn-danger <?php echo $filter == 'expired' ? 'active' : ''; ?>">Scaduti</a>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Stato</th>
|
||||
<th>Numero Ordine</th>
|
||||
<th>Nome</th>
|
||||
<th>Cognome</th>
|
||||
<th>Nome Classe</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($orders as $order) {
|
||||
$isActive = ($order["expireon"] > $today);
|
||||
$badgeClass = $isActive ? 'badge bg-success' : 'badge bg-danger';
|
||||
$badgeText = $isActive ? 'Attivo' : 'Scaduto';
|
||||
?>
|
||||
<tr>
|
||||
<td><span class="<?php echo $badgeClass; ?>"><?php echo $badgeText; ?></span></td>
|
||||
<td><?php echo $order["order_id"]; ?></td>
|
||||
<td><?php echo $order["first_name"]; ?></td>
|
||||
<td><?php echo $order["last_name"]; ?></td>
|
||||
<td><?php echo $order["servicename"]; ?></td>
|
||||
<td><?php echo $order["expireon"]; ?></td>
|
||||
<td><?php echo $order["status"]; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- End Page-content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- JAVASCRIPT -->
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,212 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// ID dell'utente (esempio, da sostituire con l'utente loggato)
|
||||
$userid = 1; // Sostituisci con l'ID utente corrente, ad esempio da sessione
|
||||
|
||||
// Query per ottenere il valore di lessonnotification
|
||||
$query = "SELECT lessonnotification FROM auth_users WHERE id = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("i", $userid);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$lessonnotification = $row['lessonnotification'];
|
||||
} else {
|
||||
$lessonnotification = 'Y'; // Valore di default se l'utente non esiste
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Opzioni</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Opzioni YogaSoul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 20px auto;
|
||||
max-width: 600px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.custom-card h2 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-check {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-check-label {
|
||||
margin-left: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.save-button {
|
||||
background-color: #1ebf73;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.save-button:hover {
|
||||
background-color: #18a060;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#lessonnotification').on('change', function() {
|
||||
var isChecked = $(this).is(':checked') ? 'Y' : 'N';
|
||||
|
||||
$.ajax({
|
||||
url: 'update_lessonnotification.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
userid: <?php echo $userid; ?>,
|
||||
lessonnotification: isChecked
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
Swal.fire({
|
||||
title: 'Successo!',
|
||||
text: 'Impostazione notifiche lezione aggiornata con successo.',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Errore!',
|
||||
text: 'Errore durante l\'aggiornamento: ' + response.error,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
Swal.fire({
|
||||
title: 'Errore!',
|
||||
text: 'Errore durante la richiesta AJAX.',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="layout-wrapper">
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Opzioni</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="custom-card">
|
||||
<h2>Impostazioni Notifiche</h2>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="lessonnotification" <?php echo $lessonnotification === 'Y' ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label" for="lessonnotification">
|
||||
Abilita notifiche per le lezioni
|
||||
</label>
|
||||
<p>con questa notifica riceverai un promemoria qualche ora prima della lezione, che ti permetterà , entro i limiti consentiti, di cancellare o riprogrammare la lezione</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
<script src="assets/js/app.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -272,7 +272,7 @@ if (!$result) {
|
||||
echo "<td>" . $row['iduser'] . "</td>";
|
||||
echo "<td>" . $row['cod'] . "</td>";
|
||||
echo "<td>" . $row['quantityclass'] . "</td>";
|
||||
echo "<td>" . "<a href='propagatesingleorder.php?idorder=" . $row['idorderbook'] . "'><button type='button' class='btn btn-success waves-effect btn-label waves-light'><i class='bx bx-check-double label-icon'></i> Propaga</button></a>" . "</td>";
|
||||
echo "<td><button type='button' class='btn btn-success waves-effect btn-label waves-light propagate-btn' data-idorder='" . $row['idorderbook'] . "'><i class='bx bx-check-double label-icon'></i> Propaga</button></td>";
|
||||
echo "<td>" . "<a href='cancelsingleorder.php?idorder=" . $row['idorderbook'] . "'><button type='button' class='btn btn-danger waves-effect waves-light'><i class='bx bx-block font-size-16 align-middle me-2'></i> Cancella</button></a>" . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
@@ -381,6 +381,55 @@ if (!$result) {
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
<script src="assets/js/app.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.propagate-btn').on('click', function() {
|
||||
var idorder = $(this).data('idorder');
|
||||
|
||||
// Chiama AJAX per calcolare la scadenza
|
||||
$.ajax({
|
||||
url: 'calculate_expiry.php',
|
||||
method: 'GET',
|
||||
data: {
|
||||
idorder: idorder
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.error) {
|
||||
Swal.fire('Errore', data.error, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
var calculatedExpiry = data.expiry_date;
|
||||
|
||||
// Mostra modal di conferma
|
||||
Swal.fire({
|
||||
title: 'Conferma Scadenza',
|
||||
html: `
|
||||
<p>Data di scadenza calcolata: <strong>${calculatedExpiry}</strong></p>
|
||||
<label for="expiry-date">Modifica scadenza (se necessario):</label>
|
||||
<input type="date" id="expiry-date" class="swal2-input" value="${calculatedExpiry}">
|
||||
`,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Conferma e Propaga',
|
||||
cancelButtonText: 'Annulla',
|
||||
preConfirm: () => {
|
||||
return document.getElementById('expiry-date').value;
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
var expiryDate = result.value || calculatedExpiry; // Usa modificata o originale
|
||||
window.location.href = `propagatesingleorder.php?idorder=${idorder}&expiry_date=${expiryDate}`;
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire('Errore', 'Impossibile calcolare la scadenza', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+193
-97
@@ -1,58 +1,92 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php
|
||||
// optionquery
|
||||
$optionquery = new WA_MySQLi_RS("optionquery", $bkngstm, 0);
|
||||
$optionquery->setQuery("SELECT * FROM option");
|
||||
$optionquery->execute();
|
||||
?>
|
||||
// Abilita visualizzazione errori PHP (solo per debug)
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once('include/headscript.php');
|
||||
|
||||
// Inizializza log
|
||||
$logFile = 'dashboard_log.txt';
|
||||
$logMessage = "Esecuzione dashboard: " . date('Y-m-d H:i:s') . "\n";
|
||||
|
||||
<?php
|
||||
// Verifica se è stato inviato un modulo
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (isset($_FILES["fileToUpload"]) && $_FILES["fileToUpload"]["error"] === UPLOAD_ERR_OK) {
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
$logMessage .= "Connessione al database fallita: " . $conn->connect_error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
$iduserlogin = $_POST["iduserlogin"];
|
||||
$iduserlogin = filter_var($_POST["iduserlogin"], FILTER_VALIDATE_INT);
|
||||
$logMessage .= "ID utente ricevuto dal form: $iduserlogin\n";
|
||||
$conn->close();
|
||||
} else {
|
||||
$logMessage .= "Errore caricamento file o iduserlogin non valido\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
$logMessage .= "Connessione al database fallita: " . $conn->connect_error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Query per selezionare i dati filtrati per iduser
|
||||
$query = "SELECT o.*, s.servicename, s.day, s.time
|
||||
$logMessage .= "Database connesso: $dbname\n";
|
||||
|
||||
// Query per selezionare i dati filtrati per iduser, inclusi maxreschedule e reprogrammed
|
||||
$iduserlogin = $iduserlogin; // Sostituisci con $iduserlogin in produzione
|
||||
$query = "SELECT o.idorderbook, o.order_id, o.idservice, o.order_date_created, o.quantityclass, o.first_lesson_date, o.expireon, o.maxreschedule, o.reprogrammed, s.servicename, s.day, s.time
|
||||
FROM orderbook o
|
||||
LEFT JOIN service s ON o.idservice = s.idservice
|
||||
WHERE o.iduser = '$iduserlogin'";
|
||||
$result = $conn->query($query);
|
||||
WHERE o.iduser = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("i", $iduserlogin);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$documents = array();
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
// Get lesson details for each order
|
||||
$order_id = $row['order_id'];
|
||||
$lesson_query = "SELECT bc.bookingstart, bc.status, bc.lostlesson, bc.expirylesson, s.servicename
|
||||
$idorderbook = $row['idorderbook'];
|
||||
$logMessage .= "Elaborazione ordine: idorderbook = $idorderbook, order_id = {$row['order_id']}\n";
|
||||
|
||||
$lesson_query = "SELECT bc.idbookingclass, bc.bookingstart, bc.status, bc.lostlesson, bc.expirylesson, bc.idservice, bc.is_reprogrammed, s.servicename
|
||||
FROM bookingclass bc
|
||||
LEFT JOIN service s ON bc.idservice = s.idservice
|
||||
WHERE bc.idorder = '$order_id'";
|
||||
$lesson_result = $conn->query($lesson_query);
|
||||
WHERE bc.idorder = ?";
|
||||
$lesson_stmt = $conn->prepare($lesson_query);
|
||||
$lesson_stmt->bind_param("i", $idorderbook);
|
||||
$lesson_stmt->execute();
|
||||
$lesson_result = $lesson_stmt->get_result();
|
||||
|
||||
$lessons = array();
|
||||
while ($lesson_row = $lesson_result->fetch_assoc()) {
|
||||
$lessons[] = $lesson_row;
|
||||
$logMessage .= "Query lezioni per idorderbook $idorderbook: $lesson_query\n";
|
||||
if ($lesson_result) {
|
||||
$logMessage .= "Numero di lezioni trovate per idorderbook $idorderbook: " . $lesson_result->num_rows . "\n";
|
||||
while ($lesson_row = $lesson_result->fetch_assoc()) {
|
||||
$lesson_row['bookingstart'] = date('c', strtotime($lesson_row['bookingstart']));
|
||||
$lessons[] = $lesson_row;
|
||||
$logMessage .= "Lezione aggiunta: " . json_encode($lesson_row) . "\n";
|
||||
}
|
||||
} else {
|
||||
$logMessage .= "Errore nella query per idorderbook $idorderbook: " . $conn->error . "\n";
|
||||
}
|
||||
$row['lessons'] = $lessons;
|
||||
$documents[] = $row;
|
||||
$logMessage .= "Lezioni per idorderbook $idorderbook: " . count($lessons) . "\n";
|
||||
$lesson_stmt->close();
|
||||
}
|
||||
$stmt->close();
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
@@ -65,7 +99,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
@@ -78,9 +112,11 @@ while ($row = $result->fetch_assoc()) {
|
||||
// Handle order click for popup
|
||||
$('.order-row').click(function() {
|
||||
var lessons = $(this).data('lessons');
|
||||
console.log('Lezioni ricevute:', lessons);
|
||||
var total = $(this).data('total');
|
||||
var orderId = $(this).data('order-id');
|
||||
var isExpired = $(this).data('is-expired');
|
||||
var isExpired = $(this).data('is-expired') === true; // Converti in booleano
|
||||
var expireOn = $(this).data('expireon');
|
||||
|
||||
// Calcolo delle date
|
||||
var now = new Date();
|
||||
@@ -99,51 +135,76 @@ while ($row = $result->fetch_assoc()) {
|
||||
}).length;
|
||||
var toSchedule = total - (booked + completed + lost + expired);
|
||||
|
||||
// Se l'ordine è scaduto, sposta le lezioni "Da Programmare" in "Scadute"
|
||||
if (isExpired) {
|
||||
expired += toSchedule;
|
||||
toSchedule = 0;
|
||||
}
|
||||
|
||||
console.log({
|
||||
booked: booked,
|
||||
completed: completed,
|
||||
lost: lost,
|
||||
expired: expired,
|
||||
toSchedule: toSchedule,
|
||||
total: total
|
||||
});
|
||||
|
||||
var expireOnFormatted = expireOn ? new Date(expireOn).toLocaleDateString('it-IT', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric'
|
||||
}) : 'Non specificata';
|
||||
|
||||
var htmlContent = `
|
||||
<h4 style="margin-bottom: 20px; color: #333; font-weight: 600;">
|
||||
Dettagli Ordine #${orderId}
|
||||
<span class="badge ${isExpired ? 'bg-danger' : 'bg-primary'}" style="margin-left: 10px; color: white;">
|
||||
${isExpired ? 'Scaduto' : 'Attivo'}
|
||||
</span>
|
||||
</h4>
|
||||
<div style="display: flex; justify-content: space-around; margin-bottom: 30px; gap: 10px;">
|
||||
<div class="stat-box" style="background-color: #d1e7dd; border: 1px solid #a3cfbb;">
|
||||
<h5 style="margin: 0; color: #0f5132; font-size: 14px;">Totale</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #0f5132;">${total}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #d4edda; border: 1px solid #b1d4b6;">
|
||||
<h5 style="margin: 0; color: #155724; font-size: 14px;">Fatte</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #155724;">${completed}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #f8d7da; border: 1px solid #f1aeb5;">
|
||||
<h5 style="margin: 0; color: #721c24; font-size: 14px;">Perse</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #721c24;">${lost}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #fff3cd; border: 1px solid #ffecb5;">
|
||||
<h5 style="margin: 0; color: #856404; font-size: 14px;">Scadute</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #856404;">${expired}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #e2d3f5; border: 1px solid #c3b2d6;">
|
||||
<h5 style="margin: 0; color: #4c2c92; font-size: 14px;">Da Programmare</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #4c2c92;">${toSchedule}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px;">
|
||||
<table class="lesson-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data e Ora</th>
|
||||
<th>Lezione</th>
|
||||
<th>Stato</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
<h4 style="margin-bottom: 20px; color: #333; font-weight: 600;">
|
||||
Dettagli Ordine #${orderId}
|
||||
<span class="badge ${isExpired ? 'bg-danger' : 'bg-primary'}" style="margin-left: 10px; color: white;">
|
||||
${isExpired ? 'Scaduto' : 'Attivo'}
|
||||
</span>
|
||||
</h4>
|
||||
<div style="display: flex; justify-content: space-around; margin-bottom: 30px; gap: 10px;">
|
||||
<div class="stat-box" style="background-color: #d1e7dd; border: 1px solid #a3cfbb;" title="Numero di lezioni acquistate per questo ordine">
|
||||
<h5 style="margin: 0; color: #0f5132; font-size: 14px;">Totale</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #0f5132;">${total}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #d4edda; border: 1px solid #b1d4b6;" title="Lezioni già praticate">
|
||||
<h5 style="margin: 0; color: #155724; font-size: 14px;">Praticate</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #155724;">${completed}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #f8d7da; border: 1px solid #f1aeb5;" title="Lezioni non praticate e non riprogrammate in tempo">
|
||||
<h5 style="margin: 0; color: #721c24; font-size: 14px;">Perse</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #721c24;">${lost}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #fff3cd; border: 1px solid #ffecb5;" title="Lezioni non riprogrammate entro la data di scadenza dell'ordine">
|
||||
<h5 style="margin: 0; color: #856404; font-size: 14px;">Scadute</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #856404;">${expired}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #e2d3f5; border: 1px solid #c3b2d6;" title="Lezioni da programmare entro la data di scadenza del tuo ordine (${expireOnFormatted})">
|
||||
<h5 style="margin: 0; color: #4c2c92; font-size: 14px;">Da Programmare</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #4c2c92;">${toSchedule}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px;">
|
||||
<p style="margin: 0 0 15px 0; color: #333; font-size: 14px; font-weight: 500;">
|
||||
Il tuo ordine scadrà il ${expireOnFormatted}
|
||||
</p>
|
||||
<table class="lesson-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data e Ora</th>
|
||||
<th>Lezione</th>
|
||||
<th>Stato</th>
|
||||
<th>Riprogrammata</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
if (lessons.length === 0) {
|
||||
htmlContent += `
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center; padding: 10px; color: #666; font-size: 13px;">
|
||||
<td colspan="4" style="text-align: center; padding: 10px; color: #666; font-size: 13px;">
|
||||
Nessuna lezione trovata per questo ordine.
|
||||
</td>
|
||||
</tr>
|
||||
@@ -175,6 +236,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
statusText = 'Programmata';
|
||||
}
|
||||
}
|
||||
var isReprogrammedText = lesson.is_reprogrammed === 'Y' ? 'Sì' : 'No';
|
||||
|
||||
htmlContent += `
|
||||
<tr class="${index % 2 === 0 ? 'even-row' : 'odd-row'}">
|
||||
@@ -189,6 +251,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
<td style="padding: 8px;">
|
||||
<span class="badge ${badgeClass}" style="color: ${badgeTextColor}; padding: 6px 10px; font-size: 12px; font-weight: 500;">${statusText}</span>
|
||||
</td>
|
||||
<td style="padding: 8px; font-size: 13px;">${isReprogrammedText}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
@@ -213,17 +276,16 @@ while ($row = $result->fetch_assoc()) {
|
||||
|
||||
// Handle details button click
|
||||
$('.details-btn').click(function(e) {
|
||||
e.stopPropagation(); // Prevent row click event
|
||||
e.stopPropagation();
|
||||
var row = $(this).closest('tr');
|
||||
var lessons = row.data('lessons');
|
||||
var total = row.data('total');
|
||||
var orderId = row.data('order-id');
|
||||
var isExpired = row.data('is-expired');
|
||||
var isExpired = row.data('is-expired') === true;
|
||||
var expireOn = row.data('expireon');
|
||||
|
||||
// Calcolo delle date
|
||||
var now = new Date();
|
||||
|
||||
// Calcolo dei conteggi
|
||||
var completed = lessons.filter(l => {
|
||||
var lessonDate = new Date(l.bookingstart);
|
||||
return (l.status === 'completed') ||
|
||||
@@ -237,6 +299,18 @@ while ($row = $result->fetch_assoc()) {
|
||||
}).length;
|
||||
var toSchedule = total - (booked + completed + lost + expired);
|
||||
|
||||
// Se l'ordine è scaduto, sposta le lezioni "Da Programmare" in "Scadute"
|
||||
if (isExpired) {
|
||||
expired += toSchedule;
|
||||
toSchedule = 0;
|
||||
}
|
||||
|
||||
var expireOnFormatted = expireOn ? new Date(expireOn).toLocaleDateString('it-IT', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric'
|
||||
}) : 'Non specificata';
|
||||
|
||||
var htmlContent = `
|
||||
<h4 style="margin-bottom: 20px; color: #333; font-weight: 600;">
|
||||
Dettagli Ordine #${orderId}
|
||||
@@ -245,23 +319,23 @@ while ($row = $result->fetch_assoc()) {
|
||||
</span>
|
||||
</h4>
|
||||
<div style="display: flex; justify-content: space-around; margin-bottom: 30px; gap: 10px;">
|
||||
<div class="stat-box" style="background-color: #d1e7dd; border: 1px solid #a3cfbb;">
|
||||
<div class="stat-box" style="background-color: #d1e7dd; border: 1px solid #a3cfbb;" title="Numero di lezioni acquistate per questo ordine">
|
||||
<h5 style="margin: 0; color: #0f5132; font-size: 14px;">Totale</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #0f5132;">${total}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #d4edda; border: 1px solid #b1d4b6;">
|
||||
<h5 style="margin: 0; color: #155724; font-size: 14px;">Fatte</h5>
|
||||
<div class="stat-box" style="background-color: #d4edda; border: 1px solid #b1d4b6;" title="Lezioni già praticate">
|
||||
<h5 style="margin: 0; color: #155724; font-size: 14px;">Praticate</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #155724;">${completed}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #f8d7da; border: 1px solid #f1aeb5;">
|
||||
<div class="stat-box" style="background-color: #f8d7da; border: 1px solid #f1aeb5;" title="Lezioni non praticate e non riprogrammate in tempo">
|
||||
<h5 style="margin: 0; color: #721c24; font-size: 14px;">Perse</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #721c24;">${lost}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #fff3cd; border: 1px solid #ffecb5;">
|
||||
<div class="stat-box" style="background-color: #fff3cd; border: 1px solid #ffecb5;" title="Lezioni non riprogrammate entro la data di scadenza dell'ordine">
|
||||
<h5 style="margin: 0; color: #856404; font-size: 14px;">Scadute</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #856404;">${expired}</p>
|
||||
</div>
|
||||
<div class="stat-box" style="background-color: #e2d3f5; border: 1px solid #c3b2d6;">
|
||||
<div class="stat-box" style="background-color: #e2d3f5; border: 1px solid #c3b2d6;" title="Lezioni da programmare entro la data di scadenza del tuo ordine (${expireOnFormatted})">
|
||||
<h5 style="margin: 0; color: #4c2c92; font-size: 14px;">Da Programmare</h5>
|
||||
<p style="font-size: 24px; font-weight: bold; margin: 5px 0; color: #4c2c92;">${toSchedule}</p>
|
||||
</div>
|
||||
@@ -273,6 +347,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
<th>Data e Ora</th>
|
||||
<th>Lezione</th>
|
||||
<th>Stato</th>
|
||||
<th>Riprogrammata</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -281,7 +356,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
if (lessons.length === 0) {
|
||||
htmlContent += `
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center; padding: 10px; color: #666; font-size: 13px;">
|
||||
<td colspan="4" style="text-align: center; padding: 10px; color: #666; font-size: 13px;">
|
||||
Nessuna lezione trovata per questo ordine.
|
||||
</td>
|
||||
</tr>
|
||||
@@ -313,6 +388,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
statusText = 'Programmata';
|
||||
}
|
||||
}
|
||||
var isReprogrammedText = lesson.is_reprogrammed === 'Y' ? 'Sì' : 'No';
|
||||
|
||||
htmlContent += `
|
||||
<tr class="${index % 2 === 0 ? 'even-row' : 'odd-row'}">
|
||||
@@ -327,6 +403,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
<td style="padding: 8px;">
|
||||
<span class="badge ${badgeClass}" style="color: ${badgeTextColor}; padding: 6px 10px; font-size: 12px; font-weight: 500;">${statusText}</span>
|
||||
</td>
|
||||
<td style="padding: 8px; font-size: 13px;">${isReprogrammedText}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
@@ -348,24 +425,24 @@ while ($row = $result->fetch_assoc()) {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
@@ -603,30 +680,46 @@ while ($row = $result->fetch_assoc()) {
|
||||
<th>N. Ticket</th>
|
||||
<th>Prima Lezione</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Riprogr. Massime</th>
|
||||
<th>Riprogrammate</th>
|
||||
<th>Stato</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) {
|
||||
$is_expired = strtotime($document['expireon']) < time();
|
||||
$logMessage .= "Order ID: {$document['idorderbook']}, Lessons count: " . count($document['lessons']) . "\n";
|
||||
?>
|
||||
<tr class="order-row"
|
||||
data-lessons='<?php echo json_encode($document['lessons']); ?>'
|
||||
data-total='<?php echo $document['quantityclass']; ?>'
|
||||
data-order-id='<?php echo $document['order_id']; ?>'
|
||||
data-is-expired='<?php echo $is_expired ? 'true' : 'false'; ?>'>
|
||||
<td><?php echo $document['order_id']; ?></td>
|
||||
data-order-id='<?php echo $document['idorderbook']; ?>'
|
||||
data-is-expired='<?php echo $is_expired ? 'true' : 'false'; ?>'
|
||||
data-expireon='<?php echo $document['expireon']; ?>'>
|
||||
<td><?php echo $document['idorderbook']; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($document['order_date_created'])); ?></td>
|
||||
<td><?php echo $document['servicename']; ?></td>
|
||||
<td><?php echo $document['day'] . ' ' . $document['time']; ?></td>
|
||||
<td><?php echo $document['quantityclass']; ?></td>
|
||||
<td><?php echo $document['first_lesson_date'] ? date('d-m-Y', strtotime($document['first_lesson_date'])) : '-'; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($document['expireon'])); ?></td>
|
||||
<td style="<?php echo $is_expired ? 'color: #dc3545;' : ''; ?>">
|
||||
<?php echo date('d-m-Y', strtotime($document['expireon'])); ?>
|
||||
</td>
|
||||
<td>
|
||||
<span style="display: inline-block; padding: 4px 8px; font-size: 11px; font-weight: 500; color: #fff; background-color: #17a2b8; border-radius: 4px;">
|
||||
<?php echo $document['maxreschedule']; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span style="display: inline-block; padding: 4px 8px; font-size: 11px; font-weight: 500; color: #fff; background-color: <?php echo ($document['reprogrammed'] >= $document['maxreschedule']) ? '#dc3545' : '#28a745'; ?>; border-radius: 4px;">
|
||||
<?php echo $document['reprogrammed']; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge <?php echo $is_expired ? 'bg-danger' : 'bg-primary'; ?>">
|
||||
<?php echo $is_expired ? 'Scaduto' : 'Attivo'; ?>
|
||||
</span>
|
||||
<button class="details-btn" data-order-id="<?php echo $document['order_id']; ?>" data-lessons='<?php echo json_encode($document['lessons']); ?>' data-total='<?php echo $document['quantityclass']; ?>' data-is-expired='<?php echo $is_expired ? 'true' : 'false'; ?>'>Dettagli</button>
|
||||
<button class="details-btn">Dettagli</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@@ -649,4 +742,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php $conn->close(); ?>
|
||||
<?php
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,412 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
|
||||
<?php
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Gestione del messaggio GET
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message'];
|
||||
} else {
|
||||
$message = 'n';
|
||||
}
|
||||
|
||||
// ID dell'insegnante (per il form DayOff)
|
||||
$idTeacher = 1;
|
||||
|
||||
// Gestione dell'inserimento del DayOff
|
||||
if (isset($_POST['submit'])) {
|
||||
$dayoffdate = $_POST['dayoff'];
|
||||
$insertQuery = "INSERT INTO dayoff (idteacher, dayoffdate) VALUES (?, ?)";
|
||||
$stmt = $conn->prepare($insertQuery);
|
||||
$stmt->bind_param("is", $idTeacher, $dayoffdate);
|
||||
if ($stmt->execute()) {
|
||||
$message = 'success_dayoff';
|
||||
} else {
|
||||
$message = 'error_dayoff';
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
// Gestione del filtro per gli ordini
|
||||
$filter = isset($_GET['filter']) ? $_GET['filter'] : 'all';
|
||||
$today = date("Y-m-d");
|
||||
$whereClause = "";
|
||||
if ($filter == 'active') {
|
||||
$whereClause = "WHERE expireon > '$today'";
|
||||
} elseif ($filter == 'expired') {
|
||||
$whereClause = "WHERE expireon <= '$today'";
|
||||
}
|
||||
|
||||
// Query SQL per recuperare tutti gli ordini con join su service
|
||||
$query = "SELECT o.idorderbook, o.first_name, o.last_name, s.servicename, o.expireon, o.status, o.nticket
|
||||
FROM orderbook o
|
||||
LEFT JOIN service s ON o.idservice = s.idservice
|
||||
$whereClause
|
||||
ORDER BY o.idorderbook DESC";
|
||||
$result = $conn->query($query);
|
||||
$orders = [];
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$orders[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// Query SQL per i DayOff
|
||||
$query_dayoff = "SELECT iddayoff, dayoffdate FROM dayoff WHERE idteacher = '1'";
|
||||
$result_dayoff = $conn->query($query_dayoff);
|
||||
$documents = [];
|
||||
if ($result_dayoff->num_rows > 0) {
|
||||
while ($row = $result_dayoff->fetch_assoc()) {
|
||||
$documents[] = $row;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Prenotazioni YogaSoul</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
// Inizializzazione del Datepicker per i campi DayOff
|
||||
$("#dayoff").datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: 0
|
||||
});
|
||||
|
||||
// Inizializzazione del Datepicker per i campi di scadenza editabili
|
||||
$(document).on('focus', '.expiryDateInput', function() {
|
||||
$(this).datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: 0,
|
||||
onSelect: function(dateText) {
|
||||
let orderId = $(this).data('order-id');
|
||||
console.log("Datepicker selezionato - idorderbook: " + orderId + ", newExpiry: " + dateText);
|
||||
confirmUpdate(orderId, dateText);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Rendere il campo scadenza editabile al click
|
||||
$(document).on('click', '.expiry-date', function() {
|
||||
let orderId = $(this).data('order-id');
|
||||
let currentDate = $(this).text().trim();
|
||||
console.log("Clic su expiry-date - idorderbook: " + orderId + ", currentDate: " + currentDate);
|
||||
if (!orderId) {
|
||||
Swal.fire('Errore!', 'ID ordine non valido.', 'error');
|
||||
return;
|
||||
}
|
||||
$(this).html(`<input type="text" class="form-control expiryDateInput" data-order-id="${orderId}" value="${currentDate}" />`);
|
||||
$(this).find('.expiryDateInput').focus();
|
||||
});
|
||||
|
||||
// Funzione per confermare l'aggiornamento della scadenza
|
||||
function confirmUpdate(orderId, newExpiry) {
|
||||
let originalCell = $(`td.expiry-date[data-order-id="${orderId}"]`);
|
||||
let originalDate = originalCell.text().trim();
|
||||
console.log("Invio AJAX - idorderbook: " + orderId + ", new_expiry: " + newExpiry);
|
||||
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "La data di scadenza verrà modificata!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Sì, modifica!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: 'update_expiry.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
order_id: orderId,
|
||||
new_expiry: newExpiry,
|
||||
update_expiry: 1
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log("Risposta AJAX:", response);
|
||||
if (response.status === 'success') {
|
||||
Swal.fire('Successo!', response.message, 'success');
|
||||
originalCell.text(newExpiry);
|
||||
} else {
|
||||
Swal.fire('Errore!', response.message, 'error');
|
||||
originalCell.text(originalDate);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Errore AJAX:', {
|
||||
status: status,
|
||||
error: error,
|
||||
responseText: xhr.responseText
|
||||
});
|
||||
Swal.fire('Errore!', 'Errore durante la richiesta al server: ' + error, 'error');
|
||||
originalCell.text(originalDate);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
originalCell.text(originalDate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Funzione per confermare la cancellazione
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
.expiry-date {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.expiry-date:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="layout-wrapper">
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Riepilogo Ordini</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<div class="dropdown d-inline-block">
|
||||
<button type="button" class="btn header-item noti-icon" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bx bx-search icon-sm align-middle"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-end p-0">
|
||||
<form class="p-2">
|
||||
<div class="search-box">
|
||||
<div class="position-relative">
|
||||
<input type="text" class="form-control rounded bg-light border-0" placeholder="Search...">
|
||||
<i class="bx bx-search search-icon"></i>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5>Riepilogo Ordini (Amministratore)</h5>
|
||||
<p>Tutti gli ordini registrati</p>
|
||||
<div class="mb-3">
|
||||
<a href="?filter=all" class="btn btn-secondary <?php echo $filter == 'all' ? 'active' : ''; ?>">Tutti</a>
|
||||
<a href="?filter=active" class="btn btn-success <?php echo $filter == 'active' ? 'active' : ''; ?>">Attivi</a>
|
||||
<a href="?filter=expired" class="btn btn-danger <?php echo $filter == 'expired' ? 'active' : ''; ?>">Scaduti</a>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Stato</th>
|
||||
<th>Numero Ordine</th>
|
||||
<th>Nome</th>
|
||||
<th>Cognome</th>
|
||||
<th>Nome Classe</th>
|
||||
<th>Numero Ticket</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($orders as $order) {
|
||||
$isActive = ($order["expireon"] > $today);
|
||||
$badgeClass = $isActive ? 'badge bg-success' : 'badge bg-danger';
|
||||
$badgeText = $isActive ? 'Attivo' : 'Scaduto';
|
||||
?>
|
||||
<tr>
|
||||
<td><span class="<?php echo $badgeClass; ?>"><?php echo $badgeText; ?></span></td>
|
||||
<td><?php echo $order["idorderbook"]; ?></td>
|
||||
<td><?php echo $order["first_name"]; ?></td>
|
||||
<td><?php echo $order["last_name"]; ?></td>
|
||||
<td><?php echo $order["servicename"]; ?></td>
|
||||
<td><?php echo $order["nticket"]; ?></td>
|
||||
<td class="expiry-date" data-order-id="<?php echo $order['idorderbook']; ?>"><?php echo $order["expireon"]; ?></td>
|
||||
<td><?php echo $order["status"]; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
<script src="assets/js/app.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
[15-Oct-2025 15:13:11 UTC] Tentativo di aggiornamento AJAX - idorderbook: 1, new_expiry: 2025-10-16
|
||||
[15-Oct-2025 15:13:19 UTC] Tentativo di aggiornamento AJAX - idorderbook: 1, new_expiry: 2025-10-15
|
||||
[15-Oct-2025 15:13:58 UTC] Tentativo di aggiornamento AJAX - idorderbook: 1, new_expiry: 2025-10-30
|
||||
@@ -0,0 +1 @@
|
||||
<?php phpinfo();
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
// Abilita visualizzazione errori PHP (solo per debug)
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Inizializza contatore e log
|
||||
$emailCount = 0;
|
||||
$errors = [];
|
||||
$logFile = 'promemoria_cron_log.txt';
|
||||
$logMessage = "Esecuzione cron: " . date('Y-m-d H:i:s') . "\n";
|
||||
|
||||
// Genera UUID per tutti i record senza token
|
||||
$updateQuery = "UPDATE bookingclass
|
||||
SET cancellation_token = UUID()
|
||||
WHERE status = 'booked'
|
||||
AND cancellation_token IS NULL";
|
||||
$updateStmt = $conn->prepare($updateQuery);
|
||||
if ($updateStmt) {
|
||||
$updateStmt->execute();
|
||||
$affectedRows = $updateStmt->affected_rows;
|
||||
$logMessage .= "Generati $affectedRows token UUID per prenotazioni senza token.\n";
|
||||
} else {
|
||||
$errors[] = "Errore preparazione query per generazione token: " . $conn->error;
|
||||
$logMessage .= "Errore generazione token: " . $conn->error . "\n";
|
||||
}
|
||||
|
||||
// Seleziona prenotazioni per domani (dalle 17:00 in poi) e dopodomani (fino alle 16:59)
|
||||
$tomorrow = date('Y-m-d', strtotime('+1 day'));
|
||||
$dayAfterTomorrow = date('Y-m-d', strtotime('+2 days'));
|
||||
$query = "SELECT bc.*, au.email, au.first_name, s.servicename
|
||||
FROM bookingclass bc
|
||||
LEFT JOIN auth_users au ON bc.iduser = au.id
|
||||
LEFT JOIN service s ON bc.idservice = s.idservice
|
||||
WHERE bc.status = 'booked' AND (
|
||||
(DATE(bc.bookingstart) = ? AND TIME(bc.bookingstart) >= '17:00:00') OR
|
||||
(DATE(bc.bookingstart) = ? AND TIME(bc.bookingstart) <= '16:59:59')
|
||||
)";
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
if (!$stmt) {
|
||||
$errors[] = "Errore preparazione query: " . $conn->error;
|
||||
file_put_contents($logFile, $logMessage . "Errore query: " . $conn->error . "\n", FILE_APPEND);
|
||||
echo "Errore preparazione query: " . $conn->error;
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->bind_param("ss", $tomorrow, $dayAfterTomorrow);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows === 0) {
|
||||
$logMessage .= "Nessuna prenotazione trovata per domani (dalle 17:00) o dopodomani (fino alle 16:59).\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "Nessuna prenotazione trovata.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$idbookingclass = $row['idbookingclass'];
|
||||
$token = $row['cancellation_token'];
|
||||
|
||||
// Verifica che il token esista
|
||||
if (empty($token)) {
|
||||
$errors[] = "Token mancante per ID $idbookingclass dopo aggiornamento UUID.";
|
||||
$logMessage .= "Token mancante per ID $idbookingclass dopo aggiornamento UUID.\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$firstname = $row['first_name'] ?? 'Utente';
|
||||
$emailuser = $row['email'];
|
||||
$servicename = $row['servicename'] ?? 'Sconosciuta';
|
||||
$bookingstart = $row['bookingstart'];
|
||||
$dataformat = date("d-m-Y H:i", strtotime($bookingstart));
|
||||
|
||||
// Determina il limite di cancellazione in base all'orario della lezione
|
||||
$lessonTime = new DateTime($bookingstart);
|
||||
$isTomorrow = $lessonTime->format('Y-m-d') === $tomorrow;
|
||||
$hour = (int)$lessonTime->format('H');
|
||||
$minute = (int)$lessonTime->format('i');
|
||||
$isBefore1700 = ($hour < 17) || ($hour === 17 && $minute === 0);
|
||||
$cancellationDeadline = $isBefore1700 ? "00:01" : "12:00";
|
||||
|
||||
// Verifica email valida
|
||||
if (!filter_var($emailuser, FILTER_VALIDATE_EMAIL)) {
|
||||
$errors[] = "Email non valida per ID $idbookingclass: $emailuser";
|
||||
$logMessage .= "Email non valida per ID $idbookingclass: $emailuser\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Link cancellazione
|
||||
$link = "https://yogibook.yogasoul.it/cancella-prenotazione.php?idbookingclass=$idbookingclass&token=$token";
|
||||
|
||||
// Messaggio email
|
||||
$message = "<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;'>Promemoria: hai la lezione $servicename del $dataformat.</span></p>
|
||||
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Puoi cancellarla fino alle $cancellationDeadline del giorno della lezione cliccando qui:</span></p>
|
||||
<a href='$link' target='_blank'>Cancella prenotazione</a>
|
||||
<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>";
|
||||
|
||||
// Definisci $messageedit per il template
|
||||
$messageedit = $message;
|
||||
|
||||
// Definisci $buttonedit
|
||||
$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);
|
||||
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;
|
||||
|
||||
if (!file_exists('mail/emailtemplate2.php')) {
|
||||
throw new Exception("File emailtemplate2.php non trovato.");
|
||||
}
|
||||
include('mail/emailtemplate2.php');
|
||||
|
||||
if (!isset($mailmessage1)) {
|
||||
throw new Exception("Variabile \$mailmessage1 non definita in emailtemplate2.php.");
|
||||
}
|
||||
|
||||
$htmlContent = str_replace('{message}', $message, $mailmessage1);
|
||||
|
||||
$mail->From = 'info@yogasoul.it';
|
||||
$mail->FromName = 'YogiBook [YogaSoul]';
|
||||
$mail->addAddress($emailuser);
|
||||
$mail->Subject = "YogiBook - Promemoria lezione!";
|
||||
$mail->Body = $htmlContent;
|
||||
$mail->AltBody = 'Promemoria lezione.';
|
||||
|
||||
$mail->send();
|
||||
$emailCount++;
|
||||
$logMessage .= "Email inviata a $emailuser per lezione ID $idbookingclass ($dataformat)\n";
|
||||
} catch (Exception $e) {
|
||||
$errors[] = "Errore invio email a $emailuser (ID $idbookingclass): " . $mail->ErrorInfo;
|
||||
$logMessage .= "Errore invio a $emailuser (ID $idbookingclass): " . $mail->ErrorInfo . "\n";
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
// Scrivi log
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
|
||||
// Output debug
|
||||
echo "Esecuzione completata: $emailCount email inviate.\n";
|
||||
if (!empty($errors)) {
|
||||
echo "Errori rilevati:\n";
|
||||
foreach ($errors as $error) {
|
||||
echo "- $error\n";
|
||||
}
|
||||
} else {
|
||||
echo "Nessun errore.\n";
|
||||
}
|
||||
echo "Dettagli nel file di log: $logFile\n";
|
||||
|
||||
$conn->close();
|
||||
@@ -0,0 +1,19 @@
|
||||
Esecuzione cron: 2025-10-08 13:39:42
|
||||
Esecuzione cron: 2025-10-08 13:40:48
|
||||
Esecuzione cron: 2025-10-08 13:54:46
|
||||
Email inviata a info@claudiosironi.com per lezione ID 8 (09-10-2025 18:15)
|
||||
Esecuzione cron: 2025-10-13 14:29:12
|
||||
Generati 0 token UUID per prenotazioni senza token.
|
||||
Email inviata a info@claudiosironi.com per lezione ID 4 (14-10-2025 18:15)
|
||||
Esecuzione cron: 2025-11-26 16:39:15
|
||||
Generati 7 token UUID per prenotazioni senza token.
|
||||
Nessuna prenotazione trovata per domani (dalle 17:00) o dopodomani (fino alle 16:59).
|
||||
Esecuzione cron: 2025-11-26 16:44:22
|
||||
Generati 0 token UUID per prenotazioni senza token.
|
||||
Nessuna prenotazione trovata per domani (dalle 17:00) o dopodomani (fino alle 16:59).
|
||||
Esecuzione cron: 2025-11-26 16:44:25
|
||||
Generati 0 token UUID per prenotazioni senza token.
|
||||
Nessuna prenotazione trovata per domani (dalle 17:00) o dopodomani (fino alle 16:59).
|
||||
Esecuzione cron: 2025-11-26 16:44:28
|
||||
Generati 0 token UUID per prenotazioni senza token.
|
||||
Nessuna prenotazione trovata per domani (dalle 17:00) o dopodomani (fino alle 16:59).
|
||||
@@ -153,12 +153,78 @@ if ($service_schedule_result->num_rows > 0) {
|
||||
$stmt_status->close();
|
||||
echo "Aggiornato lo status a 'booked' per l'ordine ID: $order_id\n";
|
||||
|
||||
// Gestione della scadenza: usa il parametro GET se fornito, altrimenti calcola come prima (ma qui assumo sia già calcolato via AJAX, per fallback calcola)
|
||||
$expireon = null;
|
||||
if (isset($_GET['expiry_date']) && !empty($_GET['expiry_date'])) {
|
||||
$expireon = $_GET['expiry_date'];
|
||||
} else {
|
||||
// Fallback: calcola se non fornito (copia la logica da calculate_expiry.php se vuoi mantenerla)
|
||||
$expiry_lessons_query = "SELECT expirylessons FROM expiryparameter WHERE quantityclass = ?";
|
||||
$stmt_expiry_lessons = $conn->prepare($expiry_lessons_query);
|
||||
$stmt_expiry_lessons->bind_param("i", $quantity_class);
|
||||
$stmt_expiry_lessons->execute();
|
||||
$expiry_lessons_result = $stmt_expiry_lessons->get_result();
|
||||
if ($expiry_lessons_result->num_rows > 0) {
|
||||
$expiry_row = $expiry_lessons_result->fetch_assoc();
|
||||
$expirylessons = $expiry_row['expirylessons'];
|
||||
$expiry_date_query = "SELECT dateschedule FROM serviceschedule WHERE idservice = ? AND dateschedule >= ? ORDER BY dateschedule LIMIT ?, 1";
|
||||
$stmt_expiry_date = $conn->prepare($expiry_date_query);
|
||||
$offset = $expirylessons - 1;
|
||||
$stmt_expiry_date->bind_param("isi", $service_id, $first_lesson_date, $offset);
|
||||
$stmt_expiry_date->execute();
|
||||
$expiry_date_result = $stmt_expiry_date->get_result();
|
||||
if ($expiry_date_result->num_rows > 0) {
|
||||
$date_row = $expiry_date_result->fetch_assoc();
|
||||
$expireon = $date_row['dateschedule'];
|
||||
}
|
||||
$stmt_expiry_date->close();
|
||||
}
|
||||
$stmt_expiry_lessons->close();
|
||||
}
|
||||
|
||||
if ($expireon) {
|
||||
// Aggiorna expireon
|
||||
$update_expiry_query = "UPDATE orderbook SET expireon = ? WHERE idorderbook = ?";
|
||||
$stmt_update_expiry = $conn->prepare($update_expiry_query);
|
||||
$stmt_update_expiry->bind_param("si", $expireon, $order_id);
|
||||
$stmt_update_expiry->execute();
|
||||
$stmt_update_expiry->close();
|
||||
echo "Aggiornata la colonna expireon per l'ordine ID: $order_id ($expireon)\n";
|
||||
} else {
|
||||
echo "Nessuna scadenza impostata per l'ordine ID: $order_id\n";
|
||||
}
|
||||
|
||||
// Recupera e aggiorna maxreschedule (invariato)
|
||||
$reschedule_number_query = "SELECT reschedulenumber FROM expiryparameter WHERE quantityclass = ?";
|
||||
$stmt_reschedule = $conn->prepare($reschedule_number_query);
|
||||
$stmt_reschedule->bind_param("i", $quantity_class);
|
||||
$stmt_reschedule->execute();
|
||||
$reschedule_number_result = $stmt_reschedule->get_result();
|
||||
|
||||
if ($reschedule_number_result && $reschedule_number_result->num_rows > 0) {
|
||||
$reschedule_row = $reschedule_number_result->fetch_assoc();
|
||||
$reschedule_number = $reschedule_row['reschedulenumber'];
|
||||
|
||||
$update_max_reschedule_query = "UPDATE orderbook SET maxreschedule = ? WHERE idorderbook = ?";
|
||||
$stmt_max_reschedule = $conn->prepare($update_max_reschedule_query);
|
||||
$stmt_max_reschedule->bind_param("ii", $reschedule_number, $order_id);
|
||||
$stmt_max_reschedule->execute();
|
||||
$stmt_max_reschedule->close();
|
||||
|
||||
echo "Aggiornata la colonna maxreschedule per l'ordine ID: $order_id\n";
|
||||
} else {
|
||||
echo "Nessun record trovato in expiryparameter per quantityclass: $quantity_class\n";
|
||||
}
|
||||
$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>
|
||||
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Il tuo abbonamento scade il: <strong>$expireon</strong></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>
|
||||
<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>
|
||||
@@ -182,89 +248,20 @@ if ($service_schedule_result->num_rows > 0) {
|
||||
$mail->SMTPSecure = 'tls';
|
||||
$mail->Port = '587';
|
||||
include('mail/emailtemplate2.php');
|
||||
$htmlContent = $mailmessage1;
|
||||
$htmlContent = $mailmessage1; // Assumo che $mailmessage1 sia il template; se devi integrare $messageedit qui, dimmelo
|
||||
$mail->From = 'info@yogasoul.it';
|
||||
$mail->FromName = 'YogiBook [YogaSoul]';
|
||||
$mail->addAddress($billing_email);
|
||||
$mail->Subject = "YogiBook - Prenotazioni effettuate per il tuo ordine $ordern";
|
||||
$mail->Body = $htmlContent;
|
||||
$mail->Body = str_replace(['{messageedit}', '{buttonedit}'], [$messageedit, $buttonedit], $htmlContent); // Se il template ha placeholders, altrimenti usa direttamente $messageedit come Body
|
||||
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
|
||||
$mail->send();
|
||||
|
||||
header("Location: orderbooklist.php");
|
||||
exit();
|
||||
} else {
|
||||
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();
|
||||
|
||||
// Recupera il numero di lezioni da expiryparameter (ora expirylessons)
|
||||
$expiry_lessons_query = "SELECT expirylessons FROM expiryparameter WHERE quantityclass = ?";
|
||||
$stmt_expiry_lessons = $conn->prepare($expiry_lessons_query);
|
||||
$stmt_expiry_lessons->bind_param("i", $quantity_class);
|
||||
$stmt_expiry_lessons->execute();
|
||||
$expiry_lessons_result = $stmt_expiry_lessons->get_result();
|
||||
|
||||
if ($expiry_lessons_result && $expiry_lessons_result->num_rows > 0) {
|
||||
$expiry_row = $expiry_lessons_result->fetch_assoc();
|
||||
$expirylessons = $expiry_row['expirylessons'];
|
||||
|
||||
// Calcola la data della expirylessons-esima lezione disponibile
|
||||
$expiry_date_query = "SELECT dateschedule FROM serviceschedule WHERE idservice = ? AND dateschedule >= ? ORDER BY dateschedule LIMIT ?, 1";
|
||||
$stmt_expiry_date = $conn->prepare($expiry_date_query);
|
||||
$offset = $expirylessons - 1; // Per prendere la n-esima riga (0-based offset)
|
||||
$stmt_expiry_date->bind_param("isi", $service_id, $first_lesson_date, $offset);
|
||||
$stmt_expiry_date->execute();
|
||||
$expiry_date_result = $stmt_expiry_date->get_result();
|
||||
|
||||
if ($expiry_date_result->num_rows > 0) {
|
||||
$date_row = $expiry_date_result->fetch_assoc();
|
||||
$expireon = $date_row['dateschedule'];
|
||||
|
||||
// Aggiorna expireon in orderbook
|
||||
$update_expiry_query = "UPDATE orderbook SET expireon = ? WHERE idorderbook = ?";
|
||||
$stmt_update_expiry = $conn->prepare($update_expiry_query);
|
||||
$stmt_update_expiry->bind_param("si", $expireon, $order_id);
|
||||
$stmt_update_expiry->execute();
|
||||
$stmt_update_expiry->close();
|
||||
|
||||
echo "Aggiornata la colonna expireon per l'ordine ID: $order_id (scadenza alla lezione n. $expirylessons: $expireon)\n";
|
||||
} else {
|
||||
// Non abbastanza lezioni: imposta a NULL o gestisci come preferisci
|
||||
$update_expiry_query = "UPDATE orderbook SET expireon = NULL WHERE idorderbook = ?";
|
||||
$stmt_update_expiry = $conn->prepare($update_expiry_query);
|
||||
$stmt_update_expiry->bind_param("i", $order_id);
|
||||
$stmt_update_expiry->execute();
|
||||
$stmt_update_expiry->close();
|
||||
|
||||
echo "Non abbastanza lezioni disponibili per calcolare la scadenza per l'ordine ID: $order_id\n";
|
||||
}
|
||||
$stmt_expiry_date->close();
|
||||
} else {
|
||||
echo "Nessun record trovato in expiryparameter per quantityclass: $quantity_class\n";
|
||||
}
|
||||
$stmt_expiry_lessons->close();
|
||||
|
||||
// Recupera il numero da expiryparameter per maxreschedule
|
||||
$reschedule_number_query = "SELECT reschedulenumber FROM expiryparameter WHERE quantityclass = ?";
|
||||
$stmt_reschedule = $conn->prepare($reschedule_number_query);
|
||||
$stmt_reschedule->bind_param("i", $quantity_class);
|
||||
$stmt_reschedule->execute();
|
||||
$reschedule_number_result = $stmt_reschedule->get_result();
|
||||
|
||||
if ($reschedule_number_result && $reschedule_number_result->num_rows > 0) {
|
||||
$reschedule_row = $reschedule_number_result->fetch_assoc();
|
||||
$reschedule_number = $reschedule_row['reschedulenumber'];
|
||||
|
||||
$update_max_reschedule_query = "UPDATE orderbook SET maxreschedule = ? WHERE idorderbook = ?";
|
||||
$stmt_max_reschedule = $conn->prepare($update_max_reschedule_query);
|
||||
$stmt_max_reschedule->bind_param("ii", $reschedule_number, $order_id);
|
||||
$stmt_max_reschedule->execute();
|
||||
$stmt_max_reschedule->close();
|
||||
|
||||
echo "Aggiornata la colonna maxreschedule per l'ordine ID: $order_id\n";
|
||||
header("Location: orderbooklist.php");
|
||||
exit();
|
||||
} else {
|
||||
echo "Nessun record trovato in expiryparameter per quantityclass: $quantity_class\n";
|
||||
}
|
||||
$stmt_reschedule->close();
|
||||
|
||||
$conn->close();
|
||||
|
||||
@@ -0,0 +1,407 @@
|
||||
<?php
|
||||
// Abilita visualizzazione errori PHP (solo per debug)
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Includi headscript.php
|
||||
require_once('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Inizializza log
|
||||
$logFile = 'rebook_from_cancel_log.txt';
|
||||
$logMessage = "Esecuzione riprogrammazione: " . date('Y-m-d H:i:s') . "\n";
|
||||
|
||||
// Log del database utilizzato
|
||||
$logMessage .= "Database connesso: $dbname\n";
|
||||
|
||||
// Recupera parametri GET
|
||||
if (!isset($_GET['idbookingclass']) || !isset($_GET['token'])) {
|
||||
$logMessage .= "Parametri mancanti: idbookingclass o token\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Riprogrammazione non possibile</h1>";
|
||||
echo "<p>Parametri mancanti.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$idbookingclass = filter_var($_GET['idbookingclass'], FILTER_VALIDATE_INT);
|
||||
$token = $_GET['token'];
|
||||
|
||||
if (!$idbookingclass) {
|
||||
$logMessage .= "Errore: idbookingclass non valido: " . $_GET['idbookingclass'] . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Riprogrammazione non possibile</h1>";
|
||||
echo "<p>Parametro idbookingclass non valido.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verifica validità della prenotazione
|
||||
$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 auth_users au ON bc.iduser = au.id
|
||||
LEFT JOIN service s ON bc.idservice = s.idservice
|
||||
WHERE bc.idbookingclass = ?
|
||||
AND bc.cancellation_token = ?
|
||||
AND bc.status = 'booked'
|
||||
AND bc.bookingstart > NOW()";
|
||||
$stmt = $conn->prepare($query);
|
||||
|
||||
if (!$stmt) {
|
||||
$logMessage .= "Errore preparazione query per ID $idbookingclass: " . $conn->error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Riprogrammazione non possibile</h1>";
|
||||
echo "<p>Errore nella preparazione della query.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->bind_param("is", $idbookingclass, $token);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows === 0) {
|
||||
$logMessage .= "Tentativo di riprogrammazione fallito per ID $idbookingclass: link non valido o lezione non prenotata\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Riprogrammazione non possibile</h1>";
|
||||
echo "<p>Il link non è valido o la lezione non è prenotata.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$bookingstart = $row['bookingstart'];
|
||||
$newtimeformat = date("d-m-Y H:i", strtotime($bookingstart));
|
||||
$expireon = $row['expireon'] ? date("d-m-Y", strtotime($row['expireon'])) : "sconosciuta";
|
||||
$emailuser = $row['email'];
|
||||
$firstname = $row['first_name'] ?? 'Utente';
|
||||
$servicename = $row['servicename'] ?? 'Sconosciuta';
|
||||
$iduser = $row['iduser'];
|
||||
$idserviceordered = $row['idservice'];
|
||||
$idorder = $row['idorder'];
|
||||
|
||||
// Verifica il limite di cancellazione/riprogrammazione
|
||||
$lessonTime = new DateTime($bookingstart);
|
||||
$hour = (int)$lessonTime->format('H');
|
||||
$minute = (int)$lessonTime->format('i');
|
||||
$isBefore1700 = ($hour < 17) || ($hour === 17 && $minute === 0);
|
||||
$currentTime = new DateTime();
|
||||
$lessonDate = $lessonTime->format('Y-m-d');
|
||||
|
||||
if ($isBefore1700) {
|
||||
$deadline = new DateTime("$lessonDate 00:01:00");
|
||||
} else {
|
||||
$deadline = new DateTime("$lessonDate 12:00:00");
|
||||
}
|
||||
|
||||
if ($currentTime > $deadline) {
|
||||
$logMessage .= "Tentativo di riprogrammazione fallito per ID $idbookingclass: orario oltre il limite (" . $deadline->format('Y-m-d H:i:s') . ")\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Riprogrammazione non possibile</h1>";
|
||||
echo "<p>Non è possibile riprogrammare la lezione dopo le " . ($isBefore1700 ? "00:01" : "12:00") . " del giorno della lezione.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupera la data di scadenza dell'ordine
|
||||
$expiryDate = new DateTime($row['expireon']);
|
||||
|
||||
// Query sulla tabella associateclass
|
||||
$sql = "SELECT idassociateservice FROM associateclass WHERE idmainservice = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $idserviceordered);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$idassociateservices = array();
|
||||
array_push($idassociateservices, $idserviceordered);
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$idassociateservices[] = $row['idassociateservice'];
|
||||
}
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
// Verifica se è stata specificata una richiesta per cambiare il mese
|
||||
if (isset($_GET['prev_month'])) {
|
||||
$currentMonthStart = $_GET['prev_month'] . '-01';
|
||||
} elseif (isset($_GET['next_month'])) {
|
||||
$currentMonthStart = $_GET['next_month'] . '-01';
|
||||
} else {
|
||||
$currentMonthStart = date("Y-m-01");
|
||||
}
|
||||
|
||||
$currentMonthEnd = date("Y-m-t", strtotime($currentMonthStart));
|
||||
|
||||
// Aggiungi filtro per la data di scadenza
|
||||
$expiryCondition = '';
|
||||
if ($expiryDate) {
|
||||
$expiryCondition = "AND ss.dateschedule <= '{$expiryDate->format('Y-m-d 23:59:59')}'";
|
||||
}
|
||||
|
||||
// Query per le lezioni disponibili
|
||||
$placeholders = implode(',', array_fill(0, count($idassociateservices), '?'));
|
||||
$query = "SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
WHERE ss.dateschedule BETWEEN ? AND DATE_ADD(?, INTERVAL 1 DAY)
|
||||
$expiryCondition
|
||||
AND ss.idservice IN ($placeholders)
|
||||
ORDER BY ss.dateschedule";
|
||||
$logMessage .= "Query lezioni disponibili: $query\n";
|
||||
$logMessage .= "Parametri: " . json_encode(array_merge([$currentMonthStart, $currentMonthEnd], $idassociateservices)) . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
if (!$stmt) {
|
||||
$logMessage .= "Errore preparazione query per lezioni disponibili: " . $conn->error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Errore</h1>";
|
||||
echo "<p>Errore nella preparazione della query per le lezioni disponibili.</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$types = 'ss' . str_repeat('i', count($idassociateservices));
|
||||
$params = array_merge([$currentMonthStart, $currentMonthEnd], $idassociateservices);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$bookedclass = $stmt->get_result();
|
||||
if ($conn->error) {
|
||||
$logMessage .= "Errore esecuzione query per lezioni disponibili: " . $conn->error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
echo "<h1>Errore</h1>";
|
||||
echo "<p>Errore nell'esecuzione della query: " . $conn->error . "</p>";
|
||||
echo "<a href='https://yogibook.yogasoul.it'>Torna al portale</a>";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Mappa dei mesi in italiano
|
||||
$italianMonths = [
|
||||
"January" => "Gennaio",
|
||||
"February" => "Febbraio",
|
||||
"March" => "Marzo",
|
||||
"April" => "Aprile",
|
||||
"May" => "Maggio",
|
||||
"June" => "Giugno",
|
||||
"July" => "Luglio",
|
||||
"August" => "Agosto",
|
||||
"September" => "Settembre",
|
||||
"October" => "Ottobre",
|
||||
"November" => "Novembre",
|
||||
"December" => "Dicembre"
|
||||
];
|
||||
|
||||
$logMessage .= "Caricata pagina di riprogrammazione per ID $idbookingclass, mese: $currentMonthStart\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Riprogramma Lezione</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" author />
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="assets/css/app.min.css" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.month-navigation {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.month-nav-button {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.current-month {
|
||||
font-size: 24px;
|
||||
margin: 0 20px;
|
||||
}
|
||||
|
||||
.booking-details {
|
||||
margin-top: 10px;
|
||||
border-top: 1px solid #ccc;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.booking-button {
|
||||
background-color: #1ebf99;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.booking-button:hover {
|
||||
background-color: #17a081;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Riprogramma Lezione</h1>
|
||||
<p>Lezione attuale: <?php echo htmlspecialchars($servicename); ?> del <?php echo htmlspecialchars($newtimeformat); ?></p>
|
||||
<p>Scadenza abbonamento: <?php echo htmlspecialchars($expireon); ?></p>
|
||||
<div class="month-navigation">
|
||||
<button class="month-nav-button" onclick="window.location.href='?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&prev_month=<?php echo date('Y-m', strtotime($currentMonthStart . ' -1 month')); ?>'"><i class="fas fa-chevron-left"></i></button>
|
||||
<span class="current-month"><?php echo $italianMonths[date('F', strtotime($currentMonthStart))]; ?> <?php echo date('Y', strtotime($currentMonthStart)); ?></span>
|
||||
<button class="month-nav-button" onclick="window.location.href='?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&next_month=<?php echo date('Y-m', strtotime($currentMonthStart . ' +1 month')); ?>'"><i class="fas fa-chevron-right"></i></button>
|
||||
</div>
|
||||
<?php while ($row = $bookedclass->fetch_assoc()) { ?>
|
||||
<div class="custom-card" onclick="this.classList.toggle('expanded')">
|
||||
<div class="custom-date-box" style="background-color: <?php echo htmlspecialchars($row['colorclass']); ?>;">
|
||||
<div class="custom-day"><?php echo date('d', strtotime($row['dateschedule'])); ?></div>
|
||||
<div class="custom-month"><?php echo $italianMonths[date('F', strtotime($row['dateschedule']))]; ?></div>
|
||||
</div>
|
||||
<div class="custom-event-details">
|
||||
<h3 class="custom-heading"><?php echo htmlspecialchars($row['servicename']); ?></h3>
|
||||
<p class="custom-paragraph"><strong>Giorno:</strong> <?php echo htmlspecialchars($row['scheduleday']); ?></p>
|
||||
<p class="custom-paragraph"><strong>Orario:</strong> <?php echo htmlspecialchars($row['startingtime']); ?></p>
|
||||
<p class="custom-paragraph"><strong>Durata:</strong> <?php echo htmlspecialchars($row['durationtime']); ?> ore</p>
|
||||
<div class="custom-actions">
|
||||
<button class="custom-action-button booking-button" onclick="window.location.href='book_lesson.php?idserviceschedule=<?php echo $row['idserviceschedule']; ?>&idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>'">Prenota</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log("Caricata pagina di riprogrammazione per ID <?php echo $idbookingclass; ?>, mese: <?php echo $currentMonthStart; ?>");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,63 @@
|
||||
Esecuzione riprogrammazione: 2025-10-13 15:06:31
|
||||
Database connesso: yogibookaury
|
||||
Query lezioni disponibili: SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
WHERE ss.dateschedule BETWEEN ? AND DATE_ADD(?, INTERVAL 1 DAY)
|
||||
AND ss.dateschedule <= '2025-10-30 23:59:59'
|
||||
AND ss.idservice IN (?,?,?,?,?,?,?,?)
|
||||
ORDER BY ss.dateschedule
|
||||
Parametri: ["2025-10-01","2025-10-31",42,41,42,43,45,47,44,48]
|
||||
Esecuzione riprogrammazione: 2025-10-13 15:06:31
|
||||
Database connesso: yogibookaury
|
||||
Query lezioni disponibili: SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
WHERE ss.dateschedule BETWEEN ? AND DATE_ADD(?, INTERVAL 1 DAY)
|
||||
AND ss.dateschedule <= '2025-10-30 23:59:59'
|
||||
AND ss.idservice IN (?,?,?,?,?,?,?,?)
|
||||
ORDER BY ss.dateschedule
|
||||
Parametri: ["2025-10-01","2025-10-31",42,41,42,43,45,47,44,48]
|
||||
Caricata pagina di riprogrammazione per ID 4, mese: 2025-10-01
|
||||
Esecuzione riprogrammazione: 2025-10-13 15:06:38
|
||||
Database connesso: yogibookaury
|
||||
Query lezioni disponibili: SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
WHERE ss.dateschedule BETWEEN ? AND DATE_ADD(?, INTERVAL 1 DAY)
|
||||
AND ss.dateschedule <= '2025-10-30 23:59:59'
|
||||
AND ss.idservice IN (?,?,?,?,?,?,?,?)
|
||||
ORDER BY ss.dateschedule
|
||||
Parametri: ["2025-11-01","2025-11-30",42,41,42,43,45,47,44,48]
|
||||
Esecuzione riprogrammazione: 2025-10-13 15:06:38
|
||||
Database connesso: yogibookaury
|
||||
Query lezioni disponibili: SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
WHERE ss.dateschedule BETWEEN ? AND DATE_ADD(?, INTERVAL 1 DAY)
|
||||
AND ss.dateschedule <= '2025-10-30 23:59:59'
|
||||
AND ss.idservice IN (?,?,?,?,?,?,?,?)
|
||||
ORDER BY ss.dateschedule
|
||||
Parametri: ["2025-11-01","2025-11-30",42,41,42,43,45,47,44,48]
|
||||
Caricata pagina di riprogrammazione per ID 4, mese: 2025-11-01
|
||||
Esecuzione riprogrammazione: 2025-10-13 15:06:41
|
||||
Database connesso: yogibookaury
|
||||
Query lezioni disponibili: SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
WHERE ss.dateschedule BETWEEN ? AND DATE_ADD(?, INTERVAL 1 DAY)
|
||||
AND ss.dateschedule <= '2025-10-30 23:59:59'
|
||||
AND ss.idservice IN (?,?,?,?,?,?,?,?)
|
||||
ORDER BY ss.dateschedule
|
||||
Parametri: ["2025-10-01","2025-10-31",42,41,42,43,45,47,44,48]
|
||||
Esecuzione riprogrammazione: 2025-10-13 15:06:41
|
||||
Database connesso: yogibookaury
|
||||
Query lezioni disponibili: SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
FROM serviceschedule ss
|
||||
LEFT JOIN service s ON ss.idservice = s.idservice
|
||||
WHERE ss.dateschedule BETWEEN ? AND DATE_ADD(?, INTERVAL 1 DAY)
|
||||
AND ss.dateschedule <= '2025-10-30 23:59:59'
|
||||
AND ss.idservice IN (?,?,?,?,?,?,?,?)
|
||||
ORDER BY ss.dateschedule
|
||||
Parametri: ["2025-10-01","2025-10-31",42,41,42,43,45,47,44,48]
|
||||
Caricata pagina di riprogrammazione per ID 4, mese: 2025-10-01
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
require_once('include/headscript.php');
|
||||
|
||||
$conn = mysqli_connect($servername, $username, $password, $dbname);
|
||||
|
||||
if (!$conn) {
|
||||
die(json_encode(['success' => false, 'message' => 'Connessione al database fallita']));
|
||||
}
|
||||
|
||||
$id_booking_class = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
$class_id = isset($_POST['class_id']) ? intval($_POST['class_id']) : 0;
|
||||
$new_date = isset($_POST['new_date']) ? $_POST['new_date'] : '';
|
||||
|
||||
if ($id_booking_class <= 0 || $class_id <= 0 || empty($new_date)) {
|
||||
die(json_encode(['success' => false, 'message' => 'Dati non validi']));
|
||||
}
|
||||
|
||||
// Ottieni i dettagli della classe attuale
|
||||
$sql = "SELECT bookingstart, servicename, day, time FROM bookingclass WHERE idbookingclass = ?";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
mysqli_stmt_bind_param($stmt, 'i', $id_booking_class);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$current_class = mysqli_fetch_assoc($result);
|
||||
|
||||
if (!$current_class) {
|
||||
die(json_encode(['success' => false, 'message' => 'Lezione non trovata']));
|
||||
}
|
||||
|
||||
// Ottieni i dettagli della nuova classe
|
||||
$sql = "SELECT servicename, day, time FROM classes WHERE id = ?";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
mysqli_stmt_bind_param($stmt, 'i', $class_id);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$new_class = mysqli_fetch_assoc($result);
|
||||
|
||||
if (!$new_class) {
|
||||
die(json_encode(['success' => false, 'message' => 'Classe non trovata']));
|
||||
}
|
||||
|
||||
// Aggiorna la lezione
|
||||
$sql = "UPDATE bookingclass
|
||||
SET bookingstart = ?, prevbookingstart = ?, servicename = ?, day = ?, time = ?
|
||||
WHERE idbookingclass = ?";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
$new_bookingstart = $new_date . ' ' . $new_class['time'] . ':00';
|
||||
mysqli_stmt_bind_param($stmt, 'sssssi', $new_bookingstart, $current_class['bookingstart'], $new_class['servicename'], $new_class['day'], $new_class['time'], $id_booking_class);
|
||||
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore durante l\'aggiornamento della lezione']);
|
||||
}
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($conn);
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once('Connections/bkngstm.php');
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
if (isset($_POST['idbookingclass'])) {
|
||||
$idbookingclass = $_POST['idbookingclass'];
|
||||
|
||||
$query = "UPDATE bookingclass SET lostlesson = 'N' WHERE idbookingclass = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("i", $idbookingclass);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => $conn->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
+313
-369
@@ -1,6 +1,6 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php // optionquery
|
||||
$optionquery = new WA_MySQLi_RS("optionquery",$bkngstm,0);
|
||||
$optionquery = new WA_MySQLi_RS("optionquery", $bkngstm, 0);
|
||||
$optionquery->setQuery("SELECT * FROM option");
|
||||
$optionquery->execute();
|
||||
?>
|
||||
@@ -8,410 +8,354 @@ $optionquery->execute();
|
||||
<?php
|
||||
// Verifica se è stato inviato un modulo
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Verifica se è stato caricato un file correttamente
|
||||
if (isset($_FILES["fileToUpload"]) && $_FILES["fileToUpload"]["error"] === UPLOAD_ERR_OK) {
|
||||
|
||||
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica la connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Ottieni l'ID dell'utente (da dove viene?)
|
||||
$iduserlogin = $_POST["iduserlogin"];
|
||||
|
||||
|
||||
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
// Verifica se è stato caricato un file correttamente
|
||||
if (isset($_FILES["fileToUpload"]) && $_FILES["fileToUpload"]["error"] === UPLOAD_ERR_OK) {
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica la connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Ottieni l'ID dell'utente (da dove viene?)
|
||||
$iduserlogin = $_POST["iduserlogin"];
|
||||
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica la connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Query per selezionare i dati filtrati per iduser
|
||||
$query = "SELECT * FROM orderbook LEFT JOIN service ON orderbook.idservice=service.idservice WHERE iduser = '$iduserlogin'";
|
||||
$result = $conn->query($query);
|
||||
// Query per selezionare i dati filtrati per iduser, includendo servicename
|
||||
$query = "SELECT orderbook.idorderbook, orderbook.nticket, orderbook.expireon, orderbook.idservice, service.servicename
|
||||
FROM orderbook LEFT JOIN service ON orderbook.idservice=service.idservice
|
||||
WHERE orderbook.iduser = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("i", $iduserlogin);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// Array per memorizzare i risultati
|
||||
$documents = array();
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$documents[] = $row;
|
||||
$documents[] = $row;
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Prenotazioni YogaSoul</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Prenotazioni YogaSoul</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSOul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({ dateFormat: "yy-mm-dd" });
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-date-box, .custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-disabled {
|
||||
background-color: #dc3545 !important;
|
||||
color: white !important;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-expired {
|
||||
background-color: #ff8c00 !important;
|
||||
color: white !important;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- <body data-layout="horizontal"> -->
|
||||
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-flex">
|
||||
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start right Content here -->
|
||||
<!-- ============================================================== -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?> </h5>
|
||||
<p>Di seguito puoi visualizzare i tuoi ordini</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<?php
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// ID dell'utente per il quale vuoi filtrare gli ordini
|
||||
$userid = $iduserlogin;
|
||||
|
||||
// Query per ottenere la somma dei ticket per ogni ordine dell'utente
|
||||
$query = "SELECT iduser, idorderbook, SUM(nticket) as total_tickets
|
||||
FROM orderbook
|
||||
WHERE iduser = $userid
|
||||
GROUP BY iduser";
|
||||
|
||||
$result = $conn->query($query);
|
||||
|
||||
if (!$result) {
|
||||
die("Query fallita: " . $conn->error);
|
||||
}
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$idOrdine = $row["idorderbook"];
|
||||
$totalTickets = $row["total_tickets"];
|
||||
|
||||
}
|
||||
} else {
|
||||
$totalTickets = 0; // Imposta a zero se non ci sono righe nella query
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?><?php //check tickets
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// ID dell'utente per il quale si desidera eseguire la query
|
||||
$iduser = $iduserlogin; // Sostituisci con l'ID utente desiderato
|
||||
|
||||
// Data e ora attuali
|
||||
$currentDateTime = date("Y-m-d H:i:s");
|
||||
|
||||
// Query per contare i record con data e ora passate e future
|
||||
$query = "SELECT COUNT(*) AS total,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule <= '$currentDateTime' THEN 1 ELSE 0 END) AS passed,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule > '$currentDateTime' THEN 1 ELSE 0 END) AS future
|
||||
FROM bookingclass
|
||||
LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule
|
||||
WHERE bookingclass.iduser = $iduser";
|
||||
|
||||
$result = $conn->query($query);
|
||||
if ($result) {
|
||||
$row = $result->fetch_assoc();
|
||||
$totalRecords = $row['total'];
|
||||
$passedRecords = $row['passed'];
|
||||
$futureRecords = $row['future'];
|
||||
|
||||
|
||||
}
|
||||
// Chiusura della connessione
|
||||
$conn->close();
|
||||
?>
|
||||
<?php
|
||||
$toprogram = $totalTickets - $passedRecords - $futureRecords;
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<th>Ordine</th>
|
||||
<th>Da prenotare </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document['order_id']; ?></td>
|
||||
<td>
|
||||
<form action="bookingpanelorder.php" method="post">
|
||||
<input type="hidden" name="idorder" value="<?php echo $document['idorderbook']; ?>">
|
||||
<input type="hidden" name="idserviceordered" value="<?php echo $document['idservice']; ?>">
|
||||
<button type="submit" class="btn btn-success waves-effect waves-light">Da prenotare: <?php echo $toprogram; ?></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="layout-wrapper">
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
<div class="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?></h5>
|
||||
<p>Di seguito puoi visualizzare i tuoi ordini</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Ordine</th>
|
||||
<th>Servizio</th>
|
||||
<th>Numero di Ticket</th>
|
||||
<th>Scadenza</th>
|
||||
<th>Da prenotare</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) : ?>
|
||||
<?php
|
||||
// Connessione al database per calcolo per ordine
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
|
||||
$idorderbook = $document['idorderbook'];
|
||||
$totalTickets = $document['nticket'];
|
||||
$expireon = $document['expireon'];
|
||||
$idservice = $document['idservice'];
|
||||
$servicename = $document['servicename'];
|
||||
|
||||
|
||||
// Verifica se l'ordine è scaduto
|
||||
$currentDate = date("Y-m-d");
|
||||
$isExpired = $expireon && $expireon < $currentDate;
|
||||
|
||||
<!-- JAVASCRIPT -->
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
// Data e ora attuali
|
||||
$currentDateTime = date("Y-m-d H:i:s");
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
// Query per contare i record per questo ordine, escludendo status = 'cancelled'
|
||||
$query = "SELECT COUNT(*) AS total,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule <= ? AND bookingclass.status = 'booked' AND bookingclass.lostlesson = 'N' THEN 1 ELSE 0 END) AS passed,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule > ? AND bookingclass.status = 'booked' AND bookingclass.lostlesson = 'N' THEN 1 ELSE 0 END) AS future,
|
||||
SUM(CASE WHEN bookingclass.lostlesson = 'Y' AND bookingclass.status != 'cancelled' THEN 1 ELSE 0 END) AS lost,
|
||||
SUM(CASE WHEN bookingclass.status = 'pending' THEN 1 ELSE 0 END) AS pending
|
||||
FROM bookingclass
|
||||
LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule
|
||||
WHERE bookingclass.iduser = ? AND bookingclass.idorder = ? AND bookingclass.status != 'cancelled'";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("ssii", $currentDateTime, $currentDateTime, $iduserlogin, $idorderbook);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
</body>
|
||||
if ($result) {
|
||||
$row = $result->fetch_assoc();
|
||||
$passedRecords = $row['passed'];
|
||||
$futureRecords = $row['future'];
|
||||
$lost = $row['lost'];
|
||||
$pending = $row['pending'];
|
||||
} else {
|
||||
$passedRecords = 0;
|
||||
$futureRecords = 0;
|
||||
$lost = 0;
|
||||
$pending = 0;
|
||||
}
|
||||
|
||||
$toprogram = $totalTickets - $passedRecords - $futureRecords - $pending - $lost;
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $idorderbook; ?></td>
|
||||
<td><?php echo htmlspecialchars($servicename); ?></td>
|
||||
<td><?php echo $totalTickets; ?></td>
|
||||
<td><?php echo $expireon ? date('d-m-Y', strtotime($expireon)) : 'N/D'; ?></td>
|
||||
<td>
|
||||
<form action="bookingpanelorder.php" method="post">
|
||||
<input type="hidden" name="idorder" value="<?php echo $idorderbook; ?>">
|
||||
<input type="hidden" name="idserviceordered" value="<?php echo $idservice; ?>">
|
||||
<button type="submit" class="btn <?php echo $isExpired ? 'btn-expired' : ($toprogram > 0 ? 'btn-success' : 'btn-disabled'); ?> waves-effect waves-light" <?php echo ($isExpired || $toprogram <= 0) ? 'disabled' : ''; ?>>
|
||||
<?php echo $isExpired ? 'Abbonamento scaduto' : 'Da prenotare: ' . $toprogram; ?>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
<script src="assets/js/app.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+619
-322
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// Abilita visualizzazione errori PHP (solo per debug, disabilita in produzione)
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Includi configurazione database
|
||||
require_once('include/headscript.php');
|
||||
|
||||
// Inizializza log
|
||||
$logFile = 'update_expired_lessons_log.txt';
|
||||
$logMessage = "Esecuzione script aggiornamento lezioni scadute: " . date('Y-m-d H:i:s') . "\n";
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
$logMessage .= "Connessione al database fallita: " . $conn->connect_error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
$logMessage .= "Database connesso: $dbname\n";
|
||||
|
||||
// Query per trovare ordini scaduti
|
||||
$query_orders = "SELECT idorderbook, order_id, expireon
|
||||
FROM orderbook
|
||||
WHERE expireon < NOW()";
|
||||
$result_orders = $conn->query($query_orders);
|
||||
|
||||
if (!$result_orders) {
|
||||
$logMessage .= "Errore nella query degli ordini scaduti: " . $conn->error . "\n";
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
$logMessage .= "Ordini scaduti trovati: " . $result_orders->num_rows . "\n";
|
||||
|
||||
$updated_lessons = 0;
|
||||
$processed_orders = array();
|
||||
|
||||
// Aggiorna le lezioni per ogni ordine scaduto
|
||||
while ($order = $result_orders->fetch_assoc()) {
|
||||
$idorderbook = $order['idorderbook'];
|
||||
$processed_orders[] = $idorderbook;
|
||||
$logMessage .= "Elaborazione ordine: idorderbook = $idorderbook, expireon = {$order['expireon']}\n";
|
||||
|
||||
// Query per aggiornare le lezioni non completate e non perse
|
||||
$update_query = "UPDATE bookingclass
|
||||
SET expirylesson = 'Y'
|
||||
WHERE idorder = ?
|
||||
AND status != 'completed'
|
||||
AND lostlesson != 'Y'
|
||||
AND expirylesson != 'Y'";
|
||||
$stmt = $conn->prepare($update_query);
|
||||
if (!$stmt) {
|
||||
$logMessage .= "Errore preparazione query per idorderbook $idorderbook: " . $conn->error . "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$stmt->bind_param("i", $idorderbook);
|
||||
$stmt->execute();
|
||||
|
||||
$affected_rows = $stmt->affected_rows;
|
||||
$updated_lessons += $affected_rows;
|
||||
$logMessage .= "Lezioni aggiornate per idorderbook $idorderbook: $affected_rows\n";
|
||||
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
$logMessage .= "Totale lezioni aggiornate: $updated_lessons\n";
|
||||
$logMessage .= "Ordini elaborati: " . implode(", ", $processed_orders) . "\n";
|
||||
|
||||
// Scrivi il log
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
|
||||
// Chiudi la connessione
|
||||
$conn->close();
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// Assicurati che non ci siano spazi o righe vuote prima di questo punto
|
||||
ob_start(); // Avvia il buffer di output
|
||||
|
||||
// Abilita debug per registrare errori
|
||||
ini_set('display_errors', 0); // Non mostrare errori sullo schermo
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', 'php_errors.log'); // Specifica il file di log
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once('include/headscript.php');
|
||||
|
||||
// Creazione della connessione
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
error_log("Connessione al database fallita: " . $conn->connect_error);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Connessione al database fallita: ' . $conn->connect_error]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Gestione della risposta AJAX
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['update_expiry'])) {
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
error_log("Richiesta non valida a update_expiry.php: metodo=" . $_SERVER['REQUEST_METHOD'] . ", update_expiry=" . (isset($_POST['update_expiry']) ? 'set' : 'not set'));
|
||||
echo json_encode(['status' => 'error', 'message' => 'Richiesta non valida']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verifica i parametri ricevuti
|
||||
$order_id = isset($_POST['order_id']) ? intval($_POST['order_id']) : 0;
|
||||
$new_expiry = isset($_POST['new_expiry']) ? $_POST['new_expiry'] : '';
|
||||
|
||||
// Log per debug
|
||||
error_log("Tentativo di aggiornamento AJAX - idorderbook: $order_id, new_expiry: $new_expiry");
|
||||
|
||||
// Controlla se idorderbook è valido
|
||||
if ($order_id <= 0) {
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
error_log("idorderbook non valido o mancante: $order_id");
|
||||
echo json_encode(['status' => 'error', 'message' => 'idorderbook non valido o mancante.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verifica se l'idorderbook esiste
|
||||
$checkStmt = $conn->prepare("SELECT idorderbook FROM orderbook WHERE idorderbook = ?");
|
||||
if (!$checkStmt) {
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
error_log("Errore preparazione query SELECT: " . $conn->error);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Errore preparazione query: ' . $conn->error]);
|
||||
exit;
|
||||
}
|
||||
$checkStmt->bind_param("i", $order_id);
|
||||
$checkStmt->execute();
|
||||
$checkResult = $checkStmt->get_result();
|
||||
if ($checkResult->num_rows === 0) {
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
error_log("idorderbook $order_id non trovato nel database.");
|
||||
echo json_encode(['status' => 'error', 'message' => 'idorderbook non trovato nel database.']);
|
||||
$checkStmt->close();
|
||||
exit;
|
||||
}
|
||||
$checkStmt->close();
|
||||
|
||||
// Esegui l'aggiornamento
|
||||
$stmt = $conn->prepare("UPDATE orderbook SET expireon = ? WHERE idorderbook = ?");
|
||||
if (!$stmt) {
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
error_log("Errore preparazione query UPDATE: " . $conn->error);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Errore preparazione query UPDATE: ' . $conn->error]);
|
||||
exit;
|
||||
}
|
||||
$stmt->bind_param("si", $new_expiry, $order_id);
|
||||
|
||||
$response = [];
|
||||
if ($stmt->execute()) {
|
||||
if ($stmt->affected_rows > 0) {
|
||||
$response['status'] = 'success';
|
||||
$response['message'] = 'Data di scadenza aggiornata con successo!';
|
||||
} else {
|
||||
$response['status'] = 'error';
|
||||
$response['message'] = 'Nessuna riga aggiornata. Verifica l\'idorderbook.';
|
||||
error_log("Nessuna riga aggiornata per idorderbook: $order_id");
|
||||
}
|
||||
} else {
|
||||
$response['status'] = 'error';
|
||||
$response['message'] = 'Errore SQL: ' . $stmt->error;
|
||||
error_log("Errore SQL: " . $stmt->error);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once('Connections/bkngstm.php');
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die(json_encode(['success' => false, 'error' => 'Connessione fallita: ' . $conn->connect_error]));
|
||||
}
|
||||
|
||||
if (isset($_POST['userid']) && isset($_POST['lessonnotification'])) {
|
||||
$userid = $_POST['userid'];
|
||||
$lessonnotification = $_POST['lessonnotification'];
|
||||
|
||||
// Validate lessonnotification value
|
||||
if (!in_array($lessonnotification, ['Y', 'N'])) {
|
||||
echo json_encode(['success' => false, 'error' => 'Valore lessonnotification non valido']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = "UPDATE auth_users SET lessonnotification = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("si", $lessonnotification, $userid);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => $conn->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'Parametri mancanti']);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 569 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
+491
-601
File diff suppressed because it is too large
Load Diff
+293
-305
@@ -1,35 +1,36 @@
|
||||
<?php require_once('include/headscript.php'); ?>
|
||||
<?php // optionquery
|
||||
$optionquery = new WA_MySQLi_RS("optionquery",$bkngstm,0);
|
||||
<?php
|
||||
// optionquery
|
||||
$optionquery = new WA_MySQLi_RS("optionquery", $bkngstm, 0);
|
||||
$optionquery->setQuery("SELECT * FROM option");
|
||||
$optionquery->execute();
|
||||
?>
|
||||
<?php
|
||||
$bookedclass = new WA_MySQLi_RS("bookedclass",$bkngstm,0);
|
||||
$bookedclass = new WA_MySQLi_RS("bookedclass", $bkngstm, 0);
|
||||
$bookedclass->setQuery("SELECT * FROM bookingclass LEFT JOIN service on bookingclass.idservice=service.idservice LEFT JOIN serviceschedule ON bookingclass.idserviceschedule=serviceschedule.idserviceschedule WHERE bookingclass.iduser='1'");
|
||||
$bookedclass->execute();
|
||||
?>
|
||||
<?php
|
||||
// Verifica se è stato inviato un modulo
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Verifica se è stato caricato un file correttamente
|
||||
if (isset($_FILES["fileToUpload"]) && $_FILES["fileToUpload"]["error"] === UPLOAD_ERR_OK) {
|
||||
|
||||
|
||||
// Verifica se tutti i campi obbligatori sono presenti
|
||||
if (isset($_FILES["fileToUpload"]) && $_FILES["fileToUpload"]["error"] === UPLOAD_ERR_OK && !empty($_POST["documentDescription"]) && !empty($_POST["expiryDate"])) {
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica la connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
$error_message = "Connessione al database fallita: " . $conn->connect_error;
|
||||
echo "<script>var errorMessage = '" . addslashes($error_message) . "';</script>";
|
||||
echo "<script>var uploadStatus = 'db_connection_error';</script>";
|
||||
die();
|
||||
}
|
||||
|
||||
// Ottieni l'ID dell'utente (da dove viene?)
|
||||
// Ottieni l'ID dell'utente
|
||||
$iduserlogin = $_POST["iduserlogin"];
|
||||
|
||||
// Altre informazioni sul documento
|
||||
$documentDescription = $_POST["documentDescription"];
|
||||
$expiryDate = $_POST["expiryDate"];
|
||||
$documentDescription = $conn->real_escape_string($_POST["documentDescription"]);
|
||||
$expiryDate = $conn->real_escape_string($_POST["expiryDate"]);
|
||||
$uploadedAt = date("Y-m-d"); // Data corrente per uploaded_at
|
||||
$originalFileName = $_FILES["fileToUpload"]["name"];
|
||||
$fileExtension = pathinfo($originalFileName, PATHINFO_EXTENSION);
|
||||
$timestamp = time(); // Timestamp corrente
|
||||
@@ -39,26 +40,37 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
// Sposta il file nella cartella di destinazione
|
||||
if (move_uploaded_file($fileTmpName, $fileDestination)) {
|
||||
// Inserisci i dati nel database
|
||||
$sql = "INSERT INTO certificateuserprofile (iduser, documentdescription, filenamedocument, expirydatedocument)
|
||||
VALUES ('$iduserlogin', '$documentDescription', '$newFileName', '$expiryDate')";
|
||||
// Inserisci i dati nel database usando prepared statement
|
||||
$sql = "INSERT INTO certificateuserprofile (iduser, documentdescription, filenamedocument, expirydatedocument, uploaded_at)
|
||||
VALUES (?, ?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("issss", $iduserlogin, $documentDescription, $newFileName, $expiryDate, $uploadedAt);
|
||||
|
||||
|
||||
|
||||
$conn->query($sql) ;
|
||||
if ($stmt->execute()) {
|
||||
echo "<script>var uploadStatus = 'success';</script>";
|
||||
} else {
|
||||
$error_message = "Errore durante l'inserimento nel database: " . $conn->error;
|
||||
echo "<script>var errorMessage = '" . addslashes($error_message) . "';</script>";
|
||||
echo "<script>var uploadStatus = 'db_insert_error';</script>";
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo "Errore nel caricamento del file.";
|
||||
$error_message = "Errore nel caricamento del file.";
|
||||
echo "<script>var errorMessage = '" . addslashes($error_message) . "';</script>";
|
||||
echo "<script>var uploadStatus = 'file_upload_error';</script>";
|
||||
}
|
||||
|
||||
// Chiudi la connessione al database
|
||||
$conn->close();
|
||||
} else {
|
||||
$error_message = "Tutti i campi sono obbligatori: descrizione, data di scadenza e file.";
|
||||
echo "<script>var errorMessage = '" . addslashes($error_message) . "';</script>";
|
||||
echo "<script>var uploadStatus = 'validation_error';</script>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
@@ -66,7 +78,7 @@ if ($conn->connect_error) {
|
||||
}
|
||||
|
||||
// ID dell'utente per il quale vuoi filtrare gli ordini
|
||||
$userid = 1;
|
||||
$userid = 1;
|
||||
|
||||
// Query per ottenere la somma dei ticket per ogni ordine dell'utente
|
||||
$query = "SELECT iduser, idorderbook, SUM(nticket) as total_tickets
|
||||
@@ -78,19 +90,18 @@ $result = $conn->query($query);
|
||||
|
||||
if (!$result) {
|
||||
die("Query fallita: " . $conn->error);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$idOrdine = $row["idorderbook"];
|
||||
$totalTickets = $row["total_tickets"];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
<?php //check tickets
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
@@ -117,23 +128,19 @@ if ($result) {
|
||||
$totalRecords = $row['total'];
|
||||
$passedRecords = $row['passed'];
|
||||
$futureRecords = $row['future'];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// Chiusura della connessione
|
||||
$conn->close();
|
||||
?>
|
||||
<?php
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
// Crea la connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Verifica la connessione
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione al database fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Query per selezionare i dati filtrati per iduser
|
||||
$query = "SELECT * FROM certificateuserprofile WHERE iduser = $iduserlogin";
|
||||
$result = $conn->query($query);
|
||||
@@ -145,341 +152,322 @@ while ($row = $result->fetch_assoc()) {
|
||||
$documents[] = $row;
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Carica Certificati</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="YogiBook - Prenotazione facile YogaSoul" name="description" />
|
||||
<meta content="Advanced Creative Solutions" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>Starter Page | webadmin - Admin & Dashboard Template</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="Premium Multipurpose Admin & Dashboard Template" name="description" />
|
||||
<meta content="Themesdesign" name="author" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="assets/images/favicon.ico">
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<!-- Bootstrap Css -->
|
||||
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
|
||||
<!-- Icons Css -->
|
||||
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- App Css-->
|
||||
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<!-- SweetAlert2 CDN -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<!-- jQuery and jQuery UI -->
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#expiryDate").datepicker({ dateFormat: "yy-mm-dd" });
|
||||
$("#expiryDate").datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
minDate: 0 // Impedisce la selezione di date passate
|
||||
});
|
||||
});
|
||||
|
||||
// Handle upload status and display modals
|
||||
$(document).ready(function() {
|
||||
if (typeof Swal === 'undefined') {
|
||||
console.error('SweetAlert2 non è caricato correttamente.');
|
||||
alert('Errore: SweetAlert2 non è disponibile. Controlla la connessione al CDN.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof uploadStatus !== 'undefined') {
|
||||
if (uploadStatus === 'success') {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Successo',
|
||||
text: 'Documento caricato con successo!',
|
||||
confirmButtonText: 'OK'
|
||||
}).then(() => {
|
||||
window.location.href = window.location.href; // Ricarica la pagina
|
||||
});
|
||||
} else if (uploadStatus === 'db_connection_error' || uploadStatus === 'db_insert_error' || uploadStatus === 'file_upload_error' || uploadStatus === 'validation_error') {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errore',
|
||||
text: errorMessage || 'Si è verificato un errore sconosciuto.',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function confirmDeleteCertificate(id) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questo certificato verrà cancellato definitivamente!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = `deletecertificate.php?id=${id}&source=user`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
display: flex;
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
background-color: white;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
.custom-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
.custom-date-box {
|
||||
flex: 1;
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
font-size: 60px;
|
||||
font-weight: bold;
|
||||
border-top-left-radius: 8px;
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
.custom-day {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
.custom-month {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
.custom-event-details {
|
||||
flex: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 20px;
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
.custom-heading {
|
||||
margin-top: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.custom-paragraph {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.custom-actions {
|
||||
display: none;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
.custom-card.expanded .custom-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
.custom-action-button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.custom-card {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.custom-date-box, .custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
.custom-date-box,
|
||||
.custom-event-details {
|
||||
width: 100%;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
text: "Questa prenotazione verrà cancellata definitivamente! Ricordati poi di riprogrammare la tua lezione!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#3085d6",
|
||||
confirmButtonText: "Sì, cancella!",
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Reindirizza direttamente alla pagina di cancellazione con l'ID come parametro.
|
||||
window.location.href = `deleteclass.php?id=${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
.custom-event-time {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<!-- <body data-layout="horizontal"> -->
|
||||
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
<body>
|
||||
<!-- Begin page -->
|
||||
<div id="layout-wrapper">
|
||||
|
||||
<!-- Top Bar -->
|
||||
<header id="page-topbar" class="isvertical-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
<!-- LOGO -->
|
||||
<?php include('include/logoarea.php'); ?>
|
||||
<button type="button" class="btn btn-sm px-3 font-size-24 header-item waves-effect vertical-menu-btn">
|
||||
<i class="bx bx-menu align-middle"></i>
|
||||
</button>
|
||||
<!-- start page title -->
|
||||
<div class="page-title-box align-self-center d-none d-md-block">
|
||||
<h4 class="page-title mb-0">Prenotazione Classi</h4>
|
||||
</div>
|
||||
|
||||
<div class="d-flex">
|
||||
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex"></div>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu"></nav>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start right Content here -->
|
||||
<!-- ============================================================== -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?> </h5>
|
||||
<p>Di seguito puoi visualizzare o caricare i certificati medici di libratoria alla pratica Yoga</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descrizione del Documento</th>
|
||||
<th>Data di Scadenza</th>
|
||||
<th>Documento</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document['documentdescription']; ?></td>
|
||||
<td><?php echo $document['expirydatedocument']; ?></td>
|
||||
<td><a href="user/document/<?php echo $document['filenamedocument']; ?>" target="_blank">Documento</a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Start right Content here -->
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if (isset($_GET['message']) && $_GET['message'] == 'success') { ?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
Certificato rimosso con successo
|
||||
</div>
|
||||
<?php } ?>
|
||||
<h5>Benvenuta/o <?php echo $firstname; ?> </h5>
|
||||
<p>Di seguito puoi visualizzare o caricare i certificati medici di liberatoria alla pratica Yoga</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descrizione del Documento</th>
|
||||
<th>Data di Scadenza</th>
|
||||
<th>Documento</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($documents as $document) { ?>
|
||||
<tr>
|
||||
<td><?php echo $document['documentdescription']; ?></td>
|
||||
<td><?php echo $document['expirydatedocument']; ?></td>
|
||||
<td><a href="user/document/<?php echo $document['filenamedocument']; ?>" target="_blank">Documento</a></td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm" onclick="confirmDeleteCertificate(<?php echo $document['idcertificateuserprofile']; ?>)">
|
||||
<i class="fas fa-trash"></i> Cancella
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="">
|
||||
<div class="row mb-12">
|
||||
<div class="col-xl-12 col-md-12">
|
||||
<div class="pb-3 pb-xl-0">
|
||||
|
||||
<div class="position-relative">
|
||||
<h3>Carica documenti</h3>
|
||||
|
||||
|
||||
</div>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="iduserlogin" class="form-control" value="<?php echo $iduserlogin; ?>">
|
||||
<label for="documentDescription">Descrizione del Documento:</label>
|
||||
<input type="text" class="form-control" name="documentDescription" required><br>
|
||||
<label for="expiryDate">Data di Scadenza:</label>
|
||||
<input type="text" id="expiryDate" class="form-control" name="expiryDate" required><br>
|
||||
<label for="fileToUpload">Seleziona un File:</label>
|
||||
<input type="file" class="form-control" name="fileToUpload" required><br>
|
||||
I documenti caricati sono solo a fini di sicurezza e cliccando su carica documento accetti il nostro regolamento privacy <br><br>
|
||||
<input type="submit" class="btn btn-primary w-md" value="Carica Documento" name="submit">
|
||||
</form>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="">
|
||||
<div class="row mb-12">
|
||||
<div class="col-xl-12 col-md-12">
|
||||
<div class="pb-3 pb-xl-0">
|
||||
<div class="position-relative">
|
||||
<h3>Carica documenti</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-9 col-md-12">
|
||||
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="iduserlogin" class="form-control" value="<?php echo $iduserlogin; ?>">
|
||||
<label for="documentDescription">Descrizione del Documento:</label>
|
||||
<input type="text" class="form-control" name="documentDescription" value="Certificato Medico" required><br>
|
||||
<label for="expiryDate">Data di Scadenza:</label>
|
||||
<input type="text" id="expiryDate" class="form-control" name="expiryDate" required><br>
|
||||
<label for="fileToUpload">Seleziona un File: (peso massimo 16 MB)</label>
|
||||
<input type="file" class="form-control" name="fileToUpload" required><br>
|
||||
I documenti caricati sono solo a fini di sicurezza e cliccando su carica documento accetti il nostro regolamento privacy <br><br>
|
||||
<input type="submit" class="btn btn-primary w-md" value="Carica Documento" name="submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-9 col-md-12"></div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Page-content -->
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<!-- end main content-->
|
||||
|
||||
</div>
|
||||
<!-- END layout-wrapper -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- JAVASCRIPT -->
|
||||
<script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/libs/metismenujs/metismenujs.min.js"></script>
|
||||
<script src="assets/libs/simplebar/simplebar.min.js"></script>
|
||||
<script src="assets/libs/eva-icons/eva.min.js"></script>
|
||||
|
||||
<script src="assets/js/app.js"></script>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,36 @@
|
||||
YogaSoul Autoresponder — Istruzioni rapide
|
||||
|
||||
COS'È
|
||||
- Crea BOZZE di risposta (non invia) per le ultime X email NON LETTE in INBOX.
|
||||
- Le bozze vengono salvate nella cartella Drafts/Bozze dell’account IMAP, in thread (In-Reply-To/References) con citazione del messaggio originale.
|
||||
|
||||
FILE NELLA CARTELLA
|
||||
- yogasoul_autoresponder.exe (oppure: email_autoresponder_yogasoul.py se lo usi con Python)
|
||||
- config.json (credenziali e impostazioni)
|
||||
- prompt_template.txt (testo/tono della risposta: modificabile liberamente)
|
||||
- yogasoul_knowledge_base.json (dati corsi, link, ecc.)
|
||||
|
||||
COME SI USA (Windows, senza Python)
|
||||
1) Apri la cartella “YogaSoul Autoresponder”.
|
||||
2) Modifica `config.json` con:
|
||||
- imap_server, email_address, email_password
|
||||
- openai_api_key
|
||||
- max_to_process (es. 5), throttle_seconds (es. 1.5)
|
||||
3) (Opz.) Modifica `prompt_template.txt` e/o `yogasoul_knowledge_base.json`.
|
||||
4) Doppio click su `yogasoul_autoresponder.exe` (oppure su `run_autoresponder.bat` se fornito).
|
||||
5) Controlla in Posta le BOZZE: dovresti vedere una bozza per ogni email non letta (fino a max_to_process).
|
||||
|
||||
IMPOSTAZIONI UTILI (config.json)
|
||||
- "max_to_process": quante email non lette processare (consigliato 5).
|
||||
- "throttle_seconds": pausa tra le richieste (consigliato 1–2s).
|
||||
- "mark_as_seen": true per segnare come lette dopo la bozza (false per lasciarle non lette).
|
||||
- "preferred_draft_folder": cartella locale alternativa se il server non ha Drafts.
|
||||
|
||||
TROUBLESHOOTING
|
||||
- Nessuna bozza: verifica credenziali IMAP/API in config.json; verifica che ci siano email UNSEEN.
|
||||
- Bozze “schiacciate”: il programma converte in HTML con <p>/<br>; se serve, modifica il prompt.
|
||||
- Rate limit/blocchi: alza "throttle_seconds" (es. 1.5–2.0) e tieni "max_to_process" basso (5).
|
||||
- Cartella bozze: il programma cerca \Drafts; in fallback crea INBOX.BozzaRisposte.
|
||||
|
||||
SICUREZZA
|
||||
- `config.json` contiene password in chiaro: conserva la cartella su un PC/utente fidato.
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"imap_server": "mail.yogasoul.it",
|
||||
"email_address": "info@yogasoul.it",
|
||||
"email_password": "!Testolina88",
|
||||
"openai_api_key": "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",
|
||||
"openai_model": "gpt-3.5-turbo",
|
||||
"preferred_draft_folder": "BozzaRisposte",
|
||||
"mark_as_seen": true,
|
||||
"throttle_seconds": 2,
|
||||
"max_to_process": 5
|
||||
}
|
||||
@@ -0,0 +1,511 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import json
|
||||
import imaplib
|
||||
import email
|
||||
import traceback
|
||||
import html as html_lib
|
||||
from email.utils import parseaddr
|
||||
from email.mime.text import MIMEText
|
||||
from email.header import decode_header, make_header
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
# ==========================
|
||||
# CONFIG da config.json (accanto allo script/EXE)
|
||||
# ==========================
|
||||
def app_dir() -> Path:
|
||||
# se "frozen" (PyInstaller), usa la cartella dell'eseguibile
|
||||
return Path(sys.executable).parent if getattr(sys, "frozen", False) else Path(__file__).resolve().parent
|
||||
|
||||
CONFIG_PATH = app_dir() / "config.json"
|
||||
|
||||
def load_config():
|
||||
try:
|
||||
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
|
||||
cfg = json.load(f)
|
||||
print(f"[CONFIG] Caricato: {CONFIG_PATH}")
|
||||
return cfg
|
||||
except Exception as e:
|
||||
print(f"[ERRORE] Impossibile leggere {CONFIG_PATH}: {e}")
|
||||
return {}
|
||||
|
||||
CFG = load_config()
|
||||
|
||||
# valori letti dal config (con default sensati)
|
||||
IMAP_SERVER = CFG.get("imap_server", "mail.yogasoul.it")
|
||||
EMAIL_ADDRESS = CFG.get("email_address", "")
|
||||
EMAIL_PASSWORD = CFG.get("email_password", "")
|
||||
OPENAI_API_KEY = CFG.get("openai_api_key", "")
|
||||
OPENAI_MODEL = CFG.get("openai_model", "gpt-3.5-turbo")
|
||||
PREFERRED_DRAFT_FOLDER = CFG.get("preferred_draft_folder", "BozzaRisposte")
|
||||
MARK_AS_SEEN = bool(CFG.get("mark_as_seen", True))
|
||||
THROTTLE_SECONDS = float(CFG.get("throttle_seconds", 0) or 0)
|
||||
MAX_TO_PROCESS = int(CFG.get("max_to_process", 5) or 5)
|
||||
# Percorsi esterni (accanto all'eseguibile)
|
||||
KB_PATH = str(app_dir() / CFG.get("kb_path", "yogasoul_knowledge_base.json"))
|
||||
PROMPT_PATH = str(app_dir() / CFG.get("prompt_path", "prompt_template.txt"))
|
||||
|
||||
# ==========================
|
||||
# UTILS
|
||||
# ==========================
|
||||
def _decode_mime_words(s):
|
||||
if not s:
|
||||
return ""
|
||||
try:
|
||||
return str(make_header(decode_header(s)))
|
||||
except Exception:
|
||||
parts = decode_header(s)
|
||||
out = []
|
||||
for text, enc in parts:
|
||||
if isinstance(text, bytes):
|
||||
out.append(text.decode(enc or "utf-8", errors="ignore"))
|
||||
else:
|
||||
out.append(text or "")
|
||||
return "".join(out)
|
||||
|
||||
def _html_to_text(html):
|
||||
try:
|
||||
text = re.sub(r"(?is)<(script|style).*?>.*?</\1>", "", html or "")
|
||||
text = re.sub(r"(?s)<br\s*/?>", "\n", text)
|
||||
text = re.sub(r"(?s)</p\s*>", "\n\n", text)
|
||||
text = re.sub(r"(?s)<.*?>", "", text)
|
||||
return text.strip()
|
||||
except Exception:
|
||||
return html or ""
|
||||
|
||||
def _ensure_html_blocks(s):
|
||||
"""Se il modello restituisce testo piatto, convertilo in HTML semplice e leggibile."""
|
||||
s = (s or "").strip()
|
||||
if "<html" in s.lower() or "<p" in s.lower() or "<br" in s.lower():
|
||||
body = s
|
||||
else:
|
||||
parts = [p.strip() for p in s.split("\n\n") if p.strip()]
|
||||
if len(parts) > 1:
|
||||
body = "".join(
|
||||
"<p>{}</p>".format(html_lib.escape(p).replace("\n", "<br>"))
|
||||
for p in parts
|
||||
)
|
||||
else:
|
||||
body = "<p>{}</p>".format(html_lib.escape(s).replace("\n", "<br>"))
|
||||
return "<!doctype html><html><body>{}</body></html>".format(body)
|
||||
|
||||
def _make_quoted_original(body_text):
|
||||
"""Crea il blocco citato del messaggio originale, safe-escaped."""
|
||||
if not body_text:
|
||||
return ""
|
||||
escaped = html_lib.escape(body_text).replace("\n", "<br>")
|
||||
return (
|
||||
"<hr>"
|
||||
"<p style='color:#666; font-size:90%'>— Messaggio originale —</p>"
|
||||
f"<blockquote style='margin:0 0 0 1em; padding-left:1em; border-left:3px solid #ddd'>{escaped}</blockquote>"
|
||||
)
|
||||
|
||||
def _inject_before_body_end(html_src: str, addition: str) -> str:
|
||||
"""Inserisce 'addition' prima di </body> in modo case-insensitive; se manca </body>, appende."""
|
||||
m = re.search(r'</\s*body\s*>', html_src, flags=re.I)
|
||||
if not m:
|
||||
return html_src + addition
|
||||
start = m.start()
|
||||
return html_src[:start] + addition + html_src[start:]
|
||||
|
||||
def load_knowledge_base(path=KB_PATH):
|
||||
if not os.path.isfile(path):
|
||||
print(f"[ATTENZIONE] KB non trovata: {path}. Proseguo senza.")
|
||||
return {}
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except Exception as e:
|
||||
print(f"[ERRORE] Lettura KB: {e}. Proseguo senza.")
|
||||
return {}
|
||||
|
||||
def assert_config():
|
||||
problems = []
|
||||
if not isinstance(IMAP_SERVER, str) or not IMAP_SERVER.strip():
|
||||
problems.append("imap_server mancante in config.json")
|
||||
if not isinstance(EMAIL_ADDRESS, str) or not EMAIL_ADDRESS.strip():
|
||||
problems.append("email_address mancante in config.json")
|
||||
if not isinstance(EMAIL_PASSWORD, str) or not EMAIL_PASSWORD.strip():
|
||||
problems.append("email_password mancante in config.json")
|
||||
if not isinstance(OPENAI_API_KEY, str) or not OPENAI_API_KEY.strip():
|
||||
problems.append("openai_api_key mancante in config.json")
|
||||
if problems:
|
||||
print("[CONFIG] Correggi config.json:")
|
||||
for p in problems:
|
||||
print(" -", p)
|
||||
return False
|
||||
return True
|
||||
|
||||
# ==========================
|
||||
# Prompt esterno
|
||||
# ==========================
|
||||
def load_prompt(path: str) -> str:
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
print(f"[PROMPT] Caricato: {path}")
|
||||
return f.read()
|
||||
except Exception as e:
|
||||
print(f"[ATTENZIONE] Prompt non trovato o illeggibile: {path} ({e})")
|
||||
return ""
|
||||
|
||||
def render_prompt(template: str, **vars_) -> str:
|
||||
# Sostituzione semplice stile {{nome}}
|
||||
out = template
|
||||
for k, v in vars_.items():
|
||||
out = out.replace(f"{{{{{k}}}}}", str(v))
|
||||
return out
|
||||
|
||||
# ==========================
|
||||
# IMAP helpers robusti
|
||||
# ==========================
|
||||
LIST_RE = re.compile(r'^\s*\((?P<flags>[^)]*)\)\s+"(?P<delim>[^"]+)"\s+(?P<name>.+?)\s*$')
|
||||
|
||||
def _parse_list_line(raw: bytes):
|
||||
s = raw.decode(errors="ignore")
|
||||
m = LIST_RE.match(s)
|
||||
if not m:
|
||||
parts = s.strip().split()
|
||||
name = parts[-1] if parts else ""
|
||||
name = name.strip('"')
|
||||
return ([], ".", name)
|
||||
flags_str = m.group("flags") or ""
|
||||
delim = m.group("delim") or "."
|
||||
name = m.group("name").strip()
|
||||
if name.startswith('"') and name.endswith('"'):
|
||||
name = name[1:-1]
|
||||
flags = [f.strip() for f in flags_str.split() if f.strip()]
|
||||
return (flags, delim, name)
|
||||
|
||||
def _list_mailboxes(mail):
|
||||
try:
|
||||
typ, boxes = mail.list()
|
||||
if typ != "OK":
|
||||
return []
|
||||
return [_parse_list_line(raw) for raw in (boxes or [])]
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
def _find_drafts_mailbox(mail):
|
||||
boxes = _list_mailboxes(mail)
|
||||
if not boxes:
|
||||
return (None, ".")
|
||||
delim_guess = boxes[0][1] if boxes[0][1] else "."
|
||||
# special-use \Drafts
|
||||
for flags, delim, name in boxes:
|
||||
if any("\\Drafts" in f or "\\drafts" in f for f in flags):
|
||||
return (name, delim or delim_guess)
|
||||
# nomi comuni
|
||||
wanted = ("drafts", "bozze", "bozza", "draft")
|
||||
for flags, delim, name in boxes:
|
||||
low = name.lower()
|
||||
if any(w in low.split(delim or ".")[-1] for w in wanted):
|
||||
return (name, delim or delim_guess)
|
||||
return (None, delim_guess)
|
||||
|
||||
def _select_or_create(mail, name, delim):
|
||||
typ, _ = mail.select(name, readonly=False)
|
||||
if typ == "OK":
|
||||
return name
|
||||
candidate = f"INBOX{delim}{name}"
|
||||
typ, _ = mail.select(candidate, readonly=False)
|
||||
if typ == "OK":
|
||||
return candidate
|
||||
mail.create(candidate)
|
||||
typ, _ = mail.select(candidate, readonly=False)
|
||||
if typ == "OK":
|
||||
return candidate
|
||||
raise RuntimeError(f"Impossibile selezionare o creare la casella '{name}' (delim='{delim}')")
|
||||
|
||||
# ==========================
|
||||
# INTENT DETECTION (semplice)
|
||||
# ==========================
|
||||
SCHEDULE_WORDS = [
|
||||
"orario", "orari", "quando", "che ore", "a che ora", "giorni", "mercoledì", "martedì",
|
||||
"lezione di", "inizia", "finisce", "durata"
|
||||
]
|
||||
BOOKING_WORDS = [
|
||||
"prenota", "prenotazione", "prenotare", "iscriversi", "iscrizione", "link", "come fare", "dove prenoto"
|
||||
]
|
||||
INFO_WORDS = [
|
||||
"informazioni", "info", "cos'è", "che cos", "benefici", "a chi è adatto", "livello", "programma",
|
||||
"insegnante", "maestro", "costi", "prezzo", "quanto costa", "materiale", "cosa portare"
|
||||
]
|
||||
|
||||
def classify_intent(subject, body):
|
||||
s = f"{subject or ''} {body or ''}".lower()
|
||||
has_info = any(w in s for w in INFO_WORDS)
|
||||
has_sched = any(w in s for w in SCHEDULE_WORDS)
|
||||
has_book = any(w in s for w in BOOKING_WORDS)
|
||||
if has_info:
|
||||
return "extended"
|
||||
if (has_sched or has_book) and not has_info:
|
||||
return "brief"
|
||||
return "brief"
|
||||
|
||||
# ==========================
|
||||
# OPENAI: GENERAZIONE BOZZA
|
||||
# ==========================
|
||||
def generate_response(email_info, kb):
|
||||
try:
|
||||
from openai import OpenAI
|
||||
client = OpenAI(api_key=OPENAI_API_KEY)
|
||||
|
||||
nickname = "amico"
|
||||
if email_info.get("sender_name"):
|
||||
nickname = email_info["sender_name"].split()[0]
|
||||
elif email_info.get("sender_email"):
|
||||
nickname = email_info["sender_email"].split("@")[0].split(".")[0] or "amico"
|
||||
|
||||
kb_json = json.dumps(kb, ensure_ascii=False, indent=2)
|
||||
intent = classify_intent(email_info.get("subject",""), email_info.get("body_text",""))
|
||||
|
||||
if intent == "brief":
|
||||
policy = ("Se il messaggio chiede solo orari e/o come prenotare, rispondi BREVE: "
|
||||
"indica orari precisi e inserisci SOLO il link prenotazione. Non aggiungere benefici o descrizioni.")
|
||||
else:
|
||||
policy = ("Se il messaggio chiede informazioni sul corso, rispondi ESTESO: "
|
||||
"includi orari, benefici principali, a chi è adatto, eventuale insegnante, e il link prenotazione.")
|
||||
|
||||
email_text = (
|
||||
f"Soggetto: {email_info.get('subject','')}\n"
|
||||
f"Mittente: {email_info.get('sender_email','')}\n"
|
||||
f"Corpo: {email_info.get('body_text','')}"
|
||||
)
|
||||
|
||||
# Prompt da file esterno (con fallback interno)
|
||||
template = load_prompt(PROMPT_PATH)
|
||||
if not template:
|
||||
template = (
|
||||
"Sei Aurora, fondatrice di YogaSoul (www.yogasoul.it), stile zen e informale, diretto.\n"
|
||||
"Rispondi in italiano, amichevole e rilassato, con emoticon yoga (🌿, 🧘♀️, 😊) senza esagerare.\n"
|
||||
"Saluta con \"Ciao {{nickname}}, bello sentirti!\" e firma con \"Namaste, Aurora - YogaSoul\".\n"
|
||||
"Usa la knowledge base per corsi, orari, prezzi, benefici, insegnanti.\n"
|
||||
"Includi sempre il link_prenotazione specifico come <a href='link'>Iscriviti qui</a> per prenotazioni,\n"
|
||||
"e il calendario <a href='https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg'>qui</a>.\n"
|
||||
"Se non sai, scrivi: \"Contattami per dettagli! 🧘♀️\".\n\n"
|
||||
"{{policy}}\n\n"
|
||||
"Knowledge Base:\n"
|
||||
"{{kb_json}}\n\n"
|
||||
"Email ricevuta:\n"
|
||||
"{{email_text}}\n\n"
|
||||
"Scrivi la risposta in HTML pulito (usa <p>, <ul>/<li> se utile; niente CSS superfluo).\n"
|
||||
)
|
||||
|
||||
prompt = render_prompt(
|
||||
template,
|
||||
nickname=nickname,
|
||||
policy=policy,
|
||||
kb_json=kb_json,
|
||||
email_text=email_text,
|
||||
)
|
||||
|
||||
resp = client.chat.completions.create(
|
||||
model=OPENAI_MODEL,
|
||||
messages=[{"role": "user", "content": prompt}],
|
||||
max_tokens=700,
|
||||
temperature=0.7,
|
||||
)
|
||||
draft_raw = (resp.choices[0].message.content or "").strip()
|
||||
return _ensure_html_blocks(draft_raw)
|
||||
except Exception as e:
|
||||
print(f"[ERRORE] OpenAI: {e}")
|
||||
traceback.print_exc()
|
||||
return _ensure_html_blocks(
|
||||
"<p>Errore con l'AI, contattami per dettagli! 🧘♀️<br>"
|
||||
"Namaste, Aurora - YogaSoul</p>"
|
||||
)
|
||||
|
||||
# ==========================
|
||||
# PIPELINE: processa TUTTE le UNSEEN (max N)
|
||||
# ==========================
|
||||
def fetch_all_unseen(mail, limit=None):
|
||||
"""Ritorna lista di dict (uno per messaggio) + seq id, senza chiudere la connessione IMAP."""
|
||||
results = []
|
||||
typ, _ = mail.select("INBOX")
|
||||
if typ != "OK":
|
||||
raise RuntimeError("Impossibile selezionare INBOX")
|
||||
typ, data = mail.search(None, "UNSEEN")
|
||||
if typ != "OK":
|
||||
raise RuntimeError("Search UNSEEN fallita")
|
||||
ids = data[0].split() # solitamente in ordine crescente (più vecchie -> più nuove)
|
||||
|
||||
if not ids:
|
||||
print("Nessuna email non letta.")
|
||||
return results
|
||||
|
||||
if limit and limit > 0:
|
||||
ids = ids[-limit:] # prendi SOLO le ultime N non lette
|
||||
|
||||
for seq_id in ids:
|
||||
typ, msg_data = mail.fetch(seq_id, "(RFC822)")
|
||||
if typ != "OK" or not msg_data or not msg_data[0]:
|
||||
print(f"[WARN] Fetch fallito per id {seq_id}")
|
||||
continue
|
||||
|
||||
msg = email.message_from_bytes(msg_data[0][1])
|
||||
name, sender_addr = parseaddr(msg.get("From", "") or "")
|
||||
subject = _decode_mime_words(msg.get("Subject", "") or "")
|
||||
message_id = msg.get("Message-ID", "") or ""
|
||||
references = msg.get("References", "") or ""
|
||||
|
||||
body_text = ""
|
||||
if msg.is_multipart():
|
||||
for part in msg.walk():
|
||||
ctype = part.get_content_type()
|
||||
disp = (part.get("Content-Disposition") or "").lower()
|
||||
if ctype == "text/plain" and "attachment" not in disp:
|
||||
payload = part.get_payload(decode=True)
|
||||
if payload is not None:
|
||||
body_text = payload.decode(errors="ignore")
|
||||
break
|
||||
if not body_text:
|
||||
for part in msg.walk():
|
||||
if part.get_content_type() == "text/html":
|
||||
payload = part.get_payload(decode=True)
|
||||
if payload is not None:
|
||||
body_text = _html_to_text(payload.decode(errors="ignore"))
|
||||
break
|
||||
else:
|
||||
payload = msg.get_payload(decode=True)
|
||||
if payload is not None:
|
||||
try:
|
||||
body_text = payload.decode(errors="ignore")
|
||||
except Exception:
|
||||
body_text = _html_to_text(payload.decode(errors="ignore"))
|
||||
|
||||
results.append({
|
||||
"seq_id": seq_id,
|
||||
"sender_email": sender_addr,
|
||||
"sender_name": name,
|
||||
"subject": subject,
|
||||
"message_id": message_id,
|
||||
"references": references,
|
||||
"body_text": body_text or "",
|
||||
})
|
||||
return results
|
||||
|
||||
def prepare_reply_mime(email_info, response_html):
|
||||
"""Costruisce il MIME HTML della risposta con quote e thread headers."""
|
||||
reply_body = _inject_before_body_end(
|
||||
response_html,
|
||||
_make_quoted_original(email_info.get("body_text",""))
|
||||
)
|
||||
|
||||
msg = MIMEText(reply_body, "html", "utf-8")
|
||||
subj = email_info.get("subject") or "[Risposta automatica] - YogaSoul"
|
||||
if not subj.lower().startswith("re:"):
|
||||
subj = f"Re: {subj}"
|
||||
msg["Subject"] = subj
|
||||
msg["From"] = EMAIL_ADDRESS
|
||||
if email_info.get("sender_email"):
|
||||
msg["To"] = email_info["sender_email"]
|
||||
if email_info.get("message_id"):
|
||||
msg["In-Reply-To"] = email_info["message_id"]
|
||||
prev_refs = email_info.get("references", "")
|
||||
if prev_refs and email_info.get("message_id"):
|
||||
msg["References"] = (prev_refs + " " + email_info["message_id"]).strip()
|
||||
elif email_info.get("message_id"):
|
||||
msg["References"] = email_info["message_id"]
|
||||
return msg
|
||||
|
||||
def ensure_drafts_folder(mail):
|
||||
"""Trova o crea la cartella bozze; ritorna (folder_name, delim)."""
|
||||
drafts_name, delim = _find_drafts_mailbox(mail)
|
||||
if drafts_name:
|
||||
return drafts_name, delim
|
||||
folder = f"INBOX{delim}{PREFERRED_DRAFT_FOLDER}"
|
||||
typ, _ = mail.select(folder, readonly=False)
|
||||
if typ == "OK":
|
||||
return folder, delim
|
||||
mail.create(folder)
|
||||
typ, _ = mail.select(folder, readonly=False)
|
||||
if typ == "OK":
|
||||
return folder, delim
|
||||
candidate = f"INBOX{delim}Drafts"
|
||||
mail.create(candidate)
|
||||
typ, _ = mail.select(candidate, readonly=False)
|
||||
if typ == "OK":
|
||||
return candidate, delim
|
||||
raise RuntimeError("Impossibile trovare/creare una cartella bozze.")
|
||||
|
||||
def append_draft(mail, folder, msg):
|
||||
"""Esegue APPEND con flag \Draft nella folder indicata."""
|
||||
flags = r"(\Draft)"
|
||||
when = imaplib.Time2Internaldate(time.time())
|
||||
typ, resp = mail.append(folder, flags, when, msg.as_bytes())
|
||||
print("[APPEND]", folder, "=>", typ, resp)
|
||||
return typ == "OK"
|
||||
|
||||
# ==========================
|
||||
# MAIN
|
||||
# ==========================
|
||||
def main():
|
||||
# Controllo config di base
|
||||
problems = []
|
||||
if not isinstance(IMAP_SERVER, str) or not IMAP_SERVER.strip():
|
||||
problems.append("imap_server mancante in config.json")
|
||||
if not isinstance(EMAIL_ADDRESS, str) or not EMAIL_ADDRESS.strip():
|
||||
problems.append("email_address mancante in config.json")
|
||||
if not isinstance(EMAIL_PASSWORD, str) or not EMAIL_PASSWORD.strip():
|
||||
problems.append("email_password mancante in config.json")
|
||||
if not isinstance(OPENAI_API_KEY, str) or not OPENAI_API_KEY.strip():
|
||||
problems.append("openai_api_key mancante in config.json")
|
||||
if problems:
|
||||
print("[CONFIG] Correggi config.json:")
|
||||
for p in problems:
|
||||
print(" -", p)
|
||||
return
|
||||
|
||||
# Login IMAP
|
||||
try:
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER)
|
||||
mail.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
|
||||
except Exception as e:
|
||||
print(f"[ERRORE] Login IMAP fallito: {e}")
|
||||
traceback.print_exc()
|
||||
return
|
||||
|
||||
try:
|
||||
drafts_folder, delim = ensure_drafts_folder(mail)
|
||||
print(f"[DEBUG] drafts_folder='{drafts_folder}' delim='{delim}'")
|
||||
|
||||
emails = fetch_all_unseen(mail, limit=MAX_TO_PROCESS)
|
||||
if not emails:
|
||||
print("Nessuna nuova email da processare.")
|
||||
mail.logout()
|
||||
return
|
||||
|
||||
kb = load_knowledge_base(KB_PATH)
|
||||
processed = 0
|
||||
|
||||
for info in emails:
|
||||
draft_html = generate_response(info, kb)
|
||||
mime_msg = prepare_reply_mime(info, draft_html)
|
||||
ok = append_draft(mail, drafts_folder, mime_msg)
|
||||
if ok and MARK_AS_SEEN:
|
||||
try:
|
||||
mail.store(info["seq_id"], "+FLAGS", "\\Seen")
|
||||
except Exception as e:
|
||||
print(f"[WARN] Non sono riuscito a marcare come letta id {info['seq_id']}: {e}")
|
||||
processed += 1
|
||||
if THROTTLE_SECONDS:
|
||||
time.sleep(THROTTLE_SECONDS)
|
||||
|
||||
print(f"✅ Elaborate {processed} email (max {MAX_TO_PROCESS}). Bozze salvate in '{drafts_folder}'.")
|
||||
mail.logout()
|
||||
except Exception as e:
|
||||
print(f"[ERRORE] Pipeline: {e}")
|
||||
traceback.print_exc()
|
||||
try:
|
||||
mail.logout()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,17 @@
|
||||
Sei Aurora, fondatrice di YogaSoul (www.yogasoul.it), stile zen e informale, diretto.
|
||||
Rispondi in italiano, amichevole e rilassato, con emoticon yoga (🌿, 🧘♀️, 😊) senza esagerare.
|
||||
Saluta con "Ciao {{nickname}}, bello sentirti!" e firma con "Namaste, Aurora - YogaSoul".
|
||||
Usa la knowledge base per corsi, orari, prezzi, benefici, insegnanti.
|
||||
Includi sempre il link_prenotazione specifico come <a href='link'>Iscriviti qui</a> per prenotazioni,
|
||||
e il calendario <a href='https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg'>qui</a>.
|
||||
Se non sai, scrivi: "Contattami per dettagli! 🧘♀️".
|
||||
|
||||
{{policy}}
|
||||
|
||||
Knowledge Base:
|
||||
{{kb_json}}
|
||||
|
||||
Email ricevuta:
|
||||
{{email_text}}
|
||||
|
||||
Scrivi la risposta in HTML pulito (usa <p>, <ul>/<li> se utile; niente CSS superfluo).
|
||||
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"corsi": [
|
||||
{
|
||||
"nome": "Yoga e Meditazione",
|
||||
"descrizione": "Pratica che unisce yoga e meditazione per promuovere equilibrio interiore e consapevolezza. Eseguita online.",
|
||||
"benefici": ["Riduce stress e ansia", "Migliora concentrazione", "Favorisce rilassamento", "Supporta benessere emotivo"],
|
||||
"adatto_a": "Tutti i livelli, ideale per chi cerca una pratica mattutina o online.",
|
||||
"orari": "Lunedì 6:00-7:00",
|
||||
"luogo": "Online",
|
||||
"prezzo": {"singola_lezione": "Da definire", "pacchetto_4_lezioni": "Da definire", "pacchetto_12_lezioni": "Da definire", "prova": "€5"},
|
||||
"insegnante": "Aurora Masiero",
|
||||
"calendario_link": "https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg",
|
||||
"link_prenotazione": "https://yogasoul.it/product/yoga-e-meditazione/",
|
||||
"fonte": "https://yogasoul.it/aerial-yoga-classi-di-prova-a-seregno-registrazione/, immagine calendario"
|
||||
},
|
||||
{
|
||||
"nome": "Pilates Matwork",
|
||||
"descrizione": "Pratica a corpo libero che rafforza il core e migliora postura e flessibilità.",
|
||||
"benefici": ["Rafforza il core", "Migliora postura", "Aumenta flessibilità", "Riduce tensioni"],
|
||||
"adatto_a": "Tutti i livelli, ideale per forza e postura. Adatto a principianti.",
|
||||
"orari": "Lunedì 18:15-19:15",
|
||||
"luogo": "Via Valassina 62b, Seregno (MB)",
|
||||
"prezzo": {"singola_lezione": "Da definire", "pacchetto_4_lezioni": "Da definire", "pacchetto_12_lezioni": "Da definire", "prova": "€5"},
|
||||
"insegnante": "Barbara",
|
||||
"calendario_link": "https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg",
|
||||
"link_prenotazione": "https://yogasoul.it/product/pilates-matwork/",
|
||||
"fonte": "https://yogasoul.it/product/pilates-matwork/, immagine calendario"
|
||||
},
|
||||
{
|
||||
"nome": "Aerial Yoga",
|
||||
"descrizione": "Pratica con tessuto sospeso, unisce yoga e acrobatica. Livelli: Intermedio, Base/Mix.",
|
||||
"benefici": ["Aumenta forza e flessibilità", "Riduce pressione articolare", "Promuove rilassamento", "Stimola creatività"],
|
||||
"adatto_a": "Principianti (Base), intermedi (Intermedio, Mix). Sconsigliato per pressione alta o gravidanza senza medico.",
|
||||
"orari": "Martedì 18:15-19:15 (Intermedio), Mercoledì 18:30-19:30 (Base/Mix), Giovedì 19:15-20:15 (Base/Mix), Venerdì 20:30-21:30 (Mix)",
|
||||
"luogo": "Via Valassina 62b, Seregno (MB)",
|
||||
"prezzo": {"singola_lezione": "Da definire", "pacchetto_4_lezioni": "Da definire", "pacchetto_12_lezioni": "Da definire", "prova": "€5"},
|
||||
"insegnante": "Aurora Masiero",
|
||||
"calendario_link": "https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg",
|
||||
"link_prenotazione": "https://yogasoul.it/product/aerial-yoga/",
|
||||
"fonte": "https://yogasoul.it/product/aerial-yoga/, immagine calendario"
|
||||
},
|
||||
{
|
||||
"nome": "Hatha Yoga",
|
||||
"descrizione": "Pratica tradizionale con asana, pranayama e meditazione per equilibrare corpo e mente.",
|
||||
"benefici": ["Migliora flessibilità", "Riduce stress", "Promuove consapevolezza", "Supporta rilassamento"],
|
||||
"adatto_a": "Principianti e tutti i livelli, ideale per un’introduzione dolce.",
|
||||
"orari": "Martedì 19:30-20:30, Giovedì 18:00-19:00 (come Hatha Vinyasa)",
|
||||
"luogo": "Via Valassina 62b, Seregno (MB)",
|
||||
"prezzo": {"singola_lezione": "Da definire", "pacchetto_4_lezioni": "Da definire", "pacchetto_12_lezioni": "Da definire", "prova": "€5"},
|
||||
"insegnante": "Giorgia",
|
||||
"calendario_link": "https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg",
|
||||
"link_prenotazione": "https://yogasoul.it/product/hatha-yoga/",
|
||||
"fonte": "https://yogasoul.it/product/hatha-yoga/, immagine calendario"
|
||||
},
|
||||
{
|
||||
"nome": "Anukalana Yoga",
|
||||
"descrizione": "Stile fluido che integra yoga, Tai Chi e danza per un approccio olistico.",
|
||||
"benefici": ["Migliora fluidità", "Aumenta flessibilità", "Favorisce rilassamento", "Supporta equilibrio energetico"],
|
||||
"adatto_a": "Tutti i livelli, ideale per chi ama movimenti creativi.",
|
||||
"orari": "Mercoledì 19:45-20:45",
|
||||
"luogo": "Via Valassina 62b, Seregno (MB)",
|
||||
"prezzo": {"singola_lezione": "Da definire", "pacchetto_4_lezioni": "Da definire", "pacchetto_12_lezioni": "Da definire", "prova": "€5"},
|
||||
"insegnante": "Aurora Masiero",
|
||||
"calendario_link": "https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg",
|
||||
"link_prenotazione": "https://yogasoul.it/product/anukalana-yoga/",
|
||||
"fonte": "https://yogasoul.it/product/anukalana-yoga/, immagine calendario"
|
||||
},
|
||||
{
|
||||
"nome": "Yoga in Gravidanza",
|
||||
"descrizione": "Pratica dolce per donne incinte, con respirazione e rilassamento. Include amaca su richiesta.",
|
||||
"benefici": ["Allevia mal di schiena", "Migliora flessibilità", "Promuove connessione col bambino", "Supporta benessere"],
|
||||
"adatto_a": "Donne incinte con approvazione medica, adatto a principianti.",
|
||||
"orari": "Sabato 9:30-10:30 (attivato su richiesta)",
|
||||
"luogo": "Via Valassina 62b, Seregno (MB)",
|
||||
"prezzo": {"singola_lezione": "Da definire", "pacchetto_4_lezioni": "Da definire", "pacchetto_12_lezioni": "Da definire", "prova": "€5"},
|
||||
"insegnante": "Aurora Masiero",
|
||||
"calendario_link": "https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg",
|
||||
"link_prenotazione": "https://yogasoul.it/product/yoga-in-gravidanza/",
|
||||
"fonte": "https://yogasoul.it/product/yoga-in-gravidanza-in-presenza-seregno/, immagine calendario"
|
||||
},
|
||||
{
|
||||
"nome": "Videocorso Yoga in Gravidanza",
|
||||
"descrizione": "Corso on-demand per donne incinte, con esercizi per prepararsi al parto.",
|
||||
"benefici": ["Allevia fastidi", "Migliora flessibilità", "Promuove rilassamento", "Accessibile 24/7"],
|
||||
"adatto_a": "Donne incinte con approvazione medica, adatto a principianti.",
|
||||
"orari": "On-demand, accessibile 24/7",
|
||||
"luogo": "Online",
|
||||
"prezzo": {"videocorso": "€30"},
|
||||
"insegnante": "Aurora Masiero",
|
||||
"calendario_link": "https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg",
|
||||
"link_prenotazione": "https://yogasoul.it/lp-courses/videocorso-yoga-in-gravidanza/",
|
||||
"fonte": "https://yogasoul.it/lp-courses/videocorso-yoga-in-gravidanza/"
|
||||
}
|
||||
],
|
||||
"prenotazioni": {
|
||||
"metodo": "Prenota sui link specifici dei corsi su www.yogasoul.it/product/... tramite YOGIBook.",
|
||||
"pagamento": "Carta di credito (Stripe) o bonifico. Fatturazione automatica.",
|
||||
"cambio_lezione": "Cambio lezione entro 24h tramite YOGIBook. Pacchetti: 4 lezioni (1 recuperabile entro 5 settimane), 12 lezioni (3 recuperabili entro scadenza).",
|
||||
"cancellazione": "Cancellazioni entro 24h, no rimborsi parziali."
|
||||
},
|
||||
"contatti": {
|
||||
"email": "info@yogasoul.it",
|
||||
"telefono": "+39 353 4636941",
|
||||
"whatsapp": "+39 353 4636941",
|
||||
"indirizzo": "Via Valassina 62b, Seregno (MB), Italia",
|
||||
"social": {
|
||||
"facebook": "https://www.facebook.com/yogasoul.it/",
|
||||
"youtube": "https://www.youtube.com/@yogasoul6746",
|
||||
"instagram": "https://www.instagram.com/aura_yogasoul/"
|
||||
}
|
||||
},
|
||||
"faq": [
|
||||
{
|
||||
"domanda": "Quali sono gli orari di Aerial Yoga?",
|
||||
"risposta": "Aerial Yoga: martedì 18:15-19:15 (Intermedio), mercoledì 18:30-19:30 (Base/Mix), giovedì 19:15-20:15 (Base/Mix), venerdì 20:30-21:30 (Mix). Prova €5, costi da definire. Calendario: https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg"
|
||||
},
|
||||
{
|
||||
"domanda": "Quanto costa Hatha Yoga e quali sono i benefici?",
|
||||
"risposta": "Hatha Yoga: prova €5, costi da definire. Benefici: flessibilità, forza, riduzione stress. Orari: martedì 19:30-20:30, giovedì 18:00-19:00. Calendario: https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg"
|
||||
},
|
||||
{
|
||||
"domanda": "Yoga in Gravidanza è attivo? Quanto costa?",
|
||||
"risposta": "Sì, attivo su richiesta il sabato 9:30-10:30. Prova €5, costi da definire, videocorso €30. Calendario: https://yogasoul.it/wp-content/uploads/2025/08/Calendario-settembre-2025-2.jpg"
|
||||
},
|
||||
{
|
||||
"domanda": "Posso provare una lezione?",
|
||||
"risposta": "Sì, tutte le prove costano €5. Prenota qui: https://yogasoul.it/aerial-yoga-classi-di-prova-a-seregno-registrazione/"
|
||||
},
|
||||
{
|
||||
"domanda": "Come prenoto o cambio una lezione?",
|
||||
"risposta": "Prenota sui link dei corsi (es. https://yogasoul.it/product/hatha-yoga/) con YOGIBook. Pagamento Stripe o bonifico, cambi entro 24h."
|
||||
},
|
||||
{
|
||||
"domanda": "Chi sono gli insegnanti?",
|
||||
"risposta": "Hatha Yoga: Giorgia, Pilates Matwork: Barbara, altri corsi: Aurora Masiero."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
## Vanguard - Advanced PHP Login and User Management
|
||||
## YogiBook Aury
|
||||
|
||||
- Website: https://vanguardapp.io
|
||||
- Documentation: https://milos.support-hub.io
|
||||
- Developed by [Milos Stojanovic](https://mstojanovic.net)
|
||||
- Website: https://vanguardapp.io
|
||||
- Documentation: https://milos.support-hub.io
|
||||
- Developed by [Milos Stojanovic](https://mstojanovic.net)
|
||||
|
||||
Attenzione creati dei cron da mettere operativi
|
||||
|
||||
update_expired_lessons.php --> identifica le lezioni scadute e le mette in bookinglcass come scadute
|
||||
non serve il cron perchè le sacadute partono da essre da programmare
|
||||
Reference in New Issue
Block a user