Alter DateTime section header to group by date from the datetime field.
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Thu, 7 Jan 2016 13:23:28 +0000 (18:53 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Thu, 7 Jan 2016 13:23:28 +0000 (18:53 +0530)
CRM/Report/Form/Activity.php

index ed9e2386cc5e4c412a236a7d8bba2e66d16fa4c1..a7eaebf57b1e5909376fc7968a0e68b3a67f153a 100644 (file)
@@ -821,6 +821,9 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}";
       $this->_having = "HAVING " . implode(' AND ', $nullFilters);
     }
     $this->orderBy();
+    if (!empty($this->_sections) && key($this->_sections) == 'civicrm_activity_activity_date_time') {
+      $this->alterSectionHeaderForDateTime();
+    }
     $this->limit();
     $sql = "{$this->_select}
 FROM civireport_activity_temp_target tar
@@ -1059,4 +1062,19 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}"
     }
   }
 
+   /*
+   * Alter DateTime section header to group by date from the datetime field.
+   *
+   */
+  public function alterSectionHeaderForDateTime() {
+    $tempQuery = "ALTER TABLE civireport_activity_temp_target ADD COLUMN civicrm_activity_activity_date VARCHAR(128)";
+    CRM_Core_DAO::executeQuery($tempQuery);
+    $updateQuery = "UPDATE civireport_activity_temp_target SET civicrm_activity_activity_date = date(civicrm_activity_activity_date_time)";
+    CRM_Core_DAO::executeQuery($updateQuery);
+    $this->_select .= ', civicrm_activity_activity_date';
+    $this->_sections['civicrm_activity_activity_date'] = $this->_sections['civicrm_activity_activity_date_time'];
+    unset($this->_sections['civicrm_activity_activity_date_time']);
+    $this->assign('sections', $this->_sections);
+  }
+
 }