prepare($sql); $st->execute($params); return $st->fetchAll(PDO::FETCH_ASSOC); } } $ideaId = isset($_GET['id']) ? (int)$_GET['id'] : 0; $isDetailView = ($ideaId > 0); $currentIdea = null; // Stockera les données si on est en vue détail // Préparation des variables par défaut pour éviter les erreurs "undefined variable" $transport = []; $lodging = []; $acts = []; $budget = []; $fixedTotal = 0; $ppTotal = 0; $planned = []; $ideas = []; $archived = []; if ($isDetailView) { // --- MODE DÉTAIL --- // 1. Récupérer l'idée principale $rows = hol_q($pdo, "SELECT * FROM pf_holidays_ideas WHERE id = ?", [$ideaId]); $currentIdea = $rows[0] ?? null; if ($currentIdea) { // 2. Récupérer les données pour la CARTE (un seul point) // Le JS filtrera lat/lng invalides $mapIdeas = hol_q($pdo, " SELECT id, title, country, region, city, CAST(lat AS DECIMAL(9,6)) AS lat, CAST(lng AS DECIMAL(9,6)) AS lng, status, desired_start_date, desired_end_date FROM pf_holidays_ideas WHERE id = ? ", [$ideaId]); // 3. Récupérer les sous-éléments (Transport, Logement, etc.) $transport = hol_q($pdo, "SELECT * FROM pf_holidays_transport WHERE idea_id = ? ORDER BY created_at DESC", [$ideaId]); $lodging = hol_q($pdo, "SELECT * FROM pf_holidays_lodging WHERE idea_id = ? ORDER BY created_at DESC", [$ideaId]); $acts = hol_q($pdo, "SELECT * FROM pf_holidays_activities WHERE idea_id = ? ORDER BY created_at DESC", [$ideaId]); $budget = hol_q($pdo, "SELECT category, label, amount, per_person FROM pf_holidays_budget_items WHERE idea_id = ? ORDER BY created_at DESC", [$ideaId]); // 4. Calculs totaux budget $sumRow = hol_q($pdo, " SELECT SUM(CASE WHEN per_person=0 THEN amount ELSE 0 END) AS fixed_total, SUM(CASE WHEN per_person=1 THEN amount ELSE 0 END) AS per_person_total FROM pf_holidays_budget_items WHERE idea_id = ? ", [$ideaId])[0] ?? ['fixed_total' => 0, 'per_person_total' => 0]; $fixedTotal = (float)($sumRow['fixed_total'] ?? 0); $ppTotal = (float)($sumRow['per_person_total'] ?? 0); } } else { // --- MODE LISTE --- // 1. Données pour la CARTE (tous les points valides) $mapIdeas = hol_q($pdo, " SELECT id, title, country, region, city, CAST(lat AS DECIMAL(9,6)) AS lat, CAST(lng AS DECIMAL(9,6)) AS lng, status, desired_start_date, desired_end_date FROM pf_holidays_ideas WHERE status IN ('draft','shortlist','favorite','planned') AND lat IS NOT NULL AND lng IS NOT NULL "); // 2. Récupérer les listes $planned = hol_q($pdo, " SELECT * FROM pf_holidays_ideas WHERE status = 'planned' ORDER BY COALESCE(desired_start_date, created_at) DESC "); $ideas = hol_q($pdo, " SELECT * FROM pf_holidays_ideas WHERE status IN ('draft','shortlist','favorite') ORDER BY FIELD(status,'favorite','shortlist','draft'), created_at DESC "); $archived = hol_q($pdo, " SELECT * FROM pf_holidays_ideas WHERE status = 'archived' ORDER BY updated_at DESC "); } ?>
Cette idée de vacances n'existe pas ou a été supprimée.
Dates souhaitées, prêtes à être réservées.
= nl2br(htmlspecialchars(mb_strimwidth($it['notes'], 0, 160, '…'))) ?>
Brouillons, favoris, shortlist.
= nl2br(htmlspecialchars(mb_strimwidth($it['notes'], 0, 160, '…'))) ?>