From 289ce87f6d9d32df3ef332bb4729e84de247a5d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 19:06:41 +0100 Subject: [PATCH] Fix fatal error --- htdocs/core/lib/functions.lib.php | 10 ++++++---- htdocs/main.inc.php | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6c6a328596f..9e1affe3b41 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2928,8 +2928,8 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor /** * Format profIDs according to country * - * @param string $profID value of profID to format - * @param string $profIDtype type of profID to format (ProfId1, ProfId2, ProfId3, ProfId4, ProfId5, ProfId6 or VATIntra) + * @param string $profID Value of profID to format + * @param string $profIDtype Type of profID to format ('1', '2', '3', '4', '5', '6' or 'VAT') * @param string $countrycode Country code to use for formatting * @param int $addcpButton Add button to copy to clipboard (1 => show only on hoover ; 2 => always display ) * @param string $separ Separation between numbers for a better visibility example : xxx xxx xxx xxxxx @@ -2939,7 +2939,9 @@ function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton { global $mysoc; - if (empty($profID) || empty($profIDtype)) return ''; + if (empty($profID) || empty($profIDtype)) { + return ''; + } if (empty($countrycode)) $countrycode = $mysoc->country_code; $newProfID = $profID; $id = substr($profIDtype, -1); @@ -2948,7 +2950,7 @@ function dol_print_profids($profID, $profIDtype, $countrycode = '', $addcpButton // France if ($id == 1 && dol_strlen($newProfID) == 9) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3); if ($id == 2 && dol_strlen($newProfID) == 14) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3).$separ.substr($newProfID, 9, 5); - if ($profIDtype == 'VATIntra' && dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3); + if ($profIDtype === 'VAT' && dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3); } if (!empty($addcpButton)) $ret = showValueWithClipboardCPButton(dol_escape_htmltag($profID), ($addcpButton == 1 ? 1 : 0), $newProfID); else $ret = $newProfID; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index acc8c440821..657b17434d7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2073,24 +2073,24 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'; if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId1", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIREN")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId1", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIREN"), 1).''; } if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId2", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIRET")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId2", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIRET"), 2).''; } if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId3", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_APE")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId3", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_APE"), 3).''; } if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId4", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_RCS")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId4", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_RCS"), 4).''; } if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId5", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID5")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId5", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID5"), 5).''; } if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') { - $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID6")).''; + $dropdownBody .= '
'.$langs->transcountry("ProfId6", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_PROFID6"), 6).''; } - $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA")).''; + $dropdownBody .= '
'.$langs->trans("VATIntraShort").': '.dol_print_profids(getDolGlobalString("MAIN_INFO_TVAINTRA"), 'VAT').''; $dropdownBody .= '
';