From b32bc653616e16b21425d10815ccdfc9274050d3 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 6 Aug 2013 21:20:25 -0700 Subject: [PATCH] Open recurring pane when data has been entered CRM-13155 ---------------------------------------- * CRM-13155: Add searching for recurring contribution data to search http://issues.civicrm.org/jira/browse/CRM-13155 --- CRM/Contribute/BAO/Query.php | 41 ++++++++++--------- .../Form/Search/ContributionRecur.tpl | 14 +++---- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 489da5347e..787540a0d7 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -239,16 +239,7 @@ 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) { + foreach (self::getRecurringFields() as $dateField => $dateFieldTitle) { if(self::buildDateWhere($values, $query, $name, $dateField, $dateFieldTitle)) { return; } @@ -839,15 +830,15 @@ 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); + + // Recurring contribution fields + foreach (self::getRecurringFields() as $key => $label) { + CRM_Core_Form_Date::buildDateRange($form, $key, 1, '_low', '_high', $label, FALSE); + // If data has been entered for a recurring field, tell the tpl layer to open the pane + if (!empty($form->_formValues[$key . '_relative']) || !empty($form->_formValues[$key . '_low']) || !empty($form->_formValues[$key . '_high'])) { + $form->assign('contribution_recur_pane_open', TRUE); + } + } $form->addYesNo('contribution_test', ts('Contribution is a Test?')); @@ -933,5 +924,17 @@ class CRM_Contribute_BAO_Query { ); return TRUE; } + + static function getRecurringFields() { + return array( + 'contribution_recur_start_date' => ts('Recurring Contribution Start Date'), + 'contribution_recur_next_sched_contribution_date' => ts('Next Scheduled Recurring Contribution'), + 'contribution_recur_cancel_date' => ts('Recurring Contribution Cancel Date'), + 'contribution_recur_end_date' => ts('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' => ts('Failed Recurring Contribution Retry Date'), + ); + } } diff --git a/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl b/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl index 2c471ab4cf..82760ffa8c 100644 --- a/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl +++ b/templates/CRM/Contribute/Form/Search/ContributionRecur.tpl @@ -24,43 +24,43 @@ +--------------------------------------------------------------------+ *} -