Trying to not include sql request into method setMysoc
This commit is contained in:
parent
31372f8948
commit
8c732a1443
@ -78,19 +78,8 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha'))
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("address",'nohtml'),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity);
|
||||
|
||||
//dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity);
|
||||
$tmparray=getState(GETPOST('state_id','int'),'all','',$db,$langs,0);
|
||||
if (! empty($tmparray['id']))
|
||||
{
|
||||
$mysoc->state_id =$tmparray['id'];
|
||||
$mysoc->state_code =$tmparray['code'];
|
||||
$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", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'alpha'),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity);
|
||||
@ -359,7 +348,7 @@ 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($mysoc->state_id,$mysoc->country_code,'state_id');
|
||||
$formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE,$mysoc->country_code,'state_id');
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
|
||||
@ -741,9 +730,7 @@ else
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("State").'</td><td>';
|
||||
if ($mysoc->state_id) {
|
||||
print getState($mysoc->state_id,$conf->global->MAIN_SHOW_STATE_CODE,0,$conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
|
||||
}
|
||||
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 ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
@ -465,10 +465,10 @@ abstract class CommonObject
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php';
|
||||
$tmparray=getState($this->state_id,'all',0,1);
|
||||
$this->state_code =$tmparray['code'];
|
||||
$this->state =$tmparray['label'];
|
||||
$this->region_code =$tmparray['region_code'];
|
||||
$this->region =$tmparray['region'];
|
||||
$this->state_code =$tmparray['code'];
|
||||
$this->state =$tmparray['label'];
|
||||
$this->region_code =$tmparray['region_code'];
|
||||
$this->region =$tmparray['region'];
|
||||
}
|
||||
|
||||
return dol_format_address($this, $withcountry, $sep);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -117,6 +117,13 @@ class Societe extends CommonObject
|
||||
var $state_code;
|
||||
var $state;
|
||||
|
||||
/**
|
||||
* Id of region
|
||||
* @var int
|
||||
*/
|
||||
var $region_code;
|
||||
var $region;
|
||||
|
||||
/**
|
||||
* State code
|
||||
* @var string
|
||||
@ -3126,29 +3133,8 @@ 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;
|
||||
|
||||
// We define state_id, state_code and state
|
||||
$state_id=$state_code=$state_label='';
|
||||
if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE))
|
||||
{
|
||||
$tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_STATE);
|
||||
$state_id=$tmp[0];
|
||||
if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" or "id:code:label:region_code:region"
|
||||
{
|
||||
$state_code=$tmp[1];
|
||||
$state_label=$tmp[2];
|
||||
}
|
||||
else // For backward compatibility
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
$state_code=getState($state_id,2,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore
|
||||
$state_label=getState($state_id,0,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore
|
||||
}
|
||||
}
|
||||
$this->state_id=$state_id;
|
||||
$this->state_code=$state_code;
|
||||
$this->state=$state_label;
|
||||
if (is_object($langs)) $this->state=($langs->trans('State'.$state_code)!='State'.$state_code)?$langs->trans('State'.$state_code):$state_label;
|
||||
$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->note_private=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user