diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index a5c76722c433..f718538df261 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -762,6 +762,14 @@ public static function recurringContribution(&$form) { } } + // If values have been supplied for recurring contribution fields, open the recurring contributions pane. + foreach (array('contribution_status_id', 'payment_processor_id', 'processor_id', 'trxn_id') as $fieldName) { + if (!empty($form->_formValues['contribution_recur_' . $fieldName])) { + $form->assign('contribution_recur_pane_open', TRUE); + break; + } + } + // Add field to check if payment is made for recurring contribution $recurringPaymentOptions = array( 1 => ts('All recurring contributions'), @@ -783,6 +791,15 @@ public static function recurringContribution(&$form) { $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 94aa7386664d..abf05f7e7151 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -375,12 +375,25 @@ public static function whereClauseSingle(&$values, &$query) { $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; return; + case 'contribution_recur_payment_processor_id': + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution_recur.payment_processor_id", $op, $value, "String"); + $paymentProcessors = civicrm_api3('PaymentProcessor', 'get', array()); + $paymentProcessorNames = array(); + foreach ($value as $paymentProcessorId) { + $paymentProcessorNames[] = $paymentProcessors['values'][$paymentProcessorId]['name']; + } + $query->_qill[$grouping][] = ts("Recurring Contribution Payment Processor %1 %2", array(1 => $op, 2 => implode(', ', $paymentProcessorNames))); + $query->_tables['civicrm_contribution_recur'] = $query->_whereTables['civicrm_contribution_recur'] = 1; + return; + case 'contribution_recur_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}", $op, $value, "String" ); + $recurFields = CRM_Contribute_DAO_ContributionRecur::fields(); + $query->_qill[$grouping][] = ts("Recurring Contribution %1 %2 '%3'", array(1 => $recurFields[$fieldName]['title'], 2 => $op, 3 => $value)); $query->_tables['civicrm_contribution_recur'] = $query->_whereTables['civicrm_contribution_recur'] = 1; return; diff --git a/templates/CRM/Contact/Form/Search/Advanced.hlp b/templates/CRM/Contact/Form/Search/Advanced.hlp index 153b8b05342f..22e35e135337 100644 --- a/templates/CRM/Contact/Form/Search/Advanced.hlp +++ b/templates/CRM/Contact/Form/Search/Advanced.hlp @@ -111,3 +111,17 @@
{ts}In the process of setting up CiviCRM components or configuring pages and profiles, you might have created test contributions, activities, participants, pledges, etc.{/ts}
{ts}Once you have finished your testing, it is a good idea to clean up by finding your test records and deleting them.{/ts}
{/htxt} + +{htxt id="processor-id-title"} +{ts}Processor ID{/ts} +{/htxt} +{htxt id="processor-id"} +{ts}This is the payment processor's own ID for the recurring contribution. Ideally it should be unique, but in practice may not be.{/ts}
+{/htxt} + +{htxt id="transaction-id-title"} +{ts}Transaction ID{/ts} +{/htxt} +{htxt id="transaction-id"} +{ts}Unique reference for the recurring contribution. May be made up of other fields, e.g. bank ID, account number, etc.{/ts}
+{/htxt} diff --git a/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl b/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl index 6e696f3f7c2a..921e40227cde 100644 --- a/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl +++ b/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl @@ -71,12 +71,33 @@