Skip to content

Commit

Permalink
ACU-115: Fix Db Error issue with Activity Reports
Browse files Browse the repository at this point in the history
Included in CiviCRM 5.25.0
PR: civicrm#17128
  • Loading branch information
tunbola committed Jun 24, 2020
1 parent d72bc69 commit d760500
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions CRM/Report/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ public function __construct() {
'operatorType' => CRM_Report_Form::OP_SELECT,
'options' => ['0' => ts('No'), '1' => ts('Yes')],
];
$this->_columns['civicrm_case_activity'] = [
'dao' => 'CRM_Case_DAO_CaseActivity',
'fields' => [],
];
}

if ($campaignEnabled) {
Expand Down Expand Up @@ -349,22 +353,16 @@ public function __construct() {
parent::__construct();
}

public function preProcess() {
// Is "Include Case Activities" selected? If yes, include the case_id as a hidden column
$formToUse = $this->noController ? NULL : $this;
$includeCaseActivities = CRM_Utils_Request::retrieve('include_case_activities_value', 'Boolean', $formToUse);
if (!empty($includeCaseActivities)) {
$this->_columns['civicrm_case_activity'] = [
'dao' => 'CRM_Case_DAO_CaseActivity',
'fields' => [
'case_id' => [
'no_display' => TRUE,
'required' => TRUE,
],
],
];
}
parent::preProcess();
protected static function addCaseActivityColumns($columns) {
$columns['civicrm_case_activity']['fields'] = [
'case_id' => [
'title' => ts('Case ID'),
'required' => TRUE,
'dbAlias' => $columns['civicrm_case_activity']['alias'] . '.case_id',
'type' => CRM_Utils_Type::T_INT,
],
];
return $columns;
}

/**
Expand Down Expand Up @@ -733,6 +731,10 @@ public function buildQuery($applyLimit = TRUE) {
}
}

if (!empty($this->_params['include_case_activities_value'])) {
$this->_columns = self::addCaseActivityColumns($this->_columns);
}

// @todo - all this temp table stuff is here because pre 4.4 the activity contact
// form did not exist.
// Fixing the way the construct method declares them will make all this redundant.
Expand Down

0 comments on commit d760500

Please sign in to comment.