2025-05-05 13:37:39 +03:00

101 lines
4.4 KiB
PHP

<?php
declare(strict_types=1);
/**
* Calendar App
*
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
*
* @author Anna Larch <anna.larch@gmx.net>
* @author Richard Steinmetz <richard@steinmetz.cloud>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Gestion\Service\InvoiceGroupPdfHandler;
use DateTime;
use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers;
class InvoiceOgfPdfHandler extends InvoiceGroupPdfHandler {
public function DrawInvoiceClientInfo(){
$this->SetFont('ComicSans', '', 10);
$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 : 39;
$this->SetXY($clientInfoXAxis,$clientInfoYAxis);
$this->Cell(0, $this->interLigneHeader, FileExportHelpers::FormatTextForExport($clientName));
$clientInfoYAxis += $this->interLigneHeader;
$this->SetXY($clientInfoXAxis,$clientInfoYAxis);
$this->MultiCell( 0, $this->interLigneHeader, trim(FileExportHelpers::FormatTextForExport($clientAddress)));
if ($clientAdressIsMultiline) {
$clientAdressIsMoreThanTwoLines = $clientAdressWidth > ($availableWidhtForClientInfo * 2);
if($clientAdressIsMoreThanTwoLines){
$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']);
$clientInfoYAxis += $this->interLigneHeader;
$this->SetXY($clientInfoXAxis,$clientInfoYAxis);
$this->Cell(0, $this->interLigneHeader, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']);
}
public function DrawInvoiceInfoTable(){
$startInvoiceInfoTable = 70;
$this->setY($startInvoiceInfoTable);
$factureDatePaiement = $this->factureData['date_paiement'];
$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', '', 9);
$this->Cell(30, 7, 'DATE', 1, 0, 'C');
$this->Cell(60, 7, 'CLIENT', 1, 0, 'C');
$this->Cell(40, 7, 'FACTURE', 1, 0, 'C');
$this->Cell(40, 7, 'ECHEANCE', 1, 0, 'C');
$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->startingYOfArticlesTable = $startInvoiceInfoTable + 20;
}
}