Allow users to show or hide the "vote allowed" column in UI

This commit is contained in:
Yoan Mollard 2023-03-16 01:29:29 +01:00
parent 72798f60a1
commit 451a0e8469
3 changed files with 14 additions and 2 deletions

View File

@ -60,6 +60,7 @@ if ($action == 'update') {
$amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
$minamount = GETPOST('MEMBER_MIN_AMOUNT');
$publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
$showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED');
$payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
$forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int');
$forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
@ -68,6 +69,7 @@ if ($action == 'update') {
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", !$showvoteallowed, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show"
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
if ($forcetype < 0) {
$res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
@ -246,6 +248,14 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (!empty($conf->global->MEMBER_COUNTERS_ARE_PUBLIC) ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1);
print "</td></tr>\n";
// Show "vote allowed" setting for membership types
$hidevoteallowed = (!empty($conf->global->MEMBER_HIDE_VOTE_ALLOWED) ? $conf->global->MEMBER_HIDE_VOTE_ALLOWED : 0);
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("MembersShowVotesAllowed");
print '</td><td>';
print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", !$hidevoteallowed, 1); // Reverse the logic "hide -> show" for retrocompatibility
print "</td></tr>\n";
// Jump to an online payment page
print '<tr class="oddeven" id="trpayment"><td>';
print $langs->trans("MEMBER_NEWFORM_PAYONLINE");

View File

@ -27,6 +27,7 @@ MembersListNotUpToDate=List of valid members with out-of-date contribution
MembersListExcluded=List of excluded members
MembersListResiliated=List of terminated members
MembersListQualified=List of qualified members
MembersShowVotesAllowed=Show whether votes are allowed, in the table of membership types
MenuMembersToValidate=Draft members
MenuMembersValidated=Validated members
MenuMembersExcluded=Excluded members

View File

@ -802,6 +802,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
$units[$lines->short_label] = $langs->trans(ucfirst($lines->label));
$publiccounters = getDolGlobalString("MEMBER_COUNTERS_ARE_PUBLIC");
$hidevoteallowed = getDolGlobalString("MEMBER_HIDE_VOTE_ALLOWED");
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy,";
$sql .= " COUNT(a.rowid) AS membercount";
@ -825,7 +826,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
print '<th class="center">'.$langs->trans("MembershipDuration").'</th>';
print '<th class="center">'.$langs->trans("Amount").'</th>';
print '<th class="center">'.$langs->trans("MembersNature").'</th>';
print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
if (empty($hidevoteallowed)) print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
if ($publiccounters) print '<th class="center">'.$langs->trans("Members").'</th>';
print '<th class="center">'.$langs->trans("NewSubscription").'</th>';
print "</tr>\n";
@ -865,7 +866,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
print $langs->trans("MorAndPhy");
}
print '</td>';
print '<td class="center">'.yn($objp->vote).'</td>';
if (empty($hidevoteallowed)) print '<td class="center">'.yn($objp->vote).'</td>';
$membercount = $objp->membercount>0? $objp->membercount: "";
if ($publiccounters) print '<td class="center">'.$membercount.'</td>';
print '<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.'">'.$langs->trans("GetMembershipButtonLabel").'</button></td>';