Merge branch 'fixes/fixe/month-invoice' into staging

This commit is contained in:
Tiavina 2025-04-02 15:47:00 +03:00
commit 499a141f44
4 changed files with 287 additions and 200 deletions

View File

@ -41,7 +41,7 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler {
$totalTtc = 0;
$totalTva = 0;
$yValue = $this->startingYOfArticlesTable + 11;
$maxDescriptionWidth = 98;
$maxDescriptionWidth = 102;
$currentIndexPosition = $this->currentIndexPosition;
for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->devisCountToGet);$currentIndexPosition++){
$currentDevis = $devisData[$currentIndexPosition];
@ -51,11 +51,11 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler {
$products = $currentDevis["products"];
$subcontractorOrderNumberText = "Numéro de sous traitance ".$currentDevis["order_number"];
$subcontractorCaseNumberText = "Numéro de dossier ".$currentDevis["case_number"];
$this->SetXY( 35,$yValue );
$this->SetXY( 29,$yValue );
$this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($subcontractorOrderNumberText),0,'0',);
$yValue += 6;
$this->SetXY( 35,$yValue );
$this->SetXY( 29,$yValue );
$this->MultiAlignCell(100, 6, FileExportHelpers::FormatTextForExport($subcontractorCaseNumberText),0,'0',);
$yValue += 6;
foreach($products as $product){
@ -70,10 +70,10 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler {
$productDescription .= " de " . $currentDevis["defunt_nom"] ?? "";
}
$tvaAmount = $valueTtc - $valueHt;
$this->SetXY( 8,$yValue );
$this->Cell(20, 6, $dateValue, 0,0);
$this->SetXY( 5,$yValue );
$this->Cell(5, 6, $dateValue, 0,0);
$this->SetXY( 35,$yValue );
$this->SetXY( 29,$yValue );
$productDescription = FileExportHelpers::FormatTextForExport($productDescription);
$productDescriptionWidth = $this->GetStringWidth($productDescription);
$productDescriptionWidthIsGreaterThanMaxWidth = $productDescriptionWidth > $maxDescriptionWidth;
@ -90,13 +90,13 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler {
$this->Cell($maxDescriptionWidth, 6, $productDescription);
}
$this->SetXY( 138,$yValue );
$this->SetXY( 135,$yValue );
$this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 160,$yValue );
$this->SetXY( 159,$yValue );
$this->Cell(20, 6, number_format($tvaAmount,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 181,$yValue );
$this->SetXY( 182,$yValue );
$this->Cell(25, 6, number_format($valueTtc,2,'.','').chr(128), 0, 1, 'C');
$yValue += 6;
$totalTva += $tvaAmount;

View File

@ -55,6 +55,7 @@ class InvoiceGroupPdfHandler extends FPDF {
{
if($this->logo != "nothing"){
$this->Image($this->logoPath."logo.png", 2, 2, 50,35);
$this->AddWatermark();
}
else{
$this->Cell(55,30,'');
@ -63,6 +64,39 @@ class InvoiceGroupPdfHandler extends FPDF {
$this->DrawInvoiceCompanyAndClientInfo();
$this->DrawInvoiceInfoTable();
}
function AddWatermark()
{
$this->SetAlpha(0.2);
$imagePath = $this->logoPath . "filigrane_pdf.png";
list($originalWidth, $originalHeight) = getimagesize($imagePath);
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
$originalWidth = $originalWidth * 0.264583;
$originalHeight = $originalHeight * 0.264583;
// Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine
$scale = 2;
$width = $originalWidth * $scale;
$height = $originalHeight * $scale;
// Calculer la position pour centrer l'image
$x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm
$y = (297 - $height) / 2; // 297 mm est la hauteur d'une page A4
// Ajouter l'image en filigrane
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
$this->SetAlpha(0.1); // Définir l'opacité
}
function SetAlpha($alpha)
{
// Appliquer la transparence au document
$this->SetFillColor(255, 255, 255, $alpha * 255);
$this->SetTextColor(0, 0, 0, $alpha * 255);
$this->SetDrawColor(0, 0, 0, $alpha * 255);
}
function Footer()
{
$this->SetY(-35);
@ -73,7 +107,7 @@ class InvoiceGroupPdfHandler extends FPDF {
')));
$this->SetY(-15);
$this->SetFont('ComicSans', 'B', 8);
$this->SetFont('ComicSans', '', 7);
$this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C');
}
@ -162,16 +196,16 @@ class InvoiceGroupPdfHandler extends FPDF {
$factureDateEcheance->modify('last day of next month');
$factureDateEcheance = $factureDateEcheance->format('d-m-Y');
$this->SetFont('ComicSans', 'B', 11);
$this->Cell(30, 7, 'DATE', 1, 0, 'C');
$this->Cell(94, 7, 'CLIENT', 1, 0, 'C');
$this->Cell(40, 7, 'FACTURE', 1, 0, 'C');
$this->Cell(40, 7, 'ECHEANCE', 1, 1, 'C');
$this->Cell(25, 7, 'DATE', 1, 0, 'C');
$this->Cell(104, 7, 'CLIENT', 1, 0, 'C');
$this->Cell(39, 7, 'FACTURE', 1, 0, 'C');
$this->Cell(36, 7, 'ECHEANCE', 1, 1, 'C');
$this->SetFont('ComicSans', '', 10);
$this->Cell(30, 7, $factureDatePaiement, 1, 0, 'C');
$this->Cell(94, 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, 1, 'C');
$this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C');
$this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C');
$this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C');
$this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C');
$this->startingYOfArticlesTable = 85;
}
@ -184,30 +218,30 @@ class InvoiceGroupPdfHandler extends FPDF {
// cadre titre des colonnes
$this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207,$this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName);
// les traits verticaux colonnes
$this->Line(35, $this->startingYOfArticlesTable, 35, 232);
$this->Line(135, $this->startingYOfArticlesTable, 135, 232);
$this->Line(160, $this->startingYOfArticlesTable, 160, 232);
$this->Line(180, $this->startingYOfArticlesTable, 180, 232);
$this->Line(28, $this->startingYOfArticlesTable, 28, 232);
$this->Line(132, $this->startingYOfArticlesTable, 132, 232);
$this->Line(157, $this->startingYOfArticlesTable, 157, 232);
$this->Line(182, $this->startingYOfArticlesTable, 182, 232);
}
public function DrawArticlesTableHeader(){
$tvaValue = $this->factureData["configuration"]->tva_default;
$columnNameY = $this->startingYOfArticlesTable + 1;
$this->SetFont('ComicSans', '', 10);
$this->SetXY( 9,$columnNameY );
$this->Cell( 20, 8, "Date", 0, 0, 'C');
$this->SetXY(12, $columnNameY);
$this->Cell(7, 8, "Date", 0, 0, 'C');
$this->SetXY( 35,$columnNameY );
$this->SetXY(28, $columnNameY);
$this->Cell(100, 8, "Description", 0, 0, 'C');
$this->SetXY( 138,$columnNameY );
$this->SetXY(135, $columnNameY);
$this->Cell(20, 8, "Prix Uni. HT", 0, 0, 'C');
$this->SetXY( 160,$columnNameY );
$this->SetXY(159, $columnNameY);
$this->Cell(20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C');
$this->SetXY( 181,$columnNameY );
$this->Cell( 25, 8, "Prix Uni. TTC", 0, 0, 'C');
$this->SetXY(185, $columnNameY);
$this->Cell(20, 8, "Prix Uni. TTC", 0, 0, 'C');
}
@ -219,7 +253,7 @@ class InvoiceGroupPdfHandler extends FPDF {
$totalTtc = 0;
$totalTva = 0;
$yValue = $this->startingYOfArticlesTable + 11;
$maxDescriptionWidth = 98;
$maxDescriptionWidth = 102;
$currentIndexPosition = $this->currentIndexPosition;
for($currentIndexPosition;$currentIndexPosition<($this->initialIndexPosition + $this->devisCountToGet);$currentIndexPosition++){
$currentDevis = $devisData[$currentIndexPosition];
@ -240,10 +274,10 @@ class InvoiceGroupPdfHandler extends FPDF {
$productDescription .= " de " . $currentDevis["defunt_nom"] ?? "";
}
$tvaAmount = $valueTtc - $valueHt;
$this->SetXY( 8,$yValue );
$this->Cell(20, 6, $dateValue, 0,0);
$this->SetXY( 5,$yValue );
$this->Cell(5, 6, $dateValue, 0,0);
$this->SetXY( 35,$yValue );
$this->SetXY( 29,$yValue );
$productDescription = FileExportHelpers::FormatTextForExport($productDescription);
$productDescriptionWidth = $this->GetStringWidth($productDescription);
$productDescriptionWidthIsGreaterThanMaxWidth = $productDescriptionWidth > $maxDescriptionWidth;
@ -260,13 +294,13 @@ class InvoiceGroupPdfHandler extends FPDF {
$this->Cell($maxDescriptionWidth, 6, $productDescription);
}
$this->SetXY( 138,$yValue );
$this->SetXY( 135,$yValue );
$this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 160,$yValue );
$this->SetXY( 159,$yValue );
$this->Cell(20, 6, number_format($tvaAmount,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 181,$yValue );
$this->SetXY( 182,$yValue );
$this->Cell(25, 6, number_format($valueTtc,2,'.','').chr(128), 0, 1, 'C');
$yValue += 6;
$totalTva += $tvaAmount;
@ -292,23 +326,29 @@ class InvoiceGroupPdfHandler extends FPDF {
$this->Ln(1);
//Table IBAN
$this->SetFont('ComicSans', '', 9);
$ibanWidth = 90;
$this->SetFont('ComicSans', '', 7);
$ibanWidth = 56;
$ibanCursorY = $this->GetY();
$this->Cell($ibanWidth, 5, 'IBAN : FR76 1360 6000 1436 5418 1800 038', 1, 1, 'C');
$ibanCursorX = $this->GetX();
$this->Cell($ibanWidth, 5, 'Code SWIFT : AGRI FR PP 836', 1, 1, 'C');
//TABLE HT
$ibanLastPositionX = $ibanCursorX+$ibanWidth + 54;
$startOfArrayX = $ibanLastPositionX;
$tableWidth = 40; // Largeur totale de la 2e table (20+20)
$marginRight = 3; // Marge par rapport au bord droit
$pageWidth = 210; // Largeur d'une page A4 en mm (portrait)
// Position correcte de la 2e table
$startOfArrayX = $pageWidth - $tableWidth - $marginRight;
$startOfArrayY = $ibanCursorY - 10;
$totalPriceArray = $this->totalPrices;
foreach($totalPriceArray as $label => $price){
$this->SetXY($startOfArrayX,$startOfArrayY);
$this->Cell(30, 5, $label, 1, 1, 'C');
$this->SetXY($startOfArrayX + 30,$startOfArrayY);
$this->Cell(30, 5, number_format($price,2,'.','').chr(128), 1, 1, 'C');
$this->Cell(20, 5, $label, 1, 1, 'C');
$this->SetXY($startOfArrayX + 20,$startOfArrayY);
$this->Cell(20, 5, number_format($price,2,'.','').chr(128), 1, 1, 'C');
$startOfArrayY += 5;
}
}

View File

@ -33,24 +33,60 @@ use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers;
class InvoicePdfHandler extends FPDF {
class InvoicePdfHandler extends FPDF
{
private $multipleFactureData = [];
private $factureData = [];
private $logo = null;
private $logoPath = "/var/www/html/data/admin/files/.gestion/";
protected $extgstates = [];
private $thereIsOrderOrCaseNumber = false;
private $startingYOfArticlesTable = 95;
function Header()
{
if ($this->logo != "nothing") {
$this->Image($this->logoPath . "logo.png", 2, 2, 50, 35);
}
else{
$this->AddWatermark();
} else {
$this->Cell(55, 30, '');
}
}
function AddWatermark()
{
$this->SetAlpha(0.2);
$imagePath = $this->logoPath . "filigrane_pdf.png";
list($originalWidth, $originalHeight) = getimagesize($imagePath);
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
$originalWidth = $originalWidth * 0.264583;
$originalHeight = $originalHeight * 0.264583;
// Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine
$scale = 2;
$width = $originalWidth * $scale;
$height = $originalHeight * $scale;
// Calculer la position pour centrer l'image
$x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm
$y = (297 - $height) / 2; // 297 mm est la hauteur d'une page A4
// Ajouter l'image en filigrane
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
$this->SetAlpha(0.1); // Définir l'opacité
}
function SetAlpha($alpha)
{
// Appliquer la transparence au document
$this->SetFillColor(255, 255, 255, $alpha * 255);
$this->SetTextColor(0, 0, 0, $alpha * 255);
$this->SetDrawColor(0, 0, 0, $alpha * 255);
}
function Footer()
{
$this->SetY(-35);
@ -61,28 +97,30 @@ class InvoicePdfHandler extends FPDF {
')));
$this->SetY(-15);
$this->SetFont('ComicSans', 'B', 8);
$this->SetFont('ComicSans', '', 7);
$this->Cell(0, 10, utf8_decode(html_entity_decode($this->factureData['configuration']->legal_one)), 0, 0, 'C');
}
public function InvoicePdfFactory(array $factureData,$logo = null){
public function InvoicePdfFactory(array $factureData, $logo = null)
{
$this->factureData = $factureData;
$this->logo = $logo;
}
public function MutlipleInvoicePdfFactory(array $multipleInvoiceData,$logo = null){
public function MutlipleInvoicePdfFactory(array $multipleInvoiceData, $logo = null)
{
$this->multipleFactureData = $multipleInvoiceData;
$this->logo = $logo;
}
public function GetMultipleInvoiceFilename($month,$year){
public function GetMultipleInvoiceFilename($month, $year)
{
$filename = "";
foreach ($this->multipleFactureData as $factureData) {
$factureType = $factureData["facture_type"];
if ($factureType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE) {
$filename = mb_strtoupper($factureData["client_nom"], 'UTF-8');
}
else{
} else {
$filename = 'GROUPE_' . mb_strtoupper($factureData["group_name"], 'UTF-8');
}
$filename .= $month != 0 ? '_' . DateHelpers::GetMonthPlainString($month) : '';
@ -92,14 +130,16 @@ class InvoicePdfHandler extends FPDF {
return $filename;
}
public function GetInvoiceFilename(){
public function GetInvoiceFilename()
{
$factureNum = $this->factureData['num'];
$factureNum = str_replace('/', '-', $factureNum);
$defuntNom = str_replace('&nbsp;', ' ', $this->factureData['defunt_nom']);
return $this->factureData['configuration']->facture_prefixe . '_' . $factureNum . '_' . mb_strtoupper($defuntNom, 'UTF-8');
}
private function DrawInvoiceCompanyInfo(){
private function DrawInvoiceCompanyInfo()
{
$this->SetY(40);
$this->SetFont('ComicSans', '', 10);
$this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->factureData['configuration']->entreprise), 0, 1);
@ -108,7 +148,8 @@ 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(){
private function DrawInvoiceClientInfo()
{
$this->SetFont('ComicSans', '', 10);
$clientName = $this->factureData['client_nom'];
if ($this->factureData["group_name"] != null && $this->factureData["group_name"] != "") {
@ -142,12 +183,14 @@ class InvoicePdfHandler extends FPDF {
$this->Cell(0, 5, FileExportHelpers::FormatTextForExport('Mail : ') . $this->factureData['client_mail']);
}
private function DrawInvoiceCompanyAndClientInfo(){
private function DrawInvoiceCompanyAndClientInfo()
{
$this->DrawInvoiceCompanyInfo();
$this->DrawInvoiceClientInfo();
}
private function DrawInvoiceInfoTable(){
private function DrawInvoiceInfoTable()
{
$this->setY(67);
$factureDatePaiement = $this->factureData['date_paiement'];
$factureDatePaiement = DateTime::createFromFormat('Y-m-d', $factureDatePaiement);
@ -156,16 +199,16 @@ class InvoicePdfHandler extends FPDF {
$factureDateEcheance->modify('last day of next month');
$factureDateEcheance = $factureDateEcheance->format('d-m-Y');
$this->SetFont('ComicSans', 'B', 11);
$this->Cell(30, 7, 'DATE', 1, 0, 'C');
$this->Cell(94, 7, 'CLIENT', 1, 0, 'C');
$this->Cell(40, 7, 'FACTURE', 1, 0, 'C');
$this->Cell(40, 7, 'ECHEANCE', 1, 1, 'C');
$this->Cell(25, 7, 'DATE', 1, 0, 'C');
$this->Cell(104, 7, 'CLIENT', 1, 0, 'C');
$this->Cell(39, 7, 'FACTURE', 1, 0, 'C');
$this->Cell(36, 7, 'ECHEANCE', 1, 1, 'C');
$this->SetFont('ComicSans', '', 10);
$this->Cell(30, 7, $factureDatePaiement, 1, 0, 'C');
$this->Cell(94, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C');
$this->Cell(40, 7, $this->factureData['num'], 1, 0, 'C');
$this->Cell(40, 7, $factureDateEcheance, 1, 1, 'C');
$this->Cell(25, 7, $factureDatePaiement, 1, 0, 'C');
$this->Cell(104, 7, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C');
$this->Cell(39, 7, $this->factureData['num'], 1, 0, 'C');
$this->Cell(36, 7, $factureDateEcheance, 1, 1, 'C');
$orderNumberIsProvided = (trim($this->factureData['order_number']) !== "" && trim($this->factureData['order_number']) !== "-");
$caseNumberIsProvided = (trim($this->factureData['case_number']) !== "" && trim($this->factureData['case_number']) !== "-");
@ -188,7 +231,8 @@ class InvoicePdfHandler extends FPDF {
$this->startingYOfArticlesTable = $this->thereIsOrderOrCaseNumber ? 95 : 85;
}
private function DrawArticlesTable(){
private function DrawArticlesTable()
{
$this->SetLineWidth(0.2);
$gapBetweenStartingOfArticlesTableAndColumnName = 10;
$tableHeight = $this->thereIsOrderOrCaseNumber ? 137 : 137 + 10;
@ -196,34 +240,35 @@ class InvoicePdfHandler extends FPDF {
// cadre titre des colonnes
$this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName);
// les traits verticaux colonnes
$this->Line(35, $this->startingYOfArticlesTable, 35, 232);
$this->Line(135, $this->startingYOfArticlesTable, 135, 232);
$this->Line(160, $this->startingYOfArticlesTable, 160, 232);
$this->Line(180, $this->startingYOfArticlesTable, 180, 232);
$this->Line(28, $this->startingYOfArticlesTable, 28, 232);
$this->Line(132, $this->startingYOfArticlesTable, 132, 232);
$this->Line(157, $this->startingYOfArticlesTable, 157, 232);
$this->Line(182, $this->startingYOfArticlesTable, 182, 232);
}
private function DrawArticlesTableHeader(){
private function DrawArticlesTableHeader()
{
$tvaValue = $this->factureData["configuration"]->tva_default;
$columnNameY = $this->startingYOfArticlesTable + 1;
$this->SetFont('ComicSans', '', 10);
$this->SetXY( 9,$columnNameY );
$this->Cell( 20, 8, "Date", 0, 0, 'C');
$this->SetXY(12, $columnNameY);
$this->Cell(7, 8, "Date", 0, 0, 'C');
$this->SetXY( 35,$columnNameY );
$this->SetXY(28, $columnNameY);
$this->Cell(100, 8, "Description", 0, 0, 'C');
$this->SetXY( 138,$columnNameY );
$this->SetXY(135, $columnNameY);
$this->Cell(20, 8, "Prix Uni. HT", 0, 0, 'C');
$this->SetXY( 160,$columnNameY );
$this->SetXY(159, $columnNameY);
$this->Cell(20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C');
$this->SetXY( 181,$columnNameY );
$this->Cell( 25, 8, "Prix Uni. TTC", 0, 0, 'C');
$this->SetXY(185, $columnNameY);
$this->Cell(20, 8, "Prix Uni. TTC", 0, 0, 'C');
}
public function DrawArticlesTableValueAndReturnTotalPrice(){
public function DrawArticlesTableValueAndReturnTotalPrice()
{
$this->SetFont('ComicSans', '', 10);
$devisDate = $this->factureData['devis_date'];
$devisDate = DateTime::createFromFormat('Y-m-d', $devisDate);
@ -246,19 +291,19 @@ class InvoicePdfHandler extends FPDF {
$productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' ' . $this->factureData["defunt_nom"];
}
$tvaAmount = $valueTtc - $valueHt;
$this->SetXY( 8,$yValue );
$this->Cell(20, 6, $dateValue, 0,0);
$this->SetXY(5, $yValue);
$this->Cell(5, 6, $dateValue, 0, 0);
$this->SetXY( 35,$yValue );
$this->MultiAlignCell(100, 6, utf8_decode(html_entity_decode($productDescription)),0,'0',);
$this->SetXY(29, $yValue);
$this->MultiAlignCell(102, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0',);
$this->SetXY( 138,$yValue );
$this->SetXY(135, $yValue);
$this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY( 160,$yValue );
$this->SetXY(159, $yValue);
$this->Cell(20, 6, number_format($tvaAmount, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY( 181,$yValue );
$this->SetXY(182, $yValue);
$this->Cell(25, 6, number_format($valueTtc, 2, '.', '') . chr(128), 0, 1, 'C');
$yValue += 12;
$totalTva += $tvaAmount;
@ -271,7 +316,8 @@ class InvoicePdfHandler extends FPDF {
];
}
private function DrawBankAndTotalPriceInfo($totalPriceArray){
private function DrawBankAndTotalPriceInfo($totalPriceArray)
{
$this->SetY(235);
$this->SetFont('ComicSans', '', 7);
$this->MultiCell(0, 5, utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de " . $this->factureData['configuration']->entreprise)));
@ -280,34 +326,41 @@ class InvoicePdfHandler extends FPDF {
$this->Ln(1);
// Table IBAN
$this->SetFont('ComicSans', '', 9);
$ibanWidth = 90;
$this->SetFont('ComicSans', '', 7);
$ibanWidth = 56;
$ibanCursorY = $this->GetY();
$this->Cell($ibanWidth, 5, 'IBAN : FR76 1360 6000 1436 5418 1800 038', 1, 1, 'C');
$ibanCursorX = $this->GetX();
$this->Cell($ibanWidth, 5, 'Code SWIFT : AGRI FR PP 836', 1, 1, 'C');
//TABLE HT
$ibanLastPositionX = $ibanCursorX+$ibanWidth + 54;
$startOfArrayX = $ibanLastPositionX;
$tableWidth = 40; // Largeur totale de la 2e table (20+20)
$marginRight = 3; // Marge par rapport au bord droit
$pageWidth = 210; // Largeur d'une page A4 en mm (portrait)
// Position correcte de la 2e table
$startOfArrayX = $pageWidth - $tableWidth - $marginRight;
$startOfArrayY = $ibanCursorY - 10;
foreach ($totalPriceArray as $label => $price) {
$this->SetXY($startOfArrayX, $startOfArrayY);
$this->Cell(30, 5, $label, 1, 1, 'C');
$this->SetXY($startOfArrayX + 30,$startOfArrayY);
$this->Cell(30, 5, number_format($price,2,'.','').chr(128), 1, 1, 'C');
$this->Cell(20, 5, $label, 1, 1, 'C');
$this->SetXY($startOfArrayX + 20, $startOfArrayY);
$this->Cell(20, 5, number_format($price, 2, '.', '') . chr(128), 1, 1, 'C');
$startOfArrayY += 5;
}
}
public function SetMultipleFactureContent(){
public function SetMultipleFactureContent()
{
foreach ($this->multipleFactureData as $factureData) {
$this->factureData = $factureData;
$this->SetFactureContent();
}
}
public function SetFactureContent(){
public function SetFactureContent()
{
$this->AddPage();
$this->SetMargins(3, 0, 3);
$this->DrawInvoiceCompanyAndClientInfo();
@ -328,8 +381,7 @@ class InvoicePdfHandler extends FPDF {
$this->MultiCell($w, $h, $text, $border, $align, $fill);
// Reset the line position to the right, like in Cell
if( $ln==0 )
{
if ($ln == 0) {
$this->SetXY($x, $y);
}
}
@ -352,11 +404,9 @@ class InvoicePdfHandler extends FPDF {
$j = 0;
$l = 0;
$nl = 1;
while($i<$nb)
{
while ($i < $nb) {
$c = $s[$i];
if($c=="\n")
{
if ($c == "\n") {
$i++;
$sep = -1;
$j = $i;
@ -367,21 +417,17 @@ class InvoicePdfHandler extends FPDF {
if ($c == ' ')
$sep = $i;
$l += $cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if ($l > $wmax) {
if ($sep == -1) {
if ($i == $j)
$i++;
}
else
} else
$i = $sep + 1;
$sep = -1;
$j = $i;
$l = 0;
$nl++;
}
else
} else
$i++;
}
return $nl;

View File

@ -167,6 +167,7 @@ class InvoicePdfService {
$templateType = $invoicePdfData['template_type_key'];
$clean_folder = html_entity_decode(string: $currentConfig->path).'/';
$factureFolders = $this->getGroupFactureFolder($invoicePdfData,$clean_folder);
switch ($templateType) {
case ClientTemplateTypeConstant::FUNECAP:
$pdf = new InvoiceFunecapPdfHandler();