Skip to content

Commit

Permalink
NEW Can create new membership type from the create member form
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed May 17, 2024
1 parent a99e72c commit 0c26be8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions htdocs/adherents/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,9 @@ function initfieldrequired() {
} else {
print '<span class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</span>';
}
if ($user->hasRight('member', 'configurer')) {
print ' <a href="'.DOL_URL_ROOT.'/adherents/type.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&typeid=--IDFORBACKTOPAGE--').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewMemberType").'"></span></a>';
}
print "</td>\n";

// Morphy
Expand Down
8 changes: 7 additions & 1 deletion htdocs/adherents/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@
if (!$error) {
$id = $object->create($user);
if ($id > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
$backurlforlist = $_SERVER["PHP_SELF"];

$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;

Check warning on line 179 in htdocs/adherents/type.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

type.php: PhanTypeMismatchArgumentInternal: Argument 2 ($replace) is $result of type \IteratorAggregate|\Traversable|\mysqli_result|bool|int|iterable|resource but \str_replace() takes array|string
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect field created after a New on another form object creation

header("Location: " . $urltogo);
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
Expand Down Expand Up @@ -432,6 +437,7 @@
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';

print dol_get_fiche_head('');

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/actions_addupdatedelete.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
}

$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect field created after a New on another form object creation

$db->commit();

Expand Down

0 comments on commit 0c26be8

Please sign in to comment.