This commit is contained in:
parent
0e4a019145
commit
235da11fe3
@ -31,7 +31,8 @@ use \FPDF;
|
||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||
use OCA\Gestion\Helpers\PriceHelpers;
|
||||
|
||||
class InvoiceGroupPdfHandler extends FPDF {
|
||||
class InvoiceGroupPdfHandler extends FPDF
|
||||
{
|
||||
public $factureData = [];
|
||||
public $logo = null;
|
||||
|
||||
@ -58,8 +59,7 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
if ($this->logo != "nothing") {
|
||||
$this->Image($this->logoPath . "logo.png", 2, 10, 75, 25);
|
||||
$this->AddWatermark();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->Cell(55, 30, '');
|
||||
}
|
||||
$this->SetMargins(3, 0, 3);
|
||||
@ -99,7 +99,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$this->SetDrawColor(0, 0, 0, $alpha * 255);
|
||||
}
|
||||
|
||||
public function DrawInvoiceCompanyAndClientInfo(){
|
||||
public function DrawInvoiceCompanyAndClientInfo()
|
||||
{
|
||||
$this->DrawInvoiceCompanyInfo();
|
||||
$this->DrawInvoiceClientInfo();
|
||||
|
||||
@ -122,7 +123,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$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->productsCount = $this->factureData["productsCount"];
|
||||
$this->devisCount = count($this->factureData['devis']);
|
||||
@ -132,19 +134,22 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$this->logo = $logo;
|
||||
}
|
||||
|
||||
public function GetInvoiceFilename(){
|
||||
public function GetInvoiceFilename()
|
||||
{
|
||||
$factureNum = $this->factureData['num'];
|
||||
$factureNum = str_replace('/', '-', $factureNum);
|
||||
$clientName = str_replace(' ', ' ', $this->factureData['group_name'] ?? '');
|
||||
return 'FACTURE' . '_' . $factureNum . '_' . mb_strtoupper($clientName, 'UTF-8');
|
||||
}
|
||||
|
||||
public function DrawPageNumbersText($pageNumber,$pageCount){
|
||||
public function DrawPageNumbersText($pageNumber, $pageCount)
|
||||
{
|
||||
$this->SetXY(120, 5);
|
||||
$this->Cell(160, 8, $pageNumber . '/' . $pageCount, 0, 0, 'C');
|
||||
}
|
||||
|
||||
public function DrawArticlesTable(){
|
||||
public function DrawArticlesTable()
|
||||
{
|
||||
$pageCount = ceil($this->devisCount / $this->maxArticlePerPage);
|
||||
$pageNumber = 1;
|
||||
while ($pageNumber <= $pageCount) {
|
||||
@ -159,7 +164,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
}
|
||||
}
|
||||
|
||||
public function DrawInvoiceCompanyInfo(){
|
||||
public function DrawInvoiceCompanyInfo()
|
||||
{
|
||||
$this->SetY(40);
|
||||
$this->SetFont('ComicSans', '', 10);
|
||||
$this->Cell(0, $this->interLigneHeader, FileExportHelpers::FormatTextForExport($this->factureData['configuration']->entreprise), 0, 1);
|
||||
@ -168,7 +174,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$this->Cell(0, $this->interLigneHeader, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->factureData['configuration']->telephone), 0, 1);
|
||||
$this->Cell(0, $this->interLigneHeader, 'Mail : ' . $this->factureData['configuration']->mail, 0, 1);
|
||||
}
|
||||
public function DrawInvoiceClientInfo(){
|
||||
public function DrawInvoiceClientInfo()
|
||||
{
|
||||
$this->SetFont('ComicSans', '', 10);
|
||||
$clientName = $this->factureData['group_name'];
|
||||
$clientInfoXAxis = 135;
|
||||
@ -207,8 +214,7 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$modulo = (int) round($gapBetweenAddressLines / $this->interLigneHeader);
|
||||
$clientInfoYAxis += $modulo * $this->interLigneHeader;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
}
|
||||
|
||||
@ -237,9 +243,10 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
}
|
||||
}
|
||||
|
||||
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
|
||||
$this->Cell(0, $this->interLigneHeader, trim(FileExportHelpers::FormatTextForExport($this->factureData['client_adress_city'])));
|
||||
if ($this->factureData['siret']) {
|
||||
$clientInfoYAxis += $this->interLigneHeader;
|
||||
$this->SetXY($clientInfoXAxis, $clientInfoYAxis);
|
||||
$this->Cell(0, $this->interLigneHeader, 'Siret: ' . $this->factureData['siret']);
|
||||
}
|
||||
@ -247,7 +254,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
|
||||
|
||||
|
||||
public function DrawInvoiceInfoTable(){
|
||||
public function DrawInvoiceInfoTable()
|
||||
{
|
||||
$startInvoiceInfoTable = 70;
|
||||
$this->setY($startInvoiceInfoTable);
|
||||
|
||||
@ -273,7 +281,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$this->startingYOfArticlesTable = $startInvoiceInfoTable + 20;
|
||||
}
|
||||
|
||||
public function DrawArticlesTableRect(){
|
||||
public function DrawArticlesTableRect()
|
||||
{
|
||||
|
||||
$this->SetLineWidth(0.2);
|
||||
$gapBetweenStartingOfArticlesTableAndColumnName = 7;
|
||||
@ -292,7 +301,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$this->Line(182 + $additionalMargRight, $this->startingYOfArticlesTable, 182 + $additionalMargRight, $endingLine);
|
||||
}
|
||||
|
||||
public function DrawArticlesTableHeader(){
|
||||
public function DrawArticlesTableHeader()
|
||||
{
|
||||
$additionalMargRight = 1;
|
||||
$tvaValue = $this->factureData["configuration"]->tva_default;
|
||||
$columnNameY = $this->startingYOfArticlesTable - 1.5;
|
||||
@ -313,7 +323,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$this->Cell(20, 10, "Prix Uni. TTC", 0, 0, 'C');
|
||||
}
|
||||
|
||||
public function DrawArticlesTableValue(){
|
||||
public function DrawArticlesTableValue()
|
||||
{
|
||||
// Set espacement avant de continue
|
||||
|
||||
$this->SetFont('ComicSans', '', 10);
|
||||
@ -390,7 +401,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
|
||||
}
|
||||
|
||||
public function DrawBankAndTotalPriceInfo(){
|
||||
public function DrawBankAndTotalPriceInfo()
|
||||
{
|
||||
$startOfYAfterMainTable = 239;
|
||||
$this->SetY($startOfYAfterMainTable);
|
||||
$this->SetFont('ComicSans', '', 8);
|
||||
@ -428,7 +440,8 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
}
|
||||
}
|
||||
|
||||
public function SetFactureContent(){
|
||||
public function SetFactureContent()
|
||||
{
|
||||
$this->AddPage();
|
||||
$this->SetMargins(2, 0, 3);
|
||||
$this->DrawArticlesTable();
|
||||
@ -445,8 +458,7 @@ class InvoiceGroupPdfHandler 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);
|
||||
}
|
||||
}
|
||||
@ -469,11 +481,9 @@ class InvoiceGroupPdfHandler 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;
|
||||
@ -484,21 +494,17 @@ class InvoiceGroupPdfHandler 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;
|
||||
@ -545,12 +551,10 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
$xc = $x + $r;
|
||||
$yc = $y + $r;
|
||||
$this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - $yc) * $k));
|
||||
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 + $r) * $k, ($hp - $y) * $k));
|
||||
}
|
||||
else
|
||||
} else
|
||||
$this->_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r);
|
||||
$this->_out($op);
|
||||
}
|
||||
@ -558,7 +562,14 @@ class InvoiceGroupPdfHandler extends FPDF {
|
||||
private function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
|
||||
{
|
||||
$h = $this->h;
|
||||
$this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1*$this->k, ($h-$y1)*$this->k,
|
||||
$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
|
||||
$this->_out(sprintf(
|
||||
'%.2F %.2F %.2F %.2F %.2F %.2F c ',
|
||||
$x1 * $this->k,
|
||||
($h - $y1) * $this->k,
|
||||
$x2 * $this->k,
|
||||
($h - $y2) * $this->k,
|
||||
$x3 * $this->k,
|
||||
($h - $y3) * $this->k
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user