Hinweistext eingefügt

This commit is contained in:
BlubbFish 2020-05-11 20:04:09 +02:00
parent 2950cd9738
commit 6a91888426

View File

@ -40,70 +40,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
class pdf_thwlieferschein extends ModelePDFDeliveryOrder class pdf_thwlieferschein extends ModelePDFDeliveryOrder
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
*/ */
public $db; public $db;
/** /**
* @var string model name * @var string model name
*/ */
public $name; public $name;
/** /**
* @var string model description (short text) * @var string model description (short text)
*/ */
public $description; public $description;
/** /**
* @var string document type * @var string document type
*/ */
public $type; public $type;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP 5.5 = array(5, 5) * e.g.: PHP 5.5 = array(5, 5)
*/ */
public $phpmin = array(5, 5); public $phpmin = array(5, 5);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
* @var string * @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/** /**
* @var int page_largeur * @var int page_largeur
*/ */
public $page_largeur; public $page_largeur;
/** /**
* @var int page_hauteur * @var int page_hauteur
*/ */
public $page_hauteur; public $page_hauteur;
/** /**
* @var array format * @var array format
*/ */
public $format; public $format;
/** /**
* @var int marge_gauche * @var int marge_gauche
*/ */
public $marge_gauche; public $marge_gauche;
/** /**
* @var int marge_droite * @var int marge_droite
*/ */
public $marge_droite; public $marge_droite;
/** /**
* @var int marge_haute * @var int marge_haute
*/ */
public $marge_haute; public $marge_haute;
/** /**
* @var int marge_basse * @var int marge_basse
*/ */
public $marge_basse; public $marge_basse;
/** /**
@ -117,8 +117,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db) {
{
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
// Translations // Translations
@ -174,22 +173,21 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) {
{ // phpcs:enable
// phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager;
global $user,$langs,$conf,$mysoc,$hookmanager;
if (! is_object($outputlangs)) $outputlangs=$langs; if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -198,37 +196,29 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// Load translation files required by the page // Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "sendings", "deliveries")); $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "sendings", "deliveries"));
if ($conf->expedition->dir_output) if ($conf->expedition->dir_output) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen) {
{
$dir = $conf->expedition->dir_output."/receipt"; $dir = $conf->expedition->dir_output."/receipt";
$file = $dir . "/SPECIMEN.pdf"; $file = $dir . "/SPECIMEN.pdf";
} } else {
else
{
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition->dir_output."/receipt/" . $objectref; $dir = $conf->expedition->dir_output."/receipt/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf"; $file = $dir . "/" . $objectref . ".pdf";
} }
if (! file_exists($dir)) if (! file_exists($dir)) {
{ if (dol_mkdir($dir) < 0) {
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0; return 0;
} }
} }
if (file_exists($dir)) if (file_exists($dir)) {
{
// Add pdfgeneration hook // Add pdfgeneration hook
if (! is_object($hookmanager)) if (! is_object($hookmanager)) {
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db); $hookmanager=new HookManager($this->db);
} }
@ -241,33 +231,30 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 30; // Height reserved to output the info and total part $heightforinfotot = 30; // 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 ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) if (class_exists('TCPDF')) {
{ $pdf->setPrintHeader(false);
$pdf->setPrintHeader(false); $pdf->setPrintFooter(false);
$pdf->setPrintFooter(false); }
} $pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File
// Set path to the background PDF File if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
{ $tplidx = $pdf->importPage(1);
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); }
$tplidx = $pdf->importPage(1);
}
// We get the shipment that is the origin of delivery receipt // We get the shipment that is the origin of delivery receipt
$expedition=new Expedition($this->db); $expedition=new Expedition($this->db);
$result = $expedition->fetch($object->origin_id); $result = $expedition->fetch($object->origin_id);
// Now we get the order that is origin of shipment // Now we get the order that is origin of shipment
$commande = new Commande($this->db); $commande = new Commande($this->db);
if ($expedition->origin == 'commande') if ($expedition->origin == 'commande') {
{
$commande->fetch($expedition->origin_id); $commande->fetch($expedition->origin_id);
} }
$object->commande=$commande; // We set order of shipment onto delivery. $object->commande=$commande; // We set order of shipment onto delivery.
@ -327,11 +314,9 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// Incoterm // Incoterm
$height_incoterms = 0; $height_incoterms = 0;
if ($conf->incoterm->enabled) if ($conf->incoterm->enabled) {
{
$desc_incoterms = $object->getIncotermsForPDF(); $desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) if ($desc_incoterms) {
{
$tab_top = 88; $tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
@ -347,10 +332,20 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$height_incoterms += 4; $height_incoterms += 4;
} }
} }
$hinweis_wichtig = "<strong>".
"Für alle Artikel mit der Artikelnummer L-XXX oder L-XXX-XXX gilt:<br>".
"Das hiermit ausgegebene Material wurde durch das Land Nordrhein-Westfalen beschafft. Durch den Rhein-Sieg-Kreis erfolgt lediglich die Verteilung an die Einrichtungen des Gesundheitswesens.".
"</strong>";
if(empty($object->note_public)) {
$object->note_public = $hinweis_wichtig;
} else {
$object->note_public = $hinweis_wichtig + "<br><br>" + $object->note_public;
}
// Affiche notes // Affiche notes
if (! empty($object->note_public)) if (! empty($object->note_public)) {
{
$tab_top = 88 + $height_incoterms; $tab_top = 88 + $height_incoterms;
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
@ -364,9 +359,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$tab_height = $tab_height - $height_note; $tab_height = $tab_height - $height_note;
$tab_top = $nexY+6; $tab_top = $nexY+6;
} } else {
else
{
$height_note=0; $height_note=0;
} }
@ -375,8 +368,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$nexY = $tab_top + 11; $nexY = $tab_top + 11;
// Loop on each lines // Loop on each lines
for ($i = 0 ; $i < $nblines ; $i++) for ($i = 0 ; $i < $nblines ; $i++) {
{
//var_dump($object->lines[$i]); die; //var_dump($object->lines[$i]); die;
@ -392,47 +384,40 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
$showpricebeforepagebreak=1; $showpricebeforepagebreak=1;
$pdf->startTransaction(); $pdf->startTransaction();
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 3, $curX, $curY, $hideref, $hidedesc); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 3, $curX, $curY, $hideref, $hidedesc);
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak if ($pageposafter > $pageposbefore) { // There is a pagebreak
{ $pdf->rollbackTransaction(true);
$pdf->rollbackTransaction(true); $pageposafter=$pageposbefore;
$pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit;
//print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 4, $curX, $curY, $hideref, $hidedesc);
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 4, $curX, $curY, $hideref, $hidedesc); $posyafter=$pdf->GetY();
$posyafter=$pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { // There is no space left for total+free text
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text if ($i == ($nblines-1)) { // No more lines, and no space left to show total, so we create a new page
{ $pdf->AddPage('', '', true);
if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page if (! empty($tplidx)) $pdf->useTemplate($tplidx);
{ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->AddPage('', '', true); $pdf->setPage($pageposafter+1);
if (! empty($tplidx)) $pdf->useTemplate($tplidx); }
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } else {
$pdf->setPage($pageposafter+1); // We found a page break
}
}
else
{
// We found a page break
// Allows data in the first page if description is long enough to break in multiples pages // Allows data in the first page if description is long enough to break in multiples pages
if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
else else
$showpricebeforepagebreak = 0; $showpricebeforepagebreak = 0;
} }
} } else { // No pagebreak
else // No pagebreak $pdf->commitTransaction();
{ }
$pdf->commitTransaction();
}
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore); $pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute); $pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@ -444,48 +429,48 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
/* /*
// TVA // TVA
$pdf->SetXY($this->posxcomm, $curY); $pdf->SetXY($this->posxcomm, $curY);
$pdf->MultiCell(10, 4, ($object->lines[$i]->tva_tx < 0 ? '*':'').abs($object->lines[$i]->tva_tx), 0, 'R'); $pdf->MultiCell(10, 4, ($object->lines[$i]->tva_tx < 0 ? '*':'').abs($object->lines[$i]->tva_tx), 0, 'R');*/
*/// Prix unitaire HT avant remise // OTHER OPTIONES #TODO
//$pdf->SetXY($this->posxcomm, $curY); //$pdf->SetXY($this->posxcomm, $curY);
//$pdf->MultiCell($this->posxqty - $this->posxcomm, 4, print_r($arr_options, true), 0, 'R', 0); //$pdf->MultiCell($this->posxqty - $this->posxcomm, 4, print_r($arr_options, true), 0, 'R', 0);
//#TODO
// Quantity // Quantity
//$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); //$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY); $pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxremainingqty - $this->posxqty, 3, $object->lines[$i]->qty_shipped, 0, 'R'); $pdf->MultiCell($this->posxremainingqty - $this->posxqty, 3, $object->lines[$i]->qty_shipped, 0, 'R');
/*
// Remaining to ship // Remaining to ship
/*$pdf->SetXY($this->posxremainingqty, $curY); $pdf->SetXY($this->posxremainingqty, $curY);
$qtyRemaining = $object->lines[$i]->qty_asked - $object->commande->expeditions[$object->lines[$i]->fk_origin_line]; $qtyRemaining = $object->lines[$i]->qty_asked - $object->commande->expeditions[$object->lines[$i]->fk_origin_line];
$pdf->MultiCell($this->page_largeur-$this->marge_droite - $this->posxremainingqty, 3, $qtyRemaining, 0, 'R'); $pdf->MultiCell($this->page_largeur-$this->marge_droite - $this->posxremainingqty, 3, $qtyRemaining, 0, 'R');*/
*//*
// Remise sur ligne /*
$pdf->SetXY($this->posxdiscount, $curY); // Remise sur ligne
if ($object->lines[$i]->remise_percent) $pdf->SetXY($this->posxdiscount, $curY);
{ if ($object->lines[$i]->remise_percent) {
$pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R'); $pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R');
} }*/
// Total HT ligne /*
$pdf->SetXY($this->postotalht, $curY); // Total HT ligne
$total = price($object->lines[$i]->price * $object->lines[$i]->qty); $pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell(23, 3, $total, 0, 'R', 0); $total = price($object->lines[$i]->price * $object->lines[$i]->qty);
$pdf->MultiCell(23, 3, $total, 0, 'R', 0);*/
// Collecte des totaux par valeur de tva /*
// dans le tableau tva["taux"]=total_tva // Collecte des totaux par valeur de tva
$tvaligne=$object->lines[$i]->price * $object->lines[$i]->qty; // dans le tableau tva["taux"]=total_tva
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; $tvaligne=$object->lines[$i]->price * $object->lines[$i]->qty;
$this->tva[ (string) $object->lines[$i]->tva_tx ] += $tvaligne; if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
*/ $this->tva[ (string) $object->lines[$i]->tva_tx ] += $tvaligne;*/
// Add line // Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
{
$pdf->setPage($pageposafter); $pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
//$pdf->SetDrawColor(190,190,200); //$pdf->SetDrawColor(190,190,200);
@ -496,15 +481,11 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$nexY+=2; // Add space between lines $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages // Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) while ($pagenb < $pageposafter) {
{
$pdf->setPage($pagenb); $pdf->setPage($pagenb);
if ($pagenb == 1) if ($pagenb == 1) {
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
} } else {
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf, $object, $outputlangs, 1); $this->_pagefoot($pdf, $object, $outputlangs, 1);
@ -513,14 +494,10 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
} }
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) {
{ if ($pagenb == 1) {
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
} } else {
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf, $object, $outputlangs, 1); $this->_pagefoot($pdf, $object, $outputlangs, 1);
@ -533,13 +510,10 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1) {
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} } else {
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
@ -566,29 +540,27 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$pdf-> SetY(90); $pdf-> SetY(90);
$w=array(40,100,50); $w=array(40,100,50);
$header=array($outputlangs->transnoentities('Reference'), $header = array(
$outputlangs->transnoentities('Label'), $outputlangs->transnoentities('Reference'),
$outputlangs->transnoentities('Qty') $outputlangs->transnoentities('Label'),
); $outputlangs->transnoentities('Qty')
);
// Header // Header
$num = count($header); $num = count($header);
for($i = 0; $i < $num; $i++) for($i = 0; $i < $num; $i++) {
{ $pdf->Cell($w[$i],7,$header[$i],1,0,'C');
$pdf->Cell($w[$i],7,$header[$i],1,0,'C'); }
}
$pdf->Ln(); $pdf->Ln();
// Data // Data
foreach($waitingDelivery as $value) foreach($waitingDelivery as $value) {
{
$pdf->Cell($w[0], 6, $value['ref'], 1, 0, 'L'); $pdf->Cell($w[0], 6, $value['ref'], 1, 0, 'L');
$pdf->Cell($w[1], 6, $value['label'], 1, 0, 'L'); $pdf->Cell($w[1], 6, $value['label'], 1, 0, 'L');
$pdf->Cell($w[2], 6, $value['qty'], 1, 1, 'R'); $pdf->Cell($w[2], 6, $value['qty'], 1, 1, 'R');
if ($pdf->GetY() > 250) if ($pdf->GetY() > 250) {
{
$this->_pagefoot($pdf,$object,$outputlangs,1); $this->_pagefoot($pdf,$object,$outputlangs,1);
$pdf->AddPage('P', 'A4'); $pdf->AddPage('P', 'A4');
@ -599,8 +571,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$pdf-> SetY(40); $pdf-> SetY(40);
$num = count($header); $num = count($header);
for($i = 0; $i < $num; $i++) for($i = 0; $i < $num; $i++) {
{
$pdf->Cell($w[$i],7,$header[$i],1,0,'C'); $pdf->Cell($w[$i],7,$header[$i],1,0,'C');
} }
@ -618,8 +589,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$pdf->Output($file, 'F'); $pdf->Output($file, 'F');
// Add pdfgeneration hook // Add pdfgeneration hook
if (! is_object($hookmanager)) if (! is_object($hookmanager)) {
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db); $hookmanager=new HookManager($this->db);
} }
@ -627,8 +597,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action; global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) if ($reshook < 0) {
{
$this->error = $hookmanager->error; $this->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
@ -639,9 +608,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$this->result = array('fullpath'=>$file); $this->result = array('fullpath'=>$file);
return 1; // No error return 1; // No error
} } else {
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0; return 0;
} }
@ -652,7 +619,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Show miscellaneous information (payment mode, payment term, ...) * Show miscellaneous information (payment mode, payment term, ...)
* *
@ -662,9 +629,8 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @return void * @return void
*/ */
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) {
{ // phpcs:enable
// phpcs:enable
global $conf,$mysoc; global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -674,11 +640,11 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3; $larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3;
$pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25);
$pdf->SetXY($this->marge_gauche + 2, $posy + 2); $pdf->SetXY($this->marge_gauche + 2, $posy + 2);
$pdf->MultiCell($larg_sign, 2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":", '', 'L'); $pdf->MultiCell($larg_sign, 2, $outputlangs->convToOutputCharset($mysoc->name).":", '', 'L');
$pdf->Rect(2*$larg_sign+$this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->Rect(2*$larg_sign+$this->marge_gauche, $posy + 1, $larg_sign, 25);
$pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $posy + 2); $pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $posy + 2);
$pdf->MultiCell($larg_sign, 2, $outputlangs->trans("ForCustomer").':', '', 'L'); $pdf->MultiCell($larg_sign, 2, 'Kunde:', '', 'L');
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@ -694,8 +660,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
* @param int $hidebottom Hide bottom bar of array * @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) {
{
global $conf,$mysoc; global $conf,$mysoc;
// Force to disable hidetop and hidebottom // Force to disable hidetop and hidebottom
@ -711,16 +676,14 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// Output Rec // Output Rec
$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
if (empty($hidetop)) if (empty($hidetop)) {
{
$pdf->line($this->marge_gauche, $tab_top+10, $this->page_largeur-$this->marge_droite, $tab_top+10); $pdf->line($this->marge_gauche, $tab_top+10, $this->page_largeur-$this->marge_droite, $tab_top+10);
} }
$pdf->SetDrawColor(128, 128, 128); $pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
if (empty($hidetop)) if (empty($hidetop)) {
{
$pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell($this->posxcomm - $this->posxdesc, 2, $outputlangs->transnoentities("Designation"), '', 'L'); $pdf->MultiCell($this->posxcomm - $this->posxdesc, 2, $outputlangs->transnoentities("Designation"), '', 'L');
} }
@ -757,8 +720,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @return void * @return void
*/ */
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) {
{
global $conf,$langs,$hookmanager; global $conf,$langs,$hookmanager;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -766,8 +728,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark // Show Draft Watermark
if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) {
{
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
} }
@ -781,22 +742,17 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// Logo // Logo
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo) {
{ if (is_readable($logo)) {
if (is_readable($logo))
{
$height=pdf_getHeightForLogo($logo); $height=pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} } else {
else
{
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
} }
} } else $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
else $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
$pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetFont('', 'B', $default_font_size + 2);
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
@ -808,19 +764,15 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
$posy+=5; $posy+=5;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
if ($object->date_valid) if ($object->date_valid) {
{
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R');
} } else {
else
{
$pdf->SetTextColor(255, 0, 0); $pdf->SetTextColor(255, 0, 0);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
} }
if ($object->thirdparty->code_client) if ($object->thirdparty->code_client) {
{
$posy+=5; $posy+=5;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -834,8 +786,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// Show list of linked objects // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
if ($showaddress) if ($showaddress) {
{
// Sender properties // Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
@ -878,8 +829,7 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// If SHIPPING contact defined on order, we use it // If SHIPPING contact defined on order, we use it
$usecontact=false; $usecontact=false;
$arrayidcontact=$object->commande->getIdContact('external', 'SHIPPING'); $arrayidcontact=$object->commande->getIdContact('external', 'SHIPPING');
if (count($arrayidcontact) > 0) if (count($arrayidcontact) > 0) {
{
$usecontact=true; $usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]); $result=$object->fetch_contact($arrayidcontact[0]);
} }
@ -929,17 +879,16 @@ class pdf_thwlieferschein extends ModelePDFDeliveryOrder
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Show footer of page. Need this->emetteur object * Show footer of page. Need this->emetteur object
* *
* @param PDF $pdf PDF * @param PDF $pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text * @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text * @return int Return height of bottom margin including footer text
*/ */
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) {
{ global $conf;
global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); }
}
} }