From aa71d04f17af5e0d3f0f39273dd7b74d681ef8a1 Mon Sep 17 00:00:00 2001 From: narindraezway Date: Tue, 29 Jul 2025 16:44:03 +0300 Subject: [PATCH] DV Thanato : add tampon and signature on pdf attestations --- .../Certificate/CertificateService.php | 21 +++++++++++++++++-- .../PdfHandler/CareCertificatePdfHandler.php | 10 +++++++-- .../PacemakerCertificatePdfHandler.php | 12 ++++++++--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/gestion/lib/Service/Certificate/CertificateService.php b/gestion/lib/Service/Certificate/CertificateService.php index ab176e4..bd2d541 100644 --- a/gestion/lib/Service/Certificate/CertificateService.php +++ b/gestion/lib/Service/Certificate/CertificateService.php @@ -64,6 +64,21 @@ class CertificateService { } return $signatureExist; } + private function tamponImageExist(){ + $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); + try{ + if(isset($storage)){ + $storage->get("/.gestion/sign.jpg"); // tampon image + $signatureExist = true; + }else{ + $signatureExist = false; + } + } + catch(\OCP\Files\NotFoundException $e) { + $signatureExist = false; + } + return $signatureExist; + } private function getLogo(){ $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); @@ -138,7 +153,8 @@ class CertificateService { $pdf->AddFont('ComicSans','','Comic Sans MS.php'); $pdf->AddFont('ComicSans','B','comic-sans-bold.php'); $signatureImageExist = $this->signatureImageExists(); - $pdf->SetCareCertificateData($devisOfDefunt,$logo,$signatureImageExist); + $tamponImageExist = $this->tamponImageExist(); + $pdf->SetCareCertificateData($devisOfDefunt,$logo,$signatureImageExist ,$tamponImageExist); $pdf->SetCareCertificate(); try { $storage->newFolder($folderDestination); @@ -202,7 +218,8 @@ class CertificateService { $pdf->AddFont('ComicSans','','Comic Sans MS.php'); $pdf->AddFont('ComicSans','B','comic-sans-bold.php'); $signatureImageExist = $this->signatureImageExists(); - $pdf->SetPacemakerCertificateData($devisOfDefunt,$logo,$signatureImageExist); + $tamponImageExist = $this->tamponImageExist(); + $pdf->SetPacemakerCertificateData($devisOfDefunt,$logo,$signatureImageExist ,$tamponImageExist); $pdf->SetPacemakerCertificate(); try { $storage->newFolder($folderDestination); diff --git a/gestion/lib/Service/Certificate/PdfHandler/CareCertificatePdfHandler.php b/gestion/lib/Service/Certificate/PdfHandler/CareCertificatePdfHandler.php index 09c690f..0ce8255 100644 --- a/gestion/lib/Service/Certificate/PdfHandler/CareCertificatePdfHandler.php +++ b/gestion/lib/Service/Certificate/PdfHandler/CareCertificatePdfHandler.php @@ -37,6 +37,7 @@ class CareCertificatePdfHandler extends FPDF { private $devisOfDefunt = []; private $logo = null; private $signatureImageExist = false; + private $tamponImageExist = false; private $imagePath = "/var/www/html/data/admin/files/.gestion/"; function Header() @@ -56,10 +57,11 @@ class CareCertificatePdfHandler extends FPDF { $this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->adresse)), 0,'C'); } - public function SetCareCertificateData(array $devisOfDefunt,$logo = null,$signatureImageExist = false){ + public function SetCareCertificateData(array $devisOfDefunt,$logo = null,$signatureImageExist = false , $tamponImageExist = false){ $this->devisOfDefunt = $devisOfDefunt; $this->logo = $logo; $this->signatureImageExist = $signatureImageExist; + $this->tamponImageExist = $tamponImageExist; } public function SetCareCertificate(){ @@ -74,8 +76,12 @@ class CareCertificatePdfHandler extends FPDF { $this->SetXY(140,$this->GetY() + 15); $this->Cell(0,10,'Cachet et signature'); + if($this->tamponImageExist){ + $this->Image($this->imagePath."sign.jpg", 120, $this->GetY() + 8, 80, 35); + } + if($this->signatureImageExist){ - $this->Image($this->imagePath."sign.png", 135, $this->GetY() + 12, 60, 40); + $this->Image($this->imagePath."sign.png", 140, $this->GetY() + 40, 40, 16); } } diff --git a/gestion/lib/Service/Certificate/PdfHandler/PacemakerCertificatePdfHandler.php b/gestion/lib/Service/Certificate/PdfHandler/PacemakerCertificatePdfHandler.php index e68db84..fc80b33 100644 --- a/gestion/lib/Service/Certificate/PdfHandler/PacemakerCertificatePdfHandler.php +++ b/gestion/lib/Service/Certificate/PdfHandler/PacemakerCertificatePdfHandler.php @@ -38,6 +38,7 @@ class PacemakerCertificatePdfHandler extends FPDF private $devisOfDefunt = []; private $logo = null; private $signatureImageExist = false; + private $tamponImageExist = false; private $imagePath = "/var/www/html/data/admin/files/.gestion/"; function Header() @@ -56,11 +57,12 @@ class PacemakerCertificatePdfHandler extends FPDF $this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->adresse)), 0, 'C'); } - public function SetPacemakerCertificateData(array $devisOfDefunt, $logo = null, $signatureImageExist = false) + public function SetPacemakerCertificateData(array $devisOfDefunt, $logo = null, $signatureImageExist = false , $tamponImageExist = false) { $this->devisOfDefunt = $devisOfDefunt; $this->logo = $logo; $this->signatureImageExist = $signatureImageExist; + $this->tamponImageExist = $tamponImageExist; } public function SetPacemakerCertificate() @@ -77,8 +79,12 @@ class PacemakerCertificatePdfHandler extends FPDF $this->SetXY(140, $this->GetY() + 15); $this->Cell(0, 10, 'Cachet et signature'); - if ($this->signatureImageExist) { - $this->Image($this->imagePath . "sign.png", 135, $this->GetY() + 12, 60, 40); + if($this->tamponImageExist){ + $this->Image($this->imagePath."sign.jpg", 120, $this->GetY() + 8, 80, 35); + } + + if($this->signatureImageExist){ + $this->Image($this->imagePath."sign.png", 140, $this->GetY() + 40, 40, 16); } }