From 2b1381bd2a4a95f96b2217afcebc686a9f592d6a Mon Sep 17 00:00:00 2001 From: Tiavina Date: Wed, 5 Feb 2025 21:03:19 +0300 Subject: [PATCH] =?UTF-8?q?finish=20invoice=20recap=20groupe=20adress=20?= =?UTF-8?q?=C3=A0=20la=20lignen=20wip=20on=20facture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InvoiceRecap/InvoiceRecapService.php | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php index 1b13885..cb972ab 100644 --- a/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php +++ b/gestion/lib/Service/InvoiceRecap/InvoiceRecapService.php @@ -202,7 +202,17 @@ class InvoiceRecapService { $pdf->Cell( 0, 7, utf8_decode($clientGroupFacturation["group_facturation_name"])); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["address"])))); + $clientAdress = FileExportHelpers::FormatTextForExport($clientGroupFacturation["address"]); + $clientAdressWidth = $pdf->GetStringWidth($clientAdress); + $maxWidth = $pdf->GetPageWidth(); + $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; + $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAdress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["postal_code"]. ' ' .$clientGroupFacturation["city"])))); @@ -290,13 +300,18 @@ class InvoiceRecapService { // adresse du facture $clientInfoXAxis = 125; - $clientInfoYAxis = 40; + $clientInfoYAxis = $clientAdressIsMultiline ? 33 : 40; $pdf->SetFont('ComicSans','',size: 11); $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, utf8_decode('Groupe '.$clientGroupFacturation["group_facturation_name"])); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["address"])))); + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAdress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientGroupFacturation["postal_code"]. ' '.$clientGroupFacturation["city"])))); @@ -584,7 +599,17 @@ class InvoiceRecapService { $pdf->Cell( 0, 7, utf8_decode($clientHeaderLabel)); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientAddress)))); + $clientAddress = FileExportHelpers::FormatTextForExport($clientAddress); + $clientAdressWidth = $pdf->GetStringWidth($clientAddress); + $maxWidth = $pdf->GetPageWidth(); + $availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis; + $clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo; + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAddress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientCity)))); @@ -672,13 +697,18 @@ class InvoiceRecapService { // adresse du facture $clientInfoXAxis = 125; - $clientInfoYAxis = 40; + $clientInfoYAxis = $clientAdressIsMultiline ? 33 : 40; $pdf->SetFont('ComicSans','',size: 11); $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, utf8_decode($clientHeaderLabel)); $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); - $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientAddress)))); + $pdf->SetMargins(0,0,10); + $pdf->MultiCell( 0, 7, trim($clientAddress)); + $pdf->SetMargins(0,0,0); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 7; + } $clientInfoYAxis += 7; $pdf->SetXY($clientInfoXAxis,$clientInfoYAxis); $pdf->Cell( 0, 7, trim(utf8_decode(html_entity_decode($clientCity))));