Skip to content

Commit

Permalink
Merge pull request #28028 from braders/php8-case-detail-report
Browse files Browse the repository at this point in the history
[REF][PHP8.2] Tidy up CRM_Report_Form_Case_Detail
  • Loading branch information
eileenmcnaughton authored Nov 6, 2023
2 parents aba8469 + cba79d5 commit 9efb910
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions CRM/Report/Form/Case/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,34 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {

protected $_caseTypeNameOrderBy = FALSE;

/**
* @var array
*/
protected $caseStatuses;

/**
* @var array
*/
protected $caseTypes;

/**
* @var array
*/
protected $relTypes;

/**
* @var array
*/
protected $caseActivityTypes;

/**
*/
public function __construct() {
$this->case_statuses = CRM_Core_OptionGroup::values('case_status');
$this->case_types = CRM_Case_PseudoConstant::caseType();
$this->caseStatuses = CRM_Core_OptionGroup::values('case_status');
$this->caseTypes = CRM_Case_PseudoConstant::caseType();
$rels = CRM_Core_PseudoConstant::relationshipType();
foreach ($rels as $relid => $v) {
$this->rel_types[$relid] = $v['label_b_a'];
$this->relTypes[$relid] = $v['label_b_a'];
}

$this->caseActivityTypes = [];
Expand Down Expand Up @@ -165,7 +185,7 @@ public function __construct() {
'title' => ts('Case Role(s)'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => $this->rel_types,
'options' => $this->relTypes,
],
'is_active' => [
'title' => ts('Active Role?'),
Expand Down Expand Up @@ -597,14 +617,14 @@ public function alterDisplay(&$rows) {
foreach ($rows as $rowNum => $row) {
if (array_key_exists('civicrm_case_status_id', $row)) {
if ($value = $row['civicrm_case_status_id']) {
$rows[$rowNum]['civicrm_case_status_id'] = $this->case_statuses[$value];
$rows[$rowNum]['civicrm_case_status_id'] = $this->caseStatuses[$value];

$entryFound = TRUE;
}
}
if (array_key_exists('civicrm_case_case_type_id', $row)) {
if ($value = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $row['civicrm_case_case_type_id'])) {
$rows[$rowNum]['civicrm_case_case_type_id'] = $this->case_types[$value];
$rows[$rowNum]['civicrm_case_case_type_id'] = $this->caseTypes[$value];

$entryFound = TRUE;
}
Expand All @@ -625,7 +645,7 @@ public function alterDisplay(&$rows) {
if ($value = $row['civicrm_relationship_case_role']) {
$caseRoles = explode(',', $value);
foreach ($caseRoles as $num => $caseRole) {
$caseRoles[$num] = $this->rel_types[$caseRole];
$caseRoles[$num] = $this->relTypes[$caseRole];
}
$rows[$rowNum]['civicrm_relationship_case_role'] = implode('; ', $caseRoles);
}
Expand Down

0 comments on commit 9efb910

Please sign in to comment.