From 68590eddbb5687196477bcdee48667004beb6a13 Mon Sep 17 00:00:00 2001 From: oversu <95a7002b-481b-4ef3-b578-f9c421550aa4@localhost> Date: Sun, 13 Sep 2026 15:57:57 +0200 Subject: [PATCH] Corrige la localisation actuelle des animaux --- CHANGELOG.md | 9 ++++++ HISTORIQUE.md | 4 +++ README.md | 2 +- VERSION | 2 +- app/Controllers/AnimalBrowseActions.php | 29 +++++++++++++++++++ app/Controllers/PlacementsController.php | 19 ++++++++++-- app/Views/_animal_show_identity.php | 6 ++-- app/Views/animal_form.php | 37 ++++++++---------------- app/Views/evolutions.php | 8 ++--- 9 files changed, 80 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3aa7e5..e29c827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ Toutes les modifications importantes du projet sont consignées ici. Le format s’inspire de [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/) et le projet suit le [versionnage sémantique](https://semver.org/lang/fr/). +## [1.0.0-rc.20] — 2026-09-13 + +### Localisation des animaux + +- regroupement des informations de récupération et de lieu actuel dans une seule section sans anciens champs en double ; +- conservation de l’adresse actuelle lors de la modification d’une fiche ; +- géocodage du nouveau lieu lors d’un placement ou d’un retour au refuge ; +- réparation ponctuelle des coordonnées manquantes des animaux déjà importés afin d’afficher leur lieu actuel sur la carte. + ## [1.0.0-rc.19] — 2026-09-13 ### Horodatage des contrôles de soins diff --git a/HISTORIQUE.md b/HISTORIQUE.md index e7efa40..29736fe 100644 --- a/HISTORIQUE.md +++ b/HISTORIQUE.md @@ -85,3 +85,7 @@ Déplacement des informations légales dans le pied de page, insertion guidée d ## `1.0.0-rc.19` — Contrôles de soins horodatés Ajout d’une date et d’une heure modifiables aux contrôles médicaux, avec reprise cohérente de l’instant choisi dans les mesures de poids et les données associées. + +## `1.0.0-rc.20` — Localisations cohérentes + +Simplification des lieux affichés dans la fiche, conservation de l’adresse actuelle et réparation des coordonnées manquantes après un import ou un placement. diff --git a/README.md b/README.md index 1800b24..914bc81 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ L’option `--apply` ne doit être utilisée qu’après lecture des rapports. L ## État du projet -La candidate actuelle est `1.0.0-rc.19`. La branche 1.0 est gelée fonctionnellement : seuls les défauts bloquants découverts pendant les validations terrain sont corrigés avant `1.0.0`. +La candidate actuelle est `1.0.0-rc.20`. La branche 1.0 est gelée fonctionnellement : seuls les défauts bloquants découverts pendant les validations terrain sont corrigés avant `1.0.0`. Le contrôle de stabilisation est disponible dans [docs/AUDIT-1.0.md](docs/AUDIT-1.0.md). diff --git a/VERSION b/VERSION index 784e940..dca2922 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0-rc.19 +1.0.0-rc.20 diff --git a/app/Controllers/AnimalBrowseActions.php b/app/Controllers/AnimalBrowseActions.php index 1e34209..86e657b 100644 --- a/app/Controllers/AnimalBrowseActions.php +++ b/app/Controllers/AnimalBrowseActions.php @@ -453,6 +453,35 @@ trait AnimalBrowseActions echo h(t('error.animal_not_found')); return; } + + // Les imports historiques peuvent contenir une adresse sans ses coordonnées. + // On complète alors la fiche une seule fois, au premier affichage de la carte. + $coordinateUpdates = []; + foreach ([ + 'rescue' => trim((string) ($animal['rescue_address'] ?: $animal['rescue_location_name'] ?? '')), + 'current' => trim((string) ($animal['current_address'] ?? '')), + ] as $kind => $address) { + if ( + $address !== '' && + ($animal[$kind . '_lat'] === null || $animal[$kind . '_lng'] === null) + ) { + $coordinates = GeoService::geocode($db, $address); + if ($coordinates) { + $coordinateUpdates[$kind . '_lat'] = $coordinates['lat']; + $coordinateUpdates[$kind . '_lng'] = $coordinates['lng']; + } + } + } + if ($coordinateUpdates) { + $assignments = []; + $parameters = [':id' => $id]; + foreach ($coordinateUpdates as $column => $value) { + $assignments[] = $column . '=:' . $column; + $parameters[':' . $column] = $value; + $animal[$column] = $value; + } + $db->prepare('UPDATE animals SET ' . implode(',', $assignments) . ' WHERE id=:id')->execute($parameters); + } if (!empty($animal['intake_owner_care_home'])) { $animal['intake_reason'] = 'owner_care_home'; } diff --git a/app/Controllers/PlacementsController.php b/app/Controllers/PlacementsController.php index 7255d35..4366c64 100644 --- a/app/Controllers/PlacementsController.php +++ b/app/Controllers/PlacementsController.php @@ -72,6 +72,15 @@ final class PlacementsController ]), ); } + $currentLat = null; + $currentLng = null; + if ($currentAddress !== '') { + $coordinates = GeoService::geocode($db, $currentAddress); + if ($coordinates) { + $currentLat = $coordinates['lat']; + $currentLng = $coordinates['lng']; + } + } $notes = trim((string) ($_POST['notes'] ?? '')); $db->beginTransaction(); try { @@ -87,8 +96,14 @@ final class PlacementsController ':user' => Auth::id(), ]); $db->prepare( - 'UPDATE animals SET status=:status,refuge_room=NULL,care_box_key=NULL,current_address=:address,current_lat=NULL,current_lng=NULL,updated_at=datetime(\'now\') WHERE id=:id', - )->execute([':status' => $status, ':address' => $currentAddress ?: null, ':id' => $animalId]); + 'UPDATE animals SET status=:status,refuge_room=NULL,care_box_key=NULL,current_address=:address,current_lat=:lat,current_lng=:lng,updated_at=datetime(\'now\') WHERE id=:id', + )->execute([ + ':status' => $status, + ':address' => $currentAddress ?: null, + ':lat' => $currentLat, + ':lng' => $currentLng, + ':id' => $animalId, + ]); $after = $animal; $after['status'] = $status; $after['refuge_room'] = null; diff --git a/app/Views/_animal_show_identity.php b/app/Views/_animal_show_identity.php index 10efc84..3d9488c 100644 --- a/app/Views/_animal_show_identity.php +++ b/app/Views/_animal_show_identity.php @@ -178,11 +178,11 @@
Date et heure modifiables pour distinguer précisément plusieurs contrôles et - mesures réalisés au cours d’une même journée.
+ 1.0.0-rc.20 +Lieu de récupération et lieu actuel clairement distingués, avec réparation + des coordonnées manquantes après un import ou un placement.