core#2174: Activity Summary report is missing pagination
authorMonish Deb <monish.deb@jmaconsulting.biz>
Wed, 9 Dec 2020 00:07:40 +0000 (05:37 +0530)
committerMonish Deb <monish.deb@jmaconsulting.biz>
Wed, 9 Dec 2020 00:10:02 +0000 (05:40 +0530)
CRM/Report/Form/ActivitySummary.php

index fe5df2864992e3af5b983f1ea9d293c1eb630dfe..6c803998905d03ba5072543d5f30a90d303822c7 100644 (file)
@@ -20,6 +20,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form {
   protected $_phoneField = FALSE;
   protected $_tempTableName;
   protected $_tempDurationSumTableName;
+  protected $_totalRows;
 
   /**
    * This report has not been optimised for group filtering.
@@ -466,7 +467,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form {
     $this->groupBy(FALSE);
 
     // build the query to calulate duration sum
-    $sql = "SELECT SUM(activity_civireport.duration) as civicrm_activity_duration_total {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
+    $sql = "SELECT SQL_CALC_FOUND_ROWS SUM(activity_civireport.duration) as civicrm_activity_duration_total {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
 
     // create temp table to store duration
     $this->_tempDurationSumTableName = $this->createTemporaryTable('tempDurationSumTable', "
@@ -478,6 +479,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form {
     {$sql}";
     CRM_Core_DAO::disableFullGroupByMode();
     CRM_Core_DAO::executeQuery($insertQuery);
+    $this->_totalRows = CRM_Core_DAO::singleValueQuery("SELECT FOUND_ROWS()");
     CRM_Core_DAO::reenableFullGroupByMode();
 
     $sql = "SELECT {$this->_tempTableName}.*,  {$this->_tempDurationSumTableName}.civicrm_activity_duration_total
@@ -494,6 +496,16 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form {
     return $sql;
   }
 
+  /**
+   * Set pager.
+   *
+   * @param int $rowCount
+   */
+  public function setPager($rowCount = self::ROW_COUNT_LIMIT) {
+    $this->_rowsFound = $this->_totalRows;
+    parent::setPager($rowCount);
+  }
+
   /**
    * Group the fields.
    *