From 94c69c08bae0f9058960760fc080e5bf0ff8e6b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 May 2024 16:41:48 +0200 Subject: [PATCH] NEW Add option PDF_ADD_POSITION --- .../commande/doc/pdf_eratosthene.modules.php | 24 ++++++++++++++- .../facture/doc/pdf_sponge.modules.php | 24 ++++++++++++++- .../modules/propale/doc/pdf_cyan.modules.php | 29 +++++++++++++++++-- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index a1558946c5b..c7258a9f3fd 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -557,6 +557,10 @@ class pdf_eratosthene extends ModelePDFCommandes $posYAfterImage = 0; $posYAfterDescription = 0; + if ($this->getColumnStatus('position')) { + $this->printStdColumnContent($pdf, $curY, 'position', $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 + $heightforinfotot))) { // If photo too high, we moved completely on new page @@ -1728,7 +1732,7 @@ class pdf_eratosthene extends ModelePDFCommandes */ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf, $hookmanager; + global $hookmanager; // Default field style for content $this->defaultContentsFieldsStyle = array( @@ -1761,6 +1765,24 @@ class pdf_eratosthene extends ModelePDFCommandes */ $rank = 0; // do not use negative rank + $this->cols['position'] = array( + 'rank' => $rank, + 'width' => 10, + 'status' => getDolGlobalInt('PDF_ERATOSHTENE_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 diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index bd3be2be8b5..8d5961d4a1b 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -714,6 +714,10 @@ class pdf_sponge extends ModelePDFFactures $posYAfterImage = 0; $posYAfterDescription = 0; + if ($this->getColumnStatus('position')) { + $this->printStdColumnContent($pdf, $curY, 'position', $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 - $page_bottom_margin)) { // If photo too high, we moved completely on new page @@ -2509,7 +2513,7 @@ class pdf_sponge extends ModelePDFFactures */ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf, $hookmanager; + global $hookmanager; // Default field style for content $this->defaultContentsFieldsStyle = array( @@ -2542,6 +2546,24 @@ class pdf_sponge extends ModelePDFFactures */ $rank = 0; // do not use negative rank + $this->cols['position'] = array( + 'rank' => $rank, + 'width' => 10, + 'status' => getDolGlobalInt('PDF_SPONGE_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 diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index b4be422e6b0..eaf82c1ade9 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -568,6 +568,10 @@ class pdf_cyan extends ModelePDFPropales $posYAfterImage = 0; $posYAfterDescription = 0; + if ($this->getColumnStatus('position')) { + $this->printStdColumnContent($pdf, $curY, 'position', $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 @@ -1602,11 +1606,12 @@ class pdf_cyan extends ModelePDFPropales $posy += 3; $pdf->SetFont('', '', $default_font_size - 2); - if ($object->ref_client) { + $ref_customer = $object->ref_customer ?? $object->ref_client; + if ($ref_customer) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($ref_customer), 65), '', 'R'); } if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) { @@ -1864,7 +1869,7 @@ class pdf_cyan extends ModelePDFPropales */ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf, $hookmanager; + global $hookmanager; // Default field style for content $this->defaultContentsFieldsStyle = array( @@ -1897,6 +1902,24 @@ class pdf_cyan extends ModelePDFPropales */ $rank = 0; // do not use negative rank + $this->cols['position'] = array( + 'rank' => $rank, + 'width' => 10, + 'status' => getDolGlobalInt('PDF_CYAN_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