From a55d27935f7e25c51916a12a36b98a06bc920dc3 Mon Sep 17 00:00:00 2001 From: oversu <95a7002b-481b-4ef3-b578-f9c421550aa4@localhost> Date: Tue, 22 Sep 2026 18:05:38 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20corriger=20le=20suivi=20m=C3=A9dical=20e?= =?UTF-8?q?t=20les=20styles=20publics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 +++ HISTORIQUE.md | 4 ++ README.md | 2 +- VERSION | 2 +- app/Controllers/AnimalMedicalActions.php | 43 ++++++++---- app/Controllers/DewormingController.php | 47 +++++++++++++ app/Routes/web.php | 3 + app/Services/PermissionService.php | 2 + app/Views/_animal_show_medical.php | 16 ++++- app/Views/_animal_show_modals.php | 84 +++++++++++++++++++++++- app/Views/_deworming_modal.php | 2 - app/Views/animal_show.php | 2 + app/Views/public_site_layout.php | 7 +- resources/lang/en.php | 3 + resources/lang/fr.php | 3 + 15 files changed, 206 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e211222..cdd69e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ 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.29] — 2026-09-22 + +### Corrections du suivi médical et du site public + +- correction du formulaire d’édition des administrations de vermifuge / anti-puce ; +- modification des traitements déjà saisis et correction des intitulés de produits médicaux ; +- accès plus visible aux vermifuges dans l’onglet médical ; +- chargement du CSS personnalisé après les styles ordinaires du site public ; +- affichage de la date de naissance dans le résumé de la fiche animale. + ## [1.0.0-rc.28] — 2026-09-15 ### Saisies médicales corrigibles diff --git a/HISTORIQUE.md b/HISTORIQUE.md index 558fd31..6fb9616 100644 --- a/HISTORIQUE.md +++ b/HISTORIQUE.md @@ -10,6 +10,10 @@ L’import depuis Animal Shelter Manager a été conçu comme un parcours pruden Avant la version 1.0, le projet a fait l’objet d’un nettoyage structurel et d’un découpage de ses fichiers les plus volumineux. La recherche universelle, les salles configurables, les traductions française et anglaise et une suite de contrôles isolés ont complété cette phase de stabilisation. +## `1.0.0-rc.29` — Suivi médical et présentation + +Les traitements et les intitulés des produits médicaux peuvent être corrigés après leur saisie. Le formulaire des vermifuges s’ouvre de nouveau correctement. La fiche animale montre sa date de naissance et le CSS personnalisé du site public prend priorité sur les styles standard. + ## `1.0.0-rc.28` — Corrections des saisies médicales Les vaccinations et administrations de vermifuges ou d’anti-puces peuvent être corrigées sans provoquer une seconde sortie de stock ni une nouvelle dépense. Les nouvelles fiches de chats proposent également la race Chat Européen par défaut. diff --git a/README.md b/README.md index 1796654..4d069ee 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.28`. 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.29`. 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 90a7420..3dcfd46 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0-rc.28 +1.0.0-rc.29 diff --git a/app/Controllers/AnimalMedicalActions.php b/app/Controllers/AnimalMedicalActions.php index 3846c5f..a8a2c4b 100644 --- a/app/Controllers/AnimalMedicalActions.php +++ b/app/Controllers/AnimalMedicalActions.php @@ -400,6 +400,7 @@ trait AnimalMedicalActions } $id = (int) ($_POST['animal_id'] ?? 0); + $entryId = (int) ($_POST['entry_id'] ?? 0); $medId = (int) ($_POST['medication_id'] ?? 0); $createMedication = !empty($_POST['create_medication']); if ($id <= 0 || (!$createMedication && $medId <= 0)) { @@ -429,6 +430,15 @@ trait AnimalMedicalActions } $db = DB::pdo(); + if ($entryId > 0) { + $existing = $db->prepare('SELECT 1 FROM treatments WHERE id=:entry AND animal_id=:animal'); + $existing->execute([':entry' => $entryId, ':animal' => $id]); + if (!$existing->fetchColumn()) { + http_response_code(404); + echo h(t('error.not_found')); + return; + } + } if ($createMedication) { $medicationName = trim((string) ($_POST['new_medication_name'] ?? '')); $medicationMolecule = trim((string) ($_POST['new_medication_molecule'] ?? '')); @@ -475,12 +485,7 @@ trait AnimalMedicalActions return; } $vet_name = $vetContact['name'] ?? $vet_name; - $stmt = $db->prepare(' - INSERT INTO treatments(animal_id, medication_id, route, dose_text, start_date, end_date, ongoing, notes, clinic_id, vet_name, clinic_contact_id, vet_contact_id, give_morning, give_evening, give_as_needed, created_by) - VALUES(:aid,:mid,:route,:dose,:start,:end,1,:notes,:clinic_id,:vet_name,:clinic_contact_id,:vet_contact_id,:give_morning,:give_evening,:give_as_needed,:created_by) - '); - $stmt->execute([ - ':aid' => $id, + $values = [ ':mid' => $medId, ':route' => $route !== '' ? $route : null, ':dose' => $dose, @@ -494,16 +499,32 @@ trait AnimalMedicalActions ':give_morning' => $giveMorning, ':give_evening' => $giveEvening, ':give_as_needed' => $giveAsNeeded, - ':created_by' => Auth::id(), - ]); - if ((int) ($_POST['tariff_id'] ?? 0) > 0) { - PricingService::record($db, $id, (int) $_POST['tariff_id'], 1, $start, 'Ajoutée avec le traitement'); + ]; + if ($entryId > 0) { + $values[':entry'] = $entryId; + $db->prepare('UPDATE treatments SET medication_id=:mid,route=:route,dose_text=:dose,start_date=:start, + end_date=:end,notes=:notes,clinic_id=:clinic_id,vet_name=:vet_name, + clinic_contact_id=:clinic_contact_id,vet_contact_id=:vet_contact_id, + give_morning=:give_morning,give_evening=:give_evening,give_as_needed=:give_as_needed + WHERE id=:entry')->execute($values); + } else { + $values[':aid'] = $id; + $values[':created_by'] = Auth::id(); + $db->prepare('INSERT INTO treatments(animal_id, medication_id, route, dose_text, start_date, end_date, + ongoing, notes, clinic_id, vet_name, clinic_contact_id, vet_contact_id, + give_morning, give_evening, give_as_needed, created_by) + VALUES(:aid,:mid,:route,:dose,:start,:end,1,:notes,:clinic_id,:vet_name, + :clinic_contact_id,:vet_contact_id,:give_morning,:give_evening,:give_as_needed,:created_by)') + ->execute($values); + if ((int) ($_POST['tariff_id'] ?? 0) > 0) { + PricingService::record($db, $id, (int) $_POST['tariff_id'], 1, $start, 'Ajoutée avec le traitement'); + } } self::logHistory( $id, 'treatment', - 'Traitement ajouté', + $entryId > 0 ? 'Traitement corrigé' : 'Traitement ajouté', "Médicament #$medId\nDose : $dose\nDébut : $start" . ($end !== '' ? "\nFin : $end" : '') . ($notes !== '' ? "\nNotes : $notes" : ''), diff --git a/app/Controllers/DewormingController.php b/app/Controllers/DewormingController.php index 5757a83..fc83a4e 100644 --- a/app/Controllers/DewormingController.php +++ b/app/Controllers/DewormingController.php @@ -4,6 +4,53 @@ declare(strict_types=1); final class DewormingController { + public static function renameProduct(): void + { + if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') { + http_response_code(405); + return; + } + if (!PermissionService::can('medical', 'edit')) { + http_response_code(403); + return; + } + $tables = ['dewormer' => 'ref_dewormers', 'medication' => 'ref_medications', 'vaccine' => 'ref_vaccines']; + $category = (string) ($_POST['category'] ?? ''); + $table = $tables[$category] ?? null; + $id = (int) ($_POST['product_id'] ?? 0); + $animalId = (int) ($_POST['animal_id'] ?? 0); + $name = trim((string) ($_POST['name'] ?? '')); + if ($table === null || $id <= 0 || $animalId <= 0 || $name === '' || mb_strlen($name) > 150) { + http_response_code(400); + echo h(t('error.bad_request')); + return; + } + $db = DB::pdo(); + $stmt = $db->prepare("SELECT name FROM $table WHERE id=:id"); + $stmt->execute([':id' => $id]); + $previous = $stmt->fetchColumn(); + if ($previous === false) { + http_response_code(404); + echo h(t('error.not_found')); + return; + } + $duplicate = $db->prepare("SELECT 1 FROM $table WHERE name=:name COLLATE NOCASE AND id<>:id"); + $duplicate->execute([':name' => $name, ':id' => $id]); + if ($duplicate->fetchColumn()) { + http_response_code(409); + echo h(t('catalog.name_exists')); + return; + } + $db->prepare("UPDATE $table SET name=:name WHERE id=:id")->execute([':name' => $name, ':id' => $id]); + AuditService::log('catalog_renamed', '/animal/product/rename', 'Intitulé de produit corrigé', 'animal', $animalId, [ + 'category' => $category, + 'product_id' => $id, + 'previous_name' => $previous, + 'new_name' => $name, + ]); + header('Location: /animal?id=' . $animalId . '#tab-med'); + } + public static function save(): void { if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') { diff --git a/app/Routes/web.php b/app/Routes/web.php index 9a12b0e..81f4db3 100644 --- a/app/Routes/web.php +++ b/app/Routes/web.php @@ -88,6 +88,9 @@ switch ($path) { case '/animal/add-deworming': DewormingController::save(); break; + case '/animal/product/rename': + DewormingController::renameProduct(); + break; case '/animal/add-vaccine': AnimalsController::addVaccine(); diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index 9de5203..a03c5a1 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -91,6 +91,8 @@ final class PermissionService '/animal/medical-status', '/animal/add-treatment', '/animal/add-vaccine', + '/animal/add-deworming', + '/animal/product/rename', '/animal/death', '/animal/prescription', '/animal/lab-report', diff --git a/app/Views/_animal_show_medical.php b/app/Views/_animal_show_medical.php index 9eaa17c..57e97f0 100644 --- a/app/Views/_animal_show_medical.php +++ b/app/Views/_animal_show_medical.php @@ -198,7 +198,7 @@
-

+

🪱

@@ -400,7 +400,19 @@ ORDER BY created_at ASC - + diff --git a/app/Views/_animal_show_modals.php b/app/Views/_animal_show_modals.php index d56aad7..46b1474 100644 --- a/app/Views/_animal_show_modals.php +++ b/app/Views/_animal_show_modals.php @@ -22,6 +22,7 @@ $currentTime = date('H:i'); @@ -332,6 +337,33 @@ $currentTime = date('H:i'); + + +