From eb20df8e64b953b495527e5bfe7ea247b0814dcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Jun 2019 14:47:46 +0200 Subject: [PATCH] Fix debug save of state into setup --- htdocs/admin/company.php | 22 ++++++++++++++++---- htdocs/core/class/html.formcompany.class.php | 4 ++-- htdocs/societe/class/societe.class.php | 3 +-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index c05305b6393..588383021a0 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -83,7 +83,11 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) $mysoc->state_label=$tmparray['label']; $s=$mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label; - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s,'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s, 'chaine', 0, '', $conf->entity); + } + else + { + dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity); } $db->begin(); @@ -385,7 +389,13 @@ if ($action == 'edit' || $action == 'updateedit') print ''; - $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE, $mysoc->country_code, 'state_id'); + $state_id=0; + if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) + { + $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_STATE); + $state_id=$tmp[0]; + } + $formcompany->select_departement($state_id, $mysoc->country_code, 'state_id'); print ''."\n"; @@ -774,8 +784,12 @@ else if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print ''.$langs->trans("Region-State").''; else print ''.$langs->trans("State").''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) print getState($conf->global->MAIN_INFO_SOCIETE_STATE, $conf->global->MAIN_SHOW_STATE_CODE, 0, $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); - else print ' '; + if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) + { + $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_STATE); + $state_id=$tmp[0]; + print getState($state_id, $conf->global->MAIN_SHOW_STATE_CODE, 0, $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); + } print ''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index d1366cb8511..17643e2d69a 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -211,13 +211,13 @@ class FormCompany * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * - * @param string $selected Code state preselected (mus be state id) + * @param int $selected Code state preselected (mus be state id) * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show * @param string $htmlname Id of department. If '', we want only the string with