diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index a056dc8e110..6cdb980f0d4 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -66,8 +66,13 @@ if ($reshook < 0) { if (($action == 'update' && !GETPOST("cancel", 'alpha')) || ($action == 'updateedit')) { - $tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0); + $tmparray = getCountry(GETPOSTINT('country_id'), 'all', $db, $langs, 0); if (!empty($tmparray['id'])) { + if ($tmparray['code'] == 'FR' && $tmparray['id'] != $mysoc->country_id) { + // For FR, default value of option to show profid SIREN is on by default + $res = dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", 1, 'chaine', 0, '', $conf->entity); + } + $mysoc->country_id = $tmparray['id']; $mysoc->country_code = $tmparray['code']; $mysoc->country_label = $tmparray['label']; @@ -75,11 +80,6 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) $s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity); - if($mysoc->country_code == 'FR' && !isset($conf->global->MAIN_PROFID1_IN_ADDRESS)){ - // For FR, default value of option to show profid SIREN is on by default - $res = dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", 1, 'chaine', 0, '', $conf->entity); - } - activateModulesRequiredByCountry($mysoc->country_code); }