From efe84d2be2223b1da7e2ea7669a1e15ac99d1570 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Thu, 2 Jan 2025 08:58:00 +0300 Subject: [PATCH] fix get logo image path and signature image path for attestation, rapport soin and rapport bijoux --- gestion/lib/Controller/PageController.php | 50 ++++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index 1551ef8..a245478 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -32,6 +32,8 @@ class PageController extends Controller { // private $src_path = "/var/www/html/apps/gestion/img/"; private $src_path = "/var/www/html/custom_apps/gestion/img/"; + private $sharedImagePath = "/var/www/html/data/.gestion/"; + private const HYTHA_35_DEFAULT_ADMIN = "Johann"; private const H2F_DEFAULT_ADMIN = "Emmanuelle"; private $urlGenerator; @@ -1979,6 +1981,21 @@ class PageController extends Controller { } catch(\OCP\Files\NotPermittedException $e) { } } + private function signatureImageExists(string $signatureImageName){ + $signatureExist = true; + try{ + if(isset($this->storage)){ + $file = $this->storage->get('/.gestion/' .$signatureImageName); + }else{ + $signatureExist = false; + } + } + catch(\OCP\Files\NotFoundException $e) { + $signatureExist = false; + } + return $signatureExist; + } + private function getLogo(){ try{ @@ -2185,7 +2202,10 @@ class PageController extends Controller { $pdf->SetMargins(0,0,0); // logo : 80 de largeur et 55 de hauteur - $pdf->Image($this->src_path."logo.jpeg", 10, 10, 55, 30); + $logo = $this->getLogo(); + if($logo != 'nothing'){ + $pdf->Image($this->sharedImagePath."logo.png", 10, 10, 55, 30); + } $pdf->SetY(55); $pdf->SetFont('Arial', 'B', 15); $pdf->Cell(0, 10, "ATTESTATION", 0, 0, 'C'); $pdf->SetMargins(15,0,15); @@ -2217,7 +2237,11 @@ class PageController extends Controller { $pdf->setY($pdf->GetY()+10); $pdf->Cell( $pdf->GetPageWidth()-30, 0, utf8_decode(html_entity_decode($current_config[0]->nom).' '.html_entity_decode($current_config[0]->prenom)), 0, 0, 'L'); $pdf->setY($pdf->GetY()+5); - $pdf->Image($this->src_path."sign.png", 15, $pdf->GetY(), 55, 30); + + $signatureExist = $this->signatureImageExists('sign.png'); + if($signatureExist){ + $pdf->Image($this->sharedImagePath."sign.png", 15, $pdf->GetY(), 55, 30); + } $pdf->setY($pdf->GetY()-5); $pdf->SetFont('Arial','',11); $pdf->Cell( $pdf->GetPageWidth()-80, 0, "Pour :", 0, 0, 'R'); @@ -2295,7 +2319,10 @@ class PageController extends Controller { $pdf->SetMargins(15,15,15); // logo : 80 de largeur et 55 de hauteur - $pdf->Image($this->src_path."logo.jpeg", 15, 15, 55, 30); + $logo = $this->getLogo(); + if($logo != 'nothing'){ + $pdf->Image($this->src_path."logo.png", 15, 15, 55, 30); + } $pdf->setXY(15, 15); $pdf->SetFont('Arial', '', 10); $pdf->MultiCell(0, 5, utf8_decode(html_entity_decode("N : ".$numFacture)), '', 'R'); $pdf->setXY(15, 55); $pdf->SetFont('Arial', 'B', 15); $pdf->Cell(80, 10, 'RAPPORT DE SOIN', 1, 1, 'C'); @@ -2452,7 +2479,11 @@ class PageController extends Controller { $pdf->setY($pdf->GetY()+10); $pdf->Cell( $pdf->GetPageWidth()-30, 0, utf8_decode(html_entity_decode($current_config[0]->nom).' '.html_entity_decode($current_config[0]->prenom)), 0, 0, 'L'); $pdf->setY($pdf->GetY()+5); - $pdf->Image($this->src_path."sign.png", 15, $pdf->GetY(), 55, 30); + + $signatureExist = $this->signatureImageExists('sign.png'); + if($signatureExist){ + $pdf->Image($this->sharedImagePath."sign.png", 15, $pdf->GetY(), 55, 30); + } $pdf->setY($pdf->GetY()-5); $pdf->SetFont('Arial','',11); $pdf->Cell( $pdf->GetPageWidth()-80, 0, "Pour :", 0, 0, 'R'); @@ -2544,7 +2575,10 @@ class PageController extends Controller { $pdf->SetAutoPagebreak(True); // logo : 80 de largeur et 55 de hauteur - $pdf->Image($this->src_path."logo.jpeg", 10, 10, 55, 30); + $logo = $this->getLogo(); + if($logo != 'nothing'){ + $pdf->Image($this->sharedImagePath."logo.png", 10, 10, 55, 30); + } $pdf->SetY(55); $pdf->SetFont('Arial', 'B', 15); $pdf->Cell(0, 10, utf8_decode(html_entity_decode("ATTESTATION BIJOU(X)")), 0, 0, 'C'); $pdf->SetMargins(15,15,15); @@ -2584,7 +2618,11 @@ class PageController extends Controller { $pdf->setY($pdf->GetY()+10); $pdf->Cell( $pdf->GetPageWidth()-30, 0, utf8_decode(html_entity_decode($current_config[0]->nom).' '.html_entity_decode($current_config[0]->prenom)), 0, 0, 'L'); $pdf->setY($pdf->GetY()+5); - $pdf->Image($this->src_path."sign.png", 15, $pdf->GetY(), 55, 30); + + $signatureExist = $this->signatureImageExists('sign.png'); + if ($signatureExist) { + $pdf->Image($this->sharedImagePath."sign.png", 15, $pdf->GetY(), 55, 30); + } $pdf->setY($pdf->GetY()-5); $pdf->SetFont('Arial','',11); $pdf->Cell( $pdf->GetPageWidth()-80, 0, "Pour :", 0, 0, 'R');