Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tab count when showing case activities #7

Merged
merged 1 commit into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions CRM/Fastactivity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR
$activity_type_id = CRM_Utils_Array::value('activity_type_id', $params);
$excludeCaseActivities = CRM_Utils_Array::value('excludeCaseActivities', $params, TRUE);

// contact_id
$contact_id = CRM_Utils_Array::value('contact_id', $params);
if ($contact_id) {
$clauses[] = "acon.contact_id = %1";
$params[1] = array($contact_id, 'Integer');
}

if (!empty($activity_type_id)) {
$clauses[] = "activity.activity_type_id IN ( " . $activity_type_id . " ) ";
}
Expand Down Expand Up @@ -243,13 +250,6 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR
}
}

// contact_id
$contact_id = CRM_Utils_Array::value('contact_id', $params);
if ($contact_id) {
$clauses[] = "acon.contact_id = %1";
$params[1] = array($contact_id, 'Integer');
}

return implode(' AND ', $clauses);
}

Expand All @@ -269,13 +269,12 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR
* count of activities
*/
public static function getContactActivitiesCount(&$params) {

$whereClause = self::whereClause($params, FALSE);

$query = "SELECT COUNT(DISTINCT acon.activity_id)
FROM civicrm_activity_contact acon
LEFT JOIN civicrm_activity activity ON acon.activity_id = activity.id ";
if ($params['excludeCaseActivities']) {
if (!$params['excludeCaseActivities']) {
$query .= 'LEFT JOIN civicrm_case_activity case_activity ON (activity.id = case_activity.activity_id) ';
}
$query .= " WHERE {$whereClause}";
Expand Down
8 changes: 3 additions & 5 deletions CRM/Fastactivity/Page/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CRM_Fastactivity_Page_Tab extends CRM_Core_Page {
/**
* Browse all activities for a particular contact.
*
* @return void
*/
public function browse() {
$this->assign('admin', FALSE);
Expand All @@ -49,14 +48,13 @@ public function browse() {
$controller->set('contactId', $this->_contactId);
$controller->setEmbedded(TRUE);
$controller->run();
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId);
}

/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @throws \CRM_Core_Exception
*/
public function preProcess() {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
Expand Down Expand Up @@ -84,7 +82,7 @@ public function preProcess() {
/**
* Run the activities "tab" page
*
* @return void
* @throws \CRM_Core_Exception
*/
public function run() {
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
Expand All @@ -104,6 +102,6 @@ public function run() {
$this->preProcess();
$this->browse();

return parent::run();
parent::run();
}
}