fixed finances my lesson etc
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
if (!isset($iduserlogin)) header('Location: login.php');
|
||||
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
// Scuola corrente
|
||||
$school_id = session('school_id');
|
||||
if (!$school_id) die("Nessuna scuola selezionata");
|
||||
|
||||
// Dati utente
|
||||
$stmt = $pdo->prepare("SELECT first_name FROM auth_users WHERE id = ?");
|
||||
$stmt->execute([$iduserlogin]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
// === LEZIONI FUTURE DELL'UTENTE (prenotate) ===
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT
|
||||
sb.id as booking_id,
|
||||
sb.booked_at,
|
||||
sb.status,
|
||||
cs.session_date,
|
||||
cs.start_time,
|
||||
cs.end_time,
|
||||
c.name as class_name,
|
||||
ct.level,
|
||||
ct.day_of_week,
|
||||
t.first_name as teacher_name,
|
||||
o.id as order_id,
|
||||
o.available_entries,
|
||||
o.total_entries,
|
||||
o.available_recoveries
|
||||
FROM session_bookings sb
|
||||
JOIN class_sessions cs ON sb.session_id = cs.id
|
||||
JOIN class_types ct ON cs.class_type_id = ct.id
|
||||
JOIN classes c ON ct.class_id = c.id
|
||||
LEFT JOIN teachers t ON cs.teacher_id = t.id
|
||||
JOIN orders o ON sb.order_id = o.id
|
||||
WHERE sb.user_id = ?
|
||||
AND cs.school_id = ?
|
||||
AND cs.session_date >= CURDATE()
|
||||
ORDER BY cs.session_date ASC, cs.start_time ASC
|
||||
");
|
||||
$stmt->execute([$iduserlogin, $school_id]);
|
||||
$bookings = $stmt->fetchAll();
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Le mie lezioni - Yogiboook</title>
|
||||
<?php include('cssinclude.php'); ?>
|
||||
<?php include('siteinfo.php'); ?>
|
||||
<style>
|
||||
:root {
|
||||
--pastel-blue: #94bacc;
|
||||
--pastel-green: #a3d9b1;
|
||||
--pastel-pink: #f8bbd0;
|
||||
}
|
||||
|
||||
.lesson-card {
|
||||
background: white;
|
||||
border-radius: 18px;
|
||||
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s ease;
|
||||
border-left: 5px solid var(--pastel-blue);
|
||||
}
|
||||
|
||||
.lesson-card:hover {
|
||||
transform: translateY(-8px);
|
||||
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 0.4em 1em;
|
||||
border-radius: 50px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-reschedule {
|
||||
background: linear-gradient(45deg, #ff9a9e, #fad0c4);
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 25px;
|
||||
padding: 0.5rem 1.2rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #e74c3c;
|
||||
color: white;
|
||||
border-radius: 25px;
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<?php include('include/navbar.php'); ?>
|
||||
<?php include('include/topbar.php'); ?>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<div class="page-content" style="background: linear-gradient(to bottom, #f8fdff, #f0f8ff);">
|
||||
|
||||
<div class="container-fluid px-4 pt-4">
|
||||
<div class="text-center mb-5">
|
||||
<h1 class="display-5 fw-bold text-primary">
|
||||
Le tue lezioni future
|
||||
</h1>
|
||||
<p class="lead text-muted">
|
||||
<?php echo $user['first_name']; ?>, ecco tutte le lezioni che hai prenotato
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php if (empty($bookings)): ?>
|
||||
<div class="text-center py-5">
|
||||
<i class="bx bx-calendar-x bx-lg text-muted"></i>
|
||||
<h4 class="text-muted mt-4">Nessuna lezione prenotata</h4>
|
||||
<p class="text-muted">Quando acquisterai un carnet o un abbonamento, potrai prenotare qui le tue lezioni!</p>
|
||||
<a href="products.php" class="btn btn-primary btn-lg mt-3">Vai ai corsi</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="row g-4">
|
||||
<?php foreach ($bookings as $b): ?>
|
||||
<div class="col-lg-6 col-xl-4">
|
||||
<div class="card lesson-card h-100">
|
||||
<div class="card-body p-4">
|
||||
<!-- Data e ora -->
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<h5 class="mb-1"><?php echo date('d', strtotime($b['session_date'])); ?></h5>
|
||||
<p class="text-muted mb-0"><?php echo ucfirst(strftime('%B %Y', strtotime($b['session_date']))); ?></p>
|
||||
</div>
|
||||
<span class="status-badge <?php
|
||||
echo $b['status'] == 'booked' ? 'bg-success' : ($b['status'] == 'cancelled' ? 'bg-danger' : 'bg-warning');
|
||||
?>">
|
||||
<?php echo $b['status'] == 'booked' ? 'Prenotata' : ($b['status'] == 'cancelled' ? 'Annullata' : 'In attesa'); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Dettagli lezione -->
|
||||
<h4 class="mb-2"><?php echo htmlspecialchars($b['class_name']); ?></h4>
|
||||
<p class="text-primary mb-2">
|
||||
<?php echo ucfirst($b['level'] ?? 'Tutti i livelli'); ?>
|
||||
<?php if ($b['day_of_week']): ?> • <?php echo ucfirst($b['day_of_week']); ?><?php endif; ?>
|
||||
</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<p class="mb-1">
|
||||
<i class="bx bx-time"></i>
|
||||
<?php echo date('H:i', strtotime($b['start_time'])); ?> - <?php echo date('H:i', strtotime($b['end_time'])); ?>
|
||||
</p>
|
||||
<?php if ($b['teacher_name']): ?>
|
||||
<p class="mb-1">
|
||||
<i class="bx bx-user"></i> Con <?php echo htmlspecialchars($b['teacher_name']); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Ingressi rimanenti -->
|
||||
<div class="alert alert-light border mb-3 py-2">
|
||||
<small class="d-block">
|
||||
<strong>Ingressi:</strong>
|
||||
<span class="text-success"><?php echo $b['available_entries']; ?></span>/<?php echo $b['total_entries']; ?>
|
||||
<?php if ($b['available_recoveries'] > 0): ?>
|
||||
• <strong>Recuperi:</strong> <?php echo $b['available_recoveries']; ?>
|
||||
<?php endif; ?>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Pulsanti azione -->
|
||||
<div class="d-flex gap-2">
|
||||
<?php if ($b['status'] == 'booked' && strtotime($b['session_date']) > time() + 86400): // più di 24h prima
|
||||
?>
|
||||
<button class="btn btn-reschedule" onclick="reschedule(<?php echo $b['booking_id']; ?>)">
|
||||
Riprogramma
|
||||
</button>
|
||||
<button class="btn btn-cancel btn-sm" onclick="cancelBooking(<?php echo $b['booking_id']; ?>)">
|
||||
Annulla
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<button class="btn btn-secondary btn-sm" disabled>
|
||||
Non modificabile
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<?php include('jsinclude.php'); ?>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script>
|
||||
function reschedule(bookingId) {
|
||||
Swal.fire({
|
||||
title: 'Riprogrammare lezione?',
|
||||
text: "Vuoi scegliere un nuovo orario per questa lezione?",
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sì, riprogramma',
|
||||
cancelButtonText: 'Annulla'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = 'reschedule.php?booking=' + bookingId;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function cancelBooking(bookingId) {
|
||||
Swal.fire({
|
||||
title: 'Annullare prenotazione?',
|
||||
text: "L'ingresso ti verrà restituito come recupero",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#e74c3c',
|
||||
confirmButtonText: 'Sì, annulla',
|
||||
cancelButtonText: 'No, tienila'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
fetch('cancel_booking.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'booking_id=' + bookingId
|
||||
}).then(r => r.json()).then(data => {
|
||||
if (data.success) {
|
||||
Swal.fire('Annullata!', 'La lezione è stata annullata e hai ricevuto un recupero.', 'success')
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire('Errore', data.message, 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user