From 7e149d0c1aa4a33e3e0de019c95d1fa74e03fadd Mon Sep 17 00:00:00 2001 From: "fefe.clochette" Date: Mon, 26 Jan 2026 10:31:32 +0100 Subject: [PATCH] Anniversary --- christmas-list.php | 594 ----------------- gift-list.php | 618 ++++++++++++++++++ header.php | 4 +- includes/auth.php | 2 +- index.php | 6 +- modules/gift-list/assets/img/corona.png | Bin 0 -> 1852 bytes .../assets/img/reis.png | Bin modules/gift-list/assets/img/sant.png | Bin 0 -> 2651 bytes .../assets/img/santa.png | Bin .../assets/img/tio.png | Bin .../gift-list.css} | 43 +- .../save-gift.php | 14 +- 12 files changed, 671 insertions(+), 610 deletions(-) delete mode 100644 christmas-list.php create mode 100644 gift-list.php create mode 100644 modules/gift-list/assets/img/corona.png rename modules/{christmas-list => gift-list}/assets/img/reis.png (100%) create mode 100644 modules/gift-list/assets/img/sant.png rename modules/{christmas-list => gift-list}/assets/img/santa.png (100%) rename modules/{christmas-list => gift-list}/assets/img/tio.png (100%) rename modules/{christmas-list/christmas-list.css => gift-list/gift-list.css} (91%) rename modules/{christmas-list => gift-list}/save-gift.php (89%) diff --git a/christmas-list.php b/christmas-list.php deleted file mode 100644 index e9d2bcf..0000000 --- a/christmas-list.php +++ /dev/null @@ -1,594 +0,0 @@ - 'Tió', - 'NOEL' => 'Nadal', - 'ROIS' => 'Reis', -]; - -$occasionIcons = [ - 'TIO' => '/modules/christmas-list/assets/img/tio.png', - 'NOEL' => '/modules/christmas-list/assets/img/santa.png', - 'ROIS' => '/modules/christmas-list/assets/img/reis.png', -]; - -// 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); - -// 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) { - $o = $gift['occasion']; - $c = $gift['child_name']; - $a = $gift['adult_name']; - $byOccasion[$o][$c][$a][] = $gift; -} -?> - -
-

Llista de regals

- - - - -
-

Vista per festa

- - -

No hi ha cap regal registrat per a .

- - - $occLabel): ?> -
-

- - - - -

- - -
- (float)$g['amount'], - $lists[$adultName] - )); - } - // Nombre de lignes: max des tailles de listes Laia/Laura/Avi Iaia - $maxRowsChild = max(array_map('count', $lists)); - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - € - -
-
- - - -
-
- - - - - - - - -
- ( €) - - - - - - - - -
-
- - - - (pagat per ) - - -
- - - - -
- -
-
- -
- - - - -
-

Resum del pressupost

- prepare(" - SELECT adult_name, child_name, occasion, SUM(amount) AS total - FROM pf_christmas_gifts - WHERE year = :year - GROUP BY adult_name, child_name, occasion - ORDER BY adult_name, child_name, occasion - "); - $stmtSum->execute(['year' => $year]); - $sums = $stmtSum->fetchAll(PDO::FETCH_ASSOC); - ?> - -
- - - - - - - - - - - - - - - - - - - -
AdultInfantFestaTotal
-
-
- - - - - - - payer) - $matrix = []; - foreach ($people as $p1) { - foreach ($people as $p2) { - if (!isset($matrix[$p1])) $matrix[$p1] = []; - $matrix[$p1][$p2] = 0.0; - } - } - - foreach ($gifts as $g) { - $adult = $g['adult_name']; - $payer = $g['payer_name'] ?? $g['adult_name']; - $amt = (float)$g['amount']; - if ($amt > 0 && $adult !== $payer) { - $matrix[$adult][$payer] += $amt; - } - } - - // Net pairwise (A<->B) - $settlements = []; // [ [from, to, amount], ... ] - for ($i = 0; $i < count($people); $i++) { - for ($j = $i + 1; $j < count($people); $j++) { - $a = $people[$i]; - $b = $people[$j]; - $net = $matrix[$a][$b] - $matrix[$b][$a]; - if ($net > 0.009) { - $settlements[] = [$a, $b, $net]; // a doit à b - } elseif ($net < -0.009) { - $settlements[] = [$b, $a, -$net]; // b doit à a - } - } - } - ?> - -
-

Tricount

- -
- - - - - - - - - - - - - - - 0 ? 'cl-mtx-owe' : 'cl-mtx-empty'); - ?> - - - - - -
- Deutor ↓ - Creditor → -
-
- -

Liquidacions

- -

Cap deute pendent.

- -
    - -
  • ha de pagar € a
  • - -
- -
- - - - - - - -
-

Llista detallada de regals

-
- - - - - - - - - - - - - - - - - - - - - - - -
AdultInfantFestaRegalEnllaç
- - 🔗 - -
-
-
-
- - - - - - - - - - - - ['TIO','NOEL','ROIS'], + 'anniversary' => ['ANNIV','SANT'], +]; + +// Vue courante (URL > Session > défaut) +$currentView = strtolower($_GET['view'] ?? ($_SESSION['gift_view'] ?? 'nadal')); +if (!isset($VIEWS[$currentView])) $currentView = 'nadal'; +$_SESSION['gift_view'] = $currentView; + +$allowedOccasions = $VIEWS[$currentView]; + +// En vue anniversary, on ajoute 3 adultes pour Pol et Pep uniquement +$extraAdults = ['Pauline', 'Papy JC', 'Mamy Caro']; +$adultsByChildForAnniv = [ + 'Pol' => array_merge($baseAdults, $extraAdults), + 'Pep' => array_merge($baseAdults, $extraAdults), + 'Elna' => $baseAdults, + 'Bru' => $baseAdults, + 'Guim' => $baseAdults, +]; + + + +// Labels d’occasion (affichage) +$allOccasionLabels = [ + 'TIO' => 'Tió', + 'NOEL' => 'Nadal', + 'ROIS' => 'Reis', + 'ANNIV' => 'Anniversary', + 'SANT' => 'Sant', +]; + +// Icônes (pense à ajouter les 2 nouvelles images) +$occasionIcons = [ + 'TIO' => '/modules/gift-list/assets/img/tio.png', + 'NOEL' => '/modules/gift-list/assets/img/santa.png', + 'ROIS' => '/modules/gift-list/assets/img/reis.png', + 'ANNIV' => '/modules/gift-list/assets/img/corona.png', + 'SANT' => '/modules/gift-list/assets/img/sant.png', +]; + +// Nom de table (renommée -> pf_gifts), fallback si pas encore migrée +$tableGifts = 'pf_gifts'; + +// Récup données filtrées par vue +$inMarks = implode(',', array_fill(0, count($allowedOccasions), '?')); +$sql = " + SELECT * + FROM {$tableGifts} + WHERE year = ? AND occasion IN ($inMarks) + ORDER BY adult_name, child_name, occasion, created_at +"; +$stmt = $pdo->prepare($sql); +$params = array_merge([$year], $allowedOccasions); +$stmt->execute($params); +$gifts = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: []; + +// Index [occasion][child][adult] +$byOccasion = []; +foreach ($gifts as $gift) { + $o = $gift['occasion']; + $c = $gift['child_name']; + $a = $gift['adult_name']; + $byOccasion[$o][$c][$a][] = $gift; +} + +// Occasions à afficher pour la vue +$occasionsToShow = array_values(array_intersect(array_keys($allOccasionLabels), $allowedOccasions)); +?> +
+
+

Llista de regals

+ +
+ + +
+

Vista per festa

+ + +

No hi ha cap regal registrat per a en aquesta vista.

+ + + +
+

+ + + + +

+ +
+ + (float)$g['amount'], $lists[$adultName])); + } + // max() compatible PHP 8 + $counts = array_map('count', $lists); + $maxRowsChild = !empty($counts) ? max($counts) : 0; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + € + +
+
+ + +
+
+ + + + + +
+ ( €) + + + + +
+
+ + + (pagat per ) + + +
+ + + +
+ + +
+
+ +
+ + +
+

Resum del pressupost

+ prepare($sqlSum); + $stmtSum->execute($params); + $sums = $stmtSum->fetchAll(PDO::FETCH_ASSOC); + ?> +
+ + + + + + + + + + + + + + +
AdultInfantFestaTotal
+
+
+ + + 0 && $adult !== $payer) { + $matrix[$adult][$payer] += $amt; + } + } + $settlements = []; + for ($i = 0; $i < count($people); $i++) { + for ($j = $i + 1; $j < count($people); $j++) { + $a = $people[$i]; $b = $people[$j]; + $net = $matrix[$a][$b] - $matrix[$b][$a]; + if ($net > 0.009) $settlements[] = [$a, $b, $net]; + elseif ($net < -0.009) $settlements[] = [$b, $a, -$net]; + } + } + ?> +
+

Tricount

+
+ + + + + + + + + + + + + 0 ? 'cl-mtx-owe' : 'cl-mtx-empty'); + ?> + + + + + +
+ Deutor ↓Creditor → +
+
+

Liquidacions

+ +

Cap deute pendent.

+ +
    + +
  • ha de pagar € a
  • + +
+ +
+ + +
+

Llista detallada de regals

+
+ + + + + + + + + + + + + + + + +
AdultInfantFestaRegalEnllaç
+ + 🔗 + +
+
+
+
+ + + + + + + + + + +">Family calendar - Christmas list + gift list diff --git a/includes/auth.php b/includes/auth.php index a83b562..be56e31 100644 --- a/includes/auth.php +++ b/includes/auth.php @@ -17,7 +17,7 @@ function require_login(?string $loginPage = '/login.php'): void } if (empty($_SESSION['user'])) { - // URL de la page courante (ex: /christmas-list.php?foo=bar) + // URL de la page courante (ex: /gift-list.php?foo=bar) $currentUrl = $_SERVER['REQUEST_URI'] ?? '/'; // On redirige vers la page de login en ajoutant ?redirect=... diff --git a/index.php b/index.php index 501f828..94a2b7b 100644 --- a/index.php +++ b/index.php @@ -49,10 +49,10 @@ require __DIR__ . '/header.php'; À venir - - + +
🎄
-

Christmas list

+

gift list

Planifica els regals de cada nen, per al Tió, el Nadal i els Reis.
diff --git a/modules/gift-list/assets/img/corona.png b/modules/gift-list/assets/img/corona.png new file mode 100644 index 0000000000000000000000000000000000000000..2050679eee7d91f4ae9c56f665152e77372b07d8 GIT binary patch literal 1852 zcmV-C2gCS@P)pdB zM0)BE2H?|~$ETuu5xY3`dFRra)rSe`vF#B3Oxg z@-EE2N45q~3n|VH7D4}k0l3jHQPL<_DT!R-ql*V_T?C!)AM{GUmP<@Uak7kFug z-quSoU(Og>Dl$!bgzu~=vN!}k34}n(U^6QhLFP|&h_T;#D#;!0Y_rP zc^(lx@39CAqrzFqxg1N^`R%5#okVndAOyr}oN3>ropuGAJWk31VD}tQgaQ@6`I@}I z`gfEv@zvbI+{hT(>Q`zF?tY9p3OKM?0zhriGEXcXG1ag}zy-dynZIK6WbJWa92Anj=sQvjpkLnQiXy7UTZ$l4#$H zf)!^i)t{?9IzwL&(piYMn&)DgPcMr7!-bSlM(e0J-lL{^L*iAEjfmz4L%^YL-grds zRb5^PFHVyNVu5ir{587_eMa`v)$_!8Y_H>6DFgM zh{gmC<0+Td;82>viQM z)MY&yS>>60>D(dpoTIgKi{+dz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m3E4@XB?jfbnKAy8j8SP8gZ`3~30J7g&WLW!-01j}h`gu*ChCuK;9SG!MqZqv$RP5F zyk=%*eq6a5&^^}UvKFAzDR0l?rC!KOHL-^G-z?4d#n_l$-(y(U%S$uEC#G@C%8iJ7 z)8~tCC^G>{cqeo0!oVb%L^oBG!6H>$BJxI#iD@nVSCqkI+sTZHbK`k;BD) zRr9-JlGl7f%oiV<>bPjcu&>*=I4911cce-pi6oLpLixYI{{S^g904R?vg`l=002ov JPDHLkV1hCs4JZHr literal 0 HcmV?d00001 diff --git a/modules/christmas-list/assets/img/santa.png b/modules/gift-list/assets/img/santa.png similarity index 100% rename from modules/christmas-list/assets/img/santa.png rename to modules/gift-list/assets/img/santa.png diff --git a/modules/christmas-list/assets/img/tio.png b/modules/gift-list/assets/img/tio.png similarity index 100% rename from modules/christmas-list/assets/img/tio.png rename to modules/gift-list/assets/img/tio.png diff --git a/modules/christmas-list/christmas-list.css b/modules/gift-list/gift-list.css similarity index 91% rename from modules/christmas-list/christmas-list.css rename to modules/gift-list/gift-list.css index d795c96..05d7159 100644 --- a/modules/christmas-list/christmas-list.css +++ b/modules/gift-list/gift-list.css @@ -1,12 +1,12 @@ /* ========================================================= */ -/* Styles généraux page Christmas list */ +/* Styles généraux page gift list */ /* ========================================================= */ -.pf-christmas-list h1 { +.pf-gift-list h1 { margin-bottom: 4px; } -.pf-christmas-list p { +.pf-gift-list p { margin-top: 0; margin-bottom: 12px; font-size: 13px; @@ -42,6 +42,18 @@ margin-top: 8px; } +/* Désactiver la grille uniquement pour la vue Anniversary */ +.pf-gift-list .cl-view-anniversary .cl-occasion-children-tables { + display: block; /* remplace la grid */ +} + +.pf-gift-list .cl-view-anniversary .cl-child-table { + width: 100%; + min-width: 720px; /* ajuste si nécessaire avec 6 colonnes */ + margin-bottom: 12px; /* espacement entre tables */ + overflow-x: auto; /* sécurité si ça déborde sur petit écran */ +} + @media (max-width: 1200px) { .cl-occasion-children-tables { grid-template-columns: repeat(2, minmax(280px, 1fr)); @@ -504,3 +516,28 @@ .cl-gift-delete { color: #b91c1c !important; } /* poubelle rouge forcé */ + +.cl-titlebar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + flex-wrap: wrap; +} +.cl-view-switch { + display: flex; + gap: 8px; +} +.cl-view-btn { + padding: 6px 10px; + border: 1px solid #ddd; + border-radius: 6px; + text-decoration: none; + color: #333; + background: #f7f7f7; +} +.cl-view-btn.is-active { + background: #333; + color: #fff; + border-color: #333; +} diff --git a/modules/christmas-list/save-gift.php b/modules/gift-list/save-gift.php similarity index 89% rename from modules/christmas-list/save-gift.php rename to modules/gift-list/save-gift.php index 4c0cb17..93f8f86 100644 --- a/modules/christmas-list/save-gift.php +++ b/modules/gift-list/save-gift.php @@ -1,6 +1,6 @@ 0) { - $stmt = $pdo->prepare("DELETE FROM pf_christmas_gifts WHERE id = :id"); + $stmt = $pdo->prepare("DELETE FROM pf_gift_gifts WHERE id = :id"); $stmt->execute(['id' => $gift_id]); } - header('Location: /christmas-list.php'); + header('Location: /gift-list.php'); exit; } @@ -36,7 +36,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $gift_id = (int)($_POST['gift_id'] ?? 0); if ($gift_id > 0 && $adult_name && $payer_name && $child_name && $occasion && $gift_desc) { $stmt = $pdo->prepare(" - UPDATE pf_christmas_gifts + UPDATE pf_gift_gifts SET year = :year, adult_name = :adult_name, payer_name = :payer_name, @@ -60,14 +60,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ]); } - header('Location: /christmas-list.php'); + header('Location: /gift-list.php'); exit; } // create (par défaut) if ($adult_name && $payer_name && $child_name && $occasion && $gift_desc) { $stmt = $pdo->prepare(" - INSERT INTO pf_christmas_gifts + INSERT INTO pf_gift_gifts (year, adult_name, payer_name, child_name, occasion, gift_description, product_link, amount) VALUES (:year, :adult_name, :payer_name, :child_name, :occasion, :gift_description, :product_link, :amount) @@ -84,6 +84,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ]); } - header('Location: /christmas-list.php'); + header('Location: /gift-list.php'); exit; }