getConnection(); // Verifica utente loggato if (!isset($iduserlogin)) { header("Location: login.php"); exit; } // Dati utente $stmt = $pdo->prepare(" SELECT first_name, last_name, phone, email, avatar FROM auth_users WHERE id = ? "); $stmt->execute([$iduserlogin]); $user = $stmt->fetch(PDO::FETCH_ASSOC); if (!$user) { die("Errore: utente non trovato."); } $user_name = htmlspecialchars(trim($user['first_name'] . ' ' . $user['last_name']) ?: 'Cliente'); // Prossimi appuntamenti (da oggi in poi, max 5) $today = date('Y-m-d'); $stmt = $pdo->prepare(" SELECT a.id, a.start_at, a.end_at, a.status, s.name AS service_name, s.color_hex AS service_color, st.first_name AS staff_first, st.last_name AS staff_last, st.color_hex AS staff_color, sh.name AS shop_name FROM appointments a LEFT JOIN services s ON a.service_id = s.id LEFT JOIN staff st ON a.staff_id = st.id LEFT JOIN shops sh ON a.shop_id = sh.id WHERE a.customer_id = (SELECT id FROM customers WHERE user_id = ? LIMIT 1) AND DATE(a.start_at) >= ? ORDER BY a.start_at ASC LIMIT 5 "); $stmt->execute([$iduserlogin, $today]); $future_appts = $stmt->fetchAll(PDO::FETCH_ASSOC); // Ultimi appuntamenti passati (max 5) $stmt = $pdo->prepare(" SELECT a.id, a.start_at, a.end_at, a.status, s.name AS service_name, s.color_hex AS service_color, st.first_name AS staff_first, st.last_name AS staff_last, st.color_hex AS staff_color, sh.name AS shop_name FROM appointments a LEFT JOIN services s ON a.service_id = s.id LEFT JOIN staff st ON a.staff_id = st.id LEFT JOIN shops sh ON a.shop_id = sh.id WHERE a.customer_id = (SELECT id FROM customers WHERE user_id = ? LIMIT 1) AND DATE(a.start_at) < ? ORDER BY a.start_at DESC LIMIT 5 "); $stmt->execute([$iduserlogin, $today]); $past_appts = $stmt->fetchAll(PDO::FETCH_ASSOC); // Helpers flash (copia-incolla esattamente qui) function setFlash(string $type, string $text): void { $_SESSION['flash'] = ['type' => $type, 'text' => $text]; } function getFlash(): ?array { if (!isset($_SESSION['flash'])) return null; $f = $_SESSION['flash']; unset($_SESSION['flash']); return $f; } // Flash $flash = getFlash(); ?> La Mia Dashboard
Prossimi Appuntamenti
Vedi tutti
Non hai appuntamenti futuri.
Prenota il tuo prossimo taglio!
'bg-success', 'pending' => 'bg-warning', 'cancelled' => 'bg-danger', 'no_show' => 'bg-secondary', default => 'bg-info' }; ?>
-
presso
Ultimi Appuntamenti
Vedi tutti
Non hai ancora appuntamenti passati.
'bg-success', 'cancelled' => 'bg-danger', 'no_show' => 'bg-secondary', default => 'bg-info' }; ?>