Skip to content

Commit

Permalink
Close Dolibarr#27777 : new massaction subscription creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hystepik committed Jan 29, 2024
1 parent 6313c57 commit deb9176
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
40 changes: 40 additions & 0 deletions htdocs/adherents/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,40 @@
}
}

// Create external user
if ($action == 'createsubscription' && $confirm == "yes" && $user->hasRight('adherent', 'creer')) {
$tmpmember = new Adherent($db);
$adht = new AdherentType($db);
$error = 0;
$nbcreated = 0;
$db->begin();

foreach ($toselect as $id) {
$now = dol_now();
$tmpmember->fetch($id);
$res = $adht->fetch($tmpmember->typeid);
if ($res > 0) {
$amount = $adht->amount;
$result = $tmpmember->subscription($now, $amount);
if ($result < 0) {
$error++;
} else {
$nbcreated++;
}
} else {
$error++;
}
}

if (!$error) {
setEventMessages($langs->trans("XSubsriptionCreated", $nbcreated), null, 'mesgs');
$db->commit();
} else {
setEventMessages($langs->trans("XSubsriptionError", $error), null, 'mesgs');
$db->rollback();
}
}

// Mass actions
$objectclass = 'Adherent';
$objectlabel = 'Members';
Expand Down Expand Up @@ -706,6 +740,9 @@
if ($user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) {
$arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser");
}
if ($user->hasRight('adherent', 'creer')) {
$arrayofmassactions['createsubscription'] = $langs->trans("CreateSubscription");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
$arrayofmassactions = array();
}
Expand Down Expand Up @@ -740,6 +777,9 @@
$modelmail = "member";
$objecttmp = new Adherent($db);
$trackid = 'mem'.$object->id;
if ($massaction == 'createsubscription') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSubsriptionCreation"), $langs->trans("ConfirmMassSubsriptionCreationQuestion", count($toselect)), "createsubscription", $formquestion, '', 0, 200, 500, 1);
}
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';

if ($search_all) {
Expand Down
7 changes: 6 additions & 1 deletion htdocs/langs/en_US/members.lang
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,9 @@ MemberLastname=Member lastname
MemberCodeDesc=Member Code, unique for all members
MemberSubscriptionStartFirstDayOf=The start date of a membership corresponds to the first day of a
MemberSubscriptionStartAfter=Minimum period before the entry into force of the start date of a subscription except renewals (example +3m = +3 months, -5d = -5 days, +1Y = +1 year)
SubscriptionLinkedToConciliatedTransaction=Membership is linked to a conciliated transaction so this modification is not allowed.
SubscriptionLinkedToConciliatedTransaction=Membership is linked to a conciliated transaction so this modification is not allowed.
ConfirmMassSubsriptionCreation=Confirm subscription creation
ConfirmMassSubsriptionCreationQuestion=Are you sure you want to create the %s selected subscription(s)?
XSubsriptionCreated=%s subscription(s) created
XSubsriptionErrors=%s subscription(s) where in error
CreateSubscription=Create subscription

0 comments on commit deb9176

Please sign in to comment.