CRM-16184 CiviReport template, break connection between filters & fields for accordia...
authorEileen McNaughton <eileen@fuzion.co.nz>
Thu, 26 Mar 2015 11:43:57 +0000 (00:43 +1300)
committerEileen McNaughton <eileen@fuzion.co.nz>
Thu, 26 Mar 2015 11:43:57 +0000 (00:43 +1300)
Sometimes fields are not present and filters are and this can break the layout

CRM/Report/Form.php
templates/CRM/Report/Form/Tabs/Filters.tpl

index f8c85cec35ee0e786bc94c92b3e56b7ac40970b9..e677a9cb96c67794579b10233f9ce984eea9f441 100644 (file)
@@ -1041,9 +1041,20 @@ class CRM_Report_Form extends CRM_Core_Form {
    * Add filters to report.
    */
   public function addFilters() {
-    $filters = array();
+    $filters = $filterGroups =array();
     $count = 1;
+
     foreach ($this->_filters as $table => $attributes) {
+      if (isset($this->_columns[$table]['group_title'])) {
+        // The presence of 'group_title' is secret code for 'is_a_custom_table'
+        // which magically means to 'display in an accordian'
+        // here we make this explicit.
+        $filterGroups[$table] = array(
+          'group_title' => $this->_columns[$table]['group_title'],
+          'use_accordian_for_field_selection' => TRUE,
+
+        );
+      }
       foreach ($attributes as $fieldName => $field) {
         // get ready with option value pair
         // @ todo being able to specific options for a field (e.g a date field) in the field spec as an array rather than an override
@@ -1159,6 +1170,7 @@ class CRM_Report_Form extends CRM_Core_Form {
       );
     }
     $this->assign('filters', $filters);
+    $this->assign('filterGroups', $filterGroups);
   }
 
   /**
index eeb0d9d81505e546f812e9e6f0bf9744757903d7..e1db9d5064bbf7f42762d17002cdb0e279aeea70 100644 (file)
@@ -30,7 +30,7 @@
       {foreach from=$filters item=table key=tableName}
         {assign  var="filterCount" value=$table|@count}
         {* Wrap custom field sets in collapsed accordion pane. *}
-        {if $colGroups.$tableName.group_title and $filterCount gte 1}
+        {if $filterGroups.$tableName.group_title and $filterCount gte 1}
           {* we should close table that contains other filter elements before we start building custom group accordian
            *}
           {if $counter eq 1}
@@ -39,7 +39,7 @@
           {/if}
           <div class="crm-accordion-wrapper crm-accordion collapsed">
             <div class="crm-accordion-header">
-              {$colGroups.$tableName.group_title}
+              {$filterGroups.$tableName.group_title}
             </div><!-- /.crm-accordion-header -->
             <div class="crm-accordion-body">
               <table class="report-layout">
@@ -65,7 +65,7 @@
                   </tr>
                 {/if}
         {/foreach}
-        {if $colGroups.$tableName.group_title}
+        {if $filterGroups.$tableName.group_title}
               </table>
             </div><!-- /.crm-accordion-body -->
           </div><!-- /.crm-accordion-wrapper -->