Skip to content

Commit

Permalink
Merge pull request #9011 from jernic/jernic-patch-1
Browse files Browse the repository at this point in the history
Select correct activity if more than one in upcoming or recent period
  • Loading branch information
monishdeb authored Oct 18, 2016
2 parents c517c07 + 2b95a25 commit fa71b5e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions CRM/Case/BAO/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -3001,18 +3001,25 @@ public static function createCaseViewsQuery($section = 'upcoming') {
AS SELECT ca.case_id, a.id, a.activity_date_time, a.status_id, a.activity_type_id
FROM civicrm_case_activity ca
INNER JOIN civicrm_activity a ON ca.activity_id=a.id
WHERE a.activity_date_time <= DATE_ADD( NOW(), INTERVAL 14 DAY )
AND a.is_current_revision = 1 AND a.is_deleted=0 AND a.status_id = $scheduled_id";
WHERE a.activity_date_time =
(SELECT b.activity_date_time FROM civicrm_case_activity bca
INNER JOIN civicrm_activity b ON bca.activity_id=b.id
WHERE b.activity_date_time <= DATE_ADD( NOW(), INTERVAL 14 DAY )
AND b.is_current_revision = 1 AND b.is_deleted=0 AND b.status_id = $scheduled_id
AND bca.case_id = ca.case_id ORDER BY b.activity_date_time ASC LIMIT 1)";
break;

case 'recent':
$sql = "CREATE OR REPLACE VIEW `civicrm_view_case_activity_recent`
AS SELECT ca.case_id, a.id, a.activity_date_time, a.status_id, a.activity_type_id
FROM civicrm_case_activity ca
INNER JOIN civicrm_activity a ON ca.activity_id=a.id
WHERE a.activity_date_time <= NOW()
AND a.activity_date_time >= DATE_SUB( NOW(), INTERVAL 14 DAY )
AND a.is_current_revision = 1 AND a.is_deleted=0 AND a.status_id <> $scheduled_id";
WHERE a.activity_date_time =
(SELECT b.activity_date_time FROM civicrm_case_activity bca
INNER JOIN civicrm_activity b ON bca.activity_id=b.id
WHERE b.activity_date_time >= DATE_SUB( NOW(), INTERVAL 14 DAY )
AND b.is_current_revision = 1 AND b.is_deleted=0 AND b.status_id <> $scheduled_id
AND bca.case_id = ca.case_id ORDER BY b.activity_date_time DESC LIMIT 1)";
break;
}
return $sql;
Expand Down

0 comments on commit fa71b5e

Please sign in to comment.