(core/dev#2104) Add gender column for target contact to activity report
authoryashodha <yashodha@cividesk.com>
Thu, 22 Oct 2020 06:15:47 +0000 (11:45 +0530)
committeryashodha <yashodha@cividesk.com>
Thu, 22 Oct 2020 06:15:47 +0000 (11:45 +0530)
CRM/Report/Form/Activity.php

index d87d4a9567036fae3ed2589b1cfe44075eeed92a..d85edac156e175b1f4d3ecb49ec39ec930453fd7 100644 (file)
@@ -100,6 +100,13 @@ class CRM_Report_Form_Activity extends CRM_Report_Form {
             'alias' => 'civicrm_contact_target',
             'dbAlias' => "civicrm_contact_target.birth_date",
           ],
+          'contact_target_gender' => [
+            'name' => 'gender_id',
+            'title' => ts('Target Gender'),
+            'alias' => 'civicrm_contact_target',
+            'dbAlias' => "civicrm_contact_target.gender_id",
+            'default' => TRUE,
+          ],
           'contact_source_id' => [
             'name' => 'id',
             'alias' => 'civicrm_contact_source',
@@ -858,6 +865,7 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}";
     $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
     $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
+    $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
     $viewLinks = FALSE;
 
     // Would we ever want to retrieve from the form controller??
@@ -1036,6 +1044,13 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}";
         }
       }
 
+      if (array_key_exists('civicrm_contact_contact_target_gender', $row)) {
+        if ($value = $row['civicrm_contact_contact_target_gender']) {
+          $rows[$rowNum]['civicrm_contact_contact_target_gender'] = $genders[$value];
+          $entryFound = TRUE;
+        }
+      }
+
       $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'activity', 'List all activities for this', ';') ? TRUE : $entryFound;
 
       if (!$entryFound) {