188 lines
6.8 KiB
PHP
188 lines
6.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* Calendar App
|
|
*
|
|
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
|
*
|
|
* @author Anna Larch <anna.larch@gmx.net>
|
|
* @author Richard Steinmetz <richard@steinmetz.cloud>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* License as published by the Free Software Foundation; either
|
|
* version 3 of the License, or any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
namespace OCA\Gestion\Service\Certificate\PdfHandler;
|
|
|
|
use DateTime;
|
|
use \FPDF;
|
|
use OCA\Gestion\Helpers\DateHelpers;
|
|
use OCA\Gestion\Helpers\FileExportHelpers;
|
|
use OCA\Gestion\Helpers\PriceHelpers;
|
|
|
|
class PacemakerCertificatePdfHandler extends FPDF {
|
|
|
|
private $devisOfDefunt = [];
|
|
private $logo = null;
|
|
private $signatureImageExist = false;
|
|
private $imagePath = "/var/www/html/data/admin/files/.gestion/";
|
|
|
|
function Header()
|
|
{
|
|
if($this->logo != "nothing"){
|
|
$this->Image($this->imagePath."logo.png", 10, 10, 75, 25);
|
|
}
|
|
else{
|
|
$this->Cell(55,30,'');
|
|
}
|
|
}
|
|
function Footer()
|
|
{
|
|
$this->SetY(-18);
|
|
$this->SetFont('ComicSans', '', 10);
|
|
$this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->legal_one)), 0, 'C');
|
|
$this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->adresse)), 0,'C');
|
|
}
|
|
|
|
public function SetPacemakerCertificateData(array $devisOfDefunt,$logo = null,$signatureImageExist = false){
|
|
$this->devisOfDefunt = $devisOfDefunt;
|
|
$this->logo = $logo;
|
|
$this->signatureImageExist = $signatureImageExist;
|
|
}
|
|
|
|
public function SetPacemakerCertificate(){
|
|
$this->AddPage();
|
|
$this->SetMargins(left:20,top:0,right:20);
|
|
$this->SetPacemakerCertificateTitle();
|
|
$this->SetPacemakerCertificateContent();
|
|
$this->SetSigning();
|
|
}
|
|
|
|
private function SetSigning(){
|
|
$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);
|
|
}
|
|
}
|
|
|
|
private function SetPacemakerCertificateContent(){
|
|
$this->SetFont('ComicSans', '', 14);
|
|
$this->MultiCell(0,7,FileExportHelpers::FormatTextForExport('La Société '. $this->devisOfDefunt['configuration']->entreprise. ' habilitée sous le numéro ' . $this->devisOfDefunt['thanato_reference'] . ', certifie par la présente que : '));
|
|
$this->SetFont('ComicSans', 'B', 14);
|
|
$this->Cell(0,12, 'Mr/Mme ' . FileExportHelpers::FormatTextForExport($this->devisOfDefunt['thanato_nom'] . ' ' . $this->devisOfDefunt['thanato_prenom']),0,1);
|
|
$this->SetFont('ComicSans', '', 14);
|
|
$this->MultiCell(0,7, FileExportHelpers::FormatTextForExport('Employé(e) au sein de notre société et titulaire du diplôme national de Thanatopracteur, a retiré ce jour, la prothèse fonctionnant à pile implantée sur le corps du défunt :'));
|
|
$this->SetFont('ComicSans', 'B', 14);
|
|
$this->Cell(0,12, FileExportHelpers::FormatTextForExport($this->devisOfDefunt['defunt_nom']),0,1);
|
|
$this->SetFont('ComicSans', '', 14);
|
|
$this->Cell(0,12, FileExportHelpers::FormatTextForExport("Qui reposait à l'adresse suivante") . ' : ',0,1);
|
|
$this->SetFont('ComicSans', 'B', 14);
|
|
$this->MultiCell(0,6, FileExportHelpers::FormatTextForExport($this->devisOfDefunt['location_of_devis']));
|
|
$this->Ln(6);
|
|
$this->SetFont('ComicSans', '', 14);
|
|
$this->Cell(0,6,
|
|
FileExportHelpers::FormatTextForExport("Numéro de série : ").
|
|
FileExportHelpers::FormatTextForExport($this->devisOfDefunt['defunt_reference_pacemaker']),0,1);
|
|
$this->Cell(0,6,
|
|
FileExportHelpers::FormatTextForExport("Marque du produit : ").
|
|
FileExportHelpers::FormatTextForExport($this->devisOfDefunt['defunt_product_brand']),0,1);
|
|
$this->Cell(0,12, FileExportHelpers::FormatTextForExport("La présente attestation est établie pour faire valoir ce que de droit."),0,5);
|
|
$this->Ln(5);
|
|
|
|
$this->MultiAlignCell(120,7,FileExportHelpers::FormatTextForExport('Fait à '). FileExportHelpers::FormatTextForExport($this->devisOfDefunt['configuration']->adresse),0);
|
|
$this->SetX(140);
|
|
$this->Cell(0,7,'le '. $this->devisOfDefunt['devis_date']->format('d/m/Y'),0);
|
|
}
|
|
|
|
private function SetPacemakerCertificateTitle(){
|
|
$this->SetY(y: 50);
|
|
$this->SetFont('ComicSans', 'B', 20);
|
|
$this->Cell(0,10,'ATTESTATION DE RETRAIT DE LA',0,1,'C');
|
|
$this->Cell(0,10,'PROTHESE FONCTIONNANT A PILE',0,1,'C');
|
|
$this->Ln(20);
|
|
}
|
|
|
|
function MultiAlignCell($w,$h,$text,$border=0,$ln=0,$align='L',$fill=false)
|
|
{
|
|
// Store reset values for (x,y) positions
|
|
$x = $this->GetX() + $w;
|
|
$y = $this->GetY();
|
|
|
|
// Make a call to FPDF's MultiCell
|
|
$this->MultiCell($w,$h,$text,$border,$align,$fill);
|
|
|
|
// Reset the line position to the right, like in Cell
|
|
if( $ln==0 )
|
|
{
|
|
$this->SetXY($x,$y);
|
|
}
|
|
}
|
|
|
|
function NbLines($w, $txt)
|
|
{
|
|
// Compute the number of lines a MultiCell of width w will take
|
|
if(!isset($this->CurrentFont))
|
|
$this->Error('No font has been set');
|
|
$cw = $this->CurrentFont['cw'];
|
|
if($w==0)
|
|
$w = $this->w-$this->rMargin-$this->x;
|
|
$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
|
|
$s = str_replace("\r",'',(string)$txt);
|
|
$nb = strlen($s);
|
|
if($nb>0 && $s[$nb-1]=="\n")
|
|
$nb--;
|
|
$sep = -1;
|
|
$i = 0;
|
|
$j = 0;
|
|
$l = 0;
|
|
$nl = 1;
|
|
while($i<$nb)
|
|
{
|
|
$c = $s[$i];
|
|
if($c=="\n")
|
|
{
|
|
$i++;
|
|
$sep = -1;
|
|
$j = $i;
|
|
$l = 0;
|
|
$nl++;
|
|
continue;
|
|
}
|
|
if($c==' ')
|
|
$sep = $i;
|
|
$l += $cw[$c];
|
|
if($l>$wmax)
|
|
{
|
|
if($sep==-1)
|
|
{
|
|
if($i==$j)
|
|
$i++;
|
|
}
|
|
else
|
|
$i = $sep+1;
|
|
$sep = -1;
|
|
$j = $i;
|
|
$l = 0;
|
|
$nl++;
|
|
}
|
|
else
|
|
$i++;
|
|
}
|
|
return $nl;
|
|
}
|
|
}
|