default value to escape null reference value on the generate pdf

This commit is contained in:
Tiavina 2025-01-21 16:13:26 +03:00
parent 7434967ec9
commit 128e4078b9

View File

@ -85,6 +85,40 @@ class CertificateService {
return base64_encode($file->getContent());
}
private function setDevisOfDefuntDefaultValue($devisOfDefunt){
$devisOfDefunt["devis_date"] = new DateTimeImmutable($devisOfDefunt["devis_date"]);
$locationOfDevis = "";
if($devisOfDefunt['lieu_nom'] != null){
$locationOfDevis .= $devisOfDefunt['lieu_nom'];
}
if($devisOfDefunt['lieu_adresse'] != null){
$locationOfDevis .= " ". $devisOfDefunt['lieu_adresse'];
}
$devisOfDefunt['location_of_devis'] = $locationOfDevis;
if($devisOfDefunt['thanato_nom'] == null){
$devisOfDefunt['thanato_nom'] = "";
}
if($devisOfDefunt['thanato_prenom'] == null){
$devisOfDefunt['thanato_prenom'] = "";
}
if($devisOfDefunt['thanato_reference'] == null){
$devisOfDefunt['thanato_reference'] = "";
}
if($devisOfDefunt['client_nom'] == null){
$devisOfDefunt['client_nom'] = "";
}
if($devisOfDefunt['client_prenom'] == null){
$devisOfDefunt['client_prenom'] = "";
}
if($devisOfDefunt['client_entreprise'] == null){
$devisOfDefunt['client_entreprise'] = "";
}
if($devisOfDefunt['client_adresse'] == null){
$devisOfDefunt['client_adresse'] = "";
}
return $devisOfDefunt;
}
public function generateCareCertificate($defuntId,$idNextCloud){
$storage = $this->rootFolder->getUserFolder($idNextCloud);
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
@ -95,17 +129,7 @@ class CertificateService {
return null;
}
$devisOfDefunt["configuration"] = $currentConfig;
$devisOfDefunt["thanato_date_habilitation"] = new DateTimeImmutable($devisOfDefunt["thanato_date_habilitation"]);
$devisOfDefunt["devis_date"] = new DateTimeImmutable($devisOfDefunt["devis_date"]);
$locationOfDevis = "";
if($devisOfDefunt['lieu_nom'] != null){
$locationOfDevis .= $devisOfDefunt['lieu_nom'];
}
if($devisOfDefunt['lieu_adresse'] != null){
$locationOfDevis .= " ". $devisOfDefunt['lieu_adresse'];
}
$devisOfDefunt['location_of_devis'] = $locationOfDevis;
$devisOfDefunt = $this->setDevisOfDefuntDefaultValue($devisOfDefunt);
$clean_folder = html_entity_decode(string: $currentConfig->path).'/';
$careCertificateFolder = $this->getCareCertificateFolder($devisOfDefunt);
$folderDestination = $clean_folder.$careCertificateFolder;
@ -169,17 +193,7 @@ class CertificateService {
return null;
}
$devisOfDefunt["configuration"] = $currentConfig;
$devisOfDefunt["thanato_date_habilitation"] = new DateTimeImmutable($devisOfDefunt["thanato_date_habilitation"]);
$devisOfDefunt["devis_date"] = new DateTimeImmutable($devisOfDefunt["devis_date"]);
$locationOfDevis = "";
if($devisOfDefunt['lieu_nom'] != null){
$locationOfDevis .= $devisOfDefunt['lieu_nom'];
}
if($devisOfDefunt['lieu_adresse'] != null){
$locationOfDevis .= " ". $devisOfDefunt['lieu_adresse'];
}
$devisOfDefunt['location_of_devis'] = $locationOfDevis;
$devisOfDefunt = $this->setDevisOfDefuntDefaultValue($devisOfDefunt);
$clean_folder = html_entity_decode(string: $currentConfig->path).'/';
$pacemakerCertificateFolder = $this->getPacemakerCertificateFolder($devisOfDefunt);
$folderDestination = $clean_folder.$pacemakerCertificateFolder;