From 530fb167a2dc8d4f97e585e27e2fd57177f4e091 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Oct 2024 22:38:51 +0200 Subject: [PATCH] NEW Support option PDF_ADD_POSITION on shipment espadon template --- .../expedition/doc/pdf_espadon.modules.php | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 40415f5f2b9..c94fdc97f78 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -98,6 +98,7 @@ class pdf_espadon extends ModelePdfExpedition $this->description = $langs->trans("DocumentModelStandardPDF"); $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + // Dimension page $this->type = 'pdf'; $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; @@ -114,7 +115,7 @@ class pdf_espadon extends ModelePdfExpedition // Get source company $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { + if (empty($this->emetteur->country_code)) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -189,9 +190,9 @@ class pdf_espadon extends ModelePdfExpedition $realpath = ''; + $arephoto = false; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { - if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { - // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo if ($obj['photo_vignette']) { $filename = $obj['photo_vignette']; } else { @@ -202,11 +203,12 @@ class pdf_espadon extends ModelePdfExpedition } $realpath = $dir.$filename; + $arephoto = true; $this->atleastonephoto = true; break; } - if ($realpath) { + if ($realpath && $arephoto) { $realpatharray[$i] = $realpath; } } @@ -328,7 +330,7 @@ class pdf_espadon extends ModelePdfExpedition } } - // Public note and Tracking code + // Displays notes. Here we are still on code executed only for the first page. $notetoshow = empty($object->note_public) ? '' : $object->note_public; // Extrafields in note @@ -582,6 +584,10 @@ class pdf_espadon extends ModelePdfExpedition $posYAfterDescription = 0; $heightforsignature = 0; + if ($this->getColumnStatus('position')) { + $this->printStdColumnContent($pdf, $curY, 'position', (string) ($i + 1)); + } + if ($this->getColumnStatus('photo')) { // We start with Photo of product line if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) { // If photo too high, we moved completely on new page @@ -1282,6 +1288,24 @@ class pdf_espadon extends ModelePdfExpedition */ $rank = 0; // do not use negative rank + $this->cols['position'] = array( + 'rank' => $rank, + 'width' => 10, + 'status' => getDolGlobalInt('PDF_ESPADON_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false), + 'title' => array( + 'textkey' => '#', // use lang key is useful in somme case with module + 'align' => 'C', + // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + // 'label' => ' ', // the final label + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'align' => 'C', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + + $rank = 5; // do not use negative rank $this->cols['desc'] = array( 'rank' => $rank, 'width' => false, // only for desc @@ -1291,14 +1315,15 @@ class pdf_espadon extends ModelePdfExpedition 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( - 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); + // Image of product $rank += 10; $this->cols['photo'] = array( 'rank' => $rank,