Merge pull request #19509 from fr69400/patch3

FIX Html conversion check with PDF_BOLD_PRODUCT_LABEL
This commit is contained in:
Laurent Destailleur 2021-11-30 14:04:10 +01:00 committed by GitHub
commit f66f9082e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 4 deletions

View File

@ -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 '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("BoldLabelOnPDF").'</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('PDF_BOLD_PRODUCT_LABEL');
} else {
print $form->selectyesno('PDF_BOLD_PRODUCT_LABEL', (!empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) ? $conf->global->PDF_BOLD_PRODUCT_LABEL : 0, 1);
}
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("BoldRefAndPeriodOnPDF").'</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('PDF_BOLD_PRODUCT_REF_AND_PERIOD');
} else {
print $form->selectyesno('PDF_BOLD_PRODUCT_REF_AND_PERIOD', (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) ? $conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD : 0, 1);
}
print '</td></tr>';
// Desc
print '<tr class="oddeven"><td>'.$langs->trans("HideDescOnPDF").'</td><td>';

View File

@ -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", '<br>', $libelleproduitservice);
}
$libelleproduitservice = '<b>'.$libelleproduitservice.'</b>';
}
}
@ -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,7 +1495,11 @@ 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", '<br>', $libelleproduitservice);
}
$ref_prodserv = '<b>'.$ref_prodserv.'</b>';
// $prefix_prodserv and $ref_prodser are not HTML var
}
$libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
@ -1527,7 +1533,10 @@ 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)) {
$libelleproduitservice .= '<b style="color:#333666;" ><em>'."__N__</b> ".$period.'</em>';
if (!dol_textishtml($libelleproduitservice)) {
$libelleproduitservice = str_replace("\n", '<br>', $libelleproduitservice);
}
$libelleproduitservice .= '<br><b style="color:#333666;" ><em>'.$period.'</em></b>';
} else {
$libelleproduitservice .= "__N__".$period;
}

View File

@ -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

View File

@ -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