fix remove filigran_pdf in header

This commit is contained in:
Tolotsoa 2025-08-22 11:16:34 +03:00
parent 64d54fe4f5
commit 477196fa39

View File

@ -27,7 +27,7 @@ declare(strict_types=1);
namespace OCA\Gestion\Service\InvoiceGroupPdfHandler; namespace OCA\Gestion\Service\InvoiceGroupPdfHandler;
use DateTime; use DateTime;
use \FPDF; use FPDF;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers; use OCA\Gestion\Helpers\PriceHelpers;
@ -54,11 +54,11 @@ class InvoiceGroupPdfHandler extends FPDF
public $additionalArticlesLineBasedOnMultiline = 0; public $additionalArticlesLineBasedOnMultiline = 0;
public $interLigneHeader = 5; public $interLigneHeader = 5;
function Header() public function Header()
{ {
if ($this->logo != "nothing") { if ($this->logo != "nothing") {
$this->Image($this->logoPath . "logo.png", 4, 2, 50, 35); $this->Image($this->logoPath . "logo.png", 4, 2, 50, 35);
$this->AddWatermark(); //$this->AddWatermark();
} else { } else {
$this->Cell(55, 30, ''); $this->Cell(55, 30, '');
} }
@ -66,7 +66,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawInvoiceCompanyAndClientInfo(); $this->DrawInvoiceCompanyAndClientInfo();
$this->DrawInvoiceInfoTable(); $this->DrawInvoiceInfoTable();
} }
function AddWatermark() public function AddWatermark()
{ {
$this->SetAlpha(0.2); $this->SetAlpha(0.2);
@ -91,7 +91,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->SetAlpha(0.1); // Définir l'opacité $this->SetAlpha(0.1); // Définir l'opacité
} }
function SetAlpha($alpha) public function SetAlpha($alpha)
{ {
// Appliquer la transparence au document // Appliquer la transparence au document
$this->SetFillColor(255, 255, 255, $alpha * 255); $this->SetFillColor(255, 255, 255, $alpha * 255);
@ -106,7 +106,7 @@ class InvoiceGroupPdfHandler extends FPDF
} }
function Footer() public function Footer()
{ {
$this->SetY(-34); $this->SetY(-34);
$this->SetFont('ComicSans', '', 7); $this->SetFont('ComicSans', '', 7);
@ -335,7 +335,7 @@ class InvoiceGroupPdfHandler extends FPDF
$totalTva = 0; $totalTva = 0;
$yValue = $this->startingYOfArticlesTable + 13; $yValue = $this->startingYOfArticlesTable + 13;
// $maxDescriptionWidth = 102; // $maxDescriptionWidth = 102;
$maxDescriptionWidth = 104.3; $maxDescriptionWidth = 104.3;
$currentIndexPosition = $this->currentIndexPosition; $currentIndexPosition = $this->currentIndexPosition;
for ($currentIndexPosition; $currentIndexPosition < ($this->initialIndexPosition + $this->devisCountToGet); $currentIndexPosition++) { for ($currentIndexPosition; $currentIndexPosition < ($this->initialIndexPosition + $this->devisCountToGet); $currentIndexPosition++) {
$currentDevis = $devisData[$currentIndexPosition]; $currentDevis = $devisData[$currentIndexPosition];
@ -449,7 +449,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawBankAndTotalPriceInfo(); $this->DrawBankAndTotalPriceInfo();
} }
function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false) public function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false)
{ {
// Store reset values for (x,y) positions // Store reset values for (x,y) positions
$x = $this->GetX() + $w; $x = $this->GetX() + $w;
@ -464,19 +464,22 @@ class InvoiceGroupPdfHandler extends FPDF
} }
} }
function NbLines($w, $txt) public function NbLines($w, $txt)
{ {
// Compute the number of lines a MultiCell of width w will take // Compute the number of lines a MultiCell of width w will take
if (!isset($this->CurrentFont)) if (!isset($this->CurrentFont)) {
$this->Error('No font has been set'); $this->Error('No font has been set');
}
$cw = $this->CurrentFont['cw']; $cw = $this->CurrentFont['cw'];
if ($w == 0) if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x; $w = $this->w - $this->rMargin - $this->x;
}
$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r", '', (string) $txt); $s = str_replace("\r", '', (string) $txt);
$nb = strlen($s); $nb = strlen($s);
if ($nb > 0 && $s[$nb - 1] == "\n") if ($nb > 0 && $s[$nb - 1] == "\n") {
$nb--; $nb--;
}
$sep = -1; $sep = -1;
$i = 0; $i = 0;
$j = 0; $j = 0;
@ -492,21 +495,25 @@ class InvoiceGroupPdfHandler extends FPDF
$nl++; $nl++;
continue; continue;
} }
if ($c == ' ') if ($c == ' ') {
$sep = $i; $sep = $i;
}
$l += $cw[$c]; $l += $cw[$c];
if ($l > $wmax) { if ($l > $wmax) {
if ($sep == -1) { if ($sep == -1) {
if ($i == $j) if ($i == $j) {
$i++; $i++;
} else }
} else {
$i = $sep + 1; $i = $sep + 1;
}
$sep = -1; $sep = -1;
$j = $i; $j = $i;
$l = 0; $l = 0;
$nl++; $nl++;
} else } else {
$i++; $i++;
}
} }
return $nl; return $nl;
} }
@ -516,38 +523,42 @@ class InvoiceGroupPdfHandler extends FPDF
{ {
$k = $this->k; $k = $this->k;
$hp = $this->h; $hp = $this->h;
if ($style == 'F') if ($style == 'F') {
$op = 'f'; $op = 'f';
elseif ($style == 'FD' || $style == 'DF') } elseif ($style == 'FD' || $style == 'DF') {
$op = 'B'; $op = 'B';
else } else {
$op = 'S'; $op = 'S';
}
$MyArc = 4 / 3 * (sqrt(2) - 1); $MyArc = 4 / 3 * (sqrt(2) - 1);
$this->_out(sprintf('%.2F %.2F m', ($x + $r) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F m', ($x + $r) * $k, ($hp - $y) * $k));
$xc = $x + $w - $r; $xc = $x + $w - $r;
$yc = $y + $r; $yc = $y + $r;
$this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - $y) * $k));
if (strpos($corners, '2') === false) if (strpos($corners, '2') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $y) * $k));
else } else {
$this->_Arc($xc + $r * $MyArc, $yc - $r, $xc + $r, $yc - $r * $MyArc, $xc + $r, $yc); $this->_Arc($xc + $r * $MyArc, $yc - $r, $xc + $r, $yc - $r * $MyArc, $xc + $r, $yc);
}
$xc = $x + $w - $r; $xc = $x + $w - $r;
$yc = $y + $h - $r; $yc = $y + $h - $r;
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $yc) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $yc) * $k));
if (strpos($corners, '3') === false) if (strpos($corners, '3') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - ($y + $h)) * $k));
else } else {
$this->_Arc($xc + $r, $yc + $r * $MyArc, $xc + $r * $MyArc, $yc + $r, $xc, $yc + $r); $this->_Arc($xc + $r, $yc + $r * $MyArc, $xc + $r * $MyArc, $yc + $r, $xc, $yc + $r);
}
$xc = $x + $r; $xc = $x + $r;
$yc = $y + $h - $r; $yc = $y + $h - $r;
$this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - ($y + $h)) * $k));
if (strpos($corners, '4') === false) if (strpos($corners, '4') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - ($y + $h)) * $k));
else } else {
$this->_Arc($xc - $r * $MyArc, $yc + $r, $xc - $r, $yc + $r * $MyArc, $xc - $r, $yc); $this->_Arc($xc - $r * $MyArc, $yc + $r, $xc - $r, $yc + $r * $MyArc, $xc - $r, $yc);
}
$xc = $x + $r; $xc = $x + $r;
$yc = $y + $r; $yc = $y + $r;
@ -555,8 +566,9 @@ class InvoiceGroupPdfHandler extends FPDF
if (strpos($corners, '1') === false) { if (strpos($corners, '1') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - $y) * $k));
$this->_out(sprintf('%.2F %.2F l', ($x + $r) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $r) * $k, ($hp - $y) * $k));
} else } else {
$this->_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r); $this->_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r);
}
$this->_out($op); $this->_out($op);
} }