From ce15dc25c8a7482b287e0a1b92bc242e60994e09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Apr 2025 19:46:52 +0200 Subject: [PATCH] FIX HTML broken by the trunc. --- .../accountancy/class/bookkeeping.class.php | 35 +++++++++++++------ .../journal/expensereportsjournal.php | 6 ++-- .../accountancy/journal/purchasesjournal.php | 8 ++--- htdocs/accountancy/journal/sellsjournal.php | 10 +++--- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 324937f868e..2d9cb5361ac 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2441,42 +2441,55 @@ class BookKeeping extends CommonObject } /** - * Generate label operation when operation is transferred into accounting + * Generate label operation when operation is transferred into accounting according to ACCOUNTING_LABEL_OPERATION_ON_TRANSFER + * If ACCOUNTING_LABEL_OPERATION_ON_TRANSFER is 0, we concat thirdparty name, ref and label. + * If ACCOUNTING_LABEL_OPERATION_ON_TRANSFER is 1, we concat thirdparty name, ref. + * If ACCOUNTING_LABEL_OPERATION_ON_TRANSFER is 2, we return just thirdparty name * * @param string $thirdpartyname Thirdparty name * @param string $reference Reference of the element * @param string $labelaccount Label of the accounting account + * @param string $full 0=Default, 1=Keep label intact (no trunc so HTML content is not corrupted) * @return string Label of the operation */ - public function accountingLabelForOperation($thirdpartyname, $reference, $labelaccount) + public function accountingLabelForOperation($thirdpartyname, $reference, $labelaccount, $full = 0) { - global $conf; - $accountingLabelOperation = ''; - if (!getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') || getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 0) { + if (!getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER')) { $truncThirdpartyName = 16; // Avoid trunc with dot in accountancy for the compatibility with another accounting software - $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (empty($full)) { + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + } else { + $accountingLabelOperation = $thirdpartyname; + } if (!empty($reference)) { $accountingLabelOperation .= ' - '. $reference; } if (!empty($labelaccount)) { $accountingLabelOperation .= ' - '. $labelaccount; } - } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 1) { + } elseif (getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 1) { $truncThirdpartyName = 32; // Avoid trunc with dot in accountancy for the compatibility with another accounting software - $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (empty($full)) { + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + } else { + $accountingLabelOperation = $thirdpartyname; + } if (!empty($reference)) { $accountingLabelOperation .= ' - '. $reference; } - } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 2) { + } elseif (getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 2) { $truncThirdpartyName = 64; // Avoid trunc with dot in accountancy for the compatibility with another accounting software - $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (empty($full)) { + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + } else { + $accountingLabelOperation = $thirdpartyname; + } } - dol_syslog('label'.$accountingLabelOperation, LOG_ERR); return $accountingLabelOperation; } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 21131a25177..aaa0c43b635 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -765,7 +765,7 @@ if (empty($action) || $action == 'view') { print ''; $userstatic->id = $tabuser[$key]['id']; $userstatic->name = $tabuser[$key]['name']; - print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -801,7 +801,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount"), 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -841,7 +841,7 @@ if (empty($action) || $action == 'view') { $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); - print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index afe272ba7d9..5565f3ac1af 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -1173,7 +1173,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount"), 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1216,7 +1216,7 @@ if (empty($action) || $action == 'view') { print ''; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1279,7 +1279,7 @@ if (empty($action) || $action == 'view') { $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1309,7 +1309,7 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)") . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)", 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index d634288e372..93ad01b7588 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1265,7 +1265,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty"), 1) . ""; print '' . ($mt >= 0 ? price($mt) : '') . ""; print '' . ($mt < 0 ? price(-$mt) : '') . ""; print ""; @@ -1296,7 +1296,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount"), 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1339,7 +1339,7 @@ if (empty($action) || $action == 'view') { print ''; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label, 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1382,7 +1382,7 @@ if (empty($action) || $action == 'view') { $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate, 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1411,7 +1411,7 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp"), 1) . ""; print '' . ($mt < 0 ? price(-$mt) : '') . ""; print '' . ($mt >= 0 ? price($mt) : '') . ""; print "";