From ebfa0c99f3e8c59e8a1f2953d578665826120ef7 Mon Sep 17 00:00:00 2001 From: "fefe.clochette" Date: Wed, 1 Apr 2026 21:18:18 +0200 Subject: [PATCH] notes voyage --- modules/holidays/holidays.js | 53 ++++++++++++------- .../holidays/includes/api/save_checkpoint.php | 11 ++-- modules/holidays/views/detail.php | 30 ++++++++--- modules/holidays/views/list.php | 5 +- 4 files changed, 66 insertions(+), 33 deletions(-) diff --git a/modules/holidays/holidays.js b/modules/holidays/holidays.js index ee47470..8aec1e7 100644 --- a/modules/holidays/holidays.js +++ b/modules/holidays/holidays.js @@ -280,7 +280,7 @@ function openCheckpointModal(mode, data = null) { searchBlock.style.display = "block"; formBlock.style.display = "none"; btnDel.style.display = "none"; - document.getElementById("cp_old_sort_order").value = ""; // Important : vide pour ajout + document.getElementById("cp_old_sort_order").value = ""; document.getElementById("cp_name").value = ""; addCpExpenseLine(); } else if (mode === "edit" && data) { @@ -291,14 +291,21 @@ function openCheckpointModal(mode, data = null) { document.getElementById("cp_lat").value = data.lat; document.getElementById("cp_lng").value = data.lng; - document.getElementById("cp_old_sort_order").value = data.sort_order; // On stocke l'index unique + document.getElementById("cp_old_sort_order").value = data.sort_order; document.getElementById("cp_name").value = data.location_name; if (data.items && data.items.length > 0) { let visibleCount = 0; data.items.forEach((it) => { if (it.name !== "PF_TECHNICAL_POINT") { - addCpExpenseLine(it.category, it.name, it.amount, it.is_paid); + // On passe it.notes à la fonction ! + addCpExpenseLine( + it.category, + it.name, + it.amount, + it.is_paid, + it.notes || "", + ); visibleCount++; } }); @@ -364,29 +371,39 @@ function addCpExpenseLine( name = "", amount = "", isPaid = 0, + notes = "", ) { const container = document.getElementById("cpExpensesContainer"); const div = document.createElement("div"); div.style.display = "flex"; - div.style.gap = "8px"; - div.style.alignItems = "center"; + div.style.flexDirection = "column"; + div.style.gap = "6px"; + div.style.padding = "10px"; + div.style.background = "#f8fafc"; + div.style.borderRadius = "8px"; + div.style.border = "1px solid #e2e8f0"; const isChecked = isPaid == 1 ? "checked" : ""; div.innerHTML = ` - - - - - +
+ + + + + + + +
+ `; container.appendChild(div); } diff --git a/modules/holidays/includes/api/save_checkpoint.php b/modules/holidays/includes/api/save_checkpoint.php index 623eaea..0e1d3a0 100644 --- a/modules/holidays/includes/api/save_checkpoint.php +++ b/modules/holidays/includes/api/save_checkpoint.php @@ -35,8 +35,7 @@ if ($holiday_id > 0 && !empty($location_name)) { } // 3. INSERTION DES LIGNES - $stmt = $pdo->prepare("INSERT INTO pf_holidays_items (holiday_id, category, name, amount, is_paid, location_name, lat, lng, sort_order) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); - $validItemsCount = 0; + $stmt = $pdo->prepare("INSERT INTO pf_holidays_items (holiday_id, category, name, amount, is_paid, location_name, lat, lng, sort_order, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $validItemsCount = 0; if (isset($_POST['items']['name'])) { foreach ($_POST['items']['name'] as $i => $raw_name) { @@ -45,15 +44,15 @@ if ($holiday_id > 0 && !empty($location_name)) { if ($name !== '' || $amount_raw !== '') { $cat = $_POST['items']['cat'][$i] ?? 'activity'; $amount = (float)$amount_raw; - $paid = isset($_POST['items']['paid'][$i]) ? 1 : 0; - $stmt->execute([$holiday_id, $cat, $name ?: 'Dépense', $amount, $paid, $location_name, $lat, $lng, $target_order]); - $validItemsCount++; + $paid = (isset($_POST['items']['paid'][$i]) && (int)$_POST['items']['paid'][$i] === 1) ? 1 : 0; + $note = trim($_POST['items']['notes'][$i] ?? ''); + $stmt->execute([$holiday_id, $cat, $name ?: 'Dépense', $amount, $paid, $location_name, $lat, $lng, $target_order, $note]); $validItemsCount++; } } } if ($validItemsCount === 0) { - $stmt->execute([$holiday_id, 'activity', 'PF_TECHNICAL_POINT', 0, 1, $location_name, $lat, $lng, $target_order]); + $stmt->execute([$holiday_id, 'activity', 'PF_TECHNICAL_POINT', 0, 1, $location_name, $lat, $lng, $target_order, '']); } // 4. GESTION DES FAVORIS diff --git a/modules/holidays/views/detail.php b/modules/holidays/views/detail.php index 380d5a1..ccfe81d 100644 --- a/modules/holidays/views/detail.php +++ b/modules/holidays/views/detail.php @@ -8,7 +8,10 @@ if ($id === 0) { echo "

Erreur.

"; exit; } $stmt = $pdo->prepare(" SELECT h.*, (COALESCE(h.budget_food, 0) + COALESCE(h.budget_extra, 0) + COALESCE((SELECT SUM(amount) FROM pf_holidays_items WHERE holiday_id = h.id), 0)) as total_cost, - (SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) as total_paid, + ( + (SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) + + (SELECT COALESCE(SUM(amount), 0) FROM pf_holidays_items WHERE holiday_id = h.id AND is_paid = 1) + ) as total_paid, (SELECT COALESCE(SUM(amount), 0) FROM pf_savings WHERE holiday_id = h.id) as total_saved FROM pf_holidays h WHERE h.id = ? "); @@ -151,12 +154,23 @@ $pctSaved = $cost > 0 ? min(100 - $pctPaid, ($saved / $cost) * 100) : 0; $visibleItemsCount++; $icon = match($it['category']) { 'transport' => '🚗', 'accommodation' => '🏨', 'activity' => '🎫', default => '🏷️' }; ?> -
- - - - - +
+
+ + + + + +
+ +
+ + 🔗 Voir le lien + + 📝 + +
+
@@ -224,7 +238,7 @@ $pctSaved = $cost > 0 ? min(100 - $pctPaid, ($saved / $cost) * 100) : 0;
-
+
diff --git a/modules/holidays/views/list.php b/modules/holidays/views/list.php index 116fe47..6eaa5a9 100644 --- a/modules/holidays/views/list.php +++ b/modules/holidays/views/list.php @@ -29,7 +29,10 @@ $sql = " COALESCE(h.budget_extra, 0) + COALESCE((SELECT SUM(amount) FROM pf_holidays_items WHERE holiday_id = h.id), 0) ) as total_cost, - (SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) as total_paid, + ( + (SELECT COALESCE(SUM(ABS(amount)), 0) FROM pf_expenses WHERE holiday_id = h.id) + + (SELECT COALESCE(SUM(amount), 0) FROM pf_holidays_items WHERE holiday_id = h.id AND is_paid = 1) + ) as total_paid, (SELECT COALESCE(SUM(amount), 0) FROM pf_savings WHERE holiday_id = h.id) as total_saved FROM pf_holidays h $whereSQL