additional fixes
authordeb.monish <monish.deb@jmaconsulting.biz>
Fri, 27 Oct 2017 18:08:09 +0000 (23:38 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Fri, 27 Oct 2017 18:12:44 +0000 (23:42 +0530)
CRM/Contact/BAO/Query.php
CRM/Report/Form/Mailing/Summary.php

index 4fc9bd6f213cd503116ce804cb96e572bf872f43..b4c5951fb6e23db23daa65da5a81403dcdf02a7e 100644 (file)
@@ -4703,11 +4703,11 @@ civicrm_relationship.is_permission_a_b = 0
    *
    */
   public static function getGroupByFromOrderBy(&$groupBy, $orderBys) {
-    if (!CRM_Utils_SQL::disableFullGroupByMode()) {
+    if (CRM_Utils_SQL::disableFullGroupByMode()) {
       foreach ($orderBys as $orderBy) {
         $orderBy = str_replace(array(' DESC', ' ASC'), '', $orderBy); // remove sort syntax from ORDER BY clauses if present
         // if ORDER BY column is not present in GROUP BY then append it to end
-        if (!strstr($groupBy, $orderBy)) {
+        if (preg_match('/(MAX|MIN)\(/i', trim($orderBy)) !== 1 && !strstr($groupBy, $orderBy)) {
           $groupBy .= ", {$orderBy}";
         }
       }
index 75f2b961747842271799018032e790fc1d512dfc..91f97eb8cea6b6f2afdea39356cfbf4cac47c109 100644 (file)
@@ -149,11 +149,13 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form {
       'order_bys' => array(
         'start_date' => array(
           'title' => ts('Start Date'),
+          'dbAlias' => 'MIN(mailing_job_civireport.start_date)',
         ),
         'end_date' => array(
           'title' => ts('End Date'),
           'default_weight' => '1',
           'default_order' => 'DESC',
+          'dbAlias' => 'MAX(mailing_job_civireport.end_date)',
         ),
       ),
       'grouping' => 'mailing-fields',