Merge pull request #15911 from atm-kevin/Fix_create_contact_from_thirdparty_from_member

Fix #15829
This commit is contained in:
Laurent Destailleur 2021-01-06 19:33:25 +01:00 committed by GitHub
commit 4f2c6e2901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3654,7 +3654,7 @@ class Societe extends CommonObject
public function create_from_member(Adherent $member, $socname = '', $socalias = '', $customercode = '')
{
// phpcs:enable
global $user, $langs;
global $conf, $user, $langs;
dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
@ -3687,6 +3687,22 @@ class Societe extends CommonObject
$result = $this->create($user);
if ($result >= 0)
{
// Auto-create contact on thirdparty creation
if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT))
{
// Fill fields needed by contact
$this->name_bis = $member->lastname;
$this->firstname = $member->firstname;
$this->civility_id = $member->civility_id;
dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
$result = $this->create_individual($user);
if ($result < 0)
{
setEventMessages($this->error, $this->errors, 'errors');
return -1;
}
}
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
$sql .= " SET fk_soc=".$this->id;
$sql .= " WHERE rowid=".$member->id;