Create a 3rd party from the self-subscription membership form
Only when ADHERENT_DEFAULT_CREATE_THIRDPARTY = 1
This commit is contained in:
parent
f93a4ce0c0
commit
f30c95ad22
@ -564,36 +564,16 @@ if (empty($reshook)) {
|
||||
$id = $object->id;
|
||||
} else {
|
||||
$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
|
||||
if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) {
|
||||
if ($result > 0) {
|
||||
// User creation
|
||||
// Create third party out of a member
|
||||
$company = new Societe($db);
|
||||
|
||||
$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);
|
||||
|
||||
$result = $company->create_from_member($object);
|
||||
if ($result < 0) {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans($company->error), null, 'errors');
|
||||
|
||||
@ -254,7 +254,7 @@ if (empty($reshook) && $action == 'add') {
|
||||
$public = GETPOSTISSET('public') ? 1 : 0;
|
||||
|
||||
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->statut = -1;
|
||||
$adh->public = $public;
|
||||
@ -375,6 +375,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)) {
|
||||
$urlback = $backtopage;
|
||||
} elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
|
||||
|
||||
@ -3904,12 +3904,21 @@ class Societe extends CommonObject
|
||||
global $conf, $user, $langs;
|
||||
|
||||
dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
|
||||
|
||||
$name = $socname ? $socname : $member->societe;
|
||||
if (empty($name)) {
|
||||
$name = $member->getFullName($langs);
|
||||
$fullname = $member->getFullName($langs);
|
||||
|
||||
if ($member->morphy == 'mor') {
|
||||
$socname = $member->company? $member->company : $member->societe;
|
||||
if (!empty($fullname) && empty($socalias)) {
|
||||
$socalias = $fullname;
|
||||
}
|
||||
} else if(empty($socname) && $member->morphy == 'phy') {
|
||||
$socname = $fullname;
|
||||
if (!empty($member->company) && empty($socalias)) {
|
||||
$socalias = $member->company;
|
||||
}
|
||||
}
|
||||
|
||||
$name = $socname;
|
||||
$alias = $socalias ? $socalias : '';
|
||||
|
||||
// Positionne parametres
|
||||
|
||||
Loading…
Reference in New Issue
Block a user