From a91e698a848c4e1ed43db52e55d00a44bc99c1b5 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 5 Aug 2013 13:26:13 +1200 Subject: [PATCH] CRM-13155 search is working but a) the recurring should have a separate pane & b) on contact the search joins via contribution & doesn't find ones with no contribution --- CRM/Contribute/BAO/Query.php | 47 ++++++++++++++++++- CRM/Contribute/Info.php | 3 +- .../CRM/Contribute/Form/Search/Common.tpl | 35 ++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 6c0791317a..55d9baa80b 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -239,7 +239,20 @@ class CRM_Contribute_BAO_Query { } $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; - + $datesToBuild = array( + 'contribution_recur_start_date' => 'Recurring Contribution Start Date', + 'contribution_recur_next_sched_contribution_date' => 'Next Scheduled Recurring Payment', + 'contribution_recur_cancel_date' => 'Recurring Contribution Cancel Date', + 'contribution_recur_end_date' => 'Recurring Contribution End Date', + 'contribution_recur_create_date' => 'Recurring Contribution Create Date', + 'contribution_recur_modified_date' => 'Recurring Contribution Modified Date', + 'contribution_recur_failure_retry_date' => 'Recurring Contribution Failure Retry Date', + ); + foreach ($datesToBuild as $dateField => $dateFieldTitle) { + if(self::buildDateWhere($values, $query, $name, $dateField, $dateFieldTitle)) { + return; + } + } switch ($name) { case 'contribution_date': case 'contribution_date_low': @@ -820,6 +833,16 @@ class CRM_Contribute_BAO_Query { $form->addYesNo('contribution_pay_later', ts('Contribution is Pay Later?')); $form->addYesNo('contribution_recurring', ts('Contribution is Recurring?')); +// $form->addElement('contribution_recur_frequency_unit', ts('Recurring Frequency Unit?')); +// $form->addElement('contribution_recur_frequency_interval', ts('Recurring Frequency Interval?')); +// $form->addElement('contribution_recur_frequency_installments', ts('Number of Recurring Installments?')); + CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_start_date', 1, '_low', '_high', ts('Recurring Start Date?'), FALSE); + CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_next_sched_contribution_date', 1, '_low', '_high', ts('Next scheduled Recurring Contribution?'), FALSE); + CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_failure_retry_date', 1, '_low', '_high', ts('Retry Date for Recurring Contribution?'), FALSE); + CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_end_date', 1, '_low', '_high', ts('End Date for Recurring Contribution?'), FALSE); + CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_cancel_date', 1, '_low', '_high', ts('Cancel Date for Recurring Contribution?'), FALSE); + CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_modified_date', 1, '_low', '_high', ts('Modified Date for Recurring Contribution?'), FALSE); + $form->addYesNo('contribution_test', ts('Contribution is a Test?')); // Add field for transaction ID search @@ -882,5 +905,27 @@ class CRM_Contribute_BAO_Query { $tables['civicrm_product'] = 1; } } + + /** + * Add the where for dates + * @param array $values array of query values + * @param object $query the query object + * @param string $name query field that is set + * @param string $field name of field to be set + * @param string $title title of the field + */ + static function buildDateWhere(&$values, $query, $name, $field, $title) { + $fieldPart = strpos($name, $field); + if($fieldPart === FALSE) { + return; + } + // we only have recurring dates using this ATM so lets' short cut to find the table name + $table = 'contribution_recur'; + $fieldName = split($table . '_', $field); + $query->dateQueryBuilder($values, + 'civicrm_' . $table, $field, $fieldName[1], $title + ); + return TRUE; + } } diff --git a/CRM/Contribute/Info.php b/CRM/Contribute/Info.php index 1cfa510826..dfe4367b0b 100644 --- a/CRM/Contribute/Info.php +++ b/CRM/Contribute/Info.php @@ -82,7 +82,8 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { // docs inherited from interface public function registerAdvancedSearchPane() { - return array('title' => ts('Contributions'), + return array( + 'title' => ts('Contributions'), 'weight' => 20, ); } diff --git a/templates/CRM/Contribute/Form/Search/Common.tpl b/templates/CRM/Contribute/Form/Search/Common.tpl index 6ac9f68ffc..1cda924062 100644 --- a/templates/CRM/Contribute/Form/Search/Common.tpl +++ b/templates/CRM/Contribute/Form/Search/Common.tpl @@ -111,6 +111,41 @@ + {ts}Recurring Payments Start Date{/ts} + + {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_start_date" from='_low' to='_high'} + + + + {ts}Recurring Contribution End Date{/ts} + + {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_end_date" from='_low' to='_high'} + + + + {ts}Recurring Contribution Modified Date{/ts} + + {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_modified_date" from='_low' to='_high'} + + + + {ts}Next Scheduled Recurring Contribution{/ts} + + {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_next_sched_contribution_date" from='_low' to='_high'} + + + + {ts}Retry Failed Recurring Contribution On{/ts} + + {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_failure_retry_date" from='_low' to='_high'} + + + + {ts}Recurring Contribution Cancel Date{/ts} + + {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_cancel_date" from='_low' to='_high'} + + -- 2.25.1