Open recurring pane when data has been entered CRM-13155
authorColeman Watts <coleman@civicrm.org>
Wed, 7 Aug 2013 04:20:25 +0000 (21:20 -0700)
committerColeman Watts <coleman@civicrm.org>
Wed, 7 Aug 2013 04:20:25 +0000 (21:20 -0700)
----------------------------------------
* CRM-13155: Add searching for recurring contribution data to search
  http://issues.civicrm.org/jira/browse/CRM-13155

CRM/Contribute/BAO/Query.php
templates/CRM/Contribute/Form/Search/ContributionRecur.tpl

index 489da5347ee1e50ec6973331ff6653a07b48d4d8..787540a0d716be9a394e1683786897fe526fab3f 100644 (file)
@@ -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'),
+    );
+  }
 }
 
index 2c471ab4cfbeaff04ca34068da1b2bb44cde47e4..82760ffa8c89f65c92dfc851cc5a28a7d8daca65 100644 (file)
  +--------------------------------------------------------------------+
 *}
 
-  <div class="crm-accordion-wrapper crm-contactDetails-accordion collapsed" id="{contribution_recur}" >
+  <div class="crm-accordion-wrapper crm-contactDetails-accordion {if empty($contribution_recur_pane_open)}collapsed{/if}" id="{contribution_recur}" >
     <div class="crm-accordion-header">
         {ts}Recurring Contributions{/ts}
     </div>
     <div class="crm-accordion-body">
     <table class="form-layout-compressed">
-      <tr><td>{ts}Recurring Payments Start Date{/ts}</td>
+      <tr><td>{ts}Start Date{/ts}</td>
         <td>
           {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_start_date" from='_low' to='_high'}
         </td>
       </tr>
       <tr>
-        <td>{ts}Recurring Contribution End Date{/ts}</td>
+        <td>{ts}End Date{/ts}</td>
         <td>
           {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_end_date" from='_low' to='_high'}
         </td>
       </tr>
       <tr>
-        <td>{ts}Recurring Contribution Modified Date{/ts}</td>
+        <td>{ts}Modified Date{/ts}</td>
         <td>
           {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_modified_date" from='_low' to='_high'}
         </td>
       </tr>
       <tr>
-        <td>{ts}Next Scheduled Recurring Contribution{/ts}</td>
+        <td>{ts}Next Scheduled{/ts}</td>
         <td>
           {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_next_sched_contribution_date" from='_low' to='_high'}
         </td>
       </tr>
       <tr>
-        <td>{ts}Retry Failed Recurring Contribution On{/ts}</td>
+        <td>{ts}Retry Date{/ts}</td>
         <td>
           {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_failure_retry_date" from='_low' to='_high'}
         </td>
       </tr>
       <tr>
-        <td>{ts}Recurring Contribution Cancel Date{/ts}</td>
+        <td>{ts}Cancel Date{/ts}</td>
         <td>
           {include file="CRM/Core/DateRange.tpl" fieldName="contribution_recur_cancel_date" from='_low' to='_high'}
         </td>