CRM-17474 Standardise contact summary report fields
authorJKingsnorth <john@johnkingsnorth.co.uk>
Mon, 2 Nov 2015 14:08:20 +0000 (14:08 +0000)
committerJKingsnorth <john@johnkingsnorth.co.uk>
Mon, 2 Nov 2015 14:08:20 +0000 (14:08 +0000)
CRM/Report/Form/Contact/Summary.php

index d496b526f494f6961cf2c30cfcd583ad819915da..f385659333c24cb74c6a747df97db0e37310660f 100644 (file)
@@ -56,44 +56,19 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form {
     $this->_columns = array(
       'civicrm_contact' => array(
         'dao' => 'CRM_Contact_DAO_Contact',
-        'fields' => array(
-          'sort_name' => array(
-            'title' => ts('Contact Name'),
-            'required' => TRUE,
-            'no_repeat' => TRUE,
-          ),
-          'first_name' => array(
-            'title' => ts('First Name'),
-          ),
-          'middle_name' => array(
-            'title' => ts('Middle Name'),
-          ),
-          'last_name' => array(
-            'title' => ts('Last Name'),
-          ),
-          'id' => array(
-            'no_display' => TRUE,
-            'required' => TRUE,
-          ),
-          'gender_id' => array(
-            'title' => ts('Gender'),
-          ),
-          'birth_date' => array(
-            'title' => ts('Birth Date'),
-          ),
-          'age' => array(
-            'title' => ts('Age'),
-            'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())',
-          ),
-          'contact_type' => array(
-            'title' => ts('Contact Type'),
-          ),
-          'contact_sub_type' => array(
-            'title' => ts('Contact Subtype'),
-          ),
+        'fields' => array_merge(
+          $this->getBasicContactFields(),
+          array(
+            'modified_date' => array(
+              'title' => ts('Modified Date'),
+              'default' => FALSE,
+            ),
+          )
         ),
         'filters' => array(
-          'sort_name' => array('title' => ts('Contact Name')),
+          'sort_name' => array(
+            'title' => ts('Contact Name')
+          ),
           'source' => array(
             'title' => ts('Contact Source'),
             'type' => CRM_Utils_Type::T_STRING,
@@ -117,6 +92,11 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form {
           'contact_sub_type' => array(
             'title' => ts('Contact Subtype'),
           ),
+          'modified_date' => array(
+            'title' => ts('Modified Date'),
+            'operatorType' => CRM_Report_Form::OP_DATE,
+            'type'         => CRM_Utils_Type::T_DATE
+          ),
         ),
         'grouping' => 'contact-fields',
         'order_bys' => array(
@@ -309,8 +289,6 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form {
   public function alterDisplay(&$rows) {
     $entryFound = FALSE;
 
-    $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id', array('localize' => TRUE));
-
     foreach ($rows as $rowNum => $row) {
       // make count columns point to detail report
       // convert sort name to links
@@ -340,8 +318,8 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form {
         $entryFound = TRUE;
       }
 
-      // handle gender id
-      $this->_initBasicRow($rows, $entryFound, $row, 'civicrm_contact_gender_id', $rowNum, $genders);
+      // Handle ID to label conversion for contact fields
+      $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contact/summary', 'View Contact Summary') ? TRUE : $entryFound;
 
       // display birthday in the configured custom format
       if (array_key_exists('civicrm_contact_birth_date', $row)) {