From 0f67a210eaf70c1087cf59a0b7491045605eb178 Mon Sep 17 00:00:00 2001 From: narindraezway Date: Wed, 30 Apr 2025 17:25:47 +0300 Subject: [PATCH] debug-delete-old-trajet-if-change-thanato --- gestion/lib/Service/GestionService.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gestion/lib/Service/GestionService.php b/gestion/lib/Service/GestionService.php index 05e76b8..0e20d79 100644 --- a/gestion/lib/Service/GestionService.php +++ b/gestion/lib/Service/GestionService.php @@ -631,19 +631,21 @@ class GestionService { if ($devis != null) { $userPrincipalName = $this->gestionBdd->getCalendarPrincipalNameByCalendarId($targetCalendarId); if ($userPrincipalName != null) { - $thanatoId = $this->gestionBdd->getThanatoIdByUserUuid($userPrincipalName); - if ($thanatoId != null) { - $thanatoHasBeenChanged = $thanatoId != $devis["id_thanato"]; + $thanato = $this->gestionBdd->getThanatoByUserUuid($userPrincipalName); + if ($thanato != null) { + $thanatoHasBeenChanged = $thanato['id'] != $devis["id_thanato"]; if ($thanatoHasBeenChanged) { + $oldThanato = $this->gestionBdd->getThanatoByThanatoId($devis['id_thanato']); + $oldThanatoUserUuid = $oldThanato['fk_user_uuid']; //delete ligne trajet from old devis $this->gestionBdd->deleteLigneTrajetByDevisId($devis['id']); //delete from home and to home trajet if there is no devis at all for this date - $thereIsThanatoDevisRattachedToLigneTrajetForADate = $this->gestionBdd->thereIsThanatoDevisRattachedToLigneTrajetForADate($devis['date'],$userPrincipalName); + $thereIsThanatoDevisRattachedToLigneTrajetForADate = $this->gestionBdd->thereIsThanatoDevisRattachedToLigneTrajetForADate($devis['date'], $oldThanatoUserUuid ); if(!$thereIsThanatoDevisRattachedToLigneTrajetForADate){ //delete all ligne trajet for this date - $this->gestionBdd->deleteThanatoLigneTrajetForADate($devis['date'],$userPrincipalName); + $this->gestionBdd->deleteThanatoLigneTrajetForADate($devis['date'], $oldThanatoUserUuid ); } - $this->gestionBdd->updateDevisThanato($devis['id'], $thanatoId); + $this->gestionBdd->updateDevisThanato($devis['id'], $thanato['id']); $this->gestionBdd->reArrangeLigneTrajetyByDevisId($devis['id'], $userPrincipalName); } }