From b501c1bdc95c7be586f90dc8bfbc425305c49fc8 Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp <85277674+olayiwola-compucorp@users.noreply.github.com> Date: Fri, 5 Jan 2024 09:18:20 +0100 Subject: [PATCH] CIWEMB-538: Support creating payment methods that can be hidden from user Applying PR https://github.com/civicrm/civicrm-core/pull/28876 --- 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 3f2bcbabdf4c..a6a4ef74b43a 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3510,6 +3510,13 @@ public static function buildOptions($fieldName, $context = NULL, $props = []) { 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 314bfaf54040..056f36b5e8f1 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -228,7 +228,7 @@ public function buildQuickForm() { $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);"] ); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index b8ef62d7fcbf..b5b584ba4223 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -655,7 +655,7 @@ public function buildQuickForm() { $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);"] ); }