fix create agenda don't create thanato automatically but set default to 0

This commit is contained in:
Tiavina 2024-12-26 20:38:49 +03:00
parent e35a6da064
commit 131e457045
3 changed files with 20 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -747,6 +747,17 @@ class Bdd {
return null;
}
public function getFirstThanatoIdByName($name) {
$sql = "SELECT min(id) as FIRST_INSERT_ID
FROM ".$this->tableprefix."thanato
WHERE nom = ?";
$res = $this->execSQLNoJsonReturn($sql,array($name));
if($res){
return $res[0]['FIRST_INSERT_ID'];
}
return null;
}
/**
* Insert lieu
*/

View File

@ -63,15 +63,18 @@ class GestionService {
return $summaryValue;
}
private function GetOrCreateThanatoFromVCalendarString(string $vCalendarString)
private function GetThanatoIdFromVCalendarString(string $vCalendarString)
{
$thanatoName = "Nom du défunt";
$thanatoId = 0;
$thanatoNames = $this->GetAttendeesNameFromVCalendarString($vCalendarString);
if(count($thanatoNames) > 0){
$thanatoName = $thanatoNames[0];
$thanatoIdFromDb = $this->gestionBdd->getFirstThanatoIdByName($thanatoName);
if($thanatoIdFromDb != null){
$thanatoId = $thanatoIdFromDb;
}
}
$thanatoId = $this->gestionBdd->getOrCreateThanatoIdByLastName($thanatoName);
return $thanatoId;
return $thanatoId;
}
private function GetAttendeesNameFromVCalendarString(string $vCalendarString): array
{
@ -93,7 +96,7 @@ class GestionService {
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString);
$locationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
$thanatoId = $this->GetOrCreateThanatoFromVCalendarString($vCalendarString);
$thanatoId = $this->GetThanatoIdFromVCalendarString($vCalendarString);
$devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId,$locationId,$thanatoId,$calendarSummary);
if($devisAlreadyCreated){
return;
@ -120,12 +123,6 @@ class GestionService {
return $locationId;
}
private function GetThanatoIdFromVCalendarString(string $vCalendarString){
$thanatoValue = $this->GetValueFromKeyInVCalendarString("EMBALMER", $vCalendarString);
$thanatoId = $this->gestionBdd->getLastThanatoIdByName($thanatoValue) ?? 0;
return $thanatoId;
}
private function GetArticlesNameFromVCalendarString(string $vCalendarString): array {
$devisArticleValue = $this->GetValueFromKeyInVCalendarString("DESCRIPTION", $vCalendarString);
$this->logger->debug('LIST OF ARTICLES',["" => $devisArticleValue]);