NEW: Public counters feature

This commit is contained in:
Yoan Mollard 2022-08-03 03:02:07 +02:00
parent 2b9e49535b
commit c581024c8c
3 changed files with 19 additions and 2 deletions

View File

@ -58,6 +58,7 @@ if ($action == 'update') {
$public = GETPOST('MEMBER_ENABLE_PUBLIC');
$amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
$editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
$publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
$payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
$forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int');
$forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
@ -65,6 +66,7 @@ if ($action == 'update') {
$res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
$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);
@ -216,6 +218,13 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1);
print "</td></tr>\n";
// SHow counter of validated members publicly
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("MemberCountersArePublic");
print '</td><td>';
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";
// Jump to an online payment page
print '<tr class="oddeven" id="trpayment"><td>';
print $langs->trans("MEMBER_NEWFORM_PAYONLINE");

View File

@ -15,6 +15,7 @@ ErrorMemberIsAlreadyLinkedToThisThirdParty=Another member (name: <b>%s</b>, logi
ErrorUserPermissionAllowsToLinksToItselfOnly=For security reasons, you must be granted permissions to edit all users to be able to link a member to a user that is not yours.
SetLinkToUser=Link to a Dolibarr user
SetLinkToThirdParty=Link to a Dolibarr third party
MemberCountersArePublic=Counters of valid members are public
MembersCards=Generation of cards for members
MembersList=List of members
MembersListToValid=List of draft members (to be validated)

View File

@ -753,10 +753,14 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
foreach ($measuringUnits->records as $lines)
$units[$lines->short_label] = $langs->trans(ucfirst($lines->label));
$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";
$publiccounters = $conf->global->MEMBER_COUNTERS_ARE_PUBLIC;
$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, COUNT(a.rowid) AS membercount";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as a";
$sql .= " ON d.rowid = a.fk_adherent_type AND a.statut>0";
$sql .= " WHERE d.entity IN (".getEntity('member_type').")";
$sql .= " AND d.statut=1";
$sql .= " AND d.statut=1 GROUP BY d.rowid";
$result = $db->query($sql);
if ($result) {
@ -772,6 +776,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
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($publiccounters) print '<th class="center">'.$langs->trans("Members").'</th>';
print '<th class="center">'.$langs->trans("NewSubscription").'</th>';
print "</tr>\n";
@ -811,6 +816,8 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
}
print '</td>';
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>';
print "</tr>";
$i++;