fixed multiple things

This commit is contained in:
2025-10-15 20:59:49 +02:00
parent 754c5f93f0
commit aff67bc496
26 changed files with 3504 additions and 1246 deletions
+60 -137
View File
@@ -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>