Debug v17 - Online membership subscription of members

This commit is contained in:
Laurent Destailleur 2023-02-09 14:30:48 +01:00
parent 9417a69f51
commit dfda68a63c
10 changed files with 32 additions and 32 deletions

View File

@ -58,7 +58,7 @@ if ($action == 'setMEMBER_ENABLE_PUBLIC') {
if ($action == 'update') {
$public = GETPOST('MEMBER_ENABLE_PUBLIC');
$amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
$editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
$minamount = GETPOST('MEMBER_MIN_AMOUNT');
$publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
$payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
$forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int');
@ -66,7 +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_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_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
if ($forcetype < 0) {
@ -232,11 +232,11 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
print '<input type="text" class="right width50" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" value="'.(!empty($conf->global->MEMBER_NEWFORM_AMOUNT) ? $conf->global->MEMBER_NEWFORM_AMOUNT : '').'">';
print "</td></tr>\n";
// Can edit
// Min amount
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("CanEditAmountDetail");
print $langs->trans("MinimumAmount");
print '</td><td>';
print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1);
print '<input type="text" class="right width50" id="MEMBER_MIN_AMOUNT" name="MEMBER_MIN_AMOUNT" value="'.(!empty($conf->global->MEMBER_MIN_AMOUNT) ? $conf->global->MEMBER_MIN_AMOUNT : '').'">';
print "</td></tr>\n";
// SHow counter of validated members publicly

View File

@ -206,7 +206,8 @@ SubscriptionsStatistics=Contributions statistics
NbOfSubscriptions=Number of contributions
AmountOfSubscriptions=Amount collected from contributions
TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation)
DefaultAmount=Default amount of contribution
DefaultAmount=Default amount of contribution (used only if no amount is defined at member type level)
MinimumAmount=Minimum amount (used only when contribution amount is free)
CanEditAmount=Subscription amount is free
CanEditAmountDetail=Visitor can choose/edit amount of its contribution regardless of the member type
AmountIsLowerToMinimumNotice=sur un dû total de %s

View File

@ -686,7 +686,7 @@ print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, 0, 'center')
print '<div align="center">';
print '<div id="divsubscribe">';
print '<div class="center subscriptionformhelptext">';
print '<div class="center subscriptionformhelptext opacitymedium justify">';
// Welcome message

View File

@ -30,7 +30,6 @@
*
* Note that you can add following constant to change behaviour of page
* MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form
* MEMBER_NEWFORM_EDITAMOUNT 0 or 1 = Amount can be edited
* MEMBER_MIN_AMOUNT Minimum amount
* MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe
* MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation)
@ -431,7 +430,7 @@ if (empty($reshook) && $action == 'add') {
}
if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') {
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed
if (empty($adht->caneditamount)) { // If edition of amount not allowed
// TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT
// It is not so important because a test is done on return of payment validation.
}
@ -505,7 +504,7 @@ print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center')
print '<div align="center">';
print '<div id="divsubscribe">';
print '<div class="center subscriptionformhelptext justify">';
print '<div class="center subscriptionformhelptext opacitymedium justify">';
if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) {
print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."<br>\n";
} else {
@ -765,7 +764,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
}
if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) {
if ($caneditamount) {
print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$showedamount.'">';
print ' '.$langs->trans("Currency".$conf->currency).'<span class="opacitymedium"> ';
print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount");
@ -833,7 +832,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
$i = 0;
while ($i < $num) {
$objp = $db->fetch_object($result);
$objp = $db->fetch_object($result); // Load the member type and information on it
print '<tr class="oddeven">';
print '<td>'.dol_escape_htmltag($objp->label).'</td>';
@ -843,7 +842,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW
print '</td>';
print '<td class="center"><span class="amount nowrap">';
$displayedamount = max(intval($objp->amount), intval(getDolGlobalInt("MEMBER_MIN_AMOUNT")));
$caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $objp->caneditamount;
$caneditamount = $objp->caneditamount;
if ($objp->subscription) {
if ($displayedamount > 0 || !$caneditamount) {
print $displayedamount.' '.strtoupper($conf->currency);

View File

@ -544,7 +544,7 @@ print load_fiche_titre($langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'ce
print '<div align="center">';
print '<div id="divsubscribe">';
print '<div class="center subscriptionformhelptext justify">';
print '<div class="center subscriptionformhelptext opacitymedium justify">';
if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) {
print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT)."<br>\n";
} else {

View File

@ -1633,7 +1633,7 @@ if ($source == 'member' || $source == 'membersubscription') {
$amount = max(0, $conf->global->MEMBER_MIN_AMOUNT, $amount);
}
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;
$caneditamount = $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));
@ -1751,13 +1751,13 @@ if ($source == 'donation') {
// Amount
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Amount");
if (empty($amount)) {
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
if (empty($conf->global->DONATION_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->DONATION_EXT_URL_SUBSCRIPTION_INFO)) {
print ' - <a href="'.$conf->global->DONATION_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>';
}
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
if (empty($conf->global->DONATION_NEWFORM_AMOUNT)) {
print ')';
}
}
@ -1767,21 +1767,21 @@ if ($source == 'donation') {
$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;
if (!empty($conf->global->DONATION_NEWFORM_EDITAMOUNT)) {
if (!empty($conf->global->DONATION_NEWFORM_AMOUNT)) {
$valtoshow = $conf->global->DONATION_NEWFORM_AMOUNT;
}
} else {
if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
if (!empty($conf->global->DONATION_NEWFORM_AMOUNT)) {
$amount = $conf->global->DONATION_NEWFORM_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);
if (!empty($conf->global->DONATION_MIN_AMOUNT) && $valtoshow) {
$valtoshow = max($conf->global->DONATION_MIN_AMOUNT, $valtoshow);
}
print '<input type="hidden" name="amount" value="'.price2num(GETPOST("amount", 'alpha'), 'MT').'">';
print '<input class="flat maxwidth75" type="text" name="newamount" value="'.$valtoshow.'">';
@ -1789,8 +1789,8 @@ if ($source == 'donation') {
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);
if (!empty($conf->global->DONATION_MIN_AMOUNT) && $valtoshow) {
$valtoshow = max($conf->global->DONATION_MIN_AMOUNT, $valtoshow);
$amount = $valtoshow;
}
print '<b class="amount">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency

View File

@ -441,7 +441,7 @@ if ($ispaymentok) {
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
// Security protection:
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If we didn't allow members to choose their membership amount (if free amount is allowed, no need to check)
if (empty($adht->caneditamount)) { // If we didn't allow members to choose their membership amount (if the amount is allowed in edit mode, no need to check)
if ($object->status == $object::STATUS_DRAFT) { // If the member is not yet validated, we check that the amount is the same as expected.
$typeid = $object->typeid;

View File

@ -450,7 +450,7 @@ print load_fiche_titre($langs->trans("NewContact"), '', '', 0, 0, 'center');
print '<div align="center">';
print '<div id="divsubscribe">';
print '<div class="center subscriptionformhelptext justify">';
print '<div class="center subscriptionformhelptext opacitymedium justify">';
if (!empty($conf->global->PROJECT_NEWFORM_TEXT)) {
print $langs->trans($conf->global->PROJECT_NEWFORM_TEXT)."<br>\n";
} else {

View File

@ -564,7 +564,7 @@ print load_fiche_titre($langs->trans("NewSuggestionOfBooth"), '', '', 0, 0, 'cen
print '<div align="center">';
print '<div id="divsubscribe">';
print '<div class="center subscriptionformhelptext justify">';
print '<div class="center subscriptionformhelptext opacitymedium justify">';
dol_htmloutput_errors($errmsg);

View File

@ -497,7 +497,7 @@ print load_fiche_titre($langs->trans("NewSuggestionOfConference"), '', '', 0, 0,
print '<div align="center">';
print '<div id="divsubscribe">';
print '<div class="center subscriptionformhelptext justify">';
print '<div class="center subscriptionformhelptext opacitymedium justify">';
dol_htmloutput_errors($errmsg, $errors);