No longer allow to edit amount in the payment step

If amount is editable, edition has been done in the previous screen in
public/members/new.php
It also allows the possibility to prevent the visitor from doing a >0
payment if this is not wanted.
This commit is contained in:
Yoan Mollard 2022-06-29 00:27:18 +02:00
parent ea0c710104
commit 759900bcce
3 changed files with 15 additions and 48 deletions

View File

@ -202,6 +202,7 @@ AmountOfSubscriptions=Amount collected from contributions
TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation)
DefaultAmount=Default amount of contribution
CanEditAmount=Visitor can choose/edit amount of its contribution
AmountIsLowerToMinimumNotice=sur un dû total de %s
MEMBER_NEWFORM_PAYONLINE=Jump on integrated online payment page
ByProperties=By nature
MembersStatisticsByProperties=Members statistics by nature

View File

@ -199,6 +199,7 @@ AmountOfSubscriptions=Montant des cotisations
TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité)
DefaultAmount=Montant par défaut de la cotisation
CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation
AmountIsLowerToMinimumNotice=sur un dû total de %s
AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s
AnyAmountWithoutAdvisedAmount=Montant libre
CanEditAmountShort=Montant libre

View File

@ -1500,7 +1500,7 @@ if ($source == 'member' || $source == 'membersubscription') {
$amount = $adht->amount;
}
$amount = price2num($amount, 'MT');
$amount = max(0, price2num($amount, 'MT'));
}
if (GETPOST('fulltag', 'alpha')) {
@ -1611,57 +1611,22 @@ if ($source == 'member' || $source == 'membersubscription') {
// Amount
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Amount");
if (empty($amount)) {
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
print ' ('.$langs->trans("ToComplete");
}
if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) {
print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>';
}
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
print ')';
}
// This place no longer allows amount edition
if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) {
print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>';
}
print '</td><td class="CTableRow2">';
$valtoshow = '';
if (empty($amount) || !is_numeric($amount)) {
$valtoshow = price2num(GETPOST("newamount", 'alpha'), 'MT');
// force default subscription amount to value defined into constant...
if (empty($valtoshow)) {
if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
$valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT;
}
} else {
if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
}
}
}
if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $amount) {
$amount = max(0, $conf->global->MEMBER_MIN_AMOUNT, $amount);
}
if (empty($amount) || !is_numeric($amount)) {
//$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT');
if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) {
$valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow);
}
print '<input type="hidden" name="amount" value="'.price2num(GETPOST("amount", 'alpha'), 'MT').'">';
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
print '<input class="flat maxwidth75" type="text" name="newamountbis" value="'.$valtoshow.'" disabled="disabled">';
print '<input type="hidden" name="newamount" value="'.$valtoshow.'">';
} else {
print '<input class="flat maxwidth75" type="text" name="newamount" value="'.$valtoshow.'">';
}
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
} else {
$valtoshow = $amount;
if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) {
$valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow);
$amount = $valtoshow;
}
print '<b class="amount">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
print '<input type="hidden" name="amount" value="'.$valtoshow.'">';
print '<input type="hidden" name="newamount" value="'.$valtoshow.'">';
print '<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
$caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $adht->caneditamount;
$minimumamount = empty($conf->global->MEMBER_MIN_AMOUNT)? $adht->amount : max($conf->global->MEMBER_MIN_AMOUNT, $adht->amount > $amount);
if(!$caneditamount && $minimumamount > $amount) {
print ' '. $langs->trans("AmountIsLowerToMinimumNotice", price($adht->amount, 1, $langs, 1, -1, -1, $currency));
}
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";