adjust cell heights and positions in invoice PDF handlers for better layout

This commit is contained in:
Narindra ezway 2025-04-16 16:09:01 +03:00
parent 7d4f230d7e
commit d0b0cf76bb
4 changed files with 64 additions and 57 deletions

View File

@ -94,10 +94,10 @@ class InvoiceFunecapPdfHandler extends InvoiceGroupPdfHandler {
}
$this->SetXY( 140,$yValue );
$this->SetXY( 144,$yValue );
$this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 163,$yValue );
$this->SetXY( 165,$yValue );
$this->Cell(20, 6, number_format($tvaAmount,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 182,$yValue );

View File

@ -253,10 +253,10 @@ class InvoiceGroupPdfHandler extends FPDF {
$this->Cell(36, 7, 'ECHEANCE', 1, 1, 'C');
$this->SetFont('ComicSans', '', 10);
$this->Cell(25, 9, $factureDatePaiement, 1, 0, 'C');
$this->Cell(104, 9, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C');
$this->Cell(39, 9, $this->factureData['num'], 1, 0, 'C');
$this->Cell(36, 9, $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 = $startInvoiceInfoTable + 20;
}
@ -264,24 +264,25 @@ class InvoiceGroupPdfHandler extends FPDF {
public function DrawArticlesTableRect(){
$this->SetLineWidth(0.2);
$gapBetweenStartingOfArticlesTableAndColumnName = 8;
$tableHeight = $this->thereIsOrderOrCaseNumber ? 137 : 137 + 10;
$gapBetweenStartingOfArticlesTableAndColumnName = 7;
$tableHeight = $this->thereIsOrderOrCaseNumber ? 137 : 137 + 7;
$this->Rect(3, $this->startingYOfArticlesTable, 204, $tableHeight, "D");
// $this->RoundedRect(3, $this->startingYOfArticlesTable, 204, $tableHeight,5 ,'1234',"D");
// cadre titre des colonnes
$this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207,$this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName);
// les traits verticaux colonnes
$additionalMargRight = 1;
$this->Line(28 + $additionalMargRight, $this->startingYOfArticlesTable, 28+ $additionalMargRight , 237);
$this->Line(135 + $additionalMargRight, $this->startingYOfArticlesTable, 135+ $additionalMargRight , 237);
$this->Line(162 + $additionalMargRight, $this->startingYOfArticlesTable, 162+ $additionalMargRight , 237);
$this->Line(182 + $additionalMargRight, $this->startingYOfArticlesTable, 182+ $additionalMargRight , 237);
$endingLine = 234;
$this->Line(27 + $additionalMargRight, $this->startingYOfArticlesTable, 27+ $additionalMargRight , $endingLine);
$this->Line(142 + $additionalMargRight, $this->startingYOfArticlesTable, 142+ $additionalMargRight , $endingLine);
$this->Line(164 + $additionalMargRight, $this->startingYOfArticlesTable, 164+ $additionalMargRight , $endingLine);
$this->Line(182 + $additionalMargRight, $this->startingYOfArticlesTable, 182+ $additionalMargRight , $endingLine);
}
public function DrawArticlesTableHeader(){
$additionalMargRight = 1;
$tvaValue = $this->factureData["configuration"]->tva_default;
$columnNameY = $this->startingYOfArticlesTable - 1;
$columnNameY = $this->startingYOfArticlesTable - 1.5;
$this->SetFont('ComicSans', '', 10);
$this->SetXY(12 + $additionalMargRight, $columnNameY);
$this->Cell(7, 10, "Date", 0, 0, 'C');
@ -289,10 +290,10 @@ class InvoiceGroupPdfHandler extends FPDF {
$this->SetXY(30 + $additionalMargRight, $columnNameY);
$this->Cell(100, 10, "Description", 0, 0, 'C');
$this->SetXY(139 + $additionalMargRight, $columnNameY);
$this->SetXY(143 + $additionalMargRight, $columnNameY);
$this->Cell(20, 10, "Prix Uni. HT", 0, 0, 'C');
$this->SetXY(162 + $additionalMargRight, $columnNameY);
$this->SetXY(163 + $additionalMargRight, $columnNameY);
$this->Cell(20, 10, 'TVA ' . $tvaValue . '%', 0, 0, 'C');
$this->SetXY(185 , $columnNameY);
@ -352,10 +353,10 @@ class InvoiceGroupPdfHandler extends FPDF {
}
$this->SetXY( 140,$yValue );
$this->SetXY(144,$yValue );
$this->Cell(20, 6, number_format($valueHt,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 163,$yValue );
$this->SetXY(165,$yValue );
$this->Cell(20, 6, number_format($tvaAmount,2,'.','').chr(128), 0, 0, 'C');
$this->SetXY( 182,$yValue );

View File

@ -82,11 +82,11 @@ class InvoiceOgfPdfHandler extends InvoiceGroupPdfHandler {
$this->Cell(34, 7, 'COMMANDE', 1, 1, 'C');
$this->SetFont('ComicSans', '', 10);
$this->Cell(30, 9, $factureDatePaiement, 1, 0, 'C');
$this->Cell(60, 9, utf8_decode(html_entity_decode($this->factureData['group_name'])), 1, 0, 'C');
$this->Cell(40, 9, $this->factureData['num'], 1, 0, 'C');
$this->Cell(40, 9, $factureDateEcheance, 1, 0, 'C');
$this->Cell(34, 9, $this->factureData["facture_order_number"], 1, 1, 'C');
$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;

View File

@ -72,14 +72,14 @@ class InvoicePdfHandler extends FPDF
$originalHeight = $originalHeight * 0.264583;
// Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine
$scale = 2;
$scale = 1.7;
$width = $originalWidth * $scale;
$height = $originalHeight * $scale;
// Calculer la position pour centrer l'image
// 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
$y = ((297 - $height) / 2 ) + 19; // 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é
}
@ -216,10 +216,10 @@ class InvoicePdfHandler extends FPDF
$this->setY(77);
$this->SetFont('ComicSans', '', 9);
$this->Cell(25, 11, $factureDatePaiement, 1, 0, 'C');
$this->Cell(104, 11, utf8_decode(html_entity_decode($this->factureData['client_nom'])), 1, 0, 'C');
$this->Cell(39, 11, $this->factureData['num'], 1, 0, 'C');
$this->Cell(36, 11, $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']) !== "-");
@ -245,37 +245,40 @@ class InvoicePdfHandler extends FPDF
private function DrawArticlesTable()
{
$this->SetLineWidth(0.2);
$gapBetweenStartingOfArticlesTableAndColumnName = 10;
$tableHeight = $this->thereIsOrderOrCaseNumber ? $this->articleTablesHeight : $this->articleTablesHeight + 10;
$gapBetweenStartingOfArticlesTableAndColumnName = 8;
$tableHeight = $this->thereIsOrderOrCaseNumber ? $this->articleTablesHeight : $this->articleTablesHeight + 7;
$this->Rect(3, $this->startingYOfArticlesTable, 204, $tableHeight, "D");
// cadre titre des colonnes
$this->Line(3, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName, 207, $this->startingYOfArticlesTable + $gapBetweenStartingOfArticlesTableAndColumnName);
// les traits verticaux colonnes
$this->Line(28, $this->startingYOfArticlesTable, 28, $this->endingYOfArticlesTable + 3);
$this->Line(132, $this->startingYOfArticlesTable, 132, $this->endingYOfArticlesTable + 3);
$this->Line(157, $this->startingYOfArticlesTable, 157, $this->endingYOfArticlesTable + 3);
$this->Line(182, $this->startingYOfArticlesTable, 182, $this->endingYOfArticlesTable + 3);
$additionalMargRight = 1;
$endingLine = 234;
$this->Line(27 + $additionalMargRight, $this->startingYOfArticlesTable, 27+ $additionalMargRight , $endingLine);
$this->Line(142 + $additionalMargRight, $this->startingYOfArticlesTable, 142+ $additionalMargRight , $endingLine);
$this->Line(164 + $additionalMargRight, $this->startingYOfArticlesTable, 164+ $additionalMargRight , $endingLine);
$this->Line(182 + $additionalMargRight, $this->startingYOfArticlesTable, 182+ $additionalMargRight , $endingLine);
}
private function DrawArticlesTableHeader()
{
$additionalMargRight = 1;
$tvaValue = $this->factureData["configuration"]->tva_default;
$columnNameY = $this->startingYOfArticlesTable + 1;
$this->SetFont('ComicSans', '', 10);
$this->SetXY(12, $columnNameY);
$this->Cell(7, 8, "Date", 0, 0, 'C');
$this->SetXY(12 + $additionalMargRight, $columnNameY);
$this->Cell(7, 10, "Date", 0, 0, 'C');
$this->SetXY(28, $columnNameY);
$this->Cell(100, 8, "Description", 0, 0, 'C');
$this->SetXY(30 + $additionalMargRight, $columnNameY);
$this->Cell(100, 10, "Description", 0, 0, 'C');
$this->SetXY(135, $columnNameY);
$this->Cell(20, 8, "Prix Uni. HT", 0, 0, 'C');
$this->SetXY(143 + $additionalMargRight, $columnNameY);
$this->Cell(20, 10, "Prix Uni. HT", 0, 0, 'C');
$this->SetXY(159, $columnNameY);
$this->Cell(20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C');
$this->SetXY(163 + $additionalMargRight, $columnNameY);
$this->Cell(20, 10, 'TVA ' . $tvaValue . '%', 0, 0, 'C');
$this->SetXY(185, $columnNameY);
$this->Cell(20, 8, "Prix Uni. TTC", 0, 0, 'C');
$this->Cell(20, 10, "Prix Uni. TTC", 0, 0, 'C');
}
public function DrawArticlesTableValueAndReturnTotalPrice()
@ -289,7 +292,8 @@ class InvoicePdfHandler extends FPDF
$totalTtc = 0;
$totalTva = 0;
$products = $this->factureData["products"];
$yValue = $this->startingYOfArticlesTable + 11;
$yValue = $this->startingYOfArticlesTable + 13;
$maxDescriptionWidth = 102;
foreach ($products as $product) {
$valueHt = $product['produit_price'] * $product['quantite'];
@ -306,15 +310,15 @@ class InvoicePdfHandler extends FPDF
$this->SetXY(5, $yValue);
$this->Cell(5, 6, $dateValue, 0, 0);
$this->SetXY(29, $yValue);
$this->MultiAlignCell(102, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0',);
$this->SetXY(30, $yValue);
$this->MultiAlignCell($maxDescriptionWidth , 6, utf8_decode(html_entity_decode($productDescription)), 0, '0',);
$this->SetXY(135, $yValue);
$this->SetXY(144, $yValue);
$this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY(159, $yValue);
$this->SetXY(165, $yValue);
$this->Cell(20, 6, number_format($tvaAmount, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY(182, $yValue);
@ -332,19 +336,21 @@ class InvoicePdfHandler extends FPDF
private function DrawBankAndTotalPriceInfo($totalPriceArray)
{
$this->SetY(235);
$this->SetY(239);
$this->SetFont('ComicSans', '', 8);
$this->MultiCell(0,4,utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de ". $this->factureData['configuration']->entreprise)));
$this->MultiCell(0,4,utf8_decode(html_entity_decode("en indiquant le numéro de facture, ou par virement :")));
$this->Ln(1);
$startOftable = 3 ;
$this->SetX($startOftable);
// Table IBAN
$this->SetFont('ComicSans', '', 8);
$ibanWidth = 62;
$ibanCursorY = $this->GetY();
$this->Cell($ibanWidth, 5, 'IBAN : FR76 1360 6000 1436 5418 1800 038', 1, 1, 'C');
$this->Cell($ibanWidth, 5, 'IBANss : FR76 1360 6000 1436 5418 1800 038', 1, 1, 'C');
$ibanCursorX = $this->GetX();
$this->SetX($startOftable);
$this->Cell($ibanWidth, 5, 'Code SWIFT : AGRI FR PP 836', 1, 1, 'C');
//TABLE HT
@ -360,9 +366,9 @@ class InvoicePdfHandler extends FPDF
foreach($totalPriceArray as $label => $price){
$this->SetXY($startOfArrayX,$startOfArrayY);
$this->Cell(24, 5, $label, 1, 1, 'C');
$this->Cell(24, 6.5, $label, 1, 1, 'C');
$this->SetXY($startOfArrayX + 24,$startOfArrayY);
$this->Cell(24, 5, number_format($price,2,'.','').chr(128), 1, 1, 'C');
$this->Cell(24, 6.5, number_format($price,2,'.','').chr(128), 1, 1, 'C');
$startOfArrayY += 5;
}
}
@ -378,7 +384,7 @@ class InvoicePdfHandler extends FPDF
public function SetFactureContent()
{
$this->AddPage();
$this->SetMargins(3, 0, 3);
$this->SetMargins(2, 0, 3);
$this->DrawInvoiceCompanyAndClientInfo();
$this->DrawInvoiceInfoTable();
$this->DrawArticlesTable();