handl client adress on simple pdf generation
This commit is contained in:
parent
235da11fe3
commit
6acbb67351
@ -166,30 +166,45 @@ class InvoicePdfHandler extends FPDF
|
||||
$clientInfoXAxis = 125;
|
||||
|
||||
$clientAddress = $this->factureData['client_real_adress'];
|
||||
$clientAdressWidth = $this->GetStringWidth($clientAddress);
|
||||
$maxWidth = $this->GetPageWidth();
|
||||
$availableWidhtForClientInfo = $maxWidth - 10 - $clientInfoXAxis;
|
||||
$clientAdressIsMultiline = $clientAdressWidth > $availableWidhtForClientInfo;
|
||||
$availableWidhtForClientInfo = $maxWidth - 2 - $clientInfoXAxis;
|
||||
$address = FileExportHelpers::FormatTextForExport(trim($clientAddress));
|
||||
$addressWidth = $this->GetStringWidth($address);
|
||||
$addressWidthGreaterThanMaxWidth = $addressWidth > $availableWidhtForClientInfo;
|
||||
$addressIsMoreThanTwoLines = ($addressWidth / $availableWidhtForClientInfo) > 2;
|
||||
|
||||
$clientInfoYAxis = $clientAdressIsMultiline ? 35 : 40;
|
||||
$clientInfoYAxis = $addressIsMoreThanTwoLines ? 35 : 35;// the old is ? 35 : 39 but not working
|
||||
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
|
||||
$this->Cell(0, $this->interLigneHeader, FileExportHelpers::FormatTextForExport($clientName));
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
$clientAddresses = explode(",", $clientAddress);
|
||||
foreach ($clientAddresses as $address) {
|
||||
$address = FileExportHelpers::FormatTextForExport(trim($address));
|
||||
$addressWidth = $this->GetStringWidth($address);
|
||||
$addressWidthGreaterThanMaxWidth = $addressWidth > $availableWidhtForClientInfo;
|
||||
$isMultiline = false;
|
||||
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
|
||||
$this->MultiCell(0, $this->interLigneHeader, trim(FileExportHelpers::FormatTextForExport($clientAddress)));
|
||||
if ($clientAdressIsMultiline) {
|
||||
$clientAdressIsMoreThanTwoLines = $clientAdressWidth > ($availableWidhtForClientInfo * 2);
|
||||
if($clientAdressIsMoreThanTwoLines){
|
||||
if ($addressWidthGreaterThanMaxWidth) {
|
||||
$yBefore = $this->GetY();
|
||||
$this->MultiCell($availableWidhtForClientInfo, $this->interLigneHeader, $address, 0, 'L');
|
||||
$yAfter = $this->GetY();
|
||||
$isMultiline = ($yAfter - $yBefore) > $this->interLigneHeader;
|
||||
if ($isMultiline) {
|
||||
$this->SetXY($this->GetX(), $yBefore);
|
||||
}
|
||||
} else {
|
||||
$this->Cell($availableWidhtForClientInfo, $this->interLigneHeader, $address);
|
||||
}
|
||||
if ($isMultiline) {
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
}
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
}
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
|
||||
$this->Cell(0, $this->interLigneHeader, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city'])));
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
|
||||
$this->Cell(0, $this->interLigneHeader,'Siret: ' . $this->factureData['siret']);
|
||||
$this->Cell(0, $this->interLigneHeader,'Siret6: ' . $this->factureData['siret']);
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
|
||||
$this->Cell(0, $this->interLigneHeader, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user