diff --git a/.env b/.env index c6c153a..2739f99 100644 --- a/.env +++ b/.env @@ -31,7 +31,6 @@ MAIL_USERNAME=info@yogasoul.it MAIL_PASSWORD=!Testolina88 MAIL_ENCRYPTION=ssl - PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 0000000..c4837a3 --- /dev/null +++ b/phpinfo.php @@ -0,0 +1 @@ + @@ -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="

Ciao $firstname ,

-

La tua richiesta di riprogrammazione è stata accettata!

-

Ecco il dettaglio della riprogrammazione $newtimeformat

-
-

Per vedere e gestire le tue lezioni clicca qui: https://yogibook.yogasoul.it

-
-

Per il primo accesso devi per prima cosa resettare la password cliccando di seguito

-
- - Reset Password - -
-
-

Ci vediamo sul tappetino!

-

Il Team Yogasoul

"; + 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=" - YogiBook - YogaSoul - "; + $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 = " +

Ciao $firstname ,

+

La tua richiesta di riprogrammazione è stata accettata!

+

Ecco il dettaglio della riprogrammazione $newtimeformat

+
+

Per vedere e gestire le tue lezioni clicca qui: https://yogibook.yogasoul.it

+
+

Per il primo accesso devi per prima cosa resettare la password cliccando di seguito

+
+ + Reset Password + +
+
+

Ci vediamo sul tappetino!

+

Il Team Yogasoul

"; + $buttonedit = " + YogiBook - YogaSoul + "; -$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(); -?> - - - - - - +?> \ No newline at end of file diff --git a/public/adminpanel.php b/public/adminpanel.php index 5734ffb..d727acb 100644 --- a/public/adminpanel.php +++ b/public/adminpanel.php @@ -1,17 +1,21 @@ - - - -setQuery("SELECT * FROM option"); -$optionquery->execute(); -?> + connect_error) { + die("Connessione fallita: " . $conn->connect_error); +} + +// Recupera maxbeforetimecancell dalla tabella option +$option_query = "SELECT maxbeforetimecancell FROM option LIMIT 1"; +$option_result = $conn->query($option_query); +if ($option_result && $option_result->num_rows > 0) { + $option_row = $option_result->fetch_assoc(); + $timetocancel = $option_row['maxbeforetimecancell']; +} else { + $timetocancel = 24; // Valore predefinito se non trovato (es. 24 ore) +} // Verifica se è stata specificata una richiesta per cambiare il mese if (isset($_GET['prev_month'])) { @@ -22,33 +26,17 @@ if (isset($_GET['prev_month'])) { $currentMonthStart = date("Y-m-01"); } -$currentDate = date("Y-m-d"); - -// Modifica: Se la data odierna è dopo l'inizio del mese corrente, imposta la data odierna come inizio -//if ($currentDate > $currentMonthStart) { -// $currentMonthStart = $currentDate; -//} - $currentMonthEnd = date("Y-m-t", strtotime($currentMonthStart)); +$bookedclass = new WA_MySQLi_RS("bookedclass", $conn, 0); $bookedclass->setQuery("SELECT * FROM serviceschedule LEFT JOIN service ON serviceschedule.idservice = service.idservice WHERE serviceschedule.dateschedule BETWEEN '$currentMonthStart' AND DATE_ADD('$currentMonthEnd', INTERVAL 1 DAY) ORDER BY serviceschedule.dateschedule"); $bookedclass->execute(); -?> - -connect_error) { - die("Connessione fallita: " . $conn->connect_error); -} - // ID dell'utente per il quale vuoi filtrare gli ordini $userid = 1; -// 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 @@ -66,31 +54,17 @@ if ($result->num_rows > 0) { $totalTickets = $row["total_tickets"]; } } else { - $totalTickets = 0; // Imposta a zero se non ci sono righe nella query + $totalTickets = 0; } -$conn->close(); -?> -connect_error) { - die("Connessione al database fallita: " . $conn->connect_error); -} - -// ID dell'utente per il quale si desidera eseguire la query -$iduser = 1; // 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 +$currentDateTime = date("Y-m-d H:i:s"); $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"; + WHERE bookingclass.iduser = $userid"; $result = $conn->query($query); if ($result) { @@ -99,7 +73,7 @@ if ($result) { $passedRecords = $row['passed']; $futureRecords = $row['future']; } -// Chiusura della connessione + $conn->close(); ?> @@ -112,25 +86,15 @@ $conn->close(); - - - - - - - - - - + + - + // Handle "Riprogramma" button click + $(".reprogram-button").click(function() { + var idbookingclass = $(this).data("idbookingclass"); + $.ajax({ + url: "get_available_classes.php?t=" + new Date().getTime(), + method: "GET", + dataType: "json", + success: function(data) { + if (data.error) { + Swal.fire('Errore', data.error, 'error'); + console.error('Errore nella risposta JSON:', data.error); + return; + } + + // Crea la tendina con le lezioni disponibili + let selectOptions = ''; + let selectedSet = false; + const now = new Date(); + const 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' + }; + + data.classes.forEach(function(cls) { + // Gestione della data + let displayDate; + if (cls.display_dateschedule) { + displayDate = cls.display_dateschedule; + } else if (cls.dateschedule) { + // Converte dateschedule (es. "2024-10-28 19:30") in formato italiano + const dateObj = new Date(cls.dateschedule); + const day = dateObj.getDate().toString().padStart(2, '0'); + const month = italianMonths[dateObj.toLocaleString('en-US', { + month: 'long' + })]; + const year = dateObj.getFullYear(); + const hours = dateObj.getHours().toString().padStart(2, '0'); + const minutes = dateObj.getMinutes().toString().padStart(2, '0'); + displayDate = `${day} ${month} ${year} ${hours}:${minutes}`; + } else { + displayDate = 'Data non disponibile'; + } + + // Gestione dell'occupazione + const occupancy = (typeof cls.occupied_seats !== 'undefined' && typeof cls.maxcapacity !== 'undefined') ? + `(${cls.occupied_seats}/${cls.maxcapacity})` : + '(0/0)'; + + // Selezione della data per il confronto + const classDate = cls.iso_dateschedule ? new Date(cls.iso_dateschedule) : (cls.dateschedule ? new Date(cls.dateschedule) : new Date()); + const isSelected = !selectedSet && classDate >= now ? 'selected' : ''; + if (!selectedSet && classDate >= now) selectedSet = true; + + selectOptions += ``; + }); + + Swal.fire({ + title: 'Riprogramma Lezione', + html: ` + + +
+ + + `, + showCancelButton: true, + confirmButtonText: 'Riprogramma', + cancelButtonText: 'Annulla', + preConfirm: () => { + const selectedClass = document.getElementById('class-select').value; + const isReprogrammed = document.getElementById('is-reprogrammed').checked ? 'Y' : 'N'; + if (!selectedClass) { + Swal.showValidationMessage('Seleziona una lezione'); + return false; + } + return { + idbookingclass: idbookingclass, + idserviceschedule: selectedClass, + is_reprogrammed: isReprogrammed + }; + } + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + url: "reprogramclass.php", + method: "POST", + data: { + idbookingclass: result.value.idbookingclass, + idserviceschedule: result.value.idserviceschedule, + is_reprogrammed: result.value.is_reprogrammed + }, + success: function(response) { + window.location.href = 'adminpanel.php?success=3'; + }, + error: function(xhr, status, error) { + console.error('Errore AJAX riprogrammazione:', status, error, xhr.responseText); + Swal.fire('Errore durante la riprogrammazione', 'Dettagli: ' + status + ' - ' + error, 'error'); + } + }); + } + }); + }, + error: function(xhr, status, error) { + console.error('Errore AJAX:', status, error, xhr.responseText); + Swal.fire('Errore durante il recupero delle lezioni', 'Dettagli: ' + status + ' - ' + error, 'error'); + } + }); + }); + }); + + 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}`; + } + }); + } + - - - - +
@@ -506,7 +585,6 @@ $conn->close();
-
-

- Il tuo ordine scadrà il ${expireOnFormatted} -

+
@@ -346,6 +347,7 @@ file_put_contents($logFile, $logMessage, FILE_APPEND); + @@ -354,7 +356,7 @@ file_put_contents($logFile, $logMessage, FILE_APPEND); if (lessons.length === 0) { htmlContent += ` - @@ -386,6 +388,7 @@ file_put_contents($logFile, $logMessage, FILE_APPEND); statusText = 'Programmata'; } } + var isReprogrammedText = lesson.is_reprogrammed === 'Y' ? 'Sì' : 'No'; htmlContent += ` @@ -400,6 +403,7 @@ file_put_contents($logFile, $logMessage, FILE_APPEND); + `; }); @@ -676,6 +680,8 @@ file_put_contents($logFile, $logMessage, FILE_APPEND); + + @@ -696,7 +702,19 @@ file_put_contents($logFile, $logMessage, FILE_APPEND); - + + +
Data e Ora Lezione StatoRiprogrammata
+ Nessuna lezione trovata per questo ordine.
${statusText} ${isReprogrammedText}
N. Ticket Prima Lezione ScadenzaRiprogr. MassimeRiprogrammate Stato
+ + + + + + + + + + diff --git a/public/phpinfo.php b/public/phpinfo.php new file mode 100644 index 0000000..c4837a3 --- /dev/null +++ b/public/phpinfo.php @@ -0,0 +1 @@ + $currentMonthStart) { } $currentMonthEnd = date("Y-m-t", strtotime($currentMonthStart)); -$bookedclass->setQuery("SELECT * FROM bookingclass +$bookedclass->setQuery("SELECT bookingclass.*, service.*, serviceschedule.*, orderbook.expireon + FROM bookingclass LEFT JOIN service ON bookingclass.idservice = service.idservice LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule + LEFT JOIN orderbook ON bookingclass.idorder = orderbook.idorderbook WHERE bookingclass.iduser = '$iduserlogin' AND bookingclass.status = 'booked' - AND serviceschedule.dateschedule BETWEEN '$currentMonthStart' AND DATE_ADD('$currentMonthEnd', INTERVAL 1 DAY) ORDER BY serviceschedule.dateschedule"); + AND serviceschedule.dateschedule BETWEEN '$currentMonthStart' AND DATE_ADD('$currentMonthEnd', INTERVAL 1 DAY) + ORDER BY serviceschedule.dateschedule"); + $bookedclass->execute(); ?> @@ -310,6 +314,29 @@ $conn->close(); } }); } + + function confirmDeleteOnly(idbookingclass, expirydate) { + Swal.fire({ + title: "Attenzione", + html: ` + Confermi di voler cancellare questa lezione?

+ RICORDA: dovrai riprogrammarla entro la scadenza del tuo abbonamento per non perderla!

+ + Scadenza: ${expirydate} + + `, + icon: "warning", + showCancelButton: true, + confirmButtonText: "Procedi", + cancelButtonText: "Annulla", + confirmButtonColor: "#d33", + cancelButtonColor: "#3085d6" + }).then((result) => { + if (result.isConfirmed) { + window.location.href = "delete_lesson.php?id=" + idbookingclass; + } + }); + } @@ -422,6 +449,14 @@ $conn->close(); + + + +
@@ -561,11 +596,17 @@ $conn->close(); getColumnVal("idbookingclass"); ?> getColumnVal("idservice"); ?> + getColumnVal("expireon"))); ?> + +
diff --git a/public/userprofiledoc.php b/public/userprofiledoc.php index dc01e9b..323582f 100644 --- a/public/userprofiledoc.php +++ b/public/userprofiledoc.php @@ -438,7 +438,7 @@ $conn->close();

- +
I documenti caricati sono solo a fini di sicurezza e cliccando su carica documento accetti il nostro regolamento privacy