Skip to content

Commit

Permalink
Merge pull request #15734 from seamuslee001/remove_activity_option_jo…
Browse files Browse the repository at this point in the history
…in_custom_search

Remove join to civicrm_option_value in favour of using getLabel funct…
  • Loading branch information
yashodha authored Nov 25, 2019
2 parents a343ef2 + 3110395 commit a2366db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
20 changes: 5 additions & 15 deletions CRM/Contact/Form/Search/Custom/ActivitySearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,19 @@ 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',
ts('Details') => 'details',
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');

Expand Down Expand Up @@ -163,10 +156,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,
Expand Down Expand Up @@ -235,6 +227,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']);
}

/**
Expand All @@ -254,10 +248,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
Expand Down
8 changes: 4 additions & 4 deletions templates/CRM/Contact/Form/Search/Custom/ActivitySearch.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,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}
Expand All @@ -81,7 +81,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>
Expand All @@ -94,7 +94,7 @@
{/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}
Expand Down

0 comments on commit a2366db

Please sign in to comment.