From 21c34a2cd9f617a9fd5dd00bd33ee7e8016d4890 Mon Sep 17 00:00:00 2001
From: Pierre Martin
Date: Sun, 16 Nov 2025 21:41:11 +0100
Subject: [PATCH] =?UTF-8?q?dates=20de=20distribution=20fixes=20et=20site?=
=?UTF-8?q?=20m=C3=A0j=20dynamiquement?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/README-distributions.md | 63 ++++++++++
src/distributions-utils.php | 208 ++++++++++++++++++++++++++++++++++
src/distributions.php | 109 ++++++++++++++++++
src/{index.html => index.php} | 137 ++++++++++------------
4 files changed, 439 insertions(+), 78 deletions(-)
create mode 100644 src/README-distributions.md
create mode 100644 src/distributions-utils.php
create mode 100644 src/distributions.php
rename src/{index.html => index.php} (84%)
diff --git a/src/README-distributions.md b/src/README-distributions.md
new file mode 100644
index 0000000..bede6d1
--- /dev/null
+++ b/src/README-distributions.md
@@ -0,0 +1,63 @@
+# Gestion des distributions
+
+## Comment mettre à jour les dates de distribution
+
+Les dates de distribution sont gérées dans le fichier `distributions.php`.
+
+### Ajouter une nouvelle distribution
+
+Ajouter une entrée dans le tableau :
+
+```php
+[
+ 'date' => '2026-07-11', // Format YYYY-MM-DD
+ 'lieu' => 'grange', // 'grange' ou 'secours'
+ 'type' => 'normal' // 'normal', 'special' ou 'annulee'
+]
+```
+
+### Distribution spéciale
+
+Pour une distribution avec un label spécial (ex: Noël, Guinguette) :
+
+```php
+[
+ 'date' => '2025-12-17',
+ 'lieu' => 'grange',
+ 'type' => 'special',
+ 'label' => '🎅 Distribution de Noël 🎅'
+]
+```
+
+### Distribution annulée
+
+Pour indiquer une date où il n'y a pas de distribution :
+
+```php
+[
+ 'date' => '2026-02-14',
+ 'lieu' => null,
+ 'type' => 'annulee',
+ 'label' => 'Pas de distribution',
+ 'raison' => 'Salon des vins et producteurs locaux'
+]
+```
+
+### Lieux disponibles
+
+- `'grange'` : La Grange de FIC (7 rue du Vieux Moulin)
+- `'secours'` : Secours Populaire (28 rue Guillaume Berdeil)
+
+## Comment ça marche
+
+Le script PHP :
+
+1. Charge les distributions depuis `distributions.php`
+2. Trouve automatiquement la prochaine distribution
+3. Affiche le calendrier avec :
+ - Les dates passées en grisé
+ - La prochaine date en surbrillance verte
+ - Les dates futures en vert clair
+ - Les dates annulées en rouge
+
+Les dates sont triées chronologiquement et la première date future devient automatiquement "Prochaine distribution".
diff --git a/src/distributions-utils.php b/src/distributions-utils.php
new file mode 100644
index 0000000..708a7aa
--- /dev/null
+++ b/src/distributions-utils.php
@@ -0,0 +1,208 @@
+= $maintenant) {
+ return $distrib;
+ }
+ }
+
+ return null;
+}
+
+/**
+ * Vérifie si une distribution est passée
+ */
+function estPassee(array $distribution): bool {
+ $maintenant = new DateTime();
+ $date = new DateTime($distribution['date']);
+ return $date < $maintenant;
+}
+
+/**
+ * Formate une date de distribution
+ */
+function formaterDate(string $date): string {
+ $dateObj = new DateTime($date);
+ $formatter = new IntlDateFormatter(
+ 'fr_FR',
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::NONE
+ );
+
+ // Retirer l'année si c'est l'année courante
+ $dateFormatee = $formatter->format($dateObj);
+
+ // Ajouter le jour de la semaine si ce n'est pas un samedi
+ $jourSemaine = $dateObj->format('N'); // 1=lundi, 6=samedi
+ if ($jourSemaine != 6) {
+ $joursTraduction = [
+ 1 => 'Lundi',
+ 2 => 'Mardi',
+ 3 => 'Mercredi',
+ 4 => 'Jeudi',
+ 5 => 'Vendredi',
+ 7 => 'Dimanche'
+ ];
+ return $joursTraduction[$jourSemaine] . ' ' . $dateObj->format('d') . ' ' .
+ ucfirst($formatter->format($dateObj));
+ }
+
+ return ucfirst($dateFormatee);
+}
+
+/**
+ * Formate une date courte (pour le calendrier)
+ */
+function formaterDateCourte(string $date): string {
+ $dateObj = new DateTime($date);
+ $formatter = new IntlDateFormatter(
+ 'fr_FR',
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::NONE,
+ 'Europe/Paris',
+ IntlDateFormatter::GREGORIAN,
+ 'd MMMM yyyy'
+ );
+
+ // Vérifier si ce n'est pas un samedi
+ $jourSemaine = $dateObj->format('N');
+ if ($jourSemaine != 6) {
+ $joursTraduction = [
+ 1 => 'Lundi',
+ 2 => 'Mardi',
+ 3 => 'Mercredi',
+ 4 => 'Jeudi',
+ 5 => 'Vendredi',
+ 7 => 'Dimanche'
+ ];
+ return '' . $joursTraduction[$jourSemaine] . ' ' .
+ $formatter->format($dateObj);
+ }
+
+ return $formatter->format($dateObj);
+}
+
+/**
+ * Formate une date complète avec jour de la semaine
+ */
+function formaterDateComplete(DateTime $date): string {
+ $formatter = new IntlDateFormatter(
+ 'fr_FR',
+ IntlDateFormatter::FULL,
+ IntlDateFormatter::NONE,
+ 'Europe/Paris',
+ IntlDateFormatter::GREGORIAN,
+ 'EEEE d MMMM'
+ );
+
+ return ucfirst($formatter->format($date));
+}
+
+/**
+ * Formate une date pour le calendrier
+ */
+function formaterDateCalendrier(DateTime $date): string {
+ $formatter = new IntlDateFormatter(
+ 'fr_FR',
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::NONE,
+ 'Europe/Paris',
+ IntlDateFormatter::GREGORIAN,
+ 'd MMMM yyyy'
+ );
+
+ return $formatter->format($date);
+}
+
+/**
+ * Retourne l'info du lieu de distribution
+ */
+function getLieuInfo(string $lieu): array {
+ $lieux = [
+ 'grange' => [
+ 'nom' => 'La Grange',
+ 'adresse' => '7 rue du Vieux Moulin',
+ 'url' => 'https://www.openstreetmap.org/#map=19/43.51294/1.32234',
+ 'description' => 'à « La Grange » de FIC – 7 rue du Vieux Moulin'
+ ],
+ 'secours' => [
+ 'nom' => 'Secours Populaire',
+ 'adresse' => '28 rue Guillaume Berdeil',
+ 'url' => 'https://www.openstreetmap.org/?mlat=43.516927&mlon=1.319663#map=19/43.516927/1.319663',
+ 'description' => 'au Secours Populaire de Frouzins – 28 rue Guillaume Berdeil'
+ ]
+ ];
+
+ return $lieux[$lieu] ?? [];
+}
+
+/**
+ * Classe CSS pour le type de distribution
+ */
+function getClasseDistribution(array $distribution, bool $estProchaine): string {
+ if ($estProchaine) {
+ return 'bg-green-500';
+ }
+
+ if (estPassee($distribution)) {
+ return 'bg-gray-50 opacity-50';
+ }
+
+ if ($distribution['type'] === 'annulee') {
+ return 'bg-red-100';
+ }
+
+ return 'bg-green-100';
+}
+
+/**
+ * Classe CSS pour le texte
+ */
+function getClasseTexte(array $distribution, bool $estProchaine): string {
+ if ($estProchaine) {
+ return 'text-white';
+ }
+
+ if ($distribution['type'] === 'annulee') {
+ return 'text-red-800';
+ }
+
+ if (estPassee($distribution)) {
+ return 'text-gray-800';
+ }
+
+ return 'text-green-800';
+}
+
+/**
+ * Label du statut
+ */
+function getLabelStatut(array $distribution, bool $estProchaine): ?string {
+ if ($estProchaine) {
+ return 'Prochaine';
+ }
+
+ if (estPassee($distribution)) {
+ return 'Passée';
+ }
+
+ return null;
+}
diff --git a/src/distributions.php b/src/distributions.php
new file mode 100644
index 0000000..8878496
--- /dev/null
+++ b/src/distributions.php
@@ -0,0 +1,109 @@
+ '2025-09-13',
+ 'lieu' => 'grange',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2025-09-27',
+ 'lieu' => 'secours',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2025-10-11',
+ 'lieu' => 'grange',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2025-10-25',
+ 'lieu' => 'secours',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2025-11-08',
+ 'lieu' => 'grange',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2025-11-22',
+ 'lieu' => 'secours',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2025-12-17',
+ 'lieu' => 'grange',
+ 'type' => 'special',
+ 'label' => '🎅 Distribution de Noël 🎅'
+ ],
+ [
+ 'date' => '2026-01-10',
+ 'lieu' => 'grange',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-01-24',
+ 'lieu' => 'secours',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-02-14',
+ 'lieu' => null,
+ 'type' => 'annulee',
+ 'label' => 'Pas de distribution',
+ 'raison' => 'Salon des vins et producteurs locaux'
+ ],
+ [
+ 'date' => '2026-02-28',
+ 'lieu' => 'secours',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-03-14',
+ 'lieu' => 'grange',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-03-28',
+ 'lieu' => 'secours',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-04-11',
+ 'lieu' => 'grange',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-04-25',
+ 'lieu' => 'secours',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-05-27',
+ 'lieu' => 'secours',
+ 'type' => 'special',
+ 'label' => ''
+ ],
+ [
+ 'date' => '2026-06-13',
+ 'lieu' => 'grange',
+ 'type' => 'normal'
+ ],
+ [
+ 'date' => '2026-07-01',
+ 'lieu' => 'grange',
+ 'type' => 'special',
+ 'label' => '🍻 La Guinguette 👯'
+ ]
+];
diff --git a/src/index.html b/src/index.php
similarity index 84%
rename from src/index.html
rename to src/index.php
index a494335..60e5b14 100644
--- a/src/index.html
+++ b/src/index.php
@@ -1,3 +1,9 @@
+
@@ -40,6 +46,11 @@
ligne et une distribution conviviale à Frouzins.
+
+
@@ -49,26 +60,25 @@
Prochaine distribution
- Samedi 11 octobre
+
+ = formaterDateComplete($dateObj) ?>
+
10h-12h
-
-
- au Secours Populaire de Frouzins – 28 rue Guillaume Berdeil
+ = $lieuInfo['description'] ?>
+
+
+ = htmlspecialchars($prochaineDistribution['label']) ?>
+
+
+
+
@@ -232,8 +243,8 @@
- Ajoutez un ou plusieurs produits portant la mention « au profit du
- secours populaire » à votre panier. Ils seront remis aux
+ Ajoutez un ou plusieurs produits portant la mention « au profit du
+ secours populaire » à votre panier. Ils seront remis aux
bénéficiaires dans les jours qui suivent la distribution.
@@ -265,79 +276,49 @@
-
-
24 septembre 2025
-
Passée
-
-
-
11 octobre 2025
-
Prochaine
-
-
-
-
+
+
-
- Mercredi 17 décembre 2025
+ // Déterminer si c'est un jour spécial (pas samedi)
+ $jourSemaine = $dateObj->format('N');
+ $estJourSpecial = $jourSemaine != 6;
+ ?>
+
+
+
+ ' . ucfirst($formatterJour->format($dateObj)) . ' ';
+ ?>
+
+ = formaterDateCalendrier($dateObj) ?>
-
- 🎅 Distribution de Noël 🎅
-
-
-
-
-
-
14 février 2026
-
- Pas de distribution
+
+
+ = htmlspecialchars($labelStatut) ?>
-
- Salon des vins et producteurs locaux
-
-
+
-
-
-
-
-
-
-
- Mercredi 27 mai 2026
+
+
+ = htmlspecialchars($distribution['label']) ?>
-
-
+
-
-
1 juillet 2025
-
- 🍻 La Guinguette 👯
+
+
+ = htmlspecialchars($distribution['raison']) ?>
+
+