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

CiviCase: fix case custom data values in Case Audit Report #16654

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 3 additions & 15 deletions CRM/Case/XMLProcessor/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,26 +956,14 @@ public static function printCaseReport() {

// Retrieve custom values for cases.
$customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($caseID, 'Case');
$extends = array('case');
$groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
$caseCustomFields = array();
foreach ($groupTree as $gid => $group_values) {
foreach ($group_values['fields'] as $id => $field_values) {
if (array_key_exists($id, $customValues)) {
$caseCustomFields[$gid]['title'] = $group_values['title'];
$caseCustomFields[$gid]['values'][$id] = array(
'label' => $field_values['label'],
'value' => $customValues[$id],
);
}
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Case', NULL, $caseID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to include the case type in the getTree() call. Otherwise it doesn't show custom fields that are specific to that case type. See e.g. https://github.com/civicrm/civicrm-core/blob/5.22.1/CRM/Case/Form/CaseView.php#L146

CRM_Core_BAO_CustomGroup::buildCustomDataView($template, $groupTree, FALSE, NULL, NULL, NULL, $caseID);

$template->assign('caseRelationships', $caseRelationships);
$template->assign('caseRoles', $caseRoles);
$template->assign('otherRelationships', $otherRelationships);
$template->assign('globalRelationships', $relGlobal);
$template->assign('globalGroupInfo', $globalGroupInfo);
$template->assign('caseCustomFields', $caseCustomFields);
$contents = self::getCaseReport($clientID,
$caseID,
$activitySetName,
Expand Down
24 changes: 13 additions & 11 deletions templates/CRM/Case/Audit/Report.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,19 @@
</table>
{/if}

{if $caseCustomFields}
{foreach from=$caseCustomFields item=group}
<h2>{$group.title}</h2>
<table class ="report-layout">
{foreach from=$group.values item=row}
<tr>
<th class="label">{$row.label}</td>
<td class="crm-case-report-custom-field">{$row.value}</td>
</tr>
{/foreach}
</table>
{if $viewCustomData}
{foreach from=$viewCustomData item=cd}
{foreach from=$cd item=group}
<h2>{$group.title}</h2>
<table class="report-layout">
{foreach from=$group.fields item=row}
<tr>
<th class="label">{$row.field_title}</td>
<td class="crm-case-report-custom-field">{$row.field_value}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be |escape'd, but I see it doesn't escape them on manage case either. Hmm.

</tr>
{/foreach}
</table>
{/foreach}
{/foreach}
{/if}

Expand Down