From 3987033aab88b28f9a5fadcbe8c3f06efa4ed0af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Jan 2018 20:53:36 +0100 Subject: [PATCH] Fix substitution in public notes of pdf --- htdocs/core/lib/functions.lib.php | 5 +++-- .../commande/doc/pdf_einstein.modules.php | 4 ++++ .../doc/pdf_standard.modules.php | 20 +++++++++++-------- .../modules/facture/doc/pdf_crabe.modules.php | 4 ++++ .../fichinter/doc/pdf_soleil.modules.php | 6 +++++- .../product/doc/pdf_standard.modules.php | 6 +++++- .../modules/propale/doc/pdf_azur.modules.php | 4 ++++ .../doc/pdf_aurore.modules.php | 12 +++++++---- 8 files changed, 45 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 96222974a13..d2333028203 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5620,10 +5620,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob } /** - * Make substition into a text string, replacing keys with vals from $substitutionarray (oldval=>newval). + * Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval). + * Texts like __(TranslationKey|langfile)__ and __[ConstantKey]__ are also replaced * * @param string $text Source string in which we must do substitution - * @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal') + * @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...) * @param Translate $outputlangs Output language * @return string Output string after substitutions * @see complete_substitutions_array diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index f5797e0fb2e..c3a7d3a7c56 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -348,6 +348,10 @@ class pdf_einstein extends ModelePDFCommandes } if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $tab_top = 88 + $height_incoterms; $pdf->SetFont('','', $default_font_size - 1); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 6182b5afca3..90746afed0e 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -262,10 +262,14 @@ class pdf_standard extends ModeleExpenseReport } if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $tab_top = 95; $pdf->SetFont('','', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; @@ -299,7 +303,7 @@ class pdf_standard extends ModeleExpenseReport $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); - + // Accountancy piece $pdf->SetXY($this->posxpiece, $curY); $pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-0.8, 4, $this->posxpiece-1, $curY, $piece_comptable, 0, 1); @@ -327,7 +331,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, dol_trunc($outputlangs->transnoentities($object->lines[$i]->type_fees_code), 12), 0, 'C'); // Project - if (! empty($conf->projet->enabled)) + if (! empty($conf->projet->enabled)) { $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY($this->posxprojet, $curY); @@ -429,7 +433,7 @@ class pdf_standard extends ModeleExpenseReport } $pdf->SetFont('','', 10); - + // Show total area box $posy=$bottomlasttab+5; $pdf->SetXY(100, $posy); @@ -475,7 +479,7 @@ class pdf_standard extends ModeleExpenseReport @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; // Pas d'erreur } else @@ -585,7 +589,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetFont('','B', $default_font_size + 2); $pdf->SetTextColor(111,81,124); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); - + if ($showaddress) { // Sender properties @@ -731,7 +735,7 @@ class pdf_standard extends ModeleExpenseReport function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') { global $conf; - + // Force to disable hidetop and hidebottom $hidebottom=0; if ($hidetop) $hidetop=-1; @@ -789,7 +793,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C'); } - if (!empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { // Project $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 9a839a826be..139e192a077 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -382,6 +382,10 @@ class pdf_crabe extends ModelePDFFactures } if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $tab_top = 88 + $height_incoterms; $pdf->SetFont('','', $default_font_size - 1); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 93e5aa11182..f63f05b07f9 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -211,6 +211,10 @@ class pdf_soleil extends ModelePDFFicheinter $notetoshow=empty($object->note_public)?'':$object->note_public; if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $tab_top = 88; $pdf->SetFont('','', $default_font_size - 1); @@ -401,7 +405,7 @@ class pdf_soleil extends ModelePDFFicheinter @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; } else diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index b42fa3a1fb2..a4b65bbe38a 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -287,6 +287,10 @@ class pdf_standard extends ModelePDFProduct } if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $tab_top = 88; $pdf->SetFont('','', $default_font_size - 1); @@ -540,7 +544,7 @@ class pdf_standard extends ModelePDFProduct @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index dc687b0d2c9..87437138812 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -388,6 +388,10 @@ class pdf_azur extends ModelePDFPropales } if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $tab_top = 88 + $height_incoterms; $pdf->SetFont('','', $default_font_size - 1); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index ecdd99d140f..3dfda4a30dd 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -314,6 +314,10 @@ class pdf_aurore extends ModelePDFSupplierProposal } if ($notetoshow) { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $tab_top = 88; $pdf->SetFont('','', $default_font_size - 1); @@ -380,11 +384,11 @@ class pdf_aurore extends ModelePDFSupplierProposal $curX = $this->posxdesc-1; $pdf->startTransaction(); - if ($posYAfterImage > 0) + if ($posYAfterImage > 0) { $descWidth = $this->posxpicture-$curX; - } - else + } + else { $descWidth = $this->posxtva-$curX; } @@ -606,7 +610,7 @@ class pdf_aurore extends ModelePDFSupplierProposal @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; // Pas d'erreur } else