From 5a165ae2bfd5d66e6b895120de4bb7acb1b1a3e8 Mon Sep 17 00:00:00 2001
From: fr69400 <82267780+fr69400@users.noreply.github.com>
Date: Sun, 28 Nov 2021 14:40:15 +0100
Subject: [PATCH 1/4] FIX PDF_NOLD_PRODUCT_LABEL
---
htdocs/admin/pdf.php | 23 +++++++++++++++++++++++
htdocs/core/lib/pdf.lib.php | 19 ++++++++++++++-----
htdocs/langs/en_US/admin.lang | 2 ++
htdocs/langs/fr_FR/admin.lang | 2 ++
4 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index c22d365d932..c4ae5d59225 100644
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -170,6 +170,13 @@ if ($action == 'update') {
dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity);
}
+ if (GETPOSTISSET('PDF_BOLD_PRODUCT_LABEL')) {
+ dolibarr_set_const($db, "PDF_BOLD_PRODUCT_LABEL", GETPOST('PDF_BOLD_PRODUCT_LABEL', 'alpha'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')){
+ dolibarr_set_const($db, "PDF_BOLD_PRODUCT_REF_AND_PERIOD", GETPOST('PDF_BOLD_PRODUCT_REF_AND_PERIOD', 'alpha'), 'chaine', 0, '', $conf->entity);
+ }
+
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
@@ -499,6 +506,22 @@ if ($conf->use_javascript_ajax) {
}
print '';
+print '
| '.$langs->trans("HideDescOnPDF").' | ';
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 5121506087c..7a78db5a14e 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1363,7 +1363,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
// Description short of product line
$libelleproduitservice = $label;
if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
- // This part of code is bugged. It introduces a HTML tag making the label a html string but without converting \n into br if it was a full text non html string before.
+ if (!dol_textishtml($libelleproduitservice)){
+ $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
+ }
$libelleproduitservice = ''.$libelleproduitservice.'';
}
}
@@ -1375,7 +1377,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) {
$tmparrayofsubproducts = reset($prodser->sousprods);
foreach ($tmparrayofsubproducts as $subprodval) {
- $libelleproduitservice .= "\n * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')';
+ $libelleproduitservice .= "__N__ * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')';
}
}
}
@@ -1419,7 +1421,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
if (empty($hidedesc)) {
if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) {
- $libelleproduitservice = $desc."\n".$libelleproduitservice;
+ $libelleproduitservice = $desc."__N__".$libelleproduitservice;
} else {
if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) {
$libelleproduitservice = $desc;
@@ -1493,10 +1495,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
+ if (!dol_textishtml($libelleproduitservice)){
+ $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
+ }
$ref_prodserv = ''.$ref_prodserv.'';
- }
+ // $prefix_prodserv and $ref_prodser are not HTML var
+ }
$libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
-
+
// Add an additional description for the category products
if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
@@ -1527,6 +1533,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
//print '>'.$outputlangs->charset_output.','.$period;
if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
+ if (!dol_textishtml($libelleproduitservice)){
+ $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
+ }
$libelleproduitservice .= ''."__N__ ".$period.'';
} else {
$libelleproduitservice .= "__N__".$period;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index c258df38441..c36f29fa0d7 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1,4 +1,6 @@
# Dolibarr language file - Source file is en_US - admin
+BoldRefAndPeriodOnPDF=Bold reference and period in PDF
+BoldLabelOnPDF=Bold label in PDF
Foundation=Foundation
Version=Version
Publisher=Publisher
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 0b4d7aa4f10..9d2de4d5ca8 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -1,4 +1,6 @@
# Dolibarr language file - Source file is en_US - admin
+BoldRefAndPeriodOnPDF=Mettre en gras la référence et la période dans les PDF
+BoldLabelOnPDF=Mettre en gras le label des produits dans les PDF
Foundation=Association
Version=Version
Publisher=Editeur
From a933793b8a43903fb6c514ae89da9df96690f9af Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Sun, 28 Nov 2021 13:42:25 +0000
Subject: [PATCH 2/4] Fixing style errors.
---
htdocs/admin/pdf.php | 2 +-
htdocs/core/lib/pdf.lib.php | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index c4ae5d59225..18a4ca0825f 100644
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -173,7 +173,7 @@ if ($action == 'update') {
if (GETPOSTISSET('PDF_BOLD_PRODUCT_LABEL')) {
dolibarr_set_const($db, "PDF_BOLD_PRODUCT_LABEL", GETPOST('PDF_BOLD_PRODUCT_LABEL', 'alpha'), 'chaine', 0, '', $conf->entity);
}
- if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')){
+ if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')) {
dolibarr_set_const($db, "PDF_BOLD_PRODUCT_REF_AND_PERIOD", GETPOST('PDF_BOLD_PRODUCT_REF_AND_PERIOD', 'alpha'), 'chaine', 0, '', $conf->entity);
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 7a78db5a14e..2d8ce3b2996 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1363,7 +1363,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
// Description short of product line
$libelleproduitservice = $label;
if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
- if (!dol_textishtml($libelleproduitservice)){
+ if (!dol_textishtml($libelleproduitservice)) {
$libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
}
$libelleproduitservice = ''.$libelleproduitservice.'';
@@ -1495,14 +1495,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
- if (!dol_textishtml($libelleproduitservice)){
+ if (!dol_textishtml($libelleproduitservice)) {
$libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
}
$ref_prodserv = ''.$ref_prodserv.'';
// $prefix_prodserv and $ref_prodser are not HTML var
- }
+ }
$libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
-
+
// Add an additional description for the category products
if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
@@ -1533,7 +1533,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
//print '>'.$outputlangs->charset_output.','.$period;
if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
- if (!dol_textishtml($libelleproduitservice)){
+ if (!dol_textishtml($libelleproduitservice)) {
$libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
}
$libelleproduitservice .= ''."__N__ ".$period.'';
From 078a0400783725cb84695719071ccec5f901786f Mon Sep 17 00:00:00 2001
From: fr69400 <82267780+fr69400@users.noreply.github.com>
Date: Tue, 30 Nov 2021 12:13:21 +0100
Subject: [PATCH 3/4] Update pdf.lib.php
---
htdocs/core/lib/pdf.lib.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 7a78db5a14e..5763187aabd 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1364,7 +1364,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
$libelleproduitservice = $label;
if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
if (!dol_textishtml($libelleproduitservice)){
- $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
+ $libelleproduitservice = str_replace("\n", ' ', $libelleproduitservice);
}
$libelleproduitservice = ''.$libelleproduitservice.'';
}
@@ -1496,7 +1496,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
if (!dol_textishtml($libelleproduitservice)){
- $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
+ $libelleproduitservice = str_replace("\n", ' ', $libelleproduitservice);
}
$ref_prodserv = ''.$ref_prodserv.'';
// $prefix_prodserv and $ref_prodser are not HTML var
@@ -1534,9 +1534,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
//print '>'.$outputlangs->charset_output.','.$period;
if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
if (!dol_textishtml($libelleproduitservice)){
- $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice);
+ $libelleproduitservice = str_replace("\n", ' ', $libelleproduitservice);
}
- $libelleproduitservice .= ''."__N__ ".$period.'';
+ $libelleproduitservice .= ' '.$period.'';
} else {
$libelleproduitservice .= "__N__".$period;
}
From c807286f0b77df8cc743549477d5b086ae1e2417 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Tue, 30 Nov 2021 11:17:48 +0000
Subject: [PATCH 4/4] Fixing style errors.
---
htdocs/core/lib/pdf.lib.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index eef5ca9ada3..b8a8551ff65 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1363,7 +1363,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
// Description short of product line
$libelleproduitservice = $label;
if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
- if (!dol_textishtml($libelleproduitservice)){
+ if (!dol_textishtml($libelleproduitservice)) {
$libelleproduitservice = str_replace("\n", ' ', $libelleproduitservice);
}
$libelleproduitservice = ''.$libelleproduitservice.'';
@@ -1495,7 +1495,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
- if (!dol_textishtml($libelleproduitservice)){
+ if (!dol_textishtml($libelleproduitservice)) {
$libelleproduitservice = str_replace("\n", ' ', $libelleproduitservice);
}
$ref_prodserv = ''.$ref_prodserv.'';
@@ -1533,7 +1533,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
//print '>'.$outputlangs->charset_output.','.$period;
if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
- if (!dol_textishtml($libelleproduitservice)){
+ if (!dol_textishtml($libelleproduitservice)) {
$libelleproduitservice = str_replace("\n", ' ', $libelleproduitservice);
}
$libelleproduitservice .= ' '.$period.'';
|