Merge pull request #21574 from ymollard/create3rdpartyV14
FIX: Create a 3rd party from the self-subscription membership form
This commit is contained in:
commit
239008b67d
@ -582,36 +582,16 @@ if (empty($reshook)) {
|
|||||||
$id = $object->id;
|
$id = $object->id;
|
||||||
} else {
|
} else {
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
|
||||||
if ($object->error) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
} else {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-create thirdparty on member creation
|
// Auto-create thirdparty on member creation
|
||||||
if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) {
|
if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) {
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
// User creation
|
// Create third party out of a member
|
||||||
$company = new Societe($db);
|
$company = new Societe($db);
|
||||||
|
$result = $company->create_from_member($object);
|
||||||
$companyalias = '';
|
|
||||||
$fullname = $object->getFullName($langs);
|
|
||||||
|
|
||||||
if ($object->morphy == 'mor') {
|
|
||||||
$companyname = $object->company;
|
|
||||||
if (!empty($fullname)) {
|
|
||||||
$companyalias = $fullname;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$companyname = $fullname;
|
|
||||||
if (!empty($object->company)) {
|
|
||||||
$companyalias = $object->company;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $company->create_from_member($object, $companyname, $companyalias);
|
|
||||||
|
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
setEventMessages($langs->trans($company->error), null, 'errors');
|
setEventMessages($langs->trans($company->error), null, 'errors');
|
||||||
|
|||||||
@ -257,7 +257,7 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$public = GETPOSTISSET('public') ? 1 : 0;
|
$public = GETPOSTISSET('public') ? 1 : 0;
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
// email a peu pres correct et le login n'existe pas
|
// E-mail looks OK and login does not exist
|
||||||
$adh = new Adherent($db);
|
$adh = new Adherent($db);
|
||||||
$adh->statut = -1;
|
$adh->statut = -1;
|
||||||
$adh->public = $public;
|
$adh->public = $public;
|
||||||
@ -378,6 +378,16 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-create thirdparty on member creation
|
||||||
|
if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) {
|
||||||
|
$company = new Societe($db);
|
||||||
|
$result = $company->create_from_member($adh);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
$errmsg .= join('<br>', $company->errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($backtopage)) {
|
if (!empty($backtopage)) {
|
||||||
$urlback = $backtopage;
|
$urlback = $backtopage;
|
||||||
} elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
|
} elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
|
||||||
|
|||||||
@ -4024,12 +4024,25 @@ class Societe extends CommonObject
|
|||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
|
dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
|
||||||
|
$fullname = $member->getFullName($langs);
|
||||||
|
|
||||||
$name = $socname ? $socname : $member->societe;
|
if ($member->morphy == 'mor') {
|
||||||
if (empty($name)) {
|
if (empty($socname)) {
|
||||||
$name = $member->getFullName($langs);
|
$socname = $member->company? $member->company : $member->societe;
|
||||||
|
}
|
||||||
|
if (!empty($fullname) && empty($socalias)) {
|
||||||
|
$socalias = $fullname;
|
||||||
|
}
|
||||||
|
} elseif (empty($socname) && $member->morphy == 'phy') {
|
||||||
|
if (empty($socname)) {
|
||||||
|
$socname = $fullname;
|
||||||
|
}
|
||||||
|
if (!empty($member->company) && empty($socalias)) {
|
||||||
|
$socalias = $member->company;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$name = $socname;
|
||||||
$alias = $socalias ? $socalias : '';
|
$alias = $socalias ? $socalias : '';
|
||||||
|
|
||||||
// Positionne parametres
|
// Positionne parametres
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user