Corriger les dossiers animaux et le suivi médical
This commit is contained in:
parent
a55d27935f
commit
7b89fd5dfa
34 changed files with 440 additions and 39 deletions
|
|
@ -746,6 +746,18 @@ trait AnimalRecordActions
|
|||
':current_lng' => $currentLng,
|
||||
]);
|
||||
|
||||
// Un décès est une donnée structurée distincte du statut. Lors d'une correction
|
||||
// explicite d'un animal déclaré à tort décédé, ne pas laisser une ancienne fiche
|
||||
// de décès continuer à alimenter la bannière et les statistiques.
|
||||
$oldWasDeceased = in_array(strtolower((string) ($old['status'] ?? '')), ['decede', 'décédé'], true);
|
||||
$isNowDeceased = in_array(strtolower($status), ['decede', 'décédé'], true);
|
||||
if ($oldWasDeceased && !$isNowDeceased) {
|
||||
$db->prepare('DELETE FROM animal_deaths WHERE animal_id=:id')->execute([':id' => $id]);
|
||||
$db->prepare(
|
||||
"INSERT INTO animal_history(animal_id,action,type,label,details,user_id) VALUES(:id,'death_correction','update','Décès annulé','La fiche de décès a été retirée après correction du statut de l’animal.',:user)",
|
||||
)->execute([':id' => $id, ':user' => Auth::id()]);
|
||||
}
|
||||
|
||||
if ($old) {
|
||||
LocationHistoryService::record(
|
||||
$db,
|
||||
|
|
|
|||
Loading…
Reference in a new issue