diff --git a/gestion/lib/Service/InvoicePdfHandler.php b/gestion/lib/Service/InvoicePdfHandler.php index 0eee5d5..6dc1e3f 100644 --- a/gestion/lib/Service/InvoicePdfHandler.php +++ b/gestion/lib/Service/InvoicePdfHandler.php @@ -105,7 +105,6 @@ class InvoicePdfHandler extends FPDF { $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(){ $this->SetFont('ComicSans', '', 10); $clientName = $this->factureData['client_nom']; @@ -113,12 +112,22 @@ class InvoicePdfHandler extends FPDF { $clientName = $this->factureData['group_name']; } $clientInfoXAxis = 125; - $clientInfoYAxis = 40; + + $clientAddress = FileExportHelpers::FormatTextForExport($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->Cell(0, 5, FileExportHelpers::FormatTextForExport($clientName)); $clientInfoYAxis += 5; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); - $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_real_adress']))); + $this->MultiCell( 0, 5, trim($clientAddress)); + if($clientAdressIsMultiline){ + $clientInfoYAxis += 5; + } $clientInfoYAxis += 5; $this->SetXY($clientInfoXAxis,$clientInfoYAxis); $this->Cell(0, 5, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city'])));