From 3c10f05a600d5c2f9e241eb5c89ad036332f9b15 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 | 10 +++++++++- CRM/Contribute/BAO/Query.php | 1 + .../Contribute/Form/Search/ContributionRecur.tpl | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index a5c76722c433..a0ab452b8468 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -780,9 +780,17 @@ public static function recurringContribution(&$form) { array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => CRM_Contribute_PseudoConstant::contributionStatus()) ); - $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('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 94aa7386664d..d07fea52ba7d 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -376,6 +376,7 @@ public static function whereClauseSingle(&$values, &$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 6e696f3f7c2a..6dd84d01acef 100644 --- a/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl +++ b/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl @@ -71,12 +71,26 @@ - {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} + + {if $contributionRecurGroupTree}