Fix debug save of state into setup

This commit is contained in:
Laurent Destailleur 2019-06-22 14:47:46 +02:00
parent fdff737329
commit eb20df8e64
3 changed files with 21 additions and 8 deletions

View File

@ -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 '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
$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 '</td></tr>'."\n";
@ -774,8 +784,12 @@ else
if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print '<tr class="oddeven"><td>'.$langs->trans("Region-State").'</td><td>';
else print '<tr class="oddeven"><td>'.$langs->trans("State").'</td><td>';
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 '&nbsp;';
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 '</td></tr>';

View File

@ -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 <option>
* @return string String with HTML select
* @see select_country()
*/
public function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id')
public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id')
{
// phpcs:enable
global $conf,$langs,$user;

View File

@ -3438,7 +3438,6 @@ class Societe extends CommonObject
$this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS;
$this->zip=empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP;
$this->town=empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN;
$this->state_id=empty($conf->global->MAIN_INFO_SOCIETE_STATE)?'':$conf->global->MAIN_INFO_SOCIETE_STATE;
$this->region_code=empty($conf->global->MAIN_INFO_SOCIETE_REGION)?'':$conf->global->MAIN_INFO_SOCIETE_REGION;
$this->object=empty($conf->global->MAIN_INFO_SOCIETE_OBJECT)?'':$conf->global->MAIN_INFO_SOCIETE_OBJECT;
@ -3472,7 +3471,7 @@ class Societe extends CommonObject
//TODO This could be replicated for region but function `getRegion` didn't exist, so I didn't added it.
// We define state_id, state_code and state
$state_id=$state_code=$state_label='';
$state_id=0;$state_code=$state_label='';
if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE))
{
$tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_STATE);