From 5951bdaa25f2756bbfd131fbab3b0923c2fb2437 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Fri, 14 Sep 2018 10:47:08 +0100 Subject: [PATCH] Allow contribution search by recurring payment processor ID / Transaction ID --- CRM/Contribute/BAO/ContributionRecur.php | 9 ++++++++ CRM/Contribute/BAO/Query.php | 1 + .../Form/Search/ContributionRecur.tpl | 23 ++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index a5c76722c4..5c2e19ca8d 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -783,6 +783,15 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) $form->addElement('text', 'contribution_recur_processor_id', ts('Processor ID'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionRecur', 'processor_id')); $form->addElement('text', 'contribution_recur_trxn_id', ts('Transaction ID'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionRecur', 'trxn_id')); + $paymentProcessorParams = [ + 'return' => ["id", "name", 'is_test'], + ]; + $paymentProcessors = civicrm_api3('PaymentProcessor', 'get', $paymentProcessorParams); + foreach ($paymentProcessors['values'] as $key => $value) { + $paymentProcessorOpts[$key] = $value['name'] . ($value['is_test'] ? ' (Test)' : ''); + } + $form->add('select', 'contribution_recur_payment_processor_id', ts('Payment Processor ID'), $paymentProcessorOpts, FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple']); + CRM_Core_BAO_Query::addCustomFormFields($form, array('ContributionRecur')); } diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 94aa738666..d07fea52ba 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -376,6 +376,7 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { return; case 'contribution_recur_processor_id': + case 'contribution_recur_payment_processor_id': case 'contribution_recur_trxn_id': $fieldName = str_replace('contribution_recur_', '', $name); $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution_recur.{$fieldName}", diff --git a/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl b/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl index 6e696f3f7c..50f038c5c2 100644 --- a/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl +++ b/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl @@ -71,12 +71,33 @@ - {ts}Recurring Contribution Status{/ts} + {ts}Status{/ts} {$form.contribution_recur_contribution_status_id.html|crmAddClass:twenty} + + {ts}Payment Processor{/ts} + + + {$form.contribution_recur_payment_processor_id.html} + + + + {ts}Transaction ID{/ts} + + + {$form.contribution_recur_trxn_id.html} + + + + {ts}Processor ID{/ts} + + + {$form.contribution_recur_processor_id.html} + + {if $contributionRecurGroupTree} -- 2.25.1