fix membership summary report group by clause
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 13 Jul 2016 06:53:03 +0000 (12:23 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Wed, 13 Jul 2016 06:53:03 +0000 (12:23 +0530)
CRM/Report/Form/Member/Summary.php

index c238084cb579947b6ecaf95ada933a24ec680cf5..f7d2f77890d7ae004b048d087fce608aee51e923 100644 (file)
@@ -363,13 +363,14 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form {
                 !empty($this->_params['group_bys_freq'][$fieldName])
               ) {
 
-                $append = "YEAR({$field['dbAlias']}),";
+                $append = "YEAR({$field['dbAlias']})";
                 if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]),
                   array('year')
                 )) {
                   $append = '';
                 }
-                $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
+                $this->_groupBy[] = $append;
+                $this->_groupBy[] = "{$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})";
                 $append = TRUE;
               }
               else {
@@ -381,8 +382,8 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form {
       }
 
       $this->_rollup = ' WITH ROLLUP';
-      $this->appendSelect($this->_selectClauses, $this->_groupBy);
-      $this->_groupBy = 'GROUP BY ' . implode(', ', $this->_groupBy) .
+      $this->appendSelect($this->_selectClauses, array_filter($this->_groupBy));
+      $this->_groupBy = 'GROUP BY ' . implode(', ', array_filter($this->_groupBy)) .
         " {$this->_rollup} ";
     }
     else {