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 = htmlspecialchars($year) ?>
-
-
-
-
-
- Vista per festa
-
-
- No hi ha cap regal registrat per a = htmlspecialchars($year) ?>.
-
-
- $occLabel): ?>
-
-
-
-
-
- = htmlspecialchars($occLabel) ?>
-
-
-
-
- (float)$g['amount'],
- $lists[$adultName]
- ));
- }
- // Nombre de lignes: max des tailles de listes Laia/Laura/Avi Iaia
- $maxRowsChild = max(array_map('count', $lists));
- ?>
-
-
-
-
-
-
-
-
- = htmlspecialchars($childName) ?>
- +
-
-
-
-
-
-
-
- = htmlspecialchars($adultName) ?>
-
- = number_format($totals[$adultName], 0, ',', ' ') ?> €
-
-
-
-
-
-
-
-
-
-
- —
- —
- —
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
= $desc ?>
-
-
= $desc ?>
-
-
-
-
-
(= number_format($amt, 0, ',', ' ') ?> €)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- (pagat per = htmlspecialchars($payer) ?>)
-
-
-
-
-
- —
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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);
- ?>
-
-
-
-
-
- Adult
- Infant
- Festa
- Total
-
-
-
-
-
- = htmlspecialchars($row['adult_name']) ?>
- = htmlspecialchars($row['child_name']) ?>
- = htmlspecialchars($allOccasionLabels[$row['occasion']] ?? $row['occasion']) ?>
- = number_format($row['total'], 0, ',', ' ') ?> €
-
-
-
-
-
-
-
-
-
-
-
-
- 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
-
-
-
-
-
-
- Deutor ↓
- Creditor →
-
-
- = htmlspecialchars($p) ?>
-
-
-
-
-
-
- = htmlspecialchars($debtor) ?>
-
- 0 ? 'cl-mtx-owe' : 'cl-mtx-empty');
- ?>
- = $display ?>
-
-
-
-
-
-
-
- Liquidacions
-
- Cap deute pendent.
-
-
-
- = htmlspecialchars($from) ?> ha de pagar = number_format($amt, 0, ',', ' ') ?> € a = htmlspecialchars($to) ?>
-
-
-
-
-
-
-
-
-
-
-
-
- Llista detallada de regals
-
-
-
-
- Adult
- Infant
- Festa
- Regal
- €
- Enllaç
-
-
-
-
-
- = htmlspecialchars($g['adult_name']) ?>
- = htmlspecialchars($g['child_name']) ?>
- = htmlspecialchars($allOccasionLabels[$g['occasion']] ?? $g['occasion']) ?>
- = htmlspecialchars($g['gift_description']) ?>
- = number_format($g['amount'], 0, ',', ' ') ?>
-
-
- 🔗
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ['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 = htmlspecialchars($year) ?>
+
+
+
+
+
+ Vista per festa
+
+
+ No hi ha cap regal registrat per a = htmlspecialchars($year) ?> en aquesta vista.
+
+
+
+
+
+
+
+
+ = htmlspecialchars($allOccasionLabels[$occCode] ?? $occCode) ?>
+
+
+
+
+ (float)$g['amount'], $lists[$adultName]));
+ }
+ // max() compatible PHP 8
+ $counts = array_map('count', $lists);
+ $maxRowsChild = !empty($counts) ? max($counts) : 0;
+ ?>
+
+
+
+
+
+
+
+
+ = htmlspecialchars($childName) ?>
+ +
+
+
+
+
+
+
+
+ = htmlspecialchars($adultName) ?>
+
+ = number_format($totals[$adultName], 0, ',', ' ') ?> €
+
+
+
+
+
+
+
+
+
+
+
+ —
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= $desc ?>
+
+
= $desc ?>
+
+
+ (= number_format($amt, 0, ',', ' ') ?> €)
+
+
+
+
+
+
+
+
+
+
+
+
+ (pagat per = htmlspecialchars($payer) ?>)
+
+
+
+
+ —
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Resum del pressupost
+ prepare($sqlSum);
+ $stmtSum->execute($params);
+ $sums = $stmtSum->fetchAll(PDO::FETCH_ASSOC);
+ ?>
+
+
+
+ Adult Infant Festa Total
+
+
+
+
+ = htmlspecialchars($row['adult_name']) ?>
+ = htmlspecialchars($row['child_name']) ?>
+ = htmlspecialchars($allOccasionLabels[$row['occasion']] ?? $row['occasion']) ?>
+ = number_format($row['total'], 0, ',', ' ') ?> €
+
+
+
+
+
+
+
+
+ 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
+
+
+
+
+
+ Deutor ↓ Creditor →
+
+ = htmlspecialchars($p) ?>
+
+
+
+
+
+ = htmlspecialchars($debtor) ?>
+
+ 0 ? 'cl-mtx-owe' : 'cl-mtx-empty');
+ ?>
+ = $display ?>
+
+
+
+
+
+
+ Liquidacions
+
+ Cap deute pendent.
+
+
+
+ = htmlspecialchars($from) ?> ha de pagar = number_format($amt, 0, ',', ' ') ?> € a = htmlspecialchars($to) ?>
+
+
+
+
+
+
+
+ Llista detallada de regals
+
+
+
+ Adult Infant Festa Regal € Enllaç
+
+
+
+
+ = htmlspecialchars($g['adult_name']) ?>
+ = htmlspecialchars($g['child_name']) ?>
+ = htmlspecialchars($allOccasionLabels[$g['occasion']] ?? $g['occasion']) ?>
+ = htmlspecialchars($g['gift_description']) ?>
+ = number_format($g['amount'], 0, ',', ' ') ?>
+
+
+ 🔗
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+">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 0000000..2050679
Binary files /dev/null and b/modules/gift-list/assets/img/corona.png differ
diff --git a/modules/christmas-list/assets/img/reis.png b/modules/gift-list/assets/img/reis.png
similarity index 100%
rename from modules/christmas-list/assets/img/reis.png
rename to modules/gift-list/assets/img/reis.png
diff --git a/modules/gift-list/assets/img/sant.png b/modules/gift-list/assets/img/sant.png
new file mode 100644
index 0000000..d0cb59f
Binary files /dev/null and b/modules/gift-list/assets/img/sant.png differ
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;
}