mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Merge pull request #32622 from atm-maxime/new_detect_country_code2
NEW : auto-detect country from code in creation (follow-up⁾
This commit is contained in:
commit
87333363d4
|
|
@ -763,6 +763,11 @@ class Adherent extends CommonObject
|
|||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
$nbrowsaffected = 0;
|
||||
$error = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -760,6 +760,11 @@ class Account extends CommonObject
|
|||
$this->status = $this->clos;
|
||||
}
|
||||
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
// Load the library to validate/check a BAN account
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
|
||||
|
||||
|
|
@ -900,6 +905,11 @@ class Account extends CommonObject
|
|||
{
|
||||
global $langs, $conf;
|
||||
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
|
|
|||
|
|
@ -607,6 +607,11 @@ class Contact extends CommonObject
|
|||
{
|
||||
global $conf;
|
||||
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->id = $id;
|
||||
|
|
|
|||
|
|
@ -1423,6 +1423,10 @@ class Product extends CommonObject
|
|||
if (empty($this->country_id)) {
|
||||
$this->country_id = 0;
|
||||
}
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
if (empty($this->state_id)) {
|
||||
$this->state_id = 0;
|
||||
|
|
|
|||
|
|
@ -255,6 +255,10 @@ class Entrepot extends CommonObject
|
|||
$this->error = "ErrorFieldRequired";
|
||||
return 0;
|
||||
}
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
|
|
@ -325,6 +329,11 @@ class Entrepot extends CommonObject
|
|||
*/
|
||||
public function update($id, $user, $notrigger = 0)
|
||||
{
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($id)) {
|
||||
|
|
|
|||
|
|
@ -1012,11 +1012,6 @@ class Societe extends CommonObject
|
|||
$this->fk_multicurrency = 0;
|
||||
}
|
||||
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::create ".$this->name);
|
||||
|
||||
$now = dol_now();
|
||||
|
|
@ -1446,6 +1441,11 @@ class Societe extends CommonObject
|
|||
$this->country_id = dol_getIdFromCode($this->db, $this->country_code, 'c_country', 'code', 'rowid');
|
||||
}
|
||||
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
|
||||
|
|
|
|||
|
|
@ -2096,6 +2096,11 @@ class User extends CommonObject
|
|||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (empty($this->country_id) && !empty($this->country_code)) {
|
||||
$country_id = getCountry($this->country_code, '3');
|
||||
$this->country_id = is_int($country_id) ? $country_id : 0;
|
||||
}
|
||||
|
||||
$nbrowsaffected = 0;
|
||||
$error = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user