Skip to content

Commit

Permalink
Fix debug save of state into setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jun 22, 2019
1 parent fdff737 commit eb20df8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
22 changes: 18 additions & 4 deletions htdocs/admin/company.php
Expand Up @@ -83,7 +83,11 @@
$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();
Expand Down Expand Up @@ -385,7 +389,13 @@


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";


Expand Down Expand Up @@ -774,8 +784,12 @@

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>';


Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/html.formcompany.class.php
Expand Up @@ -211,13 +211,13 @@ public function select_departement($selected = '', $country_codeid = 0, $htmlnam
* 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;
Expand Down
3 changes: 1 addition & 2 deletions htdocs/societe/class/societe.class.php
Expand Up @@ -3438,7 +3438,6 @@ public function setMysoc(Conf $conf)
$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;

Expand Down Expand Up @@ -3472,7 +3471,7 @@ public function setMysoc(Conf $conf)

//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);
Expand Down

0 comments on commit eb20df8

Please sign in to comment.