From 3d00c065aec07bfc437100160263e52aeef75aef Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 26 Jun 2022 23:51:10 +0200 Subject: [PATCH 01/23] Missing label for excluded members --- .../interface_50_modAgenda_ActionsAuto.class.php | 12 ++++++++++++ htdocs/langs/en_US/agenda.lang | 1 + 2 files changed, 13 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 0e018514353..4e926050f24 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -798,6 +798,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; + $object->sendtoid = 0; + } elseif ($action == 'MEMBER_EXCLUDE') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "members")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); + } + $object->actionmsg = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; + $object->sendtoid = 0; } elseif ($action == 'PROJECT_CREATE') { // Projects diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 272ec22df5c..b8f9ffa857b 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -57,6 +57,7 @@ MemberValidatedInDolibarr=Member %s validated MemberModifiedInDolibarr=Member %s modified MemberResiliatedInDolibarr=Member %s terminated MemberDeletedInDolibarr=Member %s deleted +MemberExcludedInDolibarr=Member %s excluded MemberSubscriptionAddedInDolibarr=Subscription %s for member %s added MemberSubscriptionModifiedInDolibarr=Subscription %s for member %s modified MemberSubscriptionDeletedInDolibarr=Subscription %s for member %s deleted From 6053f3e5f8228ebb557c90bfa05c0f95bdf30977 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 27 Jun 2022 00:27:00 +0200 Subject: [PATCH 02/23] Internationalize invoice lines for new memberships --- htdocs/langs/en_US/paypal.lang | 1 + htdocs/public/payment/paymentok.php | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index beaf9a5ea3f..a935cd38434 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -34,3 +34,4 @@ ARollbackWasPerformedOnPostActions=A rollback was performed on all Post actions. ValidationOfPaymentFailed=Validation of payment has failed CardOwner=Card holder PayPalBalance=Paypal credit +OnlineSubscriptionPaymentLine=Online subscription recorded on %s
Paid via %s
Originating IP address: %s
Transaction ID: %s diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c0b88736ce3..992e7ab403d 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -504,9 +504,13 @@ if ($ispaymentok) { $datesubend = dol_time_plus_duree($datesubend, -1, 'd'); } + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); $paymentdate = $now; $amount = $FinalPaymentAmt; - $label = 'Online subscription '.dol_print_date($now, 'standard').' using '.$paymentmethod.' from '.$ipaddress.' - Transaction ID = '.$TRANSACTIONID; + $formatteddate = dol_print_date($paymentdate, 'dayhour', 'auto', $outputlangs); + $label = $langs->trans("OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID); // Payment informations $accountid = 0; @@ -693,9 +697,6 @@ if ($ispaymentok) { // Send subscription email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template From 10aa31a376fada47228daf78021b3c3d43a00d30 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 27 Jun 2022 00:31:59 +0200 Subject: [PATCH 03/23] Let users know that the PDF invoice is enclosed --- htdocs/langs/en_US/members.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 22060706a36..fafa1a60400 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -135,7 +135,7 @@ CardContent=Content of your member card # Text of email templates ThisIsContentOfYourMembershipRequestWasReceived=We want to let you know that your membership request was received.

ThisIsContentOfYourMembershipWasValidated=We want to let you know that your membership was validated with the following information:

-ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded.

+ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded. Please find your invoice here enclosed.

ThisIsContentOfSubscriptionReminderEmail=We want to let you know that your subscription is about to expire or has already expired (__MEMBER_LAST_SUBSCRIPTION_DATE_END__). We hope you will renew it.

ThisIsContentOfYourCard=This is a summary of the information we have about you. Please contact us if anything is incorrect.

DescADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT=Subject of the notification email received in case of auto-inscription of a guest From 0fca79529a782cacdd47387131d527e98aaf60d8 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Tue, 28 Jun 2022 01:51:14 +0200 Subject: [PATCH 04/23] Missing lib import --- htdocs/public/members/new.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 31f1fa9f952..654fce78ccc 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -64,6 +64,7 @@ if (is_numeric($entity)) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; From 5998999f18741ec3a7c9f439231054e59ef0aa8c Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Tue, 28 Jun 2022 02:33:17 +0200 Subject: [PATCH 05/23] NEW: Add free membership amounts at the membership type level --- .../adherents/class/adherent_type.class.php | 10 +++++- htdocs/adherents/type.php | 10 +++++- htdocs/core/lib/payments.lib.php | 4 ++- .../install/mysql/migration/15.0.0-16.0.0.sql | 3 +- htdocs/langs/en_US/members.lang | 3 ++ htdocs/langs/fr_FR/members.lang | 3 ++ htdocs/public/members/new.php | 31 ++++++++++++++----- 7 files changed, 52 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3f857ce827b..38641c8664b 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -94,6 +94,11 @@ class AdherentType extends CommonObject */ public $amount; + /** + * @var int Amount can be choosen by the visitor during subscription (0 or 1) + */ + public $caneditamount; + /** * @var string Public note * @deprecated @@ -380,6 +385,7 @@ class AdherentType extends CommonObject $sql .= "morphy = '".$this->db->escape($this->morphy)."',"; $sql .= "subscription = '".$this->db->escape($this->subscription)."',"; $sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).","; + $sql .= "caneditamount = '".$this->db->escape($this->caneditamount)."',"; $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',"; $sql .= "note = '".$this->db->escape($this->note_public)."',"; $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; @@ -474,7 +480,7 @@ class AdherentType extends CommonObject { global $langs, $conf; - $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.mail_valid, d.note as note_public, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.caneditamount, d.mail_valid, d.note as note_public, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -495,6 +501,7 @@ class AdherentType extends CommonObject $this->duration_unit = substr($obj->duration, -1); $this->subscription = $obj->subscription; $this->amount = $obj->amount; + $this->caneditamount = $obj->caneditamount; $this->mail_valid = $obj->mail_valid; $this->note = $obj->note_public; // deprecated $this->note_public = $obj->note_public; @@ -850,6 +857,7 @@ class AdherentType extends CommonObject $this->note_public = 'This is a public note'; $this->mail_valid = 'This is welcome email'; $this->subscription = 1; + $this->caneditamount = 0; $this->vote = 0; $this->status = 1; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index bcd6c99afbf..0b54132b5d0 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -122,6 +122,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { $object->status = (int) $status; $object->subscription = (int) $subscription; $object->amount = ($amount == '' ? '' : price2num($amount, 'MT')); + $object->caneditamount = (int) GETPOST("caneditamount", 'int'); $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); @@ -229,7 +230,7 @@ llxHeader('', $langs->trans("MembersTypeSetup"), $help_url); if (!$rowid && $action != 'create' && $action != 'edit') { //print dol_get_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.vote, d.statut as status, d.morphy"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; @@ -276,6 +277,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''.$langs->trans("MembersNature").''; print ''.$langs->trans("SubscriptionRequired").''; print ''.$langs->trans("Amount").''; + print ''.$langs->trans("CanEditAmountShort").''; print ''.$langs->trans("VoteAllowed").''; print ''.$langs->trans("Status").''; print ' '; @@ -292,6 +294,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype->status = $objp->status; $membertype->subscription = $objp->subscription; $membertype->amount = $objp->amount; + $membertype->caneditamount = $objp->caneditamount; print ''; print ''; @@ -310,6 +313,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''.yn($objp->subscription).''; print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''; + print ''.yn($objp->caneditamount).''; print ''.yn($objp->vote).''; print ''.$membertype->getLibStatut(5).''; if ($user->rights->adherent->configurer) { @@ -380,6 +384,10 @@ if ($action == 'create') { print ''; print ''; + print ''.$langs->trans("CanEditAmountShort").''; + print $form->selectyesno("caneditamount", 0, 1); + print ''; + print ''.$langs->trans("VoteAllowed").''; print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1); print ''; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 2911564adef..c006c4b9c9f 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -318,7 +318,9 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } } elseif ($type == 'member' || $type == 'membersubscription') { $newtype = 'member'; - $out = $urltouse.'/public/payment/newpayment.php?source=member&ref='.($mode ? '' : ''); + $out = $urltouse.'/public/payment/newpayment.php?source=member'; + $out .= '&amount='.$amount; + $out .= '&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= 'member_ref'; } diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index b57cab5b4eb..c465151f9c2 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -648,4 +648,5 @@ ALTER TABLE llx_paiement MODIFY COLUMN ext_payment_id varchar(255); ALTER TABLE llx_payment_donation MODIFY COLUMN ext_payment_id varchar(255); ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN ext_payment_id varchar(255); - +-- Allow users to make subscriptions of any amount during membership subscription +ALTER TABLE llx_adherent_type ADD COLUMN caneditamount varchar(3) DEFAULT 0 AFTER amount; diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index fafa1a60400..e552755f705 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -71,6 +71,9 @@ MemberTypeCanNotBeDeleted=Member type can not be deleted NewSubscription=New contribution NewSubscriptionDesc=This form allows you to record your subscription as a new member of the foundation. If you want to renew your subscription (if already a member), please contact foundation board instead by email %s. Subscription=Contribution +AnyAmountWithAdvisedAmount=Any amount with a recommended amount of %s %s +AnyAmountWithoutAdvisedAmount=Any amount +CanEditAmountShort=Any amount Subscriptions=Contributions SubscriptionLate=Late SubscriptionNotReceived=Contribution never received diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index a6f805daca6..5f67cc681ab 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -199,6 +199,9 @@ 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 +AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s +AnyAmountWithoutAdvisedAmount=Montant libre +CanEditAmountShort=Montant libre MEMBER_NEWFORM_PAYONLINE=Rediriger sur la page intégrée de paiement en ligne ByProperties=Par nature MembersStatisticsByProperties=Statistiques des adhérents par nature diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 654fce78ccc..f6957502284 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -692,16 +692,31 @@ if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { // Clean the amount $amount = price2num($amount); - + $adht = new AdherentType($db); + $adht->fetch($typeid); + $caneditamount = $adht->caneditamount; + $showedamount = $amount>0? $amount: 0; // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; + print ''.$langs->trans("Subscription"); + if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { + print ' - '.$langs->trans("SeeHere").''; + } + print ''; + + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) { + print ''; + print ' '.$langs->trans("Currency".$conf->currency).' – '; + print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); + print ''; + } else { + print ''; + print ''; + print ' '.$langs->trans("Currency".$conf->currency); } - print ' '.$langs->trans("Currency".$conf->currency); print ''; } From ea0c710104d7b6cc7f0d31d30c14d939234989e6 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 00:23:27 +0200 Subject: [PATCH 06/23] dopayment string fix --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index b61a2e22a06..ff53ccf0e09 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1596,7 +1596,7 @@ if ($source == 'member' || $source == 'membersubscription') { print ''; print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.urlencode($source).'&ref='.urlencode($ref).'&amount='.urlencode($amount).'&typeid=\' + this.value + \'&securekey='.urlencode($SECUREKEY).'\');"', 0, 0, 0, '', '', 1); print "\n"; - } elseif ($action == dopayment) { + } elseif ($action == 'dopayment') { print ''.$langs->trans("NewMemberType"); print ''.dol_escape_htmltag($member->type); print ''; From 759900bccee95b31e7684b2d69d93370d0e176ed Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 00:27:18 +0200 Subject: [PATCH 07/23] 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"; From f8af181cee81767fd2f0f68cbd30c59f438951d5 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 00:28:33 +0200 Subject: [PATCH 08/23] Label clarification following the new per-type setting "CanEditAmount" --- htdocs/langs/en_US/members.lang | 2 +- htdocs/langs/fr_FR/members.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index d9af9c9c350..70b207c2b88 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -201,7 +201,7 @@ NbOfSubscriptions=Number of contributions 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 +CanEditAmount=Visitor can choose/edit amount of its contribution regardless of the member type AmountIsLowerToMinimumNotice=sur un dû total de %s MEMBER_NEWFORM_PAYONLINE=Jump on integrated online payment page ByProperties=By nature diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 9cf2f25a2b0..9c3c51d52c6 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -198,7 +198,7 @@ NbOfSubscriptions=Nombre de cotisations 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 +CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation quel que soit le type d'adhésion AmountIsLowerToMinimumNotice=sur un dû total de %s AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s AnyAmountWithoutAdvisedAmount=Montant libre From e7058c253e6b5014bec7e77b44a3e80301048038 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 03:25:33 +0200 Subject: [PATCH 09/23] NEW: Table of membership types --- htdocs/langs/en_US/members.lang | 3 + htdocs/langs/fr_FR/members.lang | 3 + htdocs/public/members/new.php | 580 ++++++++++++++++++-------------- 3 files changed, 339 insertions(+), 247 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 70b207c2b88..972be559eec 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -74,6 +74,9 @@ Subscription=Contribution AnyAmountWithAdvisedAmount=Any amount with a recommended amount of %s %s AnyAmountWithoutAdvisedAmount=Any amount CanEditAmountShort=Any amount +CanEditAmountShortForValues=recommended, any amount +MembershipDuration=Duration +GetMembershipButtonLabel=Get membership Subscriptions=Contributions SubscriptionLate=Late SubscriptionNotReceived=Contribution never received diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 9c3c51d52c6..a5a76c9be55 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -202,6 +202,9 @@ CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation qu AmountIsLowerToMinimumNotice=sur un dû total de %s AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s AnyAmountWithoutAdvisedAmount=Montant libre +CanEditAmountShortForValues=conseillé, montant libre +MembershipDuration=Durée +GetMembershipButtonLabel=Adhérer CanEditAmountShort=Montant libre MEMBER_NEWFORM_PAYONLINE=Rediriger sur la page intégrée de paiement en ligne ByProperties=Par nature diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index f6957502284..6f490ca5b66 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -69,6 +69,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; // Init vars $errmsg = ''; @@ -474,268 +475,353 @@ dol_htmloutput_errors($errmsg); print '
'."\n"; print ''; print ''; -print ''; -print ''; -print '
'; +if (!empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { + print ''; + print '
'; + print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; + //print $langs->trans("FieldsWithIsForPublic",'**').'
'; -print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; -//print $langs->trans("FieldsWithIsForPublic",'**').'
'; - -print dol_get_fiche_head(''); - -print ''; - - -print ''."\n"; - -// Type -if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { - $listoftype = $adht->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; - } - print ''."\n"; -} else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; -} - -// Moral/Physic attribute -$morphys["phy"] = $langs->trans("Physical"); -$morphys["mor"] = $langs->trans("Moral"); -if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; -} else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; -} - -// Company -print ''."\n"; -// Title -print ''."\n"; -// Lastname -print ''."\n"; -// Firstname -print ''."\n"; -// EMail -print ''."\n"; -// Login -if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; -} -// Gender -print ''; -print ''; -// Address -print ''."\n"; -// Zip / Town -print ''; -// Country -print ''; -// State -if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; -} -// Birthday -print ''."\n"; -// Photo -print ''."\n"; -// Public -print ''."\n"; -// Other attributes -$tpl_context = 'public'; // define template context to public -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; -// Comments -print ''; -print ''; -print ''; -print ''."\n"; - -// Add specific fields used by Dolibarr foundation for example -// TODO Move this into generic feature. -if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); - print ''."\n"; -} + jQuery(document).ready(function () { + jQuery(document).ready(function () { + function initmorphy() + { + console.log("Call initmorphy"); + if (jQuery("#morphy").val() == \'phy\') { + jQuery("#trcompany").hide(); + } + if (jQuery("#morphy").val() == \'mor\') { + jQuery("#trcompany").show(); + } + }; + initmorphy(); + jQuery("#morphy").change(function() { + initmorphy(); + }); + jQuery("#selectcountry_id").change(function() { + document.newmember.action.value="create"; + document.newmember.submit(); + }); + jQuery("#typeid").change(function() { + document.newmember.action.value="create"; + document.newmember.submit(); + }); + }); + }); + '; -if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = 0; - $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); - // Set amount for the subscription: - // - First check the amount of the member type. - $amountbytype = $adht->amountByType(1); // Load the array of amount per type - $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; - // - If not found, take the default amount - if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - // - If not set, we accept ot have amount defined as parameter (for backward compatibility). - if (empty($amount)) { - $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : ''); - } + print '
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans("Company").''; -print img_picto('', 'company', 'class="pictofixedwidth"'); -print '
'.$langs->trans('UserTitle').''; -print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' *' : '').''; -//print img_picto('', 'email', 'class="pictofixedwidth"'); -print '
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Gender").''; -$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); -print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); -print '
'.$langs->trans("Address").''."\n"; -print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; -print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75'); -print ' / '; -print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); -print '
'.$langs->trans('Country').''; -print img_picto('', 'country', 'class="pictofixedwidth"'); -$country_id = GETPOST('country_id', 'int'); -if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); -} -if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; - } - } -} -$country_code = getCountry($country_id, 2, $db, $langs); -print $form->select_country($country_id, 'country_id'); -print '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } - print '
'.$langs->trans("DateOfBirth").''; -print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); -print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; + print dol_get_fiche_head(''); print ''; - print '
'."\n"; - // Clean the amount - $amount = price2num($amount); - $adht = new AdherentType($db); - $adht->fetch($typeid); - $caneditamount = $adht->caneditamount; - $showedamount = $amount>0? $amount: 0; - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''."\n"; } else { - print ''; - print ''; - print ' '.$langs->trans("Currency".$conf->currency); + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; } + + // Moral/Physic attribute + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { + print ''."\n"; + } else { + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; + } + + // Company + print ''."\n"; + // Title + print ''."\n"; + // Lastname + print ''."\n"; + // Firstname + print ''."\n"; + // EMail + print ''."\n"; + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + // Gender + print ''; + print ''; + // Address + print ''."\n"; + // Zip / Town + print ''; + // Country + print ''; + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; + } + // Birthday + print ''."\n"; + // Photo + print ''."\n"; + // Public + print ''."\n"; + // Other attributes + $tpl_context = 'public'; // define template context to public + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Comments + print ''; + print ''; + print ''; + print ''."\n"; + + // Add specific fields used by Dolibarr foundation for example + // TODO Move this into generic feature. + if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { + $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); + print ''."\n"; + } + + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = 0; + $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); + + // Set amount for the subscription: + // - First check the amount of the member type. + $amountbytype = $adht->amountByType(1); // Load the array of amount per type + $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; + // - If not found, take the default amount + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + // - If not set, we accept ot have amount defined as parameter (for backward compatibility). + if (empty($amount)) { + $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : ''); + } + + // Clean the amount + $amount = price2num($amount); + $adht = new AdherentType($db); + $adht->fetch($typeid); + $caneditamount = $adht->caneditamount; + $showedamount = $amount>0? $amount: 0; + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''; + } + + print "
'.$langs->trans("Subscription"); - if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { - print ' - '.$langs->trans("SeeHere").''; - } - print ''; - - if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) { - print ''; - print ' '.$langs->trans("Currency".$conf->currency).' – '; - print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); - print ''; + // Type + if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { + $listoftype = $adht->liste_array(); + $tmp = array_keys($listoftype); + $defaulttype = ''; + $isempty = 1; + if (count($listoftype) == 1) { + $defaulttype = $tmp[0]; + $isempty = 0; + } + print '
'.$langs->trans("Type").' *'; + print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); + print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans("Company").''; + print img_picto('', 'company', 'class="pictofixedwidth"'); + print '
'.$langs->trans('UserTitle').''; + print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' *' : '').''; + //print img_picto('', 'email', 'class="pictofixedwidth"'); + print '
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Gender").''; + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); print '
'.$langs->trans("Address").''."\n"; + print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; + print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75'); + print ' / '; + print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); + print '
'.$langs->trans('Country').''; + print img_picto('', 'country', 'class="pictofixedwidth"'); + $country_id = GETPOST('country_id', 'int'); + if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); + } + if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) { + $country_id = $new_country_id; + } + } + } + $country_code = getCountry($country_id, 2, $db, $langs); + print $form->select_country($country_id, 'country_id'); + print '
'.$langs->trans('State').''; + if ($country_code) { + print $formcompany->select_state(GETPOST("state_id"), $country_code); + } + print '
'.$langs->trans("DateOfBirth").''; + print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); + print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; + + print ''; + print '
'.$langs->trans("Subscription"); + if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { + print ' - '.$langs->trans("SeeHere").''; + } + print ''; + + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) { + print ''; + print ' '.$langs->trans("Currency".$conf->currency).' – '; + print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); + print ''; + } else { + print ''; + print ''; + print ' '.$langs->trans("Currency".$conf->currency); + } + print '
\n"; + + print dol_get_fiche_end(); + + // Save + print '
'; + print ''; + if (!empty($backtopage)) { + print '     '; + } + print '
'; + + + print "
\n"; + print "
"; + print ''; } +else { // Show the table of membership types + // Get units + $measuringUnits = new CUnits($db); + $result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1)); + $units = array(); + foreach ($measuringUnits->records as $lines) + $units[$lines->short_label] = $langs->trans(ucfirst($lines->label)); -print "\n"; + $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 .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; + $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; + $sql .= " AND d.statut=1"; -print dol_get_fiche_end(); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + print '
'; + print ''."\n"; + print ''; -// Save -print '
'; -print ''; -if (!empty($backtopage)) { - print '     '; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ""; + $i++; + } + + // If no record found + if ($num == 0) { + $colspan = 8; + print ''; + } + + print "
'.$langs->trans("Label").''.$langs->trans("MembershipDuration").''.$langs->trans("Amount").''.$langs->trans("MembersNature").''.$langs->trans("VoteAllowed").''.$langs->trans("NewSubscription").'
'.dol_escape_htmltag($objp->label).''; + $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration); + print max(1, intval($objp->duration)).' '.$units[$unit]; + print ''; + $displayedamount = max(intval($objp->amount), intval($conf->global->MEMBER_MIN_AMOUNT)); + $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $objp->caneditamount; + if($objp->subscription) { + print $displayedamount.' '.strtoupper($conf->currency); + if ($caneditamount && $displayedamount>0) { + print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3); + } + elseif ($caneditamount) { + print $langs->transnoentities("CanEditAmountShort"); + } + } + else { + print "–"; // No subscription required + } + print ''; + if ($objp->morphy == 'phy') { + print $langs->trans("Physical"); + } elseif ($objp->morphy == 'mor') { + print $langs->trans("Moral"); + } else { + print $langs->trans("MorAndPhy"); + } + print ''.yn($objp->vote).'
'.$langs->trans("NoRecordFound").'
"; + print '
'; + + print ''; + } else { + dol_print_error($db); + } } -print ''; - - -print "\n"; -print "
"; -print ''; llxFooterVierge(); From f4d5962254504ae5df37bfc031537ef0969a6e16 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 03:27:48 +0200 Subject: [PATCH 10/23] Allow to skip membership table for retrocompatibility --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 6f490ca5b66..04ae3cdd7bd 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -476,7 +476,7 @@ print '
'. print ''; print ''; -if (!empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { +if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { print ''; print '
'; print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; From f4c7c03dc10fea94957c40f1bde99d305ca8996f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 29 Jun 2022 14:38:43 +0000 Subject: [PATCH 11/23] Fixing style errors. --- htdocs/public/members/new.php | 14 ++++++-------- htdocs/public/payment/newpayment.php | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 04ae3cdd7bd..7f3687cc006 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -702,7 +702,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ' - '.$langs->trans("SeeHere").''; } print ''; - + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } @@ -753,7 +753,7 @@ else { // Show the table of membership types $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - + print '
'; print ''."\n"; print ''; @@ -766,7 +766,7 @@ else { // Show the table of membership types print ''; print ''; print "\n"; - + $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); @@ -780,16 +780,14 @@ else { // Show the table of membership types print ''; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1c3c0202b23..a6b190bfc66 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1622,10 +1622,10 @@ if ($source == 'member' || $source == 'membersubscription') { 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) { + if (!$caneditamount && $minimumamount > $amount) { print ' '. $langs->trans("AmountIsLowerToMinimumNotice", price($adht->amount, 1, $langs, 1, -1, -1, $currency)); } - + print ''; print ''; print ''."\n"; From 6a8882b60ddd36072345bb19154865e7adc7f3d4 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Thu, 30 Jun 2022 00:39:13 +0200 Subject: [PATCH 12/23] Bugfix: regression, keep newamount equal to amount for the payment Follows 759900bccee95b31e7684b2d69d93370d0e176ed --- htdocs/public/payment/newpayment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index a6b190bfc66..faf3cafc59a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1627,6 +1627,7 @@ if ($source == 'member' || $source == 'membersubscription') { } print ''; + print ''; print ''; print ''."\n"; From 5af4e811404f35928ee8053d5ac887bcce013eb2 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Fri, 1 Jul 2022 17:39:56 +0200 Subject: [PATCH 13/23] Delay caneditamount feature to v17 --- .../install/mysql/migration/16.0.0-17.0.0.sql | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 htdocs/install/mysql/migration/16.0.0-17.0.0.sql diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql new file mode 100644 index 00000000000..67402464199 --- /dev/null +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -0,0 +1,36 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 15.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table; +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex; +-- To make pk to be auto increment (mysql): +-- -- VMYSQL4.3 ALTER TABLE llx_table ADD PRIMARY KEY(rowid); +-- -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. +-- To rebuild sequence for postgresql after insert by forcing id autoincrement fields: +-- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); + + +-- Allow users to make subscriptions of any amount during membership subscription +ALTER TABLE llx_adherent_type ADD COLUMN caneditamount varchar(3) DEFAULT 0 AFTER amount; From 4906fec4ee061b27f068086835871c178812beb8 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Fri, 8 Jul 2022 10:12:30 +0200 Subject: [PATCH 14/23] Missing migration label --- htdocs/langs/en_US/install.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index a6716034c2d..32f251707a4 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -27,6 +27,7 @@ ErrorDatabaseVersionTooLow=Database version (%s) too old. Version %s or higher i ErrorPHPVersionTooLow=PHP version too old. Version %s is required. ErrorConnectedButDatabaseNotFound=Connection to server successful but database '%s' not found. ErrorDatabaseAlreadyExists=Database '%s' already exists. +ErrorNoMigrationFilesFoundForParameters=No migration file found for the selected versions IfDatabaseNotExistsGoBackAndUncheckCreate=If the database does not exist, go back and check option "Create database". IfDatabaseExistsGoBackAndCheckCreate=If database already exists, go back and uncheck "Create database" option. WarningBrowserTooOld=Version of browser is too old. Upgrading your browser to a recent version of Firefox, Chrome or Opera is highly recommended. From f1b9a1e008a5c1c826e26a5ec3d98330fd81320e Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Fri, 8 Jul 2022 11:08:03 +0200 Subject: [PATCH 15/23] use the default amount only if the amount field is editable --- htdocs/public/members/new.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 7f3687cc006..0a2ca237f0f 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -674,15 +674,17 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = 0; $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); + $adht = new AdherentType($db); + $adht->fetch($typeid); + $caneditamount = $adht->caneditamount; // Set amount for the subscription: // - First check the amount of the member type. $amountbytype = $adht->amountByType(1); // Load the array of amount per type $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; - // - If not found, take the default amount - if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + // - If not found, take the default amount only of the user is authorized to edit it + if ($caneditamount && empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } // - If not set, we accept ot have amount defined as parameter (for backward compatibility). @@ -692,9 +694,6 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW // Clean the amount $amount = price2num($amount); - $adht = new AdherentType($db); - $adht->fetch($typeid); - $caneditamount = $adht->caneditamount; $showedamount = $amount>0? $amount: 0; // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' print '
'.$langs->trans("VoteAllowed").''.$langs->trans("NewSubscription").'
'; $displayedamount = max(intval($objp->amount), intval($conf->global->MEMBER_MIN_AMOUNT)); $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $objp->caneditamount; - if($objp->subscription) { + if ($objp->subscription) { print $displayedamount.' '.strtoupper($conf->currency); if ($caneditamount && $displayedamount>0) { print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3); - } - elseif ($caneditamount) { + } elseif ($caneditamount) { print $langs->transnoentities("CanEditAmountShort"); } - } - else { + } else { print "–"; // No subscription required } print '
'.$langs->trans("Subscription"); From abcfbca77f210e0267159b1eebae1f2f70bf625f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Jul 2022 11:36:59 +0200 Subject: [PATCH 16/23] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 38641c8664b..1b42c6e77ca 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -385,7 +385,7 @@ class AdherentType extends CommonObject $sql .= "morphy = '".$this->db->escape($this->morphy)."',"; $sql .= "subscription = '".$this->db->escape($this->subscription)."',"; $sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).","; - $sql .= "caneditamount = '".$this->db->escape($this->caneditamount)."',"; + $sql .= "caneditamount = ".((int) $this->db->escape($this->caneditamount)).","; $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',"; $sql .= "note = '".$this->db->escape($this->note_public)."',"; $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; From fd0bac05d9817d02e2ba65a7189ffd80bee1e585 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Jul 2022 11:37:29 +0200 Subject: [PATCH 17/23] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 1b42c6e77ca..86ec35139e1 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -385,7 +385,7 @@ class AdherentType extends CommonObject $sql .= "morphy = '".$this->db->escape($this->morphy)."',"; $sql .= "subscription = '".$this->db->escape($this->subscription)."',"; $sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).","; - $sql .= "caneditamount = ".((int) $this->db->escape($this->caneditamount)).","; + $sql .= "caneditamount = ".((int) $this->caneditamount).","; $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',"; $sql .= "note = '".$this->db->escape($this->note_public)."',"; $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; From 48a710dffa5d1d5402908c1f283db20a9d252272 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Jul 2022 11:37:58 +0200 Subject: [PATCH 18/23] Update type.php --- htdocs/adherents/type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 0b54132b5d0..0f1acf1bed0 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -122,7 +122,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { $object->status = (int) $status; $object->subscription = (int) $subscription; $object->amount = ($amount == '' ? '' : price2num($amount, 'MT')); - $object->caneditamount = (int) GETPOST("caneditamount", 'int'); + $object->caneditamount = GETPOSTINT("caneditamount"); $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); From 5356703f848e1d181ce4e296cb29df4426a5da88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Jul 2022 11:38:52 +0200 Subject: [PATCH 19/23] Update 16.0.0-17.0.0.sql --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 118c2f25124..02313f08f3b 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -52,4 +52,4 @@ ALTER TABLE llx_facture ADD COLUMN close_missing_amount double(24, 8) after clos ALTER TABLE llx_facture_fourn ADD COLUMN close_missing_amount double(24, 8) after close_code; -- Allow users to make subscriptions of any amount during membership subscription -ALTER TABLE llx_adherent_type ADD COLUMN caneditamount varchar(3) DEFAULT 0 AFTER amount; +ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER amount; From 2699159deae4b3d1cfdece9dd3ec1a358da14cf0 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 11 Jul 2022 11:42:18 +0200 Subject: [PATCH 20/23] Add admin link for errormsg "click here to finish mandatory setup" --- htdocs/adherents/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0096ba9a285..007ed517d2f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -677,7 +677,8 @@ if (empty($reshook)) { if (empty($labeltouse) || (int) $labeltouse === -1) { //fallback on the old configuration. - setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); + $langs->load("errors"); + setEventMessages(''.$langs->trans('WarningMandatorySetupNotComplete').'', null, 'errors'); $error++; } else { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); From 39c9eb87088a307cca35ab5728b961d887d4a5d1 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 11 Jul 2022 11:44:00 +0200 Subject: [PATCH 21/23] Fix: fetch the right amount for membership payment It was defaulting to 9.99 --- htdocs/adherents/card.php | 9 +++++++-- htdocs/core/lib/payments.lib.php | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 007ed517d2f..cb206449a97 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -2029,9 +2029,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($useonlinepayment) { print '
'; - + if(empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past + $amount = price(max($adht->amount, $object->first_subscription_amount, $object->last_subscription_amount)); + } + if(empty($amount)) { + $amount = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - print showOnlinePaymentUrl('membersubscription', $object->ref); + print showOnlinePaymentUrl('membersubscription', $object->ref, $amount); } print '
'; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 01fdc57db51..794c9d5da7e 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -173,9 +173,10 @@ function getValidOnlinePaymentMethods($paymentmethod = '') * * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...) * @param string $ref Ref of object + * @param int $amount Amount of money to request for * @return string Url string */ -function showOnlinePaymentUrl($type, $ref) +function showOnlinePaymentUrl($type, $ref, $amount='9.99') { global $langs; @@ -185,7 +186,7 @@ function showOnlinePaymentUrl($type, $ref) $servicename = ''; // Link is a generic link for all payments services (paypal, stripe, ...) $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
'; - $url = getOnlinePaymentUrl(0, $type, $ref); + $url = getOnlinePaymentUrl(0, $type, $ref, $amount); $out .= ''; @@ -199,11 +200,12 @@ function showOnlinePaymentUrl($type, $ref) * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...) * @param string $ref Ref of object * @param string $label Text or HTML tag to display, if empty it display the URL + * @param int $amount Amount of money to request for * @return string Url string */ -function getHtmlOnlinePaymentLink($type, $ref, $label = '') +function getHtmlOnlinePaymentLink($type, $ref, $label = '', $amount='9.99') { - $url = getOnlinePaymentUrl(0, $type, $ref); + $url = getOnlinePaymentUrl(0, $type, $ref, $amount); $label = $label ? $label : $url; return ''.$label.''; } @@ -215,7 +217,7 @@ function getHtmlOnlinePaymentLink($type, $ref, $label = '') * @param int $mode 0=True url, 1=Url formated with colors * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...) * @param string $ref Ref of object - * @param int $amount Amount (required and used for $type='free' only) + * @param int $amount Amount of money to request for * @param string $freetag Free tag (required and used for $type='free' only) * @param string $localorexternal 0=Url for browser, 1=Url for external access * @return string Url string From fd4c071c551ff414c80dfa3741da9bcfa6249e85 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 11 Jul 2022 11:59:02 +0200 Subject: [PATCH 22/23] Fix displayed amount when canEditAmount is true globally --- htdocs/public/members/new.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 0a2ca237f0f..7b9f59ee5cc 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -780,7 +780,9 @@ else { // Show the table of membership types $displayedamount = max(intval($objp->amount), intval($conf->global->MEMBER_MIN_AMOUNT)); $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $objp->caneditamount; if ($objp->subscription) { - print $displayedamount.' '.strtoupper($conf->currency); + if ($displayedamount > 0 || !$caneditamount) { + print $displayedamount.' '.strtoupper($conf->currency); + } if ($caneditamount && $displayedamount>0) { print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3); } elseif ($caneditamount) { From afefc369ed39f7f15169797b5083eef488d45a22 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 11 Jul 2022 10:06:31 +0000 Subject: [PATCH 23/23] Fixing style errors. --- htdocs/adherents/card.php | 4 ++-- htdocs/core/lib/payments.lib.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index cb206449a97..c60308138d2 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -2029,10 +2029,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($useonlinepayment) { print '
'; - if(empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past + if (empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past $amount = price(max($adht->amount, $object->first_subscription_amount, $object->last_subscription_amount)); } - if(empty($amount)) { + if (empty($amount)) { $amount = 0; } require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 794c9d5da7e..809b5f8dc73 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -176,7 +176,7 @@ function getValidOnlinePaymentMethods($paymentmethod = '') * @param int $amount Amount of money to request for * @return string Url string */ -function showOnlinePaymentUrl($type, $ref, $amount='9.99') +function showOnlinePaymentUrl($type, $ref, $amount = '9.99') { global $langs; @@ -203,7 +203,7 @@ function showOnlinePaymentUrl($type, $ref, $amount='9.99') * @param int $amount Amount of money to request for * @return string Url string */ -function getHtmlOnlinePaymentLink($type, $ref, $label = '', $amount='9.99') +function getHtmlOnlinePaymentLink($type, $ref, $label = '', $amount = '9.99') { $url = getOnlinePaymentUrl(0, $type, $ref, $amount); $label = $label ? $label : $url;