From 8fa49f5555f235dd8515463e9076e05afad46aa9 Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp Date: Thu, 4 Jan 2024 13:46:36 +0100 Subject: [PATCH] Support creating payment methods that can be hidden from user --- CRM/Contribute/BAO/Contribution.php | 7 +++++++ CRM/Contribute/Form/AdditionalPayment.php | 2 +- CRM/Contribute/Form/Contribution.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 9c465f9904..48001326b8 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3506,6 +3506,13 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac if ($context !== 'validate') { $params['condition'] = "v.name <> 'Template'"; } + break; + + case 'payment_instrument_id': + if (isset($props['filter'])) { + $params['condition'] = "v.filter = " . $props['filter']; + } + break; } return CRM_Core_PseudoConstant::get($className, $fieldName, $params, $context); } diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 9e24c24928..a846482e82 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -235,7 +235,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $this->add('select', 'payment_instrument_id', ts('Payment Method'), - ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), + ['' => ts('- select -')] + CRM_Contribute_BAO_Contribution::buildOptions('payment_instrument_id', 'create', ['filter' => 0]), TRUE, ['onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);", 'class' => 'crm-select2'] ); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 52e1c26c2c..0fe2526ea9 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -718,7 +718,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $checkPaymentID = array_search('Check', CRM_Contribute_BAO_Contribution::buildOptions('payment_instrument_id', 'validate')); $paymentInstrument = $this->add('select', 'payment_instrument_id', ts('Payment Method'), - ['' => ts('- select -')] + CRM_Contribute_BAO_Contribution::buildOptions('payment_instrument_id', 'create'), + ['' => ts('- select -')] + CRM_Contribute_BAO_Contribution::buildOptions('payment_instrument_id', 'create', ['filter' => 0]), $required, ['onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);", 'class' => 'crm-select2'] ); -- 2.25.1