fixed multiple things
This commit is contained in:
parent
754c5f93f0
commit
aff67bc496
@ -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;
|
||||
|
||||
@ -39,7 +39,6 @@ $bookedclass->execute();
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
@ -108,7 +107,6 @@ $conn->close();
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>YogiBook - Prenotazioni YogaSoul</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@ -150,6 +148,7 @@ $conn->close();
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Handle "Persa" button click
|
||||
$(".lost-button").click(function() {
|
||||
var idbookingclass = $(this).data("idbookingclass");
|
||||
|
||||
@ -181,46 +180,78 @@ $conn->close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Handle "Ripristina" button click
|
||||
$(".restore-button").click(function() {
|
||||
var idbookingclass = $(this).data("idbookingclass");
|
||||
|
||||
// Mostra un SweetAlert di conferma
|
||||
Swal.fire({
|
||||
title: 'Sei sicuro?',
|
||||
text: 'Vuoi davvero ripristinare questa lezione?',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sì, ripristina',
|
||||
cancelButtonText: 'Annulla'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Se l'utente conferma, esegui l'aggiornamento
|
||||
$.ajax({
|
||||
url: "ripristina_campo_lost.php",
|
||||
method: "POST",
|
||||
data: {
|
||||
idbookingclass: idbookingclass
|
||||
},
|
||||
success: function(response) {
|
||||
// Dopo aver ripristinato con successo la lezione, reindirizza all'adminpanel
|
||||
window.location.href = 'adminpanel.php?success=2';
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire('Errore durante il ripristino', '', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.lost-button {
|
||||
.lost-button,
|
||||
.restore-button {
|
||||
background-color: orange;
|
||||
/* Imposta il colore arancione */
|
||||
color: white;
|
||||
/* Imposta il testo in bianco o altro colore a tua scelta */
|
||||
border: none;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.restore-button {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.lost-button:hover {
|
||||
background-color: darkorange;
|
||||
/* Cambia il colore al passaggio del mouse se lo desideri */
|
||||
}
|
||||
|
||||
.restore-button:hover {
|
||||
background-color: darkgreen;
|
||||
}
|
||||
|
||||
.email-search-results {
|
||||
position: absolute;
|
||||
/* O posizionamento relativo a seconda delle esigenze */
|
||||
top: 100%;
|
||||
/* Posizionamento rispetto all'elemento padre */
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: white;
|
||||
/* Colore di sfondo */
|
||||
border: 1px solid #ccc;
|
||||
/* Bordo */
|
||||
max-height: 200px;
|
||||
/* Altezza massima */
|
||||
overflow-y: auto;
|
||||
/* Scorrimento verticale se i risultati superano l'altezza massima */
|
||||
z-index: 1000;
|
||||
/* Per sovrapporre altri elementi */
|
||||
display: none;
|
||||
/* Inizialmente nascosto */
|
||||
}
|
||||
|
||||
.custom-card {
|
||||
@ -298,7 +329,6 @@ $conn->close();
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
|
||||
.custom-action-button {
|
||||
background-color: #f0f0f0;
|
||||
border: none;
|
||||
@ -361,7 +391,6 @@ $conn->close();
|
||||
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}`;
|
||||
}
|
||||
});
|
||||
@ -375,37 +404,29 @@ $conn->close();
|
||||
text-align: center;
|
||||
border-radius: 10px;
|
||||
margin-right: 20px;
|
||||
/* Spazio tra i box */
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.pastel-color.blue {
|
||||
background-color: #D4E1F1;
|
||||
/* Azzurro pastello */
|
||||
}
|
||||
|
||||
.pastel-color.green {
|
||||
background-color: #FFD8B5;
|
||||
/* Verde pastello */
|
||||
}
|
||||
|
||||
.pastel-color.pink {
|
||||
background-color: #C3E6CB;
|
||||
/* Rosa pastello */
|
||||
}
|
||||
|
||||
.pastel-color.purple {
|
||||
background-color: #F4CCCC;
|
||||
/* Viola pastello */
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.pastel-color {
|
||||
margin-right: 0;
|
||||
/* Rimuovi lo spazio tra i box */
|
||||
margin-bottom: 20px;
|
||||
/* Spazio tra i box */
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -422,7 +443,6 @@ $conn->close();
|
||||
margin-top: 5px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
border: 1px solid #333;
|
||||
/* Aggiunto il bordo grigio scuro */
|
||||
}
|
||||
|
||||
.booking-row td {
|
||||
@ -432,14 +452,11 @@ $conn->close();
|
||||
|
||||
.delete-cell {
|
||||
text-align: left;
|
||||
/* Allinea il contenuto a sinistra */
|
||||
vertical-align: top;
|
||||
/* Allinea il contenuto in alto */
|
||||
}
|
||||
|
||||
.delete-button {
|
||||
display: block;
|
||||
/* Per occupare l'intera larghezza del cell */
|
||||
padding: 6px 12px;
|
||||
border: none;
|
||||
background-color: #e74c3c;
|
||||
@ -455,38 +472,22 @@ $conn->close();
|
||||
</style>
|
||||
|
||||
<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'); ?>
|
||||
|
||||
<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">
|
||||
<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">
|
||||
@ -500,9 +501,6 @@ $conn->close();
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -511,423 +509,304 @@ $conn->close();
|
||||
|
||||
<header class="ishorizontal-topbar">
|
||||
<div class="navbar-header">
|
||||
<div class="d-flex">
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-flex"></div>
|
||||
</div>
|
||||
|
||||
<div class="topnav">
|
||||
<div class="container-fluid">
|
||||
<nav class="navbar navbar-light navbar-expand-lg topnav-menu">
|
||||
|
||||
|
||||
</nav>
|
||||
<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">
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$toprogram = $totalTickets - $passedRecords - $futureRecords;
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<!-- 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-2">
|
||||
<div class="col-xl-3 col-md-12">
|
||||
<div class="pb-3 pb-xl-0">
|
||||
<form class="email-search">
|
||||
<div class="position-relative">
|
||||
<h3>Classi</h3>
|
||||
|
||||
</div>
|
||||
</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-2">
|
||||
<div class="col-xl-3 col-md-12">
|
||||
<div class="pb-3 pb-xl-0">
|
||||
<form class="email-search">
|
||||
<div class="position-relative">
|
||||
<h3>Classi</h3>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-9 col-md-12">
|
||||
<div class="text-sm-end">
|
||||
<?php if ($toprogram > 0) {
|
||||
echo '<button type="button" class="btn btn-info btn-rounded waves-effect waves-light mb-2 me-2" data-bs-toggle="modal" data-bs-target=".create-task"><i class="mdi mdi-plus me-1"></i> Programma Lezioni</button>';
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="col-xl-9 col-md-12">
|
||||
<div class="text-sm-end">
|
||||
<?php if ($toprogram > 0) {
|
||||
echo '<button type="button" class="btn btn-info btn-rounded waves-effect waves-light mb-2 me-2" data-bs-toggle="modal" data-bs-target=".create-task"><i class="mdi mdi-plus me-1"></i> Programma Lezioni</button>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- container-fluid -->
|
||||
<?php
|
||||
if (isset($_GET['success']) && $_GET['success'] == 1) { ?>
|
||||
|
||||
<div class="alert alert-danger success-message" role="alert">
|
||||
Lezione segnata come persa con successo
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="container-fluid">
|
||||
<!-- starts cards -->
|
||||
|
||||
|
||||
|
||||
<!-- Aggiungi le frecce per la navigazione tra i mesi -->
|
||||
<?php
|
||||
$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"
|
||||
];
|
||||
|
||||
?>
|
||||
<div class="month-navigation">
|
||||
<a href="?prev_month=<?php echo date('Y-m', strtotime('-1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-left fa-2x"></i>
|
||||
</a>
|
||||
<h2><?php echo $italianMonths[date("F", strtotime($currentMonthStart))] . ' ' . date("Y", strtotime($currentMonthStart)); ?></h2>
|
||||
<a href="?next_month=<?php echo date('Y-m', strtotime('+1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-right fa-2x"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$wa_startindex = 0;
|
||||
|
||||
if ($bookedclass->TotalRows == 0) {
|
||||
echo "<p>Classi non presenti per questo mese</p>";
|
||||
} else {
|
||||
while (!$bookedclass->atEnd()) {
|
||||
$wa_startindex = $bookedclass->Index;
|
||||
?>
|
||||
<?php
|
||||
// Data dalla variabile $bookedclass->getColumnVal("dateschedule")
|
||||
$dateschedule = $bookedclass->getColumnVal("dateschedule");
|
||||
|
||||
// Converti la data in un oggetto DateTime
|
||||
$dateObj = new DateTime($dateschedule);
|
||||
|
||||
// Estrai il giorno e il mese in italiano
|
||||
$dayInItalian = $dateObj->format("d");
|
||||
$monthInItalian = $dateObj->format("F");
|
||||
|
||||
// Mappa dei nomi 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"
|
||||
];
|
||||
|
||||
// Sostituisci il nome del mese con la versione italiana
|
||||
$monthInItalian = $italianMonths[$monthInItalian];
|
||||
?>
|
||||
<?php
|
||||
// Data dalla variabile $bookedclass->getColumnVal("dateschedule")
|
||||
$dateschedule = $bookedclass->getColumnVal("dateschedule");
|
||||
|
||||
// Converti la data in un oggetto DateTime
|
||||
$dateObj = new DateTime($dateschedule);
|
||||
|
||||
// Formatta la data nel nuovo formato desiderato
|
||||
$newDateFormat = $dateObj->format("d-m-Y H:i");
|
||||
|
||||
// Calculate the time difference in hours
|
||||
$currentTime = new DateTime();
|
||||
$classTime = new DateTime($dateschedule);
|
||||
$timeDifference = $classTime->diff($currentTime);
|
||||
$hoursDifference = $timeDifference->h + $timeDifference->days * 24;
|
||||
|
||||
// Check if the time difference is less than 6 hours
|
||||
$timetocancel = $optionquery->getColumnVal("maxbeforetimecancell");
|
||||
$canBeDeleted = ($hoursDifference >= $timetocancel);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<?php $mysqli = new mysqli($servername, $username, $password, $dbname);
|
||||
// Esegui una nuova query per ottenere le persone prenotate per l'evento corrente
|
||||
$eventId = $bookedclass->getColumnVal("idserviceschedule");
|
||||
$bookingQuery = "SELECT bookingclass.*, auth_users.first_name, auth_users.last_name, auth_users.id
|
||||
FROM bookingclass
|
||||
LEFT JOIN auth_users ON bookingclass.iduser=auth_users.id
|
||||
WHERE bookingclass.idserviceschedule = ? AND bookingclass.status='booked'";
|
||||
$stmt = $mysqli->prepare($bookingQuery);
|
||||
$stmt->bind_param("i", $eventId);
|
||||
$stmt->execute();
|
||||
$bookingResult = $stmt->get_result();
|
||||
|
||||
// Calcola il numero di persone prenotate
|
||||
$countPersons = $bookingResult->num_rows;
|
||||
$stmt->close();
|
||||
$mysqli->close();
|
||||
?>
|
||||
|
||||
<div class="custom-card">
|
||||
<div class="custom-date-box" style="background-color:#1ebf73">
|
||||
<div class="custom-day"><?php echo $dayInItalian; ?></div>
|
||||
<div class="custom-month"><?php echo $monthInItalian; ?></div>
|
||||
</div>
|
||||
<div class="custom-event-details" style="background-color:<?php echo ($bookedclass->getColumnVal("colorclass")); ?>">
|
||||
<h2 class="custom-heading"><?php echo ($bookedclass->getColumnVal("servicename")); ?> -<?php echo $countPersons; ?>/<?php echo ($bookedclass->getColumnVal("maxcapacity")); ?></h2>
|
||||
<p class="custom-paragraph">Quando: <?php echo $newDateFormat; ?></p>
|
||||
<p class="custom-paragraph">Luogo: via Valassina 62/B Seregno - Sala Contesto Yoga</p>
|
||||
<div class="custom">
|
||||
<button class="custom-action-button" onclick="toggleBookings(this)"><i class="fas fa-list-plus"></i> Vedi prenotazioni</button>
|
||||
</div>
|
||||
<div class="custom-actions" style="display: none;">
|
||||
<table class="booking-table">
|
||||
<?php while ($booking = $bookingResult->fetch_assoc()) : ?>
|
||||
<tr class="booking-row">
|
||||
<?php $idbookedclass = $booking['idbookingclass']; ?>
|
||||
<td>
|
||||
<?php echo $booking['first_name']; ?> <?php echo $booking['last_name']; ?>
|
||||
<?php if ($booking['lostlesson'] === 'Y'): ?>
|
||||
<span class="lost-badge">Persa</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="delete-cell">
|
||||
<button class="delete-button" onclick="handleRemoveClick(<?php echo $idbookedclass; ?>)">
|
||||
<i class="fa fa-trash"></i> Rimuovi
|
||||
</button>
|
||||
</td>
|
||||
<td class="lost-cell">
|
||||
<button class="lost-button" data-idbookingclass="<?php echo $idbookedclass; ?>">
|
||||
<i class="fas fa-wind"></i> Persa
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</table>
|
||||
|
||||
<form action="inserisci_record.php" method="post">
|
||||
<label for="name">Nome:</label>
|
||||
<input type="text" class="name" name="name"><br><br>
|
||||
|
||||
<label for="surname">Cognome:</label>
|
||||
<input type="text" class="surname" name="surname"><br><br>
|
||||
|
||||
|
||||
<label for="email">Email:</label>
|
||||
<input type="text" class="email" name="email"><br><br>
|
||||
<input type="hidden" class="userid" name="userid">
|
||||
<input type="hidden" id="idserviceschedule" name="idserviceschedule" value="<?php echo $bookedclass->getColumnVal("idserviceschedule"); ?>">
|
||||
<input type="hidden" id="status" name="status" value="booked">
|
||||
<input type="hidden" id="idorder" name="idorder" value="0">
|
||||
<input type="hidden" id="idservice" name="idservice" value="<?php echo $bookedclass->getColumnVal("idservice"); ?>">
|
||||
<input type="hidden" id="bookingstart" name="bookingstart" value="<?php echo $dateschedule; ?>">
|
||||
|
||||
|
||||
<button type="submit">Inserisci</button>
|
||||
</form>
|
||||
|
||||
<div class="search-results"></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let searchTimeout;
|
||||
|
||||
$(".surname").on("input", function() {
|
||||
clearTimeout(searchTimeout);
|
||||
|
||||
var searchTerm = $(this).val().trim();
|
||||
var currentForm = $(this).closest('form');
|
||||
var searchResults = currentForm.next('.search-results');
|
||||
|
||||
if (searchTerm.length < 3) {
|
||||
searchResults.empty();
|
||||
return;
|
||||
}
|
||||
|
||||
searchTimeout = setTimeout(function() {
|
||||
$.ajax({
|
||||
url: "searchemail.php",
|
||||
method: "POST",
|
||||
data: {
|
||||
searchTerm: searchTerm
|
||||
},
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
searchResults.empty();
|
||||
|
||||
if (data.results && data.results.length > 0) {
|
||||
searchResults.append("<p>Seleziona un utente:</p>");
|
||||
data.results.forEach(function(user) {
|
||||
searchResults.append(
|
||||
'<div class="user-result" data-email="' + user.email + '" data-userid="' + user.id + '" data-firstname="' + user.first_name + '" data-lastname="' + user.last_name + '">' +
|
||||
'Email: ' + user.email + ' | Nome: ' + user.first_name + ' | Cognome: ' + user.last_name +
|
||||
'</div>'
|
||||
);
|
||||
});
|
||||
|
||||
$(".user-result").off("click").on("click", function() {
|
||||
var selectedEmail = $(this).data("email");
|
||||
var selectedUserId = $(this).data("userid");
|
||||
var selectedFirstName = $(this).data("firstname");
|
||||
var selectedLastName = $(this).data("lastname");
|
||||
|
||||
currentForm.find(".email").val(selectedEmail);
|
||||
currentForm.find(".userid").val(selectedUserId);
|
||||
currentForm.find(".name").val(selectedFirstName);
|
||||
currentForm.find(".surname").val(selectedLastName);
|
||||
searchResults.empty();
|
||||
});
|
||||
} else {
|
||||
searchResults.append("<p>Nessun utente trovato.</p>");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
searchResults.empty();
|
||||
searchResults.append("<p>Errore durante la ricerca. Riprova.</p>");
|
||||
console.error("Errore AJAX: ", error);
|
||||
}
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
});
|
||||
|
||||
function toggleBookings(button) {
|
||||
const card = button.closest('.custom-card');
|
||||
const bookings = card.querySelector('.custom-actions');
|
||||
bookings.style.display = bookings.style.display === 'block' ? 'none' : 'block';
|
||||
}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
if (isset($_GET['success'])) {
|
||||
if ($_GET['success'] == 1) { ?>
|
||||
<div class="alert alert-danger success-message" role="alert">
|
||||
Lezione segnata come persa con successo
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
function toggleCard(card) {
|
||||
card.classList.toggle("expanded");
|
||||
}
|
||||
|
||||
function toggleCustomContent(button, content) {
|
||||
const card = button.closest('.custom-card');
|
||||
const bookings = card.querySelector('.custom-actions');
|
||||
const addForm = card.querySelector('.add-booking-form');
|
||||
|
||||
if (content === 'bookings') {
|
||||
bookings.style.display = 'block';
|
||||
addForm.style.display = 'none';
|
||||
} else if (content === 'addForm') {
|
||||
addForm.style.display = 'block';
|
||||
bookings.style.display = 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$bookedclass->moveNext();
|
||||
}
|
||||
<?php } elseif ($_GET['success'] == 2) { ?>
|
||||
<div class="alert alert-success success-message" role="alert">
|
||||
Lezione ripristinata con successo
|
||||
</div>
|
||||
<?php }
|
||||
}
|
||||
|
||||
$bookedclass->moveFirst(); // Ritorna all'inizio del recordset
|
||||
unset($wa_startindex);
|
||||
unset($wa_repeatcount);
|
||||
?>
|
||||
<!-- Aggiungi altre card qui con le stesse classi -->
|
||||
<div class="container-fluid">
|
||||
<?php
|
||||
$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"
|
||||
];
|
||||
?>
|
||||
<div class="month-navigation">
|
||||
<a href="?prev_month=<?php echo date('Y-m', strtotime('-1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-left fa-2x"></i>
|
||||
</a>
|
||||
<h2><?php echo $italianMonths[date("F", strtotime($currentMonthStart))] . ' ' . date("Y", strtotime($currentMonthStart)); ?></h2>
|
||||
<a href="?next_month=<?php echo date('Y-m', strtotime('+1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-right fa-2x"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$wa_startindex = 0;
|
||||
|
||||
if ($bookedclass->TotalRows == 0) {
|
||||
echo "<p>Classi non presenti per questo mese</p>";
|
||||
} else {
|
||||
while (!$bookedclass->atEnd()) {
|
||||
$wa_startindex = $bookedclass->Index;
|
||||
?>
|
||||
<?php
|
||||
$dateschedule = $bookedclass->getColumnVal("dateschedule");
|
||||
$dateObj = new DateTime($dateschedule);
|
||||
$dayInItalian = $dateObj->format("d");
|
||||
$monthInItalian = $dateObj->format("F");
|
||||
$monthInItalian = $italianMonths[$monthInItalian];
|
||||
$newDateFormat = $dateObj->format("d-m-Y H:i");
|
||||
|
||||
$currentTime = new DateTime();
|
||||
$classTime = new DateTime($dateschedule);
|
||||
$timeDifference = $classTime->diff($currentTime);
|
||||
$hoursDifference = $timeDifference->h + $timeDifference->days * 24;
|
||||
$timetocancel = $optionquery->getColumnVal("maxbeforetimecancell");
|
||||
$canBeDeleted = ($hoursDifference >= $timetocancel);
|
||||
|
||||
$mysqli = new mysqli($servername, $username, $password, $dbname);
|
||||
$eventId = $bookedclass->getColumnVal("idserviceschedule");
|
||||
$bookingQuery = "SELECT bookingclass.*, auth_users.first_name, auth_users.last_name, auth_users.id
|
||||
FROM bookingclass
|
||||
LEFT JOIN auth_users ON bookingclass.iduser=auth_users.id
|
||||
WHERE bookingclass.idserviceschedule = ? AND bookingclass.status='booked'";
|
||||
$stmt = $mysqli->prepare($bookingQuery);
|
||||
$stmt->bind_param("i", $eventId);
|
||||
$stmt->execute();
|
||||
$bookingResult = $stmt->get_result();
|
||||
$countPersons = $bookingResult->num_rows;
|
||||
$stmt->close();
|
||||
$mysqli->close();
|
||||
?>
|
||||
|
||||
<div class="custom-card">
|
||||
<div class="custom-date-box" style="background-color:#1ebf73">
|
||||
<div class="custom-day"><?php echo $dayInItalian; ?></div>
|
||||
<div class="custom-month"><?php echo $monthInItalian; ?></div>
|
||||
</div>
|
||||
<div class="custom-event-details" style="background-color:<?php echo ($bookedclass->getColumnVal("colorclass")); ?>">
|
||||
<h2 class="custom-heading"><?php echo ($bookedclass->getColumnVal("servicename")); ?> -<?php echo $countPersons; ?>/<?php echo ($bookedclass->getColumnVal("maxcapacity")); ?></h2>
|
||||
<p class="custom-paragraph">Quando: <?php echo $newDateFormat; ?></p>
|
||||
<p class="custom-paragraph">Luogo: via Valassina 62/B Seregno - Sala Contesto Yoga</p>
|
||||
<div class="custom">
|
||||
<button class="custom-action-button" onclick="toggleBookings(this)"><i class="fas fa-list-plus"></i> Vedi prenotazioni</button>
|
||||
</div>
|
||||
<div class="custom-actions" style="display: none;">
|
||||
<table class="booking-table">
|
||||
<?php while ($booking = $bookingResult->fetch_assoc()) : ?>
|
||||
<tr class="booking-row">
|
||||
<?php $idbookedclass = $booking['idbookingclass']; ?>
|
||||
<td>
|
||||
<?php echo $booking['first_name']; ?> <?php echo $booking['last_name']; ?>
|
||||
<?php if ($booking['lostlesson'] === 'Y'): ?>
|
||||
<span class="lost-badge">Persa</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="delete-cell">
|
||||
<button class="delete-button" onclick="handleRemoveClick(<?php echo $idbookedclass; ?>)">
|
||||
<i class="fa fa-trash"></i> Rimuovi
|
||||
</button>
|
||||
</td>
|
||||
<td class="lost-cell">
|
||||
<?php if ($booking['lostlesson'] === 'Y'): ?>
|
||||
<button class="restore-button" data-idbookingclass="<?php echo $idbookedclass; ?>">
|
||||
<i class="fas fa-undo"></i> Ripristina
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<button class="lost-button" data-idbookingclass="<?php echo $idbookedclass; ?>">
|
||||
<i class="fas fa-wind"></i> Persa
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</table>
|
||||
|
||||
<form action="inserisci_record.php" method="post">
|
||||
<label for="name">Nome:</label>
|
||||
<input type="text" class="name" name="name"><br><br>
|
||||
<label for="surname">Cognome:</label>
|
||||
<input type="text" class="surname" name="surname"><br><br>
|
||||
<label for="email">Email:</label>
|
||||
<input type="text" class="email" name="email"><br><br>
|
||||
<input type="hidden" class="userid" name="userid">
|
||||
<input type="hidden" id="idserviceschedule" name="idserviceschedule" value="<?php echo $bookedclass->getColumnVal("idserviceschedule"); ?>">
|
||||
<input type="hidden" id="status" name="status" value="booked">
|
||||
<input type="hidden" id="idorder" name="idorder" value="0">
|
||||
<input type="hidden" id="idservice" name="idservice" value="<?php echo $bookedclass->getColumnVal("idservice"); ?>">
|
||||
<input type="hidden" id="bookingstart" name="bookingstart" value="<?php echo $dateschedule; ?>">
|
||||
<button type="submit">Inserisci</button>
|
||||
</form>
|
||||
<div class="search-results"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let searchTimeout;
|
||||
|
||||
$(".surname").on("input", function() {
|
||||
clearTimeout(searchTimeout);
|
||||
|
||||
var searchTerm = $(this).val().trim();
|
||||
var currentForm = $(this).closest('form');
|
||||
var searchResults = currentForm.next('.search-results');
|
||||
|
||||
if (searchTerm.length < 3) {
|
||||
searchResults.empty();
|
||||
return;
|
||||
}
|
||||
|
||||
searchTimeout = setTimeout(function() {
|
||||
$.ajax({
|
||||
url: "searchemail.php",
|
||||
method: "POST",
|
||||
data: {
|
||||
searchTerm: searchTerm
|
||||
},
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
searchResults.empty();
|
||||
|
||||
if (data.results && data.results.length > 0) {
|
||||
searchResults.append("<p>Seleziona un utente:</p>");
|
||||
data.results.forEach(function(user) {
|
||||
searchResults.append(
|
||||
'<div class="user-result" data-email="' + user.email + '" data-userid="' + user.id + '" data-firstname="' + user.first_name + '" data-lastname="' + user.last_name + '">' +
|
||||
'Email: ' + user.email + ' | Nome: ' + user.first_name + ' | Cognome: ' + user.last_name +
|
||||
'</div>'
|
||||
);
|
||||
});
|
||||
|
||||
$(".user-result").off("click").on("click", function() {
|
||||
var selectedEmail = $(this).data("email");
|
||||
var selectedUserId = $(this).data("userid");
|
||||
var selectedFirstName = $(this).data("firstname");
|
||||
var selectedLastName = $(this).data("lastname");
|
||||
|
||||
currentForm.find(".email").val(selectedEmail);
|
||||
currentForm.find(".userid").val(selectedUserId);
|
||||
currentForm.find(".name").val(selectedFirstName);
|
||||
currentForm.find(".surname").val(selectedLastName);
|
||||
searchResults.empty();
|
||||
});
|
||||
} else {
|
||||
searchResults.append("<p>Nessun utente trovato.</p>");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
searchResults.empty();
|
||||
searchResults.append("<p>Errore durante la ricerca. Riprova.</p>");
|
||||
console.error("Errore AJAX: ", error);
|
||||
}
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
});
|
||||
|
||||
function toggleBookings(button) {
|
||||
const card = button.closest('.custom-card');
|
||||
const bookings = card.querySelector('.custom-actions');
|
||||
bookings.style.display = bookings.style.display === 'block' ? 'none' : 'block';
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleCard(card) {
|
||||
card.classList.toggle("expanded");
|
||||
}
|
||||
|
||||
function toggleCustomContent(button, content) {
|
||||
const card = button.closest('.custom-card');
|
||||
const bookings = card.querySelector('.custom-actions');
|
||||
const addForm = card.querySelector('.add-booking-form');
|
||||
|
||||
if (content === 'bookings') {
|
||||
bookings.style.display = 'block';
|
||||
addForm.style.display = 'none';
|
||||
} else if (content === 'addForm') {
|
||||
addForm.style.display = 'block';
|
||||
bookings.style.display = 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
$bookedclass->moveNext();
|
||||
}
|
||||
}
|
||||
$bookedclass->moveFirst();
|
||||
unset($wa_startindex);
|
||||
unset($wa_repeatcount);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</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>
|
||||
@ -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();
|
||||
|
||||
67
public/calculate_expiry.php
Normal file
67
public/calculate_expiry.php
Normal file
@ -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();
|
||||
@ -273,8 +273,8 @@ file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
confirmButtonText: "Cancella Lezione",
|
||||
cancelButtonText: "Riprogramma Lezione",
|
||||
showDenyButton: true,
|
||||
denyButtonText: "Torna al Portale",
|
||||
denyButtonColor: "#6c757d"
|
||||
denyButtonText: "Riprogramma Lezione",
|
||||
denyButtonColor: "#e47c06ff"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
console.log("Cliccato 'Cancella Lezione' per ID <?php echo $idbookingclass; ?>");
|
||||
@ -302,7 +302,7 @@ file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
alert("Errore: impossibile reindirizzare a rebook-from-cancel.php. Controlla la console del browser.");
|
||||
}
|
||||
} else if (result.isDenied) {
|
||||
console.log("Cliccato 'Torna al Portale', reindirizzamento a: https://yogibook.yogasoul.it");
|
||||
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); ?>");
|
||||
}
|
||||
});
|
||||
|
||||
6
public/cancella_prenotazione_log.txt
Normal file
6
public/cancella_prenotazione_log.txt
Normal file
@ -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
|
||||
1497
public/dashboard_log.txt
Normal file
1497
public/dashboard_log.txt
Normal file
File diff suppressed because it is too large
Load Diff
211
public/include/options.php
Normal file
211
public/include/options.php
Normal file
@ -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>
|
||||
@ -62,6 +62,13 @@
|
||||
<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="">
|
||||
|
||||
35
public/include/update_lessonnotification.php
Normal file
35
public/include/update_lessonnotification.php
Normal file
@ -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();
|
||||
212
public/options.php
Normal file
212
public/options.php
Normal file
@ -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>
|
||||
@ -1,69 +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);
|
||||
}
|
||||
|
||||
$logMessage .= "Database connesso: $dbname\n";
|
||||
|
||||
// Query per selezionare i dati filtrati per iduser
|
||||
$query = "SELECT o.*, s.servicename, s.day, s.time
|
||||
$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, 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'];
|
||||
echo "<!-- Debug: order_id usato: $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, 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();
|
||||
echo "<!-- Debug: Query per order_id $order_id: $lesson_query -->";
|
||||
$logMessage .= "Query lezioni per idorderbook $idorderbook: $lesson_query\n";
|
||||
if ($lesson_result) {
|
||||
echo "<!-- Debug: Numero di righe restituite: " . $lesson_result->num_rows . " -->";
|
||||
$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'])); // Formato ISO 8601
|
||||
$lesson_row['bookingstart'] = date('c', strtotime($lesson_row['bookingstart']));
|
||||
$lessons[] = $lesson_row;
|
||||
echo "<!-- Debug: Lezione aggiunta: " . json_encode($lesson_row) . " -->";
|
||||
$logMessage .= "Lezione aggiunta: " . json_encode($lesson_row) . "\n";
|
||||
}
|
||||
} else {
|
||||
echo "<!-- Debug: Errore nella query per order_id $order_id: " . $conn->error . " -->";
|
||||
$logMessage .= "Errore nella query per idorderbook $idorderbook: " . $conn->error . "\n";
|
||||
}
|
||||
$row['lessons'] = $lessons;
|
||||
$documents[] = $row;
|
||||
echo "<!-- Debug: Lezioni per order_id " . $row['order_id'] . ": " . count($lessons) . " -->";
|
||||
$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" />
|
||||
@ -76,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>
|
||||
@ -89,10 +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); // Debug
|
||||
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();
|
||||
@ -111,6 +135,12 @@ 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,
|
||||
@ -120,46 +150,55 @@ while ($row = $result->fetch_assoc()) {
|
||||
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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
if (lessons.length === 0) {
|
||||
htmlContent += `
|
||||
@ -234,17 +273,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') ||
|
||||
@ -258,6 +296,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}
|
||||
@ -266,27 +316,29 @@ 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>
|
||||
</div>
|
||||
</div> <p style="margin: 0 0 15px 0; color: #333; font-size: 14px; font-weight: 500;">
|
||||
Il tuo ordine scadrà il ${expireOnFormatted}
|
||||
</p>
|
||||
<div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px;">
|
||||
<table class="lesson-table">
|
||||
<thead>
|
||||
@ -369,24 +421,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 {
|
||||
@ -630,13 +682,15 @@ while ($row = $result->fetch_assoc()) {
|
||||
<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>
|
||||
@ -647,10 +701,9 @@ while ($row = $result->fetch_assoc()) {
|
||||
<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 echo "<!-- Total per order_id " . $document['order_id'] . ": " . $document['quantityclass'] . " -->"; ?>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -671,4 +724,7 @@ while ($row = $result->fetch_assoc()) {
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php $conn->close(); ?>
|
||||
<?php
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
$conn->close();
|
||||
?>
|
||||
@ -8,6 +8,8 @@ $conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
die("Connessione fallita: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Gestione del messaggio GET
|
||||
if (isset($_GET['message'])) {
|
||||
$message = $_GET['message'];
|
||||
} else {
|
||||
@ -31,20 +33,6 @@ if (isset($_POST['submit'])) {
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
// Gestione dell'aggiornamento della data di scadenza
|
||||
if (isset($_POST['update_expiry'])) {
|
||||
$order_id = $_POST['order_id'];
|
||||
$new_expiry = $_POST['new_expiry'];
|
||||
$stmt = $conn->prepare("UPDATE orderbook SET expireon = ? WHERE order_id = ?");
|
||||
$stmt->bind_param("si", $new_expiry, $order_id);
|
||||
if ($stmt->execute()) {
|
||||
$message = 'success';
|
||||
} else {
|
||||
$message = 'error';
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
|
||||
// Gestione del filtro per gli ordini
|
||||
$filter = isset($_GET['filter']) ? $_GET['filter'] : 'all';
|
||||
$today = date("Y-m-d");
|
||||
@ -56,11 +44,11 @@ if ($filter == 'active') {
|
||||
}
|
||||
|
||||
// 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, o.nticket
|
||||
$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.order_id DESC";
|
||||
ORDER BY o.idorderbook DESC";
|
||||
$result = $conn->query($query);
|
||||
$orders = [];
|
||||
if ($result->num_rows > 0) {
|
||||
@ -113,6 +101,7 @@ if ($result_dayoff->num_rows > 0) {
|
||||
minDate: 0,
|
||||
onSelect: function(dateText) {
|
||||
let orderId = $(this).data('order-id');
|
||||
console.log("Datepicker selezionato - idorderbook: " + orderId + ", newExpiry: " + dateText);
|
||||
confirmUpdate(orderId, dateText);
|
||||
}
|
||||
});
|
||||
@ -122,12 +111,21 @@ if ($result_dayoff->num_rows > 0) {
|
||||
$(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!",
|
||||
@ -139,35 +137,42 @@ if ($result_dayoff->num_rows > 0) {
|
||||
cancelButtonText: "Annulla"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
let form = $('<form>', {
|
||||
'method': 'POST',
|
||||
'action': ''
|
||||
}).append(
|
||||
$('<input>', {
|
||||
'type': 'hidden',
|
||||
'name': 'order_id',
|
||||
'value': orderId
|
||||
}),
|
||||
$('<input>', {
|
||||
'type': 'hidden',
|
||||
'name': 'new_expiry',
|
||||
'value': newExpiry
|
||||
}),
|
||||
$('<input>', {
|
||||
'type': 'hidden',
|
||||
'name': 'update_expiry',
|
||||
'value': '1'
|
||||
})
|
||||
);
|
||||
$('body').append(form);
|
||||
form.submit();
|
||||
$.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 {
|
||||
location.reload();
|
||||
originalCell.text(originalDate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Funzione per confermare la cancellazione (mantenuta dal template originale)
|
||||
// Funzione per confermare la cancellazione
|
||||
function confirmDelete(id, deletePageUrl) {
|
||||
Swal.fire({
|
||||
title: "Sei sicuro?",
|
||||
@ -343,9 +348,6 @@ if ($result_dayoff->num_rows > 0) {
|
||||
<div class="main-content">
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
@ -379,12 +381,12 @@ if ($result_dayoff->num_rows > 0) {
|
||||
?>
|
||||
<tr>
|
||||
<td><span class="<?php echo $badgeClass; ?>"><?php echo $badgeText; ?></span></td>
|
||||
<td><?php echo $order["order_id"]; ?></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['order_id']; ?>"><?php echo $order["expireon"]; ?></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 } ?>
|
||||
|
||||
3
public/php_errors.log
Normal file
3
public/php_errors.log
Normal file
@ -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
|
||||
@ -2,3 +2,6 @@ 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)
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -17,6 +17,9 @@ if ($conn->connect_error) {
|
||||
$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";
|
||||
@ -147,7 +150,7 @@ $currentMonthEnd = date("Y-m-t", strtotime($currentMonthStart));
|
||||
// Aggiungi filtro per la data di scadenza
|
||||
$expiryCondition = '';
|
||||
if ($expiryDate) {
|
||||
$expiryCondition = "AND serviceschedule.dateschedule <= '{$expiryDate->format('Y-m-d 23:59:59')}'";
|
||||
$expiryCondition = "AND ss.dateschedule <= '{$expiryDate->format('Y-m-d 23:59:59')}'";
|
||||
}
|
||||
|
||||
// Query per le lezioni disponibili
|
||||
@ -159,13 +162,35 @@ $query = "SELECT ss.*, s.servicename, s.colorclass, s.maxcapacity
|
||||
$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 = [
|
||||
@ -200,7 +225,7 @@ file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
<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@10"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<style>
|
||||
.custom-card {
|
||||
margin: 10px auto;
|
||||
@ -325,156 +350,54 @@ file_put_contents($logFile, $logMessage, FILE_APPEND);
|
||||
}
|
||||
|
||||
.booking-button {
|
||||
background-color: #1ebf73;
|
||||
color: #fff;
|
||||
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: #17a663;
|
||||
background-color: #17a081;
|
||||
}
|
||||
</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">Riprogramma la tua lezione</h4>
|
||||
</div>
|
||||
<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="d-flex">
|
||||
<?php include('include/languageselection.php'); ?>
|
||||
<?php include('include/profiletopbar.php'); ?>
|
||||
<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>
|
||||
</header>
|
||||
<?php include('include/sidebar.php'); ?>
|
||||
<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">
|
||||
<h3>Riprogrammazione Lezione</h3>
|
||||
<p>Lezione attuale: <?php echo htmlspecialchars($servicename); ?> del <?php echo htmlspecialchars($newtimeformat); ?></p>
|
||||
<p>Scadenza abbonamento: <?php echo htmlspecialchars($expireon); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="month-navigation">
|
||||
<a href="?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&prev_month=<?php echo date('Y-m', strtotime('-1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-left fa-2x"></i>
|
||||
</a>
|
||||
<h2><?php echo $italianMonths[date("F", strtotime($currentMonthStart))] . ' ' . date("Y", strtotime($currentMonthStart)); ?></h2>
|
||||
<a href="?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&next_month=<?php echo date('Y-m', strtotime('+1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-right fa-2x"></i>
|
||||
</a>
|
||||
</div>
|
||||
<?php if ($bookedclass->num_rows == 0): ?>
|
||||
<p>Classi non presenti per questo mese o oltre la data di scadenza.</p>
|
||||
<a href="https://yogibook.yogasoul.it" class="btn btn-primary">Torna al portale</a>
|
||||
<?php else: ?>
|
||||
<?php while ($row = $bookedclass->fetch_assoc()): ?>
|
||||
<?php
|
||||
$dateschedule = $row['dateschedule'];
|
||||
$dateObj = new DateTime($dateschedule);
|
||||
$dayInItalian = $dateObj->format("d");
|
||||
$monthInItalian = $italianMonths[$dateObj->format("F")];
|
||||
$newDateFormat = $dateObj->format("d-m-Y H:i");
|
||||
|
||||
$eventId = $row['idserviceschedule'];
|
||||
$bookingQuery = "SELECT iduser FROM bookingclass WHERE idserviceschedule = ? AND status='booked'";
|
||||
$stmtBooking = $conn->prepare($bookingQuery);
|
||||
$stmtBooking->bind_param("i", $eventId);
|
||||
$stmtBooking->execute();
|
||||
$bookingResult = $stmtBooking->get_result();
|
||||
$countPersons = $bookingResult->num_rows;
|
||||
$stmtBooking->close();
|
||||
|
||||
$maxcapacity = $row['maxcapacity'];
|
||||
$freeplace = $maxcapacity - $countPersons;
|
||||
|
||||
$idcheckservice = $row['idserviceschedule'];
|
||||
$query = "SELECT * FROM bookingclass WHERE idserviceschedule = ? AND iduser = ?";
|
||||
$stmtCheck = $conn->prepare($query);
|
||||
$stmtCheck->bind_param("ii", $idcheckservice, $iduser);
|
||||
$stmtCheck->execute();
|
||||
$resultcheck = $stmtCheck->get_result();
|
||||
$alreadybooked = $resultcheck->num_rows > 0 ? 'Y' : 'N';
|
||||
$stmtCheck->close();
|
||||
?>
|
||||
<div class="custom-card" onclick="toggleCard(this)">
|
||||
<?php if ($alreadybooked == 'Y'): ?>
|
||||
<div class="custom-date-box" style="background-color:#FF6609">
|
||||
<?php elseif ($freeplace > 0): ?>
|
||||
<div class="custom-date-box" style="background-color:#1ebf73">
|
||||
<?php else: ?>
|
||||
<div class="custom-date-box" style="background-color:#9C9C9C">
|
||||
<?php endif; ?>
|
||||
<div class="custom-day"><?php echo $dayInItalian; ?></div>
|
||||
<div class="custom-month"><?php echo $monthInItalian; ?></div>
|
||||
</div>
|
||||
<?php if ($alreadybooked == 'Y'): ?>
|
||||
<div class="custom-event-details" style="background-color:#FFAC7A">
|
||||
<?php elseif ($freeplace > 0): ?>
|
||||
<div class="custom-event-details" style="background-color:<?php echo htmlspecialchars($row['colorclass']); ?>">
|
||||
<?php else: ?>
|
||||
<div class="custom-event-details" style="background-color:#CDCDCD">
|
||||
<?php endif; ?>
|
||||
<h2 class="custom-heading"><?php echo htmlspecialchars($row['servicename']); ?> - <?php echo $countPersons; ?>/<?php echo $maxcapacity; ?></h2>
|
||||
<p class="custom-paragraph">Quando: <?php echo $newDateFormat; ?></p>
|
||||
<p class="custom-paragraph">Luogo: via Valassina 62/B Seregno - Sala Contesto Yoga</p>
|
||||
<div class="booking-details">
|
||||
<?php if ($alreadybooked == 'Y'): ?>
|
||||
<button class="booking-button"><i class="fa fa-check"></i> Sei già prenotata/o</button>
|
||||
<?php elseif ($freeplace > 0): ?>
|
||||
<a href="rebookandgo.php?idpreviousbooking=<?php echo $idbookingclass; ?>&idservicenew=<?php echo $row['idservice']; ?>&idnewbooking=<?php echo $row['idserviceschedule']; ?>&iduser=<?php echo $iduser; ?>">
|
||||
<button class="booking-button"><i class="fas fa-arrow-circle-right"></i> Riprogramma Classe</button>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<button class="booking-button"><i class="fa fa-stop"></i> Classe Piena</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
<div class="month-navigation">
|
||||
<a href="?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&prev_month=<?php echo date('Y-m', strtotime('-1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-left fa-2x"></i>
|
||||
</a>
|
||||
<h2><?php echo $italianMonths[date("F", strtotime($currentMonthStart))] . ' ' . date("Y", strtotime($currentMonthStart)); ?></h2>
|
||||
<a href="?idbookingclass=<?php echo $idbookingclass; ?>&token=<?php echo urlencode($token); ?>&next_month=<?php echo date('Y-m', strtotime('+1 month', strtotime($currentMonthStart))); ?>" class="arrow-link">
|
||||
<i class="fas fa-chevron-right fa-2x"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function toggleCard(card) {
|
||||
card.classList.toggle("expanded");
|
||||
}
|
||||
</script>
|
||||
<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>
|
||||
<?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>
|
||||
|
||||
63
public/rebook_from_cancel_log.txt
Normal file
63
public/rebook_from_cancel_log.txt
Normal file
@ -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
|
||||
26
public/ripristina_campo_lost.php
Normal file
26
public/ripristina_campo_lost.php
Normal file
@ -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();
|
||||
@ -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>
|
||||
78
public/update_expired_lessons.php
Normal file
78
public/update_expired_lessons.php
Normal file
@ -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();
|
||||
103
public/update_expiry.php
Normal file
103
public/update_expiry.php
Normal file
@ -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;
|
||||
35
public/update_lessonnotification.php
Normal file
35
public/update_lessonnotification.php
Normal file
@ -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();
|
||||
@ -30,7 +30,6 @@ if ($currentDate > $currentMonthStart) {
|
||||
}
|
||||
|
||||
$currentMonthEnd = date("Y-m-t", strtotime($currentMonthStart));
|
||||
echo $currentMonthEnd;
|
||||
$bookedclass->setQuery("SELECT * FROM bookingclass
|
||||
LEFT JOIN service ON bookingclass.idservice = service.idservice
|
||||
LEFT JOIN serviceschedule ON bookingclass.idserviceschedule = serviceschedule.idserviceschedule
|
||||
@ -85,15 +84,15 @@ $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 per contare i record con data e ora passate e future, escludendo status = 'cancelled'
|
||||
$query = "SELECT COUNT(*) AS total,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule <= '$currentDateTime' AND bookingclass.status = 'booked' AND bookingclass.lostlesson = 'N' THEN 1 ELSE 0 END) AS passed,
|
||||
SUM(CASE WHEN serviceschedule.dateschedule > '$currentDateTime' AND bookingclass.status = 'booked' AND bookingclass.lostlesson = 'N' THEN 1 ELSE 0 END) AS future,
|
||||
SUM(CASE WHEN bookingclass.lostlesson = 'Y' THEN 1 ELSE 0 END) AS lost,
|
||||
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 = $iduser";
|
||||
WHERE bookingclass.iduser = $iduser AND bookingclass.status != 'cancelled'";
|
||||
|
||||
$result = $conn->query($query);
|
||||
if ($result) {
|
||||
|
||||
13
readme.md
13
readme.md
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user