Merge pull request #20758 from ns-info90/develop
Warehouse pdf generation issue #20632
This commit is contained in:
commit
96519d2a3b
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@stocks.sourceforge.net>
|
||||
* 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
|
||||
* 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
|
||||
$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)
|
||||
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
|
||||
$heightforfooter += 6;
|
||||
}
|
||||
|
||||
if (class_exists('TCPDF')) {
|
||||
$pdf->setPrintHeader(false);
|
||||
@ -520,7 +524,7 @@ class pdf_standard extends ModelePDFStock
|
||||
$pdf->SetLineStyle(array('dash'=>0));
|
||||
|
||||
$pdf->SetFont('', 'B', $default_font_size - 1);
|
||||
$pdf->SetTextColor(0, 0, 120);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
// Ref.
|
||||
$pdf->SetXY($this->posxdesc, $curY);
|
||||
@ -677,58 +681,60 @@ class pdf_standard extends ModelePDFStock
|
||||
}
|
||||
|
||||
$pdf->SetDrawColor(128, 128, 128);
|
||||
|
||||
$pdf->SetFont('', 'B', $default_font_size - 3);
|
||||
|
||||
// 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->SetDrawColor(200, 200, 200);
|
||||
$pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
|
||||
$pdf->SetLineStyle(array('dash'=>0));
|
||||
$pdf->SetDrawColor(128, 128, 128);
|
||||
$pdf->SetTextColor(0, 0, 120);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
|
||||
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->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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
@ -810,7 +816,10 @@ class pdf_standard extends ModelePDFStock
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Label").' : '.$object->lieu, '', 'R');
|
||||
if (!empty($object->lieu)) {
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Label").' : '.$object->lieu, '', 'R');
|
||||
}
|
||||
|
||||
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
@ -831,51 +840,54 @@ class pdf_standard extends ModelePDFStock
|
||||
$yafterright = $pdf->GetY();
|
||||
|
||||
// Description
|
||||
$nexY = max($yafterleft, $yafterright);
|
||||
$nexY += 5;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
$nbpage = $pdf->getPage();
|
||||
if ($nbpage == 1) {
|
||||
$nexY = max($yafterleft, $yafterright);
|
||||
$nexY += 5;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
|
||||
$calcproductsunique = $object->nb_different_products();
|
||||
$calcproducts = $object->nb_products();
|
||||
$calcproductsunique = $object->nb_different_products();
|
||||
$calcproducts = $object->nb_products();
|
||||
|
||||
// Total nb of different products
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
// Total nb of different products
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
|
||||
// Nb of products
|
||||
$valtoshow = price2num($calcproducts['nb'], 'MS');
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow) ? '0' : $valtoshow), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
// Nb of products
|
||||
$valtoshow = price2num($calcproducts['nb'], 'MS');
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow) ? '0' : $valtoshow), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
|
||||
// Value
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
// Value
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
|
||||
// Value
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Date").' : </b>'.dol_print_date(dol_now(), 'dayhour'), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
// Value
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Date").' : </b>'.dol_print_date(dol_now(), 'dayhour'), 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
|
||||
// Last movement
|
||||
$sql = "SELECT max(m.datem) as datem";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
|
||||
$sql .= " WHERE m.fk_entrepot = ".((int) $object->id);
|
||||
$resqlbis = $this->db->query($sql);
|
||||
if ($resqlbis) {
|
||||
$obj = $this->db->fetch_object($resqlbis);
|
||||
$lastmovementdate = $this->db->jdate($obj->datem);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
// Last movement
|
||||
$sql = "SELECT max(m.datem) as datem";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
|
||||
$sql .= " WHERE m.fk_entrepot = ".((int) $object->id);
|
||||
$resqlbis = $this->db->query($sql);
|
||||
if ($resqlbis) {
|
||||
$obj = $this->db->fetch_object($resqlbis);
|
||||
$lastmovementdate = $this->db->jdate($obj->datem);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
if ($lastmovementdate) {
|
||||
$toWrite = dol_print_date($lastmovementdate, 'dayhour').' ';
|
||||
} else {
|
||||
$toWrite = $outputlangs->transnoentities("None");
|
||||
}
|
||||
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
|
||||
}
|
||||
|
||||
if ($lastmovementdate) {
|
||||
$toWrite = dol_print_date($lastmovementdate, 'dayhour').' ';
|
||||
} else {
|
||||
$toWrite = $outputlangs->transnoentities("None");
|
||||
}
|
||||
|
||||
$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
|
||||
$nexY = $pdf->GetY();
|
||||
|
||||
$posy += 2;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user