Enhance module Member
This commit is contained in:
parent
a4eb4aa802
commit
263e110ca3
@ -107,6 +107,7 @@ if ($action == 'set_default') {
|
||||
$res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
|
||||
$res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
// Use vat for invoice creation
|
||||
if ($conf->facture->enabled) {
|
||||
@ -219,6 +220,11 @@ print '<tr class="oddeven"><td>'.$langs->trans("MemberSendInformationByMailByDef
|
||||
print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Create an external user login for each new member subscription validated
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MemberCreateAnExternalUserForSubscriptionValidated").'</td><td>';
|
||||
print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', (!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN) ? $conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN : 0), 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Insert subscription into bank account
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MoreActionsOnSubscription").'</td>';
|
||||
$arraychoices = array('0'=>$langs->trans("None"));
|
||||
|
||||
@ -247,6 +247,42 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
|
||||
// Create external user
|
||||
if ($massaction == 'createexternaluser' && $user->rights->adherent->creer && $user->rights->user->user->creer) {
|
||||
$tmpmember = new Adherent($db);
|
||||
$error = 0;
|
||||
$nbcreated = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
foreach ($toselect as $idtoclose) {
|
||||
$tmpmember->fetch($idtoclose);
|
||||
|
||||
if(!empty($tmpmember->fk_soc)){
|
||||
$nuser = new User($db);
|
||||
$tmpuser = dol_clone($tmpmember);
|
||||
|
||||
$result = $nuser->create_from_member($tmpuser, $tmpmember->login);
|
||||
|
||||
if ($result < 0 && !count($tmpmember->errors)) {
|
||||
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
|
||||
} else {
|
||||
if ($result > 0) {
|
||||
$nbcreated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs');
|
||||
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// Mass actions
|
||||
$objectclass = 'Adherent';
|
||||
$objectlabel = 'Members';
|
||||
@ -555,6 +591,9 @@ if ($user->rights->adherent->supprimer) {
|
||||
if ($user->rights->societe->creer) {
|
||||
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
|
||||
}
|
||||
if ($user->rights->adherent->creer && $user->rights->user->user->creer) {
|
||||
$arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser");
|
||||
}
|
||||
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
|
||||
@ -6835,6 +6835,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
||||
$substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__';
|
||||
$substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__';
|
||||
$substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__';
|
||||
$substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = 'Login and pass of the external user account';
|
||||
/*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__';
|
||||
$substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/
|
||||
}
|
||||
@ -6910,6 +6911,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
|
||||
}
|
||||
$substitutionarray['__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname : '');
|
||||
$substitutionarray['__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname : '');
|
||||
$substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = '';
|
||||
if (method_exists($object, 'getFullName')) {
|
||||
$substitutionarray['__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs);
|
||||
}
|
||||
|
||||
@ -1431,6 +1431,7 @@ MemberMainOptions=Main options
|
||||
AdherentLoginRequired= Manage a Login for each member
|
||||
AdherentMailRequired=Email required to create a new member
|
||||
MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default
|
||||
MemberCreateAnExternalUserForSubscriptionValidated=Create an external user login for each new member subscription validated
|
||||
VisitorCanChooseItsPaymentMode=Visitor can choose from available payment modes
|
||||
MEMBER_REMINDER_EMAIL=Enable automatic reminder <b>by email</b> of expired subscriptions. Note: Module <strong>%s</strong> must be enabled and correctly setup to send reminders.
|
||||
MembersDocModules=Document templates for documents generated from member record
|
||||
|
||||
@ -1125,6 +1125,7 @@ UpdateForAllLines=Update for all lines
|
||||
OnHold=On hold
|
||||
Civility=Civility
|
||||
AffectTag=Affect Tag
|
||||
CreateExternalUser=Create external user
|
||||
ConfirmAffectTag=Bulk Tag Affect
|
||||
ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)?
|
||||
CategTypeNotFound=No tag type found for type of records
|
||||
|
||||
@ -213,3 +213,4 @@ SendReminderForExpiredSubscription=Send reminder by email to members when subscr
|
||||
MembershipPaid=Membership paid for current period (until %s)
|
||||
YouMayFindYourInvoiceInThisEmail=You may find your invoice attached to this email
|
||||
XMembersClosed=%s member(s) closed
|
||||
XExternalUserCreated=%s external user(s) created
|
||||
|
||||
@ -623,6 +623,27 @@ if ($ispaymentok) {
|
||||
}
|
||||
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
|
||||
// Create external user
|
||||
if(!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN)){
|
||||
$infouserlogin = '';
|
||||
$nuser = new User($db);
|
||||
$tmpuser = dol_clone($object);
|
||||
|
||||
$result = $nuser->create_from_member($tmpuser, $object->login);
|
||||
$newpassword = $nuser->setPassword($user, '');
|
||||
|
||||
if ($result < 0) {
|
||||
$outputlangs->load("errors");
|
||||
$postactionmessages[] = 'Error in create external user : '.$nuser->error;
|
||||
} else {
|
||||
$infouserlogin .= $outputlangs->trans("Login").': '.$nuser->login."<br>"."\n";
|
||||
$infouserlogin .= $outputlangs->trans("Password").': '.$newpassword;
|
||||
$postactionmessages[] = $langs->trans("NewUserCreated", $nuser->login);
|
||||
}
|
||||
$substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
|
||||
}
|
||||
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user