From 3f01cbd8aa90bffdc8a3fa113e810becc7c18110 Mon Sep 17 00:00:00 2001 From: "fefe.clochette" Date: Fri, 23 Jan 2026 12:23:47 +0100 Subject: [PATCH] christmas --- christmas-list.php | 370 +++++++++++------ global.css | 11 +- modules/christmas-list/christmas-list.css | 439 +++++++++++++------- modules/family-calendar/family-calendar.css | 4 +- 4 files changed, 524 insertions(+), 300 deletions(-) diff --git a/christmas-list.php b/christmas-list.php index 4296a4b..f79cb70 100644 --- a/christmas-list.php +++ b/christmas-list.php @@ -1,163 +1,174 @@ 'Tió', - 'NADAL' => 'Nadal', - 'REIS' => 'Reis', +// IMPORTANT : aligner les codes avec ta BDD (enum('TIO','NOEL','ROIS')) +$allOccasionLabels = [ + 'TIO' => 'Tió', + 'NOEL' => 'Nadal', + 'ROIS' => 'Reis', ]; -// Récup données +// Récup toutes les données pour l’année $stmt = $pdo->prepare(" SELECT * FROM pf_christmas_gifts WHERE year = :year + ORDER BY adult_name, child_name, occasion, created_at "); $stmt->execute(['year' => $year]); $gifts = $stmt->fetchAll(PDO::FETCH_ASSOC); -// Indexer par [adult][child][occasion] -$byAdult = []; +// Si aucune donnée, on évite les notices plus bas +if (!$gifts) { + $gifts = []; +} + +// 1) Indexer par [occasion][child][adult] pour l'affichage par fête +$byOccasion = []; // [occasion][child][adult][] = gifts foreach ($gifts as $gift) { - $a = $gift['adult_name']; - $c = $gift['child_name']; $o = $gift['occasion']; - $byAdult[$a][$c][$o][] = $gift; + $c = $gift['child_name']; + $a = $gift['adult_name']; + $byOccasion[$o][$c][$a][] = $gift; } ?>
-

Christmas list

-

Visió sintètica dels regals per adult, infant i festa. Afegeix nous regals amb el botó “+”.

+

Llista de regals

+ + +
-
- - - - - - - - - +

Vista per festa

- - - - - $occLabel): ?> - - - - - - - - - - - - - - - $occLabel): ?> - - -
- -
Adult
-
- -
    - -
  • - - 0): ?> - - ( €) - - -
  • - -
- - – Cap regal + +

No hi ha cap regal registrat per a .

-
-
- 0): ?> - Total: € - -   - -
+ $occLabel): ?> +
+

- -
-
+
+ -
-
- - - - + foreach ($childrenForOccasion as $childName): + // Prépare les listes par adulte pour cet enfant et cette fête + $lists = []; + $totals = []; + foreach ($adults as $adultName) { + $lists[$adultName] = $byOccasion[$occCode][$childName][$adultName] ?? []; + $totals[$adultName] = array_sum(array_map( + fn($g) => (float)$g['amount'], + $lists[$adultName] + )); + } + // Nombre de lignes: max des tailles de listes Laia/Laura/Avi Iaia + $maxRowsChild = max(array_map('count', $lists)); + ?> + + + + + + - - -
- - -
- -
- - -
- - - + + + + + - - + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + € + +
+
+ + + + + + + + 0): ?> + ( €) + + + + +
-
-
+
+ + + + +

Resum del pressupost

- + @@ -195,38 +206,129 @@ foreach ($gifts as $gift) {
+ + + + +
+

Llista detallada de regals

+
+ + + + + + + + + + + + + + + + + + + + + + + +
AdultInfantFestaRegalEnllaç
+ + 🔗 + +
+
+
- + + + +