From 084bc9af3c7ffe95cfadfaebc480e2de635ad65c Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Tue, 6 May 2025 14:32:48 +0200 Subject: [PATCH] Use the getValidPayment to detect payment modules --- htdocs/adherents/admin/website.php | 44 ++++++++++++++++-------------- htdocs/don/admin/website.php | 9 +++--- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 1c45e25c404..4c8996ea70a 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -32,6 +32,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; /** @@ -49,6 +50,10 @@ $langs->loadLangs(array("admin", "members")); $action = GETPOST('action', 'aZ09'); +// Hook to be used by external payment modules (ie Payzen, ...) +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('newpayment')); + if (!$user->admin) { accessforbidden(); } @@ -143,23 +148,18 @@ if ($conf->use_javascript_ajax) { print 'jQuery(document).ready(function () { function initemail() { - if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') - { + if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') { jQuery("#tremail").hide(); - } - else - { + } else { jQuery("#tremail").show(); } } function initfields() { - if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\') - { + if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\') { jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide(); } - if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\') - { + if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\') { jQuery("#trforcetype, #tramount, #tredit, #trpayment").show(); if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide(); else jQuery("#tremail").show(); @@ -197,7 +197,6 @@ print '

'; if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print '
'; - //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').'
'; if (isModEnabled('multicompany')) { $entity_qr = '?entity='.((int) $conf->entity); @@ -289,18 +288,23 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print ''; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); print ''; + + // Initialize $validpaymentmethod + // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods() + $validpaymentmethod = getValidOnlinePaymentMethods('', 1); + + // Define $listofval using the $validpaymentmethod $listofval = array(); - $listofval['-1'] = $langs->trans('No'); - $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'; - if (isModEnabled('paybox')) { - $listofval['paybox'] = 'Paybox'; - } - if (isModEnabled('paypal')) { - $listofval['paypal'] = 'PayPal'; - } - if (isModEnabled('stripe')) { - $listofval['stripe'] = 'Stripe'; + $listofval['-1'] = array('label' => $langs->trans('No')); + $listofval['all'] = array('label' => $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')', 'data-html' => $langs->trans('Yes').'   ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'); + foreach ($validpaymentmethod as $key => $val) { + if (is_array($val)) { + $listofval[$key] = $val; + } else { + $listofval[$key] = array('label' => $key, 'status' => 'valid'); + } } + print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0); print "\n"; diff --git a/htdocs/don/admin/website.php b/htdocs/don/admin/website.php index df2b6a948c2..031a286c097 100644 --- a/htdocs/don/admin/website.php +++ b/htdocs/don/admin/website.php @@ -104,8 +104,9 @@ if ($action == 'update') { $form = new Form($db); $title = $langs->trans("DonationsSetup"); +$help_url = 'EN:Module_Donation|FR:Module_Don'; -llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-don page-admin_website'); +llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-don page-admin_website'); $linkback = ''.$langs->trans("BackToModuleList").''; @@ -126,12 +127,10 @@ if ($conf->use_javascript_ajax) { print 'jQuery(document).ready(function () { function initfields() { - if (jQuery("#DONATION_ENABLE_PUBLIC").val()==\'0\') - { + if (jQuery("#DONATION_ENABLE_PUBLIC").val()==\'0\') { jQuery("#trforcetype, #tramount, #tredit, #trpayment").hide(); } - if (jQuery("#DONATION_ENABLE_PUBLIC").val()==\'1\') - { + if (jQuery("#DONATION_ENABLE_PUBLIC").val()==\'1\') { jQuery("#trforcetype, #tramount, #tredit, #trpayment").show(); } }