From 759900bccee95b31e7684b2d69d93370d0e176ed Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 00:27:18 +0200 Subject: [PATCH] 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. --- htdocs/langs/en_US/members.lang | 1 + htdocs/langs/fr_FR/members.lang | 1 + htdocs/public/payment/newpayment.php | 61 ++++++---------------------- 3 files changed, 15 insertions(+), 48 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index e552755f705..d9af9c9c350 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -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 diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 5f67cc681ab..9cf2f25a2b0 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -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 diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index ff53ccf0e09..1c3c0202b23 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -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 ''.$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 ' - '.$langs->trans("SeeHere").''; - } - 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 ' - '.$langs->trans("SeeHere").''; } print ''; - $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 ''; - if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - print ''; - } else { - print ''; - } - print ' '.$langs->trans("Currency".$currency).''; - } else { - $valtoshow = $amount; - if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { - $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); - $amount = $valtoshow; - } - print ''.price($valtoshow, 1, $langs, 1, -1, -1, $currency).''; // Price with currency - print ''; - print ''; + print ''.price($amount, 1, $langs, 1, -1, -1, $currency).''; // 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 ''; print ''; print ''."\n";