From 35f9f34c0204b73a20af40384ac48b0d2786a3a5 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 2 Apr 2025 12:19:35 +0300 Subject: [PATCH 01/10] add minutes into talk message --- gestion/lib/Db/Bdd.php | 14 +++++++++++--- gestion/lib/Helpers/VCalendarHelpers.php | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index ccb5e60..d6b1fa9 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -3840,8 +3840,16 @@ class Bdd { } $calendarData = $this->getCalendarDataByCalendarObjectUuid($devis->num); $devisTimeValue = VCalendarHelpers::GetStartAndEndTimeFromVCalendarString($calendarData); - $devis->startTime = $devisTimeValue["startTime"]; - $devis->endTime = $devisTimeValue["endTime"]; + $startTimeValueWithMinutes = ""; + $endTimeValueWithMinutes = ""; + if($devisTimeValue["datetimeStart"]){ + $startTimeValueWithMinutes = $devisTimeValue["datetimeStart"]->format('H\hi'); + } + if($devisTimeValue["datetimeEnd"]){ + $endTimeValueWithMinutes = $devisTimeValue["datetimeEnd"]->format('H\hi'); + } + $devis->startTime = $startTimeValueWithMinutes; + $devis->endTime = $endTimeValueWithMinutes; $devisProducts = $this->getDevisProduits($devisId); $devisProducts = json_encode($devisProducts); $devisProducts = json_decode($devisProducts); @@ -3885,7 +3893,7 @@ class Bdd { $message .= html_entity_decode($devis->nom_defunt); $message .= ' le '.$devisDate; - $message .= 'à '.$devis->startTime. ' '; + $message .= ' à '.$devis->startTime. ' '; $message .= ' à '.html_entity_decode($devis->lieu). ' '. html_entity_decode($devis->adresse_soin); diff --git a/gestion/lib/Helpers/VCalendarHelpers.php b/gestion/lib/Helpers/VCalendarHelpers.php index 2b4f9d6..411ad18 100644 --- a/gestion/lib/Helpers/VCalendarHelpers.php +++ b/gestion/lib/Helpers/VCalendarHelpers.php @@ -41,6 +41,8 @@ class VCalendarHelpers $endTimeValue = ""; $totalHours = 0; $totalWorkedHours = 0; + $dateStart = null; + $dateEnd = null; if($vCalendarString != ""){ $dateStart = self::GetDateStartOrDateEndFromVCalendarString("DTSTART", $vCalendarString); if($dateStart != null){ @@ -54,6 +56,8 @@ class VCalendarHelpers $totalWorkedHours = DateHelpers::GetWorkingHoursBetweenDatetimeEndAndDatetimeStart($dateEnd,$dateStart); } return [ + "datetimeStart" => $dateStart, + "datetimeEnd" => $dateEnd, "startTime" => $startTimeValue, "endTime" => $endTimeValue, "totalHours" => $totalHours, From 006e791e52835a69722de77412eea3495f52a6fa Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 2 Apr 2025 12:26:26 +0300 Subject: [PATCH 02/10] add senderUser parameter to createDevisTalkRoomMessageAndReturnMessage method --- gestion/lib/Db/TalkDb.php | 4 ++-- gestion/lib/Service/TalkService.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gestion/lib/Db/TalkDb.php b/gestion/lib/Db/TalkDb.php index 77e9658..15d0ba0 100644 --- a/gestion/lib/Db/TalkDb.php +++ b/gestion/lib/Db/TalkDb.php @@ -195,9 +195,9 @@ class TalkDb { [$messageId,$roomId,$idNextCloud]); } - public function createDevisTalkRoomMessageAndReturnMessage($roomId,$message){ + public function createDevisTalkRoomMessageAndReturnMessage($roomId,$message,$senderUser){ $this->createDevisTalkRoomMessage( - BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD, + $senderUser, $message, self::DEVIS_TALK_ROOM_VERB_COMMENT, $roomId, diff --git a/gestion/lib/Service/TalkService.php b/gestion/lib/Service/TalkService.php index 295b7ed..4baca6f 100644 --- a/gestion/lib/Service/TalkService.php +++ b/gestion/lib/Service/TalkService.php @@ -94,7 +94,7 @@ class TalkService { else{ $roomToken = $room['token']; } - $devisMessage = $this->talkDb->createDevisTalkRoomMessageAndReturnMessage($room['id'],$message); + $devisMessage = $this->talkDb->createDevisTalkRoomMessageAndReturnMessage($room['id'],$message,$senderUser); $this->talkDb->updateRoomLastMessage($room['id'],$devisMessage['id']); $this->talkDb->setAttendeeLastReadMessage($room['id'],$devisMessage['id'],$senderUser); //send notifications From 8a7f3758ced489f1edd41525c7e22361c0a527ae Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 2 Apr 2025 12:59:40 +0300 Subject: [PATCH 03/10] add cc on send email (facture,attestation) --- gestion/lib/Controller/InvoiceController.php | 14 ++++++++++++++ gestion/lib/Controller/PageController.php | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/gestion/lib/Controller/InvoiceController.php b/gestion/lib/Controller/InvoiceController.php index e43efdd..6c22a80 100644 --- a/gestion/lib/Controller/InvoiceController.php +++ b/gestion/lib/Controller/InvoiceController.php @@ -1,6 +1,7 @@ mailer = $mailer; $this->gestionRepository = $bdd; $this->mailerService = $mailerService; + $this->config = $config; try{ $this->storage = $rootFolder->getUserFolder($this->currentUserIdNextcloud); @@ -93,6 +98,12 @@ class InvoiceController extends Controller $factureContent = $factureGeneratedResponse["content"]; $factureDate = DateHelpers::convertInvoiceDateToMonthAndYearOnly($facture['date_paiement']); try { + $senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null; + $senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null; + $senderEmail = null; + if($senderEmailAddress && $senderEmailDomain){ + $senderEmail = $senderEmailAddress.'@'.$senderEmailDomain; + } $message = $this->mailer->createMessage(); $message->setTo(recipients: [$email => "Facture"]); $content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf"); @@ -106,6 +117,9 @@ class InvoiceController extends Controller "

Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .

". $signature ); + if($senderEmail != null){ + $message->setCc([$senderEmail]); + } $this->mailer->send($message); $this->gestionRepository->setFactureSentDate($factureId); } catch (Exception $e) { diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index 62fdd04..becb02c 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -1590,6 +1590,12 @@ class PageController extends Controller { $devis = $this->myDb->getDevisOfDefunt($defuntId); if($devis != null){ // try { + $senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null; + $senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null; + $senderEmail = null; + if($senderEmailAddress && $senderEmailDomain){ + $senderEmail = $senderEmailAddress.'@'.$senderEmailDomain; + } $client_email = $to; $client_nom = $devis['client_nom']; $data = $this->storage->get($ff_pdf)->getContent(); @@ -1608,6 +1614,10 @@ class PageController extends Controller { "

$body_text

". $signature ); + + if($senderEmail != null){ + $message->setCc([$senderEmail]); + } $this->mailer->send($message); return new DataResponse("", 200, ['Content-Type' => 'application/json']); // } catch (Exception $e) { From fc6c370ca329a1aa8df742b2e50b57e00e51e2f1 Mon Sep 17 00:00:00 2001 From: Narindra ezway Date: Wed, 2 Apr 2025 15:43:17 +0300 Subject: [PATCH 04/10] add default template type and adjust PDF layout for invoice details --- .../InvoiceFunecapPdfHandler.php | 18 +- .../InvoiceGroupPdfHandler.php | 116 ++++-- gestion/lib/Service/InvoicePdfHandler.php | 352 ++++++++++-------- gestion/lib/Service/InvoicePdfService.php | 3 + 4 files changed, 289 insertions(+), 200 deletions(-) diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php index 38a8417..d395892 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php @@ -41,7 +41,7 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler { $totalTtc = 0; $totalTva = 0; $yValue = $this->startingYOfArticlesTable + 11; - $maxDescriptionWidth = 98; + $maxDescriptionWidth = 102; $currentIndexPosition = $this->currentIndexPosition; for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->devisCountToGet);$currentIndexPosition++){ $currentDevis = $devisData[$currentIndexPosition]; @@ -51,11 +51,11 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler { $products = $currentDevis["products"]; $subcontractorOrderNumberText = "Numéro de sous traitance ".$currentDevis["order_number"]; $subcontractorCaseNumberText = "Numéro de dossier ".$currentDevis["case_number"]; - $this->SetXY( 35,$yValue ); + $this->SetXY( 29,$yValue ); $this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($subcontractorOrderNumberText),0,'0',); $yValue += 6; - $this->SetXY( 35,$yValue ); + $this->SetXY( 29,$yValue ); $this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($subcontractorCaseNumberText),0,'0',); $yValue += 6; foreach($products as $product){ @@ -70,10 +70,10 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler { $productDescription .= " de " . $currentDevis["defunt_nom"] ?? ""; } $tvaAmount = $valueTtc - $valueHt; - $this->SetXY( 8,$yValue ); - $this->Cell(20, 6, $dateValue, 0,0); + $this->SetXY( 5,$yValue ); + $this->Cell(5, 6, $dateValue, 0,0); - $this->SetXY( 35,$yValue ); + $this->SetXY( 29,$yValue ); $productDescription = FileExportHelpers::FormatTextForExport($productDescription); $productDescriptionWidth = $this->GetStringWidth($productDescription); $productDescriptionWidthIsGreaterThanMaxWidth = $productDescriptionWidth > $maxDescriptionWidth; @@ -90,13 +90,13 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler { $this->Cell($maxDescriptionWidth, 6, $productDescription); } - $this->SetXY( 138,$yValue ); + $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); - $this->SetXY( 160,$yValue ); + $this->SetXY( 159,$yValue ); $this->Cell(20, 6, number_format($tvaAmount,2,'.','').chr(128), 0, 0, 'C'); - $this->SetXY( 181,$yValue ); + $this->SetXY( 182,$yValue ); $this->Cell(25, 6, number_format($valueTtc,2,'.','').chr(128), 0, 1, 'C'); $yValue += 6; $totalTva += $tvaAmount; diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php index 78406fe..778b99b 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php @@ -55,6 +55,7 @@ class InvoiceGroupPdfHandler extends FPDF { { if($this->logo != "nothing"){ $this->Image($this->logoPath."logo.png", 2, 2, 50,35); + $this->AddWatermark(); } else{ $this->Cell(55,30,''); @@ -63,6 +64,39 @@ class InvoiceGroupPdfHandler extends FPDF { $this->DrawInvoiceCompanyAndClientInfo(); $this->DrawInvoiceInfoTable(); } + function AddWatermark() + { + $this->SetAlpha(0.2); + + $imagePath = $this->logoPath . "filigrane_pdf.png"; + list($originalWidth, $originalHeight) = getimagesize($imagePath); + + // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) + // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) + $originalWidth = $originalWidth * 0.264583; + $originalHeight = $originalHeight * 0.264583; + + // Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine + $scale = 2; + $width = $originalWidth * $scale; + $height = $originalHeight * $scale; + // Calculer la position pour centrer l'image + $x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm + $y = (297 - $height) / 2; // 297 mm est la hauteur d'une page A4 + + // Ajouter l'image en filigrane + $this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur + $this->SetAlpha(0.1); // Définir l'opacité + } + + function SetAlpha($alpha) + { + // Appliquer la transparence au document + $this->SetFillColor(255, 255, 255, $alpha * 255); + $this->SetTextColor(0, 0, 0, $alpha * 255); + $this->SetDrawColor(0, 0, 0, $alpha * 255); + } + function Footer() { $this->SetY(-35); @@ -73,7 +107,7 @@ class InvoiceGroupPdfHandler extends FPDF { '))); $this->SetY(-15); - $this->SetFont('ComicSans', 'B', 8); + $this->SetFont('ComicSans', '', 7); $this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C'); } @@ -162,16 +196,16 @@ class InvoiceGroupPdfHandler extends FPDF { $factureDateEcheance->modify('last day of next month'); $factureDateEcheance = $factureDateEcheance->format('d-m-Y'); $this->SetFont('ComicSans', 'B', 11); - $this->Cell(30, 7, 'DATE', 1, 0, 'C'); - $this->Cell(94, 7, 'CLIENT', 1, 0, 'C'); - $this->Cell(40, 7, 'FACTURE', 1, 0, 'C'); - $this->Cell(40, 7, 'ECHEANCE', 1, 1, 'C'); + $this->Cell(25, 7, 'DATE', 1, 0, 'C'); + $this->Cell(104, 7, 'CLIENT', 1, 0, 'C'); + $this->Cell(39, 7, 'FACTURE', 1, 0, 'C'); + $this->Cell(36, 7, 'ECHEANCE', 1, 1, 'C'); $this->SetFont('ComicSans', '', 10); - $this->Cell(30, 7, $factureDatePaiement, 1, 0, 'C'); - $this->Cell(94, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C'); - $this->Cell(40, 7, $this->factureData['num'], 1, 0, 'C'); - $this->Cell(40, 7, $factureDateEcheance, 1, 1, 'C'); + $this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C'); + $this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C'); + $this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C'); + $this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C'); $this->startingYOfArticlesTable = 85; } @@ -184,30 +218,30 @@ class InvoiceGroupPdfHandler extends FPDF { // cadre titre des colonnes $this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207,$this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName); // les traits verticaux colonnes - $this->Line(35, $this->startingYOfArticlesTable, 35, 232); - $this->Line(135, $this->startingYOfArticlesTable, 135, 232); - $this->Line(160, $this->startingYOfArticlesTable, 160, 232); - $this->Line(180, $this->startingYOfArticlesTable, 180, 232); + $this->Line(28, $this->startingYOfArticlesTable, 28, 232); + $this->Line(132, $this->startingYOfArticlesTable, 132, 232); + $this->Line(157, $this->startingYOfArticlesTable, 157, 232); + $this->Line(182, $this->startingYOfArticlesTable, 182, 232); } public function DrawArticlesTableHeader(){ $tvaValue = $this->factureData["configuration"]->tva_default; $columnNameY = $this->startingYOfArticlesTable + 1; - $this->SetFont('ComicSans','',10); - $this->SetXY( 9,$columnNameY ); - $this->Cell( 20, 8, "Date", 0, 0, 'C'); + $this->SetFont('ComicSans', '', 10); + $this->SetXY(12, $columnNameY); + $this->Cell(7, 8, "Date", 0, 0, 'C'); - $this->SetXY( 35,$columnNameY ); - $this->Cell( 100, 8, "Description", 0, 0, 'C'); + $this->SetXY(28, $columnNameY); + $this->Cell(100, 8, "Description", 0, 0, 'C'); - $this->SetXY( 138,$columnNameY ); - $this->Cell( 20, 8, "Prix Uni. HT", 0, 0, 'C'); + $this->SetXY(135, $columnNameY); + $this->Cell(20, 8, "Prix Uni. HT", 0, 0, 'C'); - $this->SetXY( 160,$columnNameY ); - $this->Cell( 20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C'); + $this->SetXY(159, $columnNameY); + $this->Cell(20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C'); - $this->SetXY( 181,$columnNameY ); - $this->Cell( 25, 8, "Prix Uni. TTC", 0, 0, 'C'); + $this->SetXY(185, $columnNameY); + $this->Cell(20, 8, "Prix Uni. TTC", 0, 0, 'C'); } @@ -219,7 +253,7 @@ class InvoiceGroupPdfHandler extends FPDF { $totalTtc = 0; $totalTva = 0; $yValue = $this->startingYOfArticlesTable + 11; - $maxDescriptionWidth = 98; + $maxDescriptionWidth = 102; $currentIndexPosition = $this->currentIndexPosition; for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->devisCountToGet);$currentIndexPosition++){ $currentDevis = $devisData[$currentIndexPosition]; @@ -240,10 +274,10 @@ class InvoiceGroupPdfHandler extends FPDF { $productDescription .= " de " . $currentDevis["defunt_nom"] ?? ""; } $tvaAmount = $valueTtc - $valueHt; - $this->SetXY( 8,$yValue ); - $this->Cell(20, 6, $dateValue, 0,0); + $this->SetXY( 5,$yValue ); + $this->Cell(5, 6, $dateValue, 0,0); - $this->SetXY( 35,$yValue ); + $this->SetXY( 29,$yValue ); $productDescription = FileExportHelpers::FormatTextForExport($productDescription); $productDescriptionWidth = $this->GetStringWidth($productDescription); $productDescriptionWidthIsGreaterThanMaxWidth = $productDescriptionWidth > $maxDescriptionWidth; @@ -260,13 +294,13 @@ class InvoiceGroupPdfHandler extends FPDF { $this->Cell($maxDescriptionWidth, 6, $productDescription); } - $this->SetXY( 138,$yValue ); + $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); - $this->SetXY( 160,$yValue ); + $this->SetXY( 159,$yValue ); $this->Cell(20, 6, number_format($tvaAmount,2,'.','').chr(128), 0, 0, 'C'); - $this->SetXY( 181,$yValue ); + $this->SetXY( 182,$yValue ); $this->Cell(25, 6, number_format($valueTtc,2,'.','').chr(128), 0, 1, 'C'); $yValue += 6; $totalTva += $tvaAmount; @@ -292,23 +326,29 @@ class InvoiceGroupPdfHandler extends FPDF { $this->Ln(1); //Table IBAN - $this->SetFont('ComicSans', '', 9); - $ibanWidth = 90; + $this->SetFont('ComicSans', '', 7); + $ibanWidth = 56; $ibanCursorY = $this->GetY(); $this->Cell($ibanWidth, 5, 'IBAN : FR76 1360 6000 1436 5418 1800 038', 1, 1, 'C'); $ibanCursorX = $this->GetX(); $this->Cell($ibanWidth, 5, 'Code SWIFT : AGRI FR PP 836', 1, 1, 'C'); //TABLE HT - $ibanLastPositionX = $ibanCursorX+$ibanWidth + 54; - $startOfArrayX = $ibanLastPositionX; + $tableWidth = 40; // Largeur totale de la 2e table (20+20) + $marginRight = 3; // Marge par rapport au bord droit + $pageWidth = 210; // Largeur d'une page A4 en mm (portrait) + + // Position correcte de la 2e table + $startOfArrayX = $pageWidth - $tableWidth - $marginRight; $startOfArrayY = $ibanCursorY - 10; + + $totalPriceArray = $this->totalPrices; foreach($totalPriceArray as $label => $price){ $this->SetXY($startOfArrayX,$startOfArrayY); - $this->Cell(30, 5, $label, 1, 1, 'C'); - $this->SetXY($startOfArrayX + 30,$startOfArrayY); - $this->Cell(30, 5, number_format($price,2,'.','').chr(128), 1, 1, 'C'); + $this->Cell(20, 5, $label, 1, 1, 'C'); + $this->SetXY($startOfArrayX + 20,$startOfArrayY); + $this->Cell(20, 5, number_format($price,2,'.','').chr(128), 1, 1, 'C'); $startOfArrayY += 5; } } diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index 6ecefe6..4e3629f 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -33,200 +33,245 @@ use OCA\Gestion\Helpers\DateHelpers; use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\PriceHelpers; -class InvoicePdfHandler extends FPDF { +class InvoicePdfHandler extends FPDF +{ private $multipleFactureData = []; private $factureData = []; private $logo = null; private $logoPath = "/var/www/html/data/admin/files/.gestion/"; - + protected $extgstates = []; private $thereIsOrderOrCaseNumber = false; private $startingYOfArticlesTable = 95; function Header() { - if($this->logo != "nothing"){ - $this->Image($this->logoPath."logo.png", 2, 2, 50,35); - } - else{ - $this->Cell(55,30,''); + if ($this->logo != "nothing") { + $this->Image($this->logoPath . "logo.png", 2, 2, 50, 35); + $this->AddWatermark(); + } else { + $this->Cell(55, 30, ''); } } + + function AddWatermark() + { + $this->SetAlpha(0.2); + + $imagePath = $this->logoPath . "filigrane_pdf.png"; + list($originalWidth, $originalHeight) = getimagesize($imagePath); + + // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) + // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) + $originalWidth = $originalWidth * 0.264583; + $originalHeight = $originalHeight * 0.264583; + + // Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine + $scale = 2; + $width = $originalWidth * $scale; + $height = $originalHeight * $scale; + // Calculer la position pour centrer l'image + $x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm + $y = (297 - $height) / 2; // 297 mm est la hauteur d'une page A4 + + // Ajouter l'image en filigrane + $this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur + $this->SetAlpha(0.1); // Définir l'opacité + } + + function SetAlpha($alpha) + { + // Appliquer la transparence au document + $this->SetFillColor(255, 255, 255, $alpha * 255); + $this->SetTextColor(0, 0, 0, $alpha * 255); + $this->SetDrawColor(0, 0, 0, $alpha * 255); + } + + function Footer() { $this->SetY(-35); $this->SetFont('ComicSans', '', 7); - $this->MultiCell(0,5,utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); + $this->MultiCell(0, 5, utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); $this->Ln(1); - $this->MultiCell(0,5,utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du code de commerce ). -'))); + $this->MultiCell(0, 5, utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du code de commerce ). +'))); $this->SetY(-15); - $this->SetFont('ComicSans', 'B', 8); + $this->SetFont('ComicSans', '', 7); $this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C'); } - public function InvoicePdfFactory(array $factureData,$logo = null){ + public function InvoicePdfFactory(array $factureData, $logo = null) + { $this->factureData = $factureData; $this->logo = $logo; } - public function MutlipleInvoicePdfFactory(array $multipleInvoiceData,$logo = null){ + public function MutlipleInvoicePdfFactory(array $multipleInvoiceData, $logo = null) + { $this->multipleFactureData = $multipleInvoiceData; $this->logo = $logo; } - public function GetMultipleInvoiceFilename($month,$year){ + public function GetMultipleInvoiceFilename($month, $year) + { $filename = ""; - foreach($this->multipleFactureData as $factureData){ + foreach ($this->multipleFactureData as $factureData) { $factureType = $factureData["facture_type"]; - if($factureType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){ - $filename = mb_strtoupper($factureData["client_nom"],'UTF-8'); + if ($factureType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE) { + $filename = mb_strtoupper($factureData["client_nom"], 'UTF-8'); + } else { + $filename = 'GROUPE_' . mb_strtoupper($factureData["group_name"], 'UTF-8'); } - else{ - $filename = 'GROUPE_'.mb_strtoupper($factureData["group_name"],'UTF-8'); - } - $filename .= $month != 0 ? '_'.DateHelpers::GetMonthPlainString($month) :''; - $filename .= "_".$year; + $filename .= $month != 0 ? '_' . DateHelpers::GetMonthPlainString($month) : ''; + $filename .= "_" . $year; break; } return $filename; } - public function GetInvoiceFilename(){ + public function GetInvoiceFilename() + { $factureNum = $this->factureData['num']; - $factureNum = str_replace('/','-',$factureNum); - $defuntNom = str_replace(' ',' ',$this->factureData['defunt_nom']); - return $this->factureData['configuration']->facture_prefixe.'_'.$factureNum.'_'.mb_strtoupper($defuntNom,'UTF-8'); + $factureNum = str_replace('/', '-', $factureNum); + $defuntNom = str_replace(' ', ' ', $this->factureData['defunt_nom']); + return $this->factureData['configuration']->facture_prefixe . '_' . $factureNum . '_' . mb_strtoupper($defuntNom, 'UTF-8'); } - private function DrawInvoiceCompanyInfo(){ + private function DrawInvoiceCompanyInfo() + { $this->SetY(40); $this->SetFont('ComicSans', '', 10); $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->factureData['configuration']->entreprise), 0, 1); $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse']), 0, 1); $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse_city']), 0, 1); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->factureData['configuration']->telephone),0,1); + $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->factureData['configuration']->telephone), 0, 1); $this->Cell(0, 5, 'Mail : ' . $this->factureData['configuration']->mail, 0, 1); } - private function DrawInvoiceClientInfo(){ + private function DrawInvoiceClientInfo() + { $this->SetFont('ComicSans', '', 10); $clientName = $this->factureData['client_nom']; - if($this->factureData["group_name"] != null && $this->factureData["group_name"] != ""){ + if ($this->factureData["group_name"] != null && $this->factureData["group_name"] != "") { $clientName = $this->factureData['group_name']; } $clientInfoXAxis = 125; - + $clientAddress = $this->factureData['client_real_adress']; $clientAdressWidth = $this->GetStringWidth($clientAddress); $maxWidth = $this->GetPageWidth(); $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; - + $clientInfoYAxis = $clientAdressIsMultiline ? 35 : 40; - $this->SetXY($clientInfoXAxis,$clientInfoYAxis); + $this->SetXY($clientInfoXAxis, $clientInfoYAxis); $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($clientName)); $clientInfoYAxis += 5; - $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->MultiCell( 0, 5, trim(FileExportHelpers::FormatTextForExport($clientAddress))); - if($clientAdressIsMultiline){ + $this->SetXY($clientInfoXAxis, $clientInfoYAxis); + $this->MultiCell(0, 5, trim(FileExportHelpers::FormatTextForExport($clientAddress))); + if ($clientAdressIsMultiline) { $clientInfoYAxis += 5; } $clientInfoYAxis += 5; - $this->SetXY($clientInfoXAxis,$clientInfoYAxis); + $this->SetXY($clientInfoXAxis, $clientInfoYAxis); $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); $clientInfoYAxis += 5; - $this->SetXY($clientInfoXAxis,$clientInfoYAxis); + $this->SetXY($clientInfoXAxis, $clientInfoYAxis); $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Numéro') . ' Siret: ' . $this->factureData['siret']); $clientInfoYAxis += 5; - $this->SetXY($clientInfoXAxis,$clientInfoYAxis); + $this->SetXY($clientInfoXAxis, $clientInfoYAxis); $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']); } - private function DrawInvoiceCompanyAndClientInfo(){ + private function DrawInvoiceCompanyAndClientInfo() + { $this->DrawInvoiceCompanyInfo(); $this->DrawInvoiceClientInfo(); } - private function DrawInvoiceInfoTable(){ + private function DrawInvoiceInfoTable() + { $this->setY(67); $factureDatePaiement = $this->factureData['date_paiement']; - $factureDatePaiement = DateTime::createFromFormat('Y-m-d',$factureDatePaiement); + $factureDatePaiement = DateTime::createFromFormat('Y-m-d', $factureDatePaiement); $factureDateEcheance = $factureDatePaiement; $factureDatePaiement = $factureDatePaiement->format('d-m-Y'); $factureDateEcheance->modify('last day of next month'); $factureDateEcheance = $factureDateEcheance->format('d-m-Y'); $this->SetFont('ComicSans', 'B', 11); - $this->Cell(30, 7, 'DATE', 1, 0, 'C'); - $this->Cell(94, 7, 'CLIENT', 1, 0, 'C'); - $this->Cell(40, 7, 'FACTURE', 1, 0, 'C'); - $this->Cell(40, 7, 'ECHEANCE', 1, 1, 'C'); + $this->Cell(25, 7, 'DATE', 1, 0, 'C'); + $this->Cell(104, 7, 'CLIENT', 1, 0, 'C'); + $this->Cell(39, 7, 'FACTURE', 1, 0, 'C'); + $this->Cell(36, 7, 'ECHEANCE', 1, 1, 'C'); $this->SetFont('ComicSans', '', 10); - $this->Cell(30, 7, $factureDatePaiement, 1, 0, 'C'); - $this->Cell(94, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C'); - $this->Cell(40, 7, $this->factureData['num'], 1, 0, 'C'); - $this->Cell(40, 7, $factureDateEcheance, 1, 1, 'C'); + $this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C'); + $this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C'); + $this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C'); + $this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C'); - $orderNumberIsProvided = (trim($this->factureData['order_number']) !== "" && trim($this->factureData['order_number']) !== "-" ); + $orderNumberIsProvided = (trim($this->factureData['order_number']) !== "" && trim($this->factureData['order_number']) !== "-"); $caseNumberIsProvided = (trim($this->factureData['case_number']) !== "" && trim($this->factureData['case_number']) !== "-"); - if($orderNumberIsProvided){ + if ($orderNumberIsProvided) { $this->thereIsOrderOrCaseNumber = true; $this->Ln(2); - if($caseNumberIsProvided == false){ + if ($caseNumberIsProvided == false) { $this->Ln(3); } - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport("Bon de commande: ".$this->factureData['order_number']),0,1,'C'); + $this->Cell(0, 5, FileExportHelpers::FormatTextForExport("Bon de commande: " . $this->factureData['order_number']), 0, 1, 'C'); } - if($caseNumberIsProvided){ + if ($caseNumberIsProvided) { $this->thereIsOrderOrCaseNumber = true; - if($orderNumberIsProvided == false){ + if ($orderNumberIsProvided == false) { $this->Ln(5); } - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport("Numéro de dossier: ".$this->factureData['case_number']),0,1,'C'); + $this->Cell(0, 5, FileExportHelpers::FormatTextForExport("Numéro de dossier: " . $this->factureData['case_number']), 0, 1, 'C'); } - $this->startingYOfArticlesTable = $this->thereIsOrderOrCaseNumber ? 95 : 85; + $this->startingYOfArticlesTable = $this->thereIsOrderOrCaseNumber ? 95 : 85; } - private function DrawArticlesTable(){ + private function DrawArticlesTable() + { $this->SetLineWidth(0.2); $gapBetweenStartingOfArticlesTableAndColumnName = 10; $tableHeight = $this->thereIsOrderOrCaseNumber ? 137 : 137 + 10; $this->Rect(3, $this->startingYOfArticlesTable, 204, $tableHeight, "D"); // cadre titre des colonnes - $this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207,$this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName); + $this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName); // les traits verticaux colonnes - $this->Line(35, $this->startingYOfArticlesTable, 35, 232); - $this->Line(135, $this->startingYOfArticlesTable, 135, 232); - $this->Line(160, $this->startingYOfArticlesTable, 160, 232); - $this->Line(180, $this->startingYOfArticlesTable, 180, 232); + $this->Line(28, $this->startingYOfArticlesTable, 28, 232); + $this->Line(132, $this->startingYOfArticlesTable, 132, 232); + $this->Line(157, $this->startingYOfArticlesTable, 157, 232); + $this->Line(182, $this->startingYOfArticlesTable, 182, 232); } - private function DrawArticlesTableHeader(){ + private function DrawArticlesTableHeader() + { $tvaValue = $this->factureData["configuration"]->tva_default; $columnNameY = $this->startingYOfArticlesTable + 1; - $this->SetFont('ComicSans','',10); - $this->SetXY( 9,$columnNameY ); - $this->Cell( 20, 8, "Date", 0, 0, 'C'); + $this->SetFont('ComicSans', '', 10); + $this->SetXY(12, $columnNameY); + $this->Cell(7, 8, "Date", 0, 0, 'C'); - $this->SetXY( 35,$columnNameY ); - $this->Cell( 100, 8, "Description", 0, 0, 'C'); + $this->SetXY(28, $columnNameY); + $this->Cell(100, 8, "Description", 0, 0, 'C'); - $this->SetXY( 138,$columnNameY ); - $this->Cell( 20, 8, "Prix Uni. HT", 0, 0, 'C'); + $this->SetXY(135, $columnNameY); + $this->Cell(20, 8, "Prix Uni. HT", 0, 0, 'C'); - $this->SetXY( 160,$columnNameY ); - $this->Cell( 20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C'); - - $this->SetXY( 181,$columnNameY ); - $this->Cell( 25, 8, "Prix Uni. TTC", 0, 0, 'C'); + $this->SetXY(159, $columnNameY); + $this->Cell(20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C'); + $this->SetXY(185, $columnNameY); + $this->Cell(20, 8, "Prix Uni. TTC", 0, 0, 'C'); } - public function DrawArticlesTableValueAndReturnTotalPrice(){ - $this->SetFont('ComicSans','',10); + public function DrawArticlesTableValueAndReturnTotalPrice() + { + $this->SetFont('ComicSans', '', 10); $devisDate = $this->factureData['devis_date']; - $devisDate = DateTime::createFromFormat('Y-m-d',$devisDate); + $devisDate = DateTime::createFromFormat('Y-m-d', $devisDate); $devisDate = $devisDate->format('d-m-Y'); $tvaValue = $this->factureData["configuration"]->tva_default; $totalHt = 0; @@ -234,82 +279,90 @@ class InvoicePdfHandler extends FPDF { $totalTva = 0; $products = $this->factureData["products"]; $yValue = $this->startingYOfArticlesTable + 11; - foreach($products as $product){ + foreach ($products as $product) { $valueHt = $product['produit_price']; - $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue); - $totalHt+=$valueHt; - $totalTtc+=$valueTtc; + $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue); + $totalHt += $valueHt; + $totalTtc += $valueTtc; $productDescription = $product["produit_description"]; $dateValue = ""; - if($product === end($products)){ + if ($product === end($products)) { $dateValue = $devisDate; - $productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' '. $this->factureData["defunt_nom"]; + $productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' ' . $this->factureData["defunt_nom"]; } $tvaAmount = $valueTtc - $valueHt; - $this->SetXY( 8,$yValue ); - $this->Cell(20, 6, $dateValue, 0,0); + $this->SetXY(5, $yValue); + $this->Cell(5, 6, $dateValue, 0, 0); - $this->SetXY( 35,$yValue ); - $this->MultiAlignCell(100, 6, utf8_decode(html_entity_decode($productDescription)),0,'0',); + $this->SetXY(29, $yValue); + $this->MultiAlignCell(102, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0',); - $this->SetXY( 138,$yValue ); - $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); - - $this->SetXY( 160,$yValue ); - $this->Cell(20, 6, number_format($tvaAmount,2,'.','').chr(128), 0, 0, 'C'); - - $this->SetXY( 181,$yValue ); - $this->Cell(25, 6, number_format($valueTtc,2,'.','').chr(128), 0, 1, 'C'); + $this->SetXY(135, $yValue); + $this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C'); + + $this->SetXY(159, $yValue); + $this->Cell(20, 6, number_format($tvaAmount, 2, '.', '') . chr(128), 0, 0, 'C'); + + $this->SetXY(182, $yValue); + $this->Cell(25, 6, number_format($valueTtc, 2, '.', '') . chr(128), 0, 1, 'C'); $yValue += 12; $totalTva += $tvaAmount; } return [ "TOTAL HT" => $totalHt, - "TVA ".$tvaValue. "%" => $totalTva, + "TVA " . $tvaValue . "%" => $totalTva, "TOTAL TTC" => $totalTtc ]; } - private function DrawBankAndTotalPriceInfo($totalPriceArray){ + private function DrawBankAndTotalPriceInfo($totalPriceArray) + { $this->SetY(235); $this->SetFont('ComicSans', '', 7); - $this->MultiCell(0,5,utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de ". $this->factureData['configuration']->entreprise))); - $this->MultiCell(0,5,utf8_decode(html_entity_decode("en indiquant le numéro de facture, ou par virement :"))); + $this->MultiCell(0, 5, utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de " . $this->factureData['configuration']->entreprise))); + $this->MultiCell(0, 5, utf8_decode(html_entity_decode("en indiquant le numéro de facture, ou par virement :"))); $this->Ln(1); - - //Table IBAN - $this->SetFont('ComicSans', '', 9); - $ibanWidth = 90; + + // Table IBAN + $this->SetFont('ComicSans', '', 7); + $ibanWidth = 56; $ibanCursorY = $this->GetY(); $this->Cell($ibanWidth, 5, 'IBAN : FR76 1360 6000 1436 5418 1800 038', 1, 1, 'C'); $ibanCursorX = $this->GetX(); $this->Cell($ibanWidth, 5, 'Code SWIFT : AGRI FR PP 836', 1, 1, 'C'); - + //TABLE HT - $ibanLastPositionX = $ibanCursorX+$ibanWidth + 54; - $startOfArrayX = $ibanLastPositionX; + $tableWidth = 40; // Largeur totale de la 2e table (20+20) + $marginRight = 3; // Marge par rapport au bord droit + $pageWidth = 210; // Largeur d'une page A4 en mm (portrait) + + // Position correcte de la 2e table + $startOfArrayX = $pageWidth - $tableWidth - $marginRight; $startOfArrayY = $ibanCursorY - 10; - foreach($totalPriceArray as $label => $price){ - $this->SetXY($startOfArrayX,$startOfArrayY); - $this->Cell(30, 5, $label, 1, 1, 'C'); - $this->SetXY($startOfArrayX + 30,$startOfArrayY); - $this->Cell(30, 5, number_format($price,2,'.','').chr(128), 1, 1, 'C'); + + foreach ($totalPriceArray as $label => $price) { + $this->SetXY($startOfArrayX, $startOfArrayY); + $this->Cell(20, 5, $label, 1, 1, 'C'); + $this->SetXY($startOfArrayX + 20, $startOfArrayY); + $this->Cell(20, 5, number_format($price, 2, '.', '') . chr(128), 1, 1, 'C'); $startOfArrayY += 5; } } - public function SetMultipleFactureContent(){ - foreach($this->multipleFactureData as $factureData){ + public function SetMultipleFactureContent() + { + foreach ($this->multipleFactureData as $factureData) { $this->factureData = $factureData; $this->SetFactureContent(); } } - public function SetFactureContent(){ + public function SetFactureContent() + { $this->AddPage(); - $this->SetMargins(3,0,3); + $this->SetMargins(3, 0, 3); $this->DrawInvoiceCompanyAndClientInfo(); $this->DrawInvoiceInfoTable(); $this->DrawArticlesTable(); @@ -318,45 +371,42 @@ class InvoicePdfHandler extends FPDF { $this->DrawBankAndTotalPriceInfo($totalPriceValue); } - 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(); + 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); + // 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); - } - } + // Reset the line position to the right, like in Cell + if ($ln == 0) { + $this->SetXY($x, $y); + } + } - function NbLines($w, $txt) + function NbLines($w, $txt) { // Compute the number of lines a MultiCell of width w will take - if(!isset($this->CurrentFont)) + 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); + 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") + if ($nb > 0 && $s[$nb - 1] == "\n") $nb--; $sep = -1; $i = 0; $j = 0; $l = 0; $nl = 1; - while($i<$nb) - { + while ($i < $nb) { $c = $s[$i]; - if($c=="\n") - { + if ($c == "\n") { $i++; $sep = -1; $j = $i; @@ -364,24 +414,20 @@ class InvoicePdfHandler extends FPDF { $nl++; continue; } - if($c==' ') + if ($c == ' ') $sep = $i; $l += $cw[$c]; - if($l>$wmax) - { - if($sep==-1) - { - if($i==$j) + if ($l > $wmax) { + if ($sep == -1) { + if ($i == $j) $i++; - } - else - $i = $sep+1; + } else + $i = $sep + 1; $sep = -1; $j = $i; $l = 0; $nl++; - } - else + } else $i++; } return $nl; diff --git a/gestion/lib/Service/InvoicePdfService.php b/gestion/lib/Service/InvoicePdfService.php index 032d436..0d31386 100644 --- a/gestion/lib/Service/InvoicePdfService.php +++ b/gestion/lib/Service/InvoicePdfService.php @@ -167,6 +167,9 @@ class InvoicePdfService { $templateType = $invoicePdfData['template_type_key']; $clean_folder = html_entity_decode(string: $currentConfig->path).'/'; $factureFolders = $this->getGroupFactureFolder($invoicePdfData,$clean_folder); + //TODO: add template type + $templateType = ClientTemplateTypeConstant::OGF; + switch ($templateType) { case ClientTemplateTypeConstant::FUNECAP: $pdf = new InvoiceFunecapPdfHandler(); From 33171b894306efe087ae989443c5de9d3b92d9a2 Mon Sep 17 00:00:00 2001 From: Narindra ezway Date: Wed, 2 Apr 2025 15:44:57 +0300 Subject: [PATCH 05/10] remove test code InvoicePdfService --- gestion/lib/Service/InvoicePdfService.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/gestion/lib/Service/InvoicePdfService.php b/gestion/lib/Service/InvoicePdfService.php index 0d31386..1f3eb24 100644 --- a/gestion/lib/Service/InvoicePdfService.php +++ b/gestion/lib/Service/InvoicePdfService.php @@ -167,8 +167,6 @@ class InvoicePdfService { $templateType = $invoicePdfData['template_type_key']; $clean_folder = html_entity_decode(string: $currentConfig->path).'/'; $factureFolders = $this->getGroupFactureFolder($invoicePdfData,$clean_folder); - //TODO: add template type - $templateType = ClientTemplateTypeConstant::OGF; switch ($templateType) { case ClientTemplateTypeConstant::FUNECAP: From fb614dbe608d956589f42f07d887fb9ee2d0af2c Mon Sep 17 00:00:00 2001 From: Narindra ezway Date: Wed, 2 Apr 2025 16:40:48 +0300 Subject: [PATCH 06/10] add new payment methods for invoice processing --- gestion/lib/Sql/20250402-ADD_NEW_PAYMENT_METHODE_VALUE.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 gestion/lib/Sql/20250402-ADD_NEW_PAYMENT_METHODE_VALUE.sql diff --git a/gestion/lib/Sql/20250402-ADD_NEW_PAYMENT_METHODE_VALUE.sql b/gestion/lib/Sql/20250402-ADD_NEW_PAYMENT_METHODE_VALUE.sql new file mode 100644 index 0000000..cf9c088 --- /dev/null +++ b/gestion/lib/Sql/20250402-ADD_NEW_PAYMENT_METHODE_VALUE.sql @@ -0,0 +1,4 @@ +INSERT INTO oc_gestion_facture_payment_type (facture_payment_type_label) +VALUES + ('LCR'), + ('Prélèvement'); \ No newline at end of file From 9a4b221f7750733f548091d9a37bc98df7c2a409 Mon Sep 17 00:00:00 2001 From: Narindra ezway Date: Fri, 4 Apr 2025 16:22:35 +0300 Subject: [PATCH 07/10] set font to Comic Sans and size 7 for all price value in pdf --- .../Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php | 2 ++ .../Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php | 2 ++ gestion/lib/Service/InvoicePdfHandler.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php index d395892..a5ba597 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php @@ -90,6 +90,8 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler { $this->Cell($maxDescriptionWidth, 6, $productDescription); } + $this->SetFont('ComicSans', '', 7); + $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php index 778b99b..685c3d1 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php @@ -294,6 +294,8 @@ class InvoiceGroupPdfHandler extends FPDF { $this->Cell($maxDescriptionWidth, 6, $productDescription); } + $this->SetFont('ComicSans', '', 7); + $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index 4e3629f..d7d7a4b 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -297,6 +297,8 @@ class InvoicePdfHandler extends FPDF $this->SetXY(29, $yValue); $this->MultiAlignCell(102, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0',); + $this->SetFont('ComicSans', '', 7); + $this->SetXY(135, $yValue); $this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C'); From f16729aecf0bc08f156cd51c93f817d02720fb3e Mon Sep 17 00:00:00 2001 From: Narindra ezway Date: Fri, 4 Apr 2025 18:05:11 +0300 Subject: [PATCH 08/10] Adjust font sizes and spacing --- .../InvoiceFunecapPdfHandler.php | 8 +-- .../InvoiceGroupPdfHandler.php | 68 ++++++++++--------- .../InvoiceOgfPdfHandler.php | 34 +++++----- gestion/lib/Service/InvoicePdfHandler.php | 44 ++++++------ gestion/lib/Service/InvoicePdfService.php | 4 +- 5 files changed, 83 insertions(+), 75 deletions(-) diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php index a5ba597..08a75df 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceFunecapPdfHandler.php @@ -40,7 +40,7 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler { $totalHt = 0; $totalTtc = 0; $totalTva = 0; - $yValue = $this->startingYOfArticlesTable + 11; + $yValue = $this->startingYOfArticlesTable + 13; $maxDescriptionWidth = 102; $currentIndexPosition = $this->currentIndexPosition; for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->devisCountToGet);$currentIndexPosition++){ @@ -89,9 +89,9 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler { } else { $this->Cell($maxDescriptionWidth, 6, $productDescription); } - - $this->SetFont('ComicSans', '', 7); - + + $this->SetFont('ComicSans', '', 8); + $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php index 685c3d1..68a0325 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php @@ -99,14 +99,14 @@ class InvoiceGroupPdfHandler extends FPDF { function Footer() { - $this->SetY(-35); + $this->SetY(-38); $this->SetFont('ComicSans', '', size: 7); - $this->MultiCell(0,5,utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); + $this->MultiCell(0,4,utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); $this->Ln(1); - $this->MultiCell(0,5,utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du code de commerce ). + $this->MultiCell(0,4,utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du code de commerce ). '))); - $this->SetY(-15); + $this->SetY(-10); $this->SetFont('ComicSans', '', 7); $this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C'); } @@ -151,11 +151,11 @@ class InvoiceGroupPdfHandler extends FPDF { public function DrawInvoiceCompanyInfo(){ $this->SetY(40); $this->SetFont('ComicSans', '', 10); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->factureData['configuration']->entreprise), 0, 1); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse']), 0, 1); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse_city']), 0, 1); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->factureData['configuration']->telephone),0,1); - $this->Cell(0, 5, 'Mail : ' . $this->factureData['configuration']->mail, 0, 1); + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport($this->factureData['configuration']->entreprise), 0, 1); + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse']), 0, 1); + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport($this->factureData['configuration_adresse_city']), 0, 1); + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->factureData['configuration']->telephone),0,1); + $this->Cell(0, 4, 'Mail : ' . $this->factureData['configuration']->mail, 0, 1); } public function DrawInvoiceClientInfo(){ $this->SetFont('ComicSans', '', 10); @@ -170,21 +170,22 @@ class InvoiceGroupPdfHandler extends FPDF { $clientInfoYAxis = $clientAdressIsMultiline ? 35 : 40; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($clientName)); - $clientInfoYAxis += 5; + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport($clientName)); + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->MultiCell( 0, 5, trim(FileExportHelpers::FormatTextForExport($clientAddress))); + $this->MultiCell( 0, 4, trim(FileExportHelpers::FormatTextForExport($clientAddress))); if($clientAdressIsMultiline){ - $clientInfoYAxis += 5; + $clientInfoYAxis += 4; } - $clientInfoYAxis += 5; + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); + $this->Cell(0, 4, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); } public function DrawInvoiceCompanyAndClientInfo(){ $this->DrawInvoiceCompanyInfo(); $this->DrawInvoiceClientInfo(); + } public function DrawInvoiceInfoTable(){ @@ -202,12 +203,12 @@ class InvoiceGroupPdfHandler extends FPDF { $this->Cell(36, 7, 'ECHEANCE', 1, 1, 'C'); $this->SetFont('ComicSans', '', 10); - $this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C'); - $this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C'); - $this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C'); - $this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C'); + $this->Cell(25, 11, $factureDatePaiement, 1, 0, 'C'); + $this->Cell(104, 11, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C'); + $this->Cell(39, 11, $this->factureData['num'], 1, 0, 'C'); + $this->Cell(36, 11, $factureDateEcheance, 1, 1, 'C'); - $this->startingYOfArticlesTable = 85; + $this->startingYOfArticlesTable = 88; } public function DrawArticlesTableRect(){ @@ -218,10 +219,10 @@ class InvoiceGroupPdfHandler extends FPDF { // cadre titre des colonnes $this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207,$this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName); // les traits verticaux colonnes - $this->Line(28, $this->startingYOfArticlesTable, 28, 232); - $this->Line(132, $this->startingYOfArticlesTable, 132, 232); - $this->Line(157, $this->startingYOfArticlesTable, 157, 232); - $this->Line(182, $this->startingYOfArticlesTable, 182, 232); + $this->Line(28, $this->startingYOfArticlesTable, 28, 235); + $this->Line(132, $this->startingYOfArticlesTable, 132, 235); + $this->Line(157, $this->startingYOfArticlesTable, 157, 235); + $this->Line(182, $this->startingYOfArticlesTable, 182, 235); } public function DrawArticlesTableHeader(){ @@ -242,17 +243,18 @@ class InvoiceGroupPdfHandler extends FPDF { $this->SetXY(185, $columnNameY); $this->Cell(20, 8, "Prix Uni. TTC", 0, 0, 'C'); - } public function DrawArticlesTableValue(){ + // Set espacement avant de continue + $this->SetFont('ComicSans','',10); $devisData = $this->factureData['devis']; $tvaValue = $this->factureData["configuration"]->tva_default; $totalHt = 0; $totalTtc = 0; $totalTva = 0; - $yValue = $this->startingYOfArticlesTable + 11; + $yValue = $this->startingYOfArticlesTable + 13; $maxDescriptionWidth = 102; $currentIndexPosition = $this->currentIndexPosition; for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->devisCountToGet);$currentIndexPosition++){ @@ -294,7 +296,7 @@ class InvoiceGroupPdfHandler extends FPDF { $this->Cell($maxDescriptionWidth, 6, $productDescription); } - $this->SetFont('ComicSans', '', 7); + $this->SetFont('ComicSans', '', 8); $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); @@ -320,16 +322,16 @@ class InvoiceGroupPdfHandler extends FPDF { } public function DrawBankAndTotalPriceInfo(){ - $this->SetY(235); + $this->SetY(238); $this->SetFont('ComicSans', '', 7); - $this->MultiCell(0,5,utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de ". $this->factureData['configuration']->entreprise))); - $this->MultiCell(0,5,utf8_decode(html_entity_decode("en indiquant le numéro de facture, ou par virement :"))); + $this->MultiCell(0,4,utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de ". $this->factureData['configuration']->entreprise))); + $this->MultiCell(0,4,utf8_decode(html_entity_decode("en indiquant le numéro de facture, ou par virement :"))); $this->Ln(1); //Table IBAN - $this->SetFont('ComicSans', '', 7); - $ibanWidth = 56; + $this->SetFont('ComicSans', '', 8); + $ibanWidth = 62; $ibanCursorY = $this->GetY(); $this->Cell($ibanWidth, 5, 'IBAN : FR76 1360 6000 1436 5418 1800 038', 1, 1, 'C'); $ibanCursorX = $this->GetX(); @@ -342,7 +344,7 @@ class InvoiceGroupPdfHandler extends FPDF { // Position correcte de la 2e table $startOfArrayX = $pageWidth - $tableWidth - $marginRight; - $startOfArrayY = $ibanCursorY - 10; + $startOfArrayY = $ibanCursorY - 5; $totalPriceArray = $this->totalPrices; diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceOgfPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceOgfPdfHandler.php index 66a2529..ab33335 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceOgfPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceOgfPdfHandler.php @@ -43,24 +43,24 @@ class InvoiceOgfPdfHandler extends InvoiceGroupPdfHandler { $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; - $clientInfoYAxis = $clientAdressIsMultiline ? 35 : 40; + $clientInfoYAxis = $clientAdressIsMultiline ? 35 : 39; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($clientName)); - $clientInfoYAxis += 5; + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport($clientName)); + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->MultiCell( 0, 5, trim(FileExportHelpers::FormatTextForExport($clientAddress))); + $this->MultiCell( 0, 4, trim(FileExportHelpers::FormatTextForExport($clientAddress))); if($clientAdressIsMultiline){ - $clientInfoYAxis += 5; + $clientInfoYAxis += 4; } - $clientInfoYAxis += 5; + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); - $clientInfoYAxis += 5; + $this->Cell(0, 4, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Numéro') . ' Siret: ' . $this->factureData['siret']); - $clientInfoYAxis += 5; + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport('Numéro') . ' Siret: ' . $this->factureData['siret']); + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']); + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']); } public function DrawInvoiceInfoTable(){ @@ -79,13 +79,13 @@ class InvoiceOgfPdfHandler extends InvoiceGroupPdfHandler { $this->Cell(34, 7, 'COMMANDE', 1, 1, 'C'); $this->SetFont('ComicSans', '', 10); - $this->Cell(30, 7, $factureDatePaiement, 1, 0, 'C'); - $this->Cell(60, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C'); - $this->Cell(40, 7, $this->factureData['num'], 1, 0, 'C'); - $this->Cell(40, 7, $factureDateEcheance, 1, 0, 'C'); - $this->Cell(34, 7, $this->factureData["facture_order_number"], 1, 1, 'C'); + $this->Cell(30, 11, $factureDatePaiement, 1, 0, 'C'); + $this->Cell(60, 11, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C'); + $this->Cell(40, 11, $this->factureData['num'], 1, 0, 'C'); + $this->Cell(40, 11, $factureDateEcheance, 1, 0, 'C'); + $this->Cell(34, 11, $this->factureData["facture_order_number"], 1, 1, 'C'); - $this->startingYOfArticlesTable = 85; + $this->startingYOfArticlesTable = 88; } diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index d7d7a4b..a246338 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -89,14 +89,14 @@ class InvoicePdfHandler extends FPDF function Footer() { - $this->SetY(-35); + $this->SetY(-38); $this->SetFont('ComicSans', '', 7); - $this->MultiCell(0, 5, utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); + $this->MultiCell(0, 4, utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); $this->Ln(1); - $this->MultiCell(0, 5, utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du code de commerce ). + $this->MultiCell(0, 4, utf8_decode(html_entity_decode('Si les frais de recouvrement sont supérieurs à ce montant forfaitaire, une indemnisation complémentaire sera due sur présentation de justificatifs ( articles L.441-3 et L.441-6 du code de commerce ). '))); - $this->SetY(-15); + $this->SetY(-10); $this->SetFont('ComicSans', '', 7); $this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C'); } @@ -165,22 +165,22 @@ class InvoicePdfHandler extends FPDF $clientInfoYAxis = $clientAdressIsMultiline ? 35 : 40; $this->SetXY($clientInfoXAxis, $clientInfoYAxis); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport($clientName)); - $clientInfoYAxis += 5; + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport($clientName)); + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis, $clientInfoYAxis); - $this->MultiCell(0, 5, trim(FileExportHelpers::FormatTextForExport($clientAddress))); + $this->MultiCell(0, 4, trim(FileExportHelpers::FormatTextForExport($clientAddress))); if ($clientAdressIsMultiline) { - $clientInfoYAxis += 5; + $clientInfoYAxis += 4; } - $clientInfoYAxis += 5; + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis, $clientInfoYAxis); - $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); - $clientInfoYAxis += 5; + $this->Cell(0, 4, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city']))); + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis, $clientInfoYAxis); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Numéro') . ' Siret: ' . $this->factureData['siret']); - $clientInfoYAxis += 5; + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport('Numéro') . ' Siret: ' . $this->factureData['siret']); + $clientInfoYAxis += 4; $this->SetXY($clientInfoXAxis, $clientInfoYAxis); - $this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']); + $this->Cell(0, 4, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']); } private function DrawInvoiceCompanyAndClientInfo() @@ -191,7 +191,7 @@ class InvoicePdfHandler extends FPDF private function DrawInvoiceInfoTable() { - $this->setY(67); + $this->setY(80); $factureDatePaiement = $this->factureData['date_paiement']; $factureDatePaiement = DateTime::createFromFormat('Y-m-d', $factureDatePaiement); $factureDateEcheance = $factureDatePaiement; @@ -204,11 +204,14 @@ class InvoicePdfHandler extends FPDF $this->Cell(39, 7, 'FACTURE', 1, 0, 'C'); $this->Cell(36, 7, 'ECHEANCE', 1, 1, 'C'); + $this->setY(90); + $this->SetFont('ComicSans', '', 10); - $this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C'); - $this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C'); - $this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C'); - $this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C'); + $this->setY(30); + $this->Cell(25, 11, $factureDatePaiement, 1, 0, 'C'); + $this->Cell(104, 11, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C'); + $this->Cell(39, 11, $this->factureData['num'], 1, 0, 'C'); + $this->Cell(36, 11, $factureDateEcheance, 1, 1, 'C'); $orderNumberIsProvided = (trim($this->factureData['order_number']) !== "" && trim($this->factureData['order_number']) !== "-"); $caseNumberIsProvided = (trim($this->factureData['case_number']) !== "" && trim($this->factureData['case_number']) !== "-"); @@ -228,7 +231,7 @@ class InvoicePdfHandler extends FPDF $this->Cell(0, 5, FileExportHelpers::FormatTextForExport("Numéro de dossier: " . $this->factureData['case_number']), 0, 1, 'C'); } - $this->startingYOfArticlesTable = $this->thereIsOrderOrCaseNumber ? 95 : 85; + $this->startingYOfArticlesTable = $this->thereIsOrderOrCaseNumber ? 98 : 88; } private function DrawArticlesTable() @@ -297,6 +300,7 @@ class InvoicePdfHandler extends FPDF $this->SetXY(29, $yValue); $this->MultiAlignCell(102, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0',); + $this->SetFont('ComicSans', '', 7); $this->SetXY(135, $yValue); diff --git a/gestion/lib/Service/InvoicePdfService.php b/gestion/lib/Service/InvoicePdfService.php index 1f3eb24..1e49346 100644 --- a/gestion/lib/Service/InvoicePdfService.php +++ b/gestion/lib/Service/InvoicePdfService.php @@ -167,7 +167,9 @@ class InvoicePdfService { $templateType = $invoicePdfData['template_type_key']; $clean_folder = html_entity_decode(string: $currentConfig->path).'/'; $factureFolders = $this->getGroupFactureFolder($invoicePdfData,$clean_folder); - + //For testing + // $templateType = ClientTemplateTypeConstant::OGF; + switch ($templateType) { case ClientTemplateTypeConstant::FUNECAP: $pdf = new InvoiceFunecapPdfHandler(); From 3cdc581d676f243d06ee78d12d9b95eebd8cf43c Mon Sep 17 00:00:00 2001 From: Narindra ezway Date: Fri, 4 Apr 2025 18:39:38 +0300 Subject: [PATCH 09/10] Adjust footer position in PDF invoices --- .../Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php | 2 +- gestion/lib/Service/InvoicePdfHandler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php index 68a0325..3b485f9 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php @@ -99,7 +99,7 @@ class InvoiceGroupPdfHandler extends FPDF { function Footer() { - $this->SetY(-38); + $this->SetY(-34); $this->SetFont('ComicSans', '', size: 7); $this->MultiCell(0,4,utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); $this->Ln(1); diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index a246338..bca330f 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -89,7 +89,7 @@ class InvoicePdfHandler extends FPDF function Footer() { - $this->SetY(-38); + $this->SetY(-34); $this->SetFont('ComicSans', '', 7); $this->MultiCell(0, 4, utf8_decode(html_entity_decode('Tout retard de paiement entraînera de plein droit une pénalité de retard de 3 fois le taux légal ( Loi 2008-776 du 4 août 2008) et une indemnité forfaitaire de 40 EUR pour frais de recouvrement sera appliquée.'))); $this->Ln(1); From 63aa9029bbd3635e4cee92b2f37d4fd2087d6bbb Mon Sep 17 00:00:00 2001 From: Narindra ezway Date: Fri, 4 Apr 2025 18:53:15 +0300 Subject: [PATCH 10/10] Set font size for product details in PDF invoices --- .../Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php | 3 ++- gestion/lib/Service/InvoicePdfHandler.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php index 3b485f9..bff6755 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php @@ -265,6 +265,8 @@ class InvoiceGroupPdfHandler extends FPDF { $products = $currentDevis["products"]; $productIncrement = 0; foreach($products as $product){ + $this->SetFont('ComicSans', '', 8); + $valueHt = $product['produit_price'] * $product["quantite"]; $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt,$tvaValue); $totalHt+=$valueHt; @@ -296,7 +298,6 @@ class InvoiceGroupPdfHandler extends FPDF { $this->Cell($maxDescriptionWidth, 6, $productDescription); } - $this->SetFont('ComicSans', '', 8); $this->SetXY( 135,$yValue ); $this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C'); diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index bca330f..f041e95 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -283,6 +283,9 @@ class InvoicePdfHandler extends FPDF $products = $this->factureData["products"]; $yValue = $this->startingYOfArticlesTable + 11; foreach ($products as $product) { + + $this->SetFont('ComicSans', '', 8); + $valueHt = $product['produit_price']; $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue); $totalHt += $valueHt; @@ -301,7 +304,6 @@ class InvoicePdfHandler extends FPDF $this->MultiAlignCell(102, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0',); - $this->SetFont('ComicSans', '', 7); $this->SetXY(135, $yValue); $this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C');