Merge pull request #20758 from ns-info90/develop

Warehouse pdf generation issue #20632
This commit is contained in:
Laurent Destailleur 2022-05-01 12:16:02 +02:00 committed by GitHub
commit 96519d2a3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@stocks.sourceforge.net> /* Copyright (C) 2017 Laurent Destailleur <eldy@stocks.sourceforge.net>
* Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2022 Nicolas Silobre <nsilobre@ns-info90.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -255,6 +256,9 @@ class pdf_standard extends ModelePDFStock
$heightforinfotot = 40; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
$heightforfooter += 6;
}
if (class_exists('TCPDF')) { if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
@ -520,7 +524,7 @@ class pdf_standard extends ModelePDFStock
$pdf->SetLineStyle(array('dash'=>0)); $pdf->SetLineStyle(array('dash'=>0));
$pdf->SetFont('', 'B', $default_font_size - 1); $pdf->SetFont('', 'B', $default_font_size - 1);
$pdf->SetTextColor(0, 0, 120); $pdf->SetTextColor(0, 0, 0);
// Ref. // Ref.
$pdf->SetXY($this->posxdesc, $curY); $pdf->SetXY($this->posxdesc, $curY);
@ -677,58 +681,60 @@ class pdf_standard extends ModelePDFStock
} }
$pdf->SetDrawColor(128, 128, 128); $pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetFont('', 'B', $default_font_size - 3);
// Output Rect // Output Rect
//$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200))); $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200)));
$pdf->SetDrawColor(200, 200, 200); $pdf->SetDrawColor(200, 200, 200);
$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top); $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
$pdf->SetLineStyle(array('dash'=>0)); $pdf->SetLineStyle(array('dash'=>0));
$pdf->SetDrawColor(128, 128, 128); $pdf->SetDrawColor(128, 128, 128);
$pdf->SetTextColor(0, 0, 120); $pdf->SetTextColor(0, 0, 0);
if (empty($hidetop)) { if (empty($hidetop)) {
//$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); // line takes a position y in 2nd parameter and 4th parameter
$pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell($this->wref, 3, $outputlangs->transnoentities("Ref"), '', 'L'); $pdf->MultiCell($this->wref, 3, $outputlangs->transnoentities("Ref"), '', 'L');
} }
//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); $pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxlabel - 1, $tab_top + 1); $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
$pdf->MultiCell($this->posxqty - $this->posxlabel - 1, 2, $outputlangs->transnoentities("Label"), '', 'L'); $pdf->MultiCell($this->posxqty - $this->posxlabel - 1, 2, $outputlangs->transnoentities("Label"), '', 'C');
} }
//$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxqty - 1, $tab_top + 1); $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
$pdf->MultiCell($this->posxup - $this->posxqty - 1, 2, $outputlangs->transnoentities("Units"), '', 'R'); $pdf->MultiCell($this->posxup - $this->posxqty - 1, 2, $outputlangs->transnoentities("Units"), '', 'C');
} }
//$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxup - 1, $tab_top + 1); $pdf->SetXY($this->posxup - 1, $tab_top + 1);
$pdf->MultiCell($this->posxunit - $this->posxup - 1, 2, $outputlangs->transnoentities("AverageUnitPricePMPShort"), '', 'R'); $pdf->MultiCell($this->posxunit - $this->posxup - 1, 2, $outputlangs->transnoentities("AverageUnitPricePMPShort"), '', 'C');
} }
//$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1); $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', 'R'); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', 'C');
} }
//$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("SellPriceMin"), '', 'R'); $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("SellPriceMin"), '', 'C');
} }
//$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->postotalht - 1, $tab_top + 1); $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'C');
} }
if (empty($hidetop)) { if (empty($hidetop)) {
@ -810,7 +816,10 @@ class pdf_standard extends ModelePDFStock
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
if (!empty($object->lieu)) {
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Label").' : '.$object->lieu, '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Label").' : '.$object->lieu, '', 'R');
}
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
@ -831,6 +840,8 @@ class pdf_standard extends ModelePDFStock
$yafterright = $pdf->GetY(); $yafterright = $pdf->GetY();
// Description // Description
$nbpage = $pdf->getPage();
if ($nbpage == 1) {
$nexY = max($yafterleft, $yafterright); $nexY = max($yafterleft, $yafterright);
$nexY += 5; $nexY += 5;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
@ -876,6 +887,7 @@ class pdf_standard extends ModelePDFStock
} }
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1); $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
}
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$posy += 2; $posy += 2;