CRM-21547: Add UI order by options to Contact logging summary report
authordeb.monish <monish.deb@jmaconsulting.biz>
Wed, 13 Dec 2017 13:25:27 +0000 (18:55 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Wed, 13 Dec 2017 13:25:27 +0000 (18:55 +0530)
CRM/Logging/ReportSummary.php
CRM/Report/Form/Contact/LoggingSummary.php

index f03184045c16d823d000ad7ee379dac4fcde1ee5..7cee3df17cd866fbbe0b2e571a4b811ea23e9cd0 100644 (file)
@@ -303,11 +303,13 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form {
 
     // note the group by columns are same as that used in alterDisplay as $newRows - $key
     $this->limit();
+    $this->orderBy();
     $sql = "{$this->_select}
 FROM civicrm_temp_civireport_logsummary entity_log_civireport
 WHERE {$logTypeTableClause}
 GROUP BY log_civicrm_entity_log_date, log_civicrm_entity_log_type_label, log_civicrm_entity_log_conn_id, log_civicrm_entity_log_user_id, log_civicrm_entity_altered_contact_id, log_civicrm_entity_log_grouping
-ORDER BY log_civicrm_entity_log_date DESC {$this->_limit}";
+{$this->_orderBy}
+{$this->_limit} ";
     $sql = str_replace('modified_contact_civireport.display_name', 'entity_log_civireport.altered_contact', $sql);
     $sql = str_replace('modified_contact_civireport.id', 'entity_log_civireport.altered_contact_id', $sql);
     $sql = str_replace(array(
index 11901cdb3f3162d2cf9fc64157486f6ecef97ebd..38845457ca84ae85c4edce918cec2713940889cf 100644 (file)
@@ -142,6 +142,19 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
             'type' => CRM_Utils_Type::T_INT,
           ),
         ),
+        'order_bys' => array(
+          'log_date' => array(
+            'title' => ts('Log Date (When)'),
+            'default' => TRUE,
+            'default_weight' => '0',
+            'default_order' => 'DESC',
+          ),
+          'altered_contact' => array(
+            'name' => 'display_name',
+            'title' => ts('Altered Contact'),
+            'alias' => 'modified_contact_civireport',
+          ),
+        ),
       ),
       'altered_by_contact' => array(
         'dao' => 'CRM_Contact_DAO_Contact',
@@ -160,6 +173,12 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary {
             'type' => CRM_Utils_Type::T_STRING,
           ),
         ),
+        'order_bys' => array(
+          'altered_by_contact' => array(
+            'name' => 'display_name',
+            'title' => ts('Altered by'),
+          ),
+        ),
       ),
     );
   }