Allow contribution search by recurring payment processor ID / Transaction ID
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 14 Sep 2018 09:47:08 +0000 (10:47 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sun, 7 Oct 2018 10:54:37 +0000 (11:54 +0100)
CRM/Contribute/BAO/ContributionRecur.php
CRM/Contribute/BAO/Query.php
templates/CRM/Contribute/Form/Search/ContributionRecur.tpl

index a5c76722c4339cca4753afcb0dd3edf417270dbc..5c2e19ca8d01c04ac1ed3b4db827cef04be38cb0 100644 (file)
@@ -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'));
 
   }
index 94aa7386664d475fbf2bda4e4458c7fc6dbb4a62..d07fea52ba7d57e2088b63cc044b46e16cf91f7e 100644 (file)
@@ -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}",
index 6e696f3f7c2a418df5c9002f9514e5af8cde7b8d..50f038c5c23ab5465daaab14a8904a5130293a72 100644 (file)
         </td>
       </tr>
       <tr>
-        <td>{ts}Recurring Contribution Status{/ts}</td>
+        <td>{ts}Status{/ts}</td>
         <td></td>
         <td col='span2'>
           {$form.contribution_recur_contribution_status_id.html|crmAddClass:twenty}
         </td>
       </tr>
+      <tr>
+        <td>{ts}Payment Processor{/ts}</td>
+        <td></td>
+        <td col='span2'>
+          {$form.contribution_recur_payment_processor_id.html}
+        </td>
+      </tr>
+      <tr>
+        <td>{ts}Transaction ID{/ts}</td>
+        <td></td>
+        <td col='span2'>
+          {$form.contribution_recur_trxn_id.html}
+        </td>
+      </tr>
+      <tr>
+        <td>{ts}Processor ID{/ts}</td>
+        <td></td>
+        <td col='span2'>
+          {$form.contribution_recur_processor_id.html}
+        </td>
+      </tr>
       {if $contributionRecurGroupTree}
         <tr>
           <td colspan="4">