Remove join to civicrm_option_value in favour of using getLabel function instead
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 5 Nov 2019 05:44:05 +0000 (16:44 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 7 Nov 2019 20:09:07 +0000 (07:09 +1100)
CRM/Contact/Form/Search/Custom/ActivitySearch.php
templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl

index 4a582f81d9719e852e7e926de219910d0a155a98..65f6d25896c46229c288f34e08b34f06dc10ab13 100644 (file)
@@ -49,13 +49,12 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea
      */
     $this->_columns = [
       ts('Name') => 'sort_name',
-      ts('Status') => 'activity_status',
-      ts('Activity Type') => 'activity_type',
+      ts('Status') => 'activity_status_id',
+      ts('Activity Type') => 'activity_type_id',
       ts('Activity Subject') => 'activity_subject',
       ts('Scheduled By') => 'source_contact',
       ts('Scheduled Date') => 'activity_date',
       ' ' => 'activity_id',
-      '  ' => 'activity_type_id',
       '   ' => 'case_id',
       ts('Location') => 'location',
       ts('Duration') => 'duration',
@@ -63,12 +62,6 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea
       ts('Assignee') => 'assignee',
     ];
 
-    $this->_groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
-      'activity_status',
-      'id',
-      'name'
-    );
-
     //Add custom fields to columns array for inclusion in export
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Activity');
 
@@ -179,10 +172,9 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea
                 activity.id                 as activity_id,
                 activity.activity_type_id   as activity_type_id,
                 contact_b.sort_name         as source_contact,
-                ov1.label                   as activity_type,
                 activity.subject            as activity_subject,
                 activity.activity_date_time as activity_date,
-                ov2.label                   as activity_status,
+                activity.status_id          as activity_status_id,
                 cca.case_id                 as case_id,
                 activity.location           as location,
                 activity.duration           as duration,
@@ -251,6 +243,8 @@ ORDER BY contact_a.sort_name';
    */
   public function alterRow(&$row) {
     $row['activity_date'] = CRM_Utils_Date::customFormat($row['activity_date'], '%B %E%f, %Y %l:%M %P');
+    $row['activity_type_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_DAO_Activity', 'activity_type_id', $row['activity_type_id']);
+    $row['activity_status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_DAO_Activity', 'activity_status_id', $row['activity_status_id']);
   }
 
   /**
@@ -270,10 +264,6 @@ ORDER BY contact_a.sort_name';
                  ON activity.id = target.activity_id AND target.record_type_id = {$targetID}
             JOIN civicrm_contact contact_a
                  ON contact_a.id = target.contact_id
-            JOIN civicrm_option_value ov1
-                 ON activity.activity_type_id = ov1.value AND ov1.option_group_id = 2
-            JOIN civicrm_option_value ov2
-                 ON activity.status_id = ov2.value AND ov2.option_group_id = {$this->_groupId}
             LEFT JOIN civicrm_activity_contact sourceContact
                  ON activity.id = sourceContact.activity_id AND sourceContact.record_type_id = {$sourceID}
             JOIN civicrm_contact contact_b
index 8911ed890409d2bd9ff7c05e0877ac9a16369ebc..7f3478a7e0597cbfb45ad55ffa8aa02f8a28b7d4 100644 (file)
@@ -76,8 +76,8 @@
               <thead class="sticky">
                 <th scope="col" title="Select All Rows">{$form.toggleSelect.html}</th>
                 {foreach from=$columnHeaders item=header}
-                  {if ($header.sort eq 'activity_id') or ($header.sort eq 'activity_type_id') or ($header.sort eq 'case_id') }
-                  {elseif ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status') or ($header.sort eq 'activity_type') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) }
+                  {if ($header.sort eq 'activity_id') or ($header.sort eq 'case_id') }
+                  {elseif ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status_id') or ($header.sort eq 'activity_type_id') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) }
                     <th scope="col">
                       {if $header.sort}
                         {assign var='key' value=$header.sort}
@@ -97,7 +97,7 @@
                   {assign var=cbName value=$row.checkbox}
                   <td>{$form.$cbName.html}</td>
                   {foreach from=$columnHeaders item=header}
-                    {if ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status') or ($header.sort eq 'activity_type') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) }
+                    {if ($header.sort eq 'sort_name') or ($header.sort eq 'activity_status_id') or ($header.sort eq 'activity_type_id') or ($header.sort eq 'activity_subject') or ($header.sort eq 'source_contact') or ($header.SORT eq 'activity_date') or ($header.name eq null) }
                       {assign var=fName value=$header.sort}
                       {if $fName eq 'sort_name'}
                          <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`"}">{$row.sort_name}</a></td>
                            {/if}
                            {if isset($row.activity_subject) AND $row.activity_subject NEQ 'NULL'}{$row.activity_subject}{else}{ts}(no subject){/ts}{/if}</a>
                          </td>
-                       {elseif ($fName eq 'activity_id') or ($fName eq 'activity_type_id') or ($fName eq 'case_id')}
+                       {elseif ($fName eq 'activity_id') or ($fName eq 'case_id')}
                        {else}
                           <td>{$row.$fName}</td>
                        {/if}