From 39848d2ce994a32b656e1b758696e7af49b2755e Mon Sep 17 00:00:00 2001 From: Tiavina Date: Mon, 7 Apr 2025 17:18:46 +0300 Subject: [PATCH] fix funecap address multiline --- .../InvoiceGroupPdfHandler.php | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php index 1fae1f0..746b8d7 100644 --- a/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php +++ b/gestion/lib/Service/InvoiceGroupPdfHandler/InvoiceGroupPdfHandler.php @@ -171,11 +171,22 @@ class InvoiceGroupPdfHandler extends FPDF { $this->Cell(0, 4, FileExportHelpers::FormatTextForExport($clientName)); $clientInfoYAxis += 4; if ( $this->factureData['group_type'] == 'single' ) { - $addressWidth = $this->GetStringWidth($clientAddress); - $isMultiline = $addressWidth > $availableWidhtForClientInfo; + $address = FileExportHelpers::FormatTextForExport($clientAddress); + $addressWidth = $this->GetStringWidth($address); + $addressWidthGreaterThanMaxWidth = $addressWidth > $availableWidhtForClientInfo; + $isMultiline = false; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->MultiCell( 0, 4, trim(FileExportHelpers::FormatTextForExport($clientAddress))); - + if ($addressWidthGreaterThanMaxWidth) { + $yBefore = $this->GetY(); + $this->MultiCell($availableWidhtForClientInfo, 4, $address,0,'L'); + $yAfter = $this->GetY(); + $isMultiline = ($yAfter - $yBefore) > 4; + if($isMultiline){ + $this->SetXY($this->GetX(),$yBefore); + } + } else { + $this->Cell($availableWidhtForClientInfo, 4, $address); + } if($isMultiline){ $clientInfoYAxis += 4; } @@ -184,10 +195,22 @@ class InvoiceGroupPdfHandler extends FPDF { }else{ $clientAddresses = explode(",",$clientAddress); foreach ($clientAddresses as $address) { + $address = FileExportHelpers::FormatTextForExport($address); $addressWidth = $this->GetStringWidth($address); - $isMultiline = $addressWidth > $availableWidhtForClientInfo; + $addressWidthGreaterThanMaxWidth = $addressWidth > $availableWidhtForClientInfo; + $isMultiline = false; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->MultiCell( 0, 4, trim(FileExportHelpers::FormatTextForExport($address))); + if ($addressWidthGreaterThanMaxWidth) { + $yBefore = $this->GetY(); + $this->MultiCell($availableWidhtForClientInfo, 4, $address,0,'L'); + $yAfter = $this->GetY(); + $isMultiline = ($yAfter - $yBefore) > 4; + if($isMultiline){ + $this->SetXY($this->GetX(),$yBefore); + } + } else { + $this->Cell($availableWidhtForClientInfo, 4, $address); + } if($isMultiline){ $clientInfoYAxis += 4; }