Use the getValidPayment to detect payment modules

This commit is contained in:
ldestailleur 2025-05-06 14:32:48 +02:00
parent 6a22102155
commit 084bc9af3c
2 changed files with 28 additions and 25 deletions

View file

@ -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 '<br><br>';
if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print '<br>';
//print $langs->trans('FollowingLinksArePublic').'<br>';
print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
if (isModEnabled('multicompany')) {
$entity_qr = '?entity='.((int) $conf->entity);
@ -289,18 +288,23 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print '<tr class="oddeven" id="trpayment"><td>';
print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
print '</td><td>';
// 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').' &nbsp; <span class="opacitymedium">('.$langs->trans("VisitorCanChooseItsPaymentMode").')</span>');
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 "</td></tr>\n";

View file

@ -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 = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
@ -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();
}
}