From 720a09dacb744c07311f253450a32810e6a618ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 May 2022 15:57:10 +0200 Subject: [PATCH] Fix regression --- htdocs/admin/expensereport_rules.php | 4 ++-- htdocs/comm/propal/card.php | 4 ++-- htdocs/commande/card.php | 4 ++-- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/lib/functions.lib.php | 4 +++- htdocs/holiday/class/holiday.class.php | 6 +++--- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 1146232dca3..62fb097841b 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -266,11 +266,11 @@ foreach ($rules as $rule) { if ($rule->fk_c_type_fees == -1) { echo $langs->trans('AllExpenseReport'); } else { - $key = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); + $key = getDictionaryValue('c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); if ($key && $key != $langs->trans($key)) { echo $langs->trans($key); } else { - $value = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id'); + $value = getDictionaryValue('c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id'); echo $langs->trans($value ? $value : 'Undefined'); // TODO check to return trans of 'code' } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 229919d7e5d..22a816acc1d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -692,7 +692,7 @@ if (empty($reshook)) { $deposit = null; $locationTarget = ''; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if ( !$error && GETPOST('statut', 'int') == $object::STATUS_SIGNED && GETPOST('generate_deposit', 'alpha') == 'on' @@ -1999,7 +1999,7 @@ if ($action == 'create') { array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6ba7b9086c3..b1d0cdb9223 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1184,7 +1184,7 @@ if (empty($reshook)) { $error = 0; $deposit = null; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if ( GETPOST('generate_deposit', 'alpha') == 'on' && ! empty($deposit_percent_from_payment_terms) @@ -2025,7 +2025,7 @@ if ($action == 'create' && $usercancreate) { if ($nbMandated > 0 ) $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e3fac863c77..7de827ff1d2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3290,7 +3290,7 @@ if ($action == 'create') { $typedeposit = GETPOST('typedeposit', 'aZ09'); $valuedeposit = GETPOST('valuedeposit', 'int'); if (empty($typedeposit) && ! empty($objectsrc->deposit_percent)) { - $origin_payment_conditions_deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id); + $origin_payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id); if (! empty($origin_payment_conditions_deposit_percent)) { $typedeposit = 'variable'; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0804f55b1ee..e29ecc251ff 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1501,7 +1501,7 @@ class Facture extends CommonInvoice return null; } - $payment_conditions_deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $origin->cond_reglement_id); + $payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $origin->cond_reglement_id); if (empty($payment_conditions_deposit_percent)) { $origin->error = 'ErrorPaymentConditionsNotEligibleToDepositCreation'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cabb50520fb..0758c696e29 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2606,7 +2606,7 @@ abstract class CommonObject } if (empty($deposit_percent) || $deposit_percent < 0) { - $deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $id); + $deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $id); } if ($deposit_percent > 100) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5025347dcb2..04713acbc8f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9862,7 +9862,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) * Return the value of a filed into a dictionary for the record $id. * This also set all the values into a cache for a next search. * - * @param string $tablename Name of dictionary + * @param string $tablename Name of table dictionary (without the MAIN_DB_PREFIX, example: 'c_holiday_types') * @param string $field The name of field where to find the value to return * @param int $id Id of line record * @param bool $checkentity Add filter on entity @@ -9873,6 +9873,8 @@ function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowi { global $conf, $db; + $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename); // Clean name of table for backward compatibility. + $dictvalues = (isset($conf->cache['dictvalues_'.$tablename]) ? $conf->cache['dictvalues_'.$tablename] : null); if (is_null($dictvalues)) { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index d0bed943429..1e11e81f543 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -704,7 +704,7 @@ class Holiday extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; - $checkBalance = getDictionaryValue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); if ($checkBalance > 0) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); @@ -817,7 +817,7 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; - $checkBalance = getDictionaryValue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); if ($checkBalance > 0) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); @@ -936,7 +936,7 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; - $checkBalance = getDictionaryValue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + $checkBalance = getDictionaryValue('c_holiday_types', 'block_if_negative', $this->fk_type); if ($checkBalance > 0 && $this->statut != self::STATUS_DRAFT) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type);