From 36b1c22d3d28c62e7d02445b61487ea4ebaca015 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Mon, 13 Nov 2023 00:05:07 -0500 Subject: [PATCH] php warnings on case dashboard --- CRM/Case/BAO/Case.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index d6d3c55cd9..3361bd9138 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -768,17 +768,19 @@ HERESQL; $caseTypes = CRM_Case_PseudoConstant::caseType(); $caseStatuses = CRM_Case_PseudoConstant::caseStatus(); - $caseTypes = array_flip($caseTypes); // get statuses as headers for the table $url = CRM_Utils_System::url('civicrm/case/search', "reset=1&force=1&all=1&case_status_id="); - foreach ($caseStatuses as $key => $name) { - $caseSummary['headers'][$key]['status'] = $name; + $rows = []; + foreach ($caseStatuses as $key => $caseStatusLabel) { + $caseSummary['headers'][$key]['status'] = $caseStatusLabel; $caseSummary['headers'][$key]['url'] = $url . $key; + foreach ($caseTypes as $caseTypeLabel) { + $rows[$caseTypeLabel][$caseStatusLabel] = ['count' => NULL, 'url' => NULL]; + } } // build rows with actual data - $rows = []; $myGroupByClause = $mySelectClause = $myCaseFromClause = $myCaseWhereClauseA = $myCaseWhereClauseB = ''; if ($allCases) { @@ -827,10 +829,7 @@ SELECT civicrm_case.id, case_status.label AS case_status, status_id, civicrm_cas $res = CRM_Core_DAO::executeQuery($query); while ($res->fetch()) { - if (!isset($rows[$res->case_type])) { - $rows[$res->case_type] = array_fill_keys($caseStatuses, []); - } - if (!empty($rows[$res->case_type]) && !empty($rows[$res->case_type][$res->case_status])) { + if (!empty($rows[$res->case_type][$res->case_status]['count'])) { $rows[$res->case_type][$res->case_status]['count'] = $rows[$res->case_type][$res->case_status]['count'] + 1; } else { @@ -842,7 +841,7 @@ SELECT civicrm_case.id, case_status.label AS case_status, status_id, civicrm_cas ]; } } - $caseSummary['rows'] = array_merge($caseTypes, $rows); + $caseSummary['rows'] = $rows; return $caseSummary; } -- 2.25.1