From 3110395af7e98c61403b4a05c38fd4aef80157bf Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 5 Nov 2019 16:44:05 +1100 Subject: [PATCH] Remove join to civicrm_option_value in favour of using getLabel function instead --- .../Form/Search/Custom/ActivitySearch.php | 20 +++++-------------- .../Form/Search/Custom/ActivitySearch.tpl | 8 ++++---- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ActivitySearch.php b/CRM/Contact/Form/Search/Custom/ActivitySearch.php index 4a582f81d971..65f6d25896c4 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -49,13 +49,12 @@ public function __construct(&$formValues) { */ $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 @@ public function __construct(&$formValues) { 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 @@ public function all( 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 @@ public function all( */ 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 @@ public function from() { 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 diff --git a/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl b/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl index 8911ed890409..7f3478a7e059 100644 --- a/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl +++ b/templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl @@ -76,8 +76,8 @@ {$form.toggleSelect.html} {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) } {if $header.sort} {assign var='key' value=$header.sort} @@ -97,7 +97,7 @@ {assign var=cbName value=$row.checkbox} {$form.$cbName.html} {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'} {$row.sort_name} @@ -110,7 +110,7 @@ {/if} {if isset($row.activity_subject) AND $row.activity_subject NEQ 'NULL'}{$row.activity_subject}{else}{ts}(no subject){/ts}{/if} - {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} {$row.$fName} {/if}