Skip to content

Commit

Permalink
NEW : auto-detect country from code in creation (follow-up⁾
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-maxime committed Jan 10, 2025
1 parent b48c923 commit ba2dab2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
5 changes: 5 additions & 0 deletions htdocs/adherents/class/adherent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,11 @@ public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass =

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;

Expand Down
10 changes: 10 additions & 0 deletions htdocs/compta/bank/class/account.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,11 @@ public function create($user, $notrigger = 0)
$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';

Expand Down Expand Up @@ -900,6 +905,11 @@ public function update($user, $notrigger = 0)
{
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();
Expand Down
5 changes: 5 additions & 0 deletions htdocs/contact/class/contact.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,11 @@ public function update($id, $user = null, $notrigger = 0, $action = 'update', $n
{
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;
Expand Down
4 changes: 4 additions & 0 deletions htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,10 @@ public function update($id, $user, $notrigger = 0, $action = 'update', $updatety
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;
Expand Down
9 changes: 9 additions & 0 deletions htdocs/product/stock/class/entrepot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ public function create($user, $notrigger = 0)
$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();

Expand Down Expand Up @@ -325,6 +329,11 @@ public function create($user, $notrigger = 0)
*/
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)) {
Expand Down
10 changes: 5 additions & 5 deletions htdocs/societe/class/societe.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,11 +1010,6 @@ public function create(User $user, $notrigger = 0)
$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();
Expand Down Expand Up @@ -1441,6 +1436,11 @@ public function update($id, User $user, $call_trigger = 1, $allowmodcodeclient =
$id = $this->id;
}

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);
Expand Down
5 changes: 5 additions & 0 deletions htdocs/user/class/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,11 @@ public function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpa
{
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;

Expand Down

0 comments on commit ba2dab2

Please sign in to comment.