Skip to content

Commit

Permalink
dev/user-interface#45 Show associated participants on contributionVie…
Browse files Browse the repository at this point in the history
…w form
  • Loading branch information
braders committed Feb 8, 2022
1 parent 8990a43 commit 4a9939e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions CRM/Contribute/Form/ContributionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ public function preProcess() {
}
}

$participantLineItems = \Civi\Api4\LineItem::get()
->addSelect('entity_id', 'participant.role_id:label', 'participant.fee_level', 'participant.contact_id', 'contact.display_name')
->addJoin('Participant AS participant', 'LEFT', ['participant.id', '=', 'entity_id'])
->addJoin('Contact AS contact', 'LEFT', ['contact.id', '=', 'participant.contact_id'])
->addWhere('entity_table', '=', 'civicrm_participant')
->addWhere('contribution_id', '=', $id)
->execute();

$associatedParticipants = FALSE;
if ($participantLineItems->count()) {
foreach ($participantLineItems as $participant) {
$associatedParticipants[] = [
'participantLink' => CRM_Utils_System::url('civicrm/contact/view/participant',
"action=view&reset=1&id={$participant['entity_id']}&cid={$participant['participant.contact_id']}&context=home"
),
'participantName' => $participant['contact.display_name'],
'fee' => join(', ', $participant['participant.fee_level']),
'role' => join(', ', $participant['participant.role_id:label']),
];
}
}
$this->assign('associatedParticipants', $associatedParticipants);

$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', NULL, $id, 0, $values['financial_type_id'] ?? NULL,
NULL, TRUE, NULL, FALSE, CRM_Core_Permission::VIEW);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $id);
Expand Down
8 changes: 8 additions & 0 deletions templates/CRM/Contribute/Form/ContributionView.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
{/if}
</td>
</tr>
{if $associatedParticipants}
<tr>
<td class="label">{ts}Associated participants{/ts}</td>
<td>
{include file="CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl" associatedParticipants=$associatedParticipants}
</td>
</tr>
{/if}
{if $invoicing && $tax_amount}
<tr>
<td class="label">{ts 1=$taxTerm}Total %1 Amount{/ts}</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<table>
<tbody>
<tr class="columnheader">
<th>{ts}Participant{/ts}</th>
<th>{ts}Role{/ts}</th>
<th>{ts}Fee{/ts}</th>
</tr>
{foreach from=$associatedParticipants item="participant"}
<tr>
<td><a href='{$participant.participantLink}'>{$participant.participantName|escape}</a></td></td>
<td>{$participant.role|escape}</td>
<td>{$participant.fee|escape}</td>
</tr>
{/foreach}
</tbody>
</table>

0 comments on commit 4a9939e

Please sign in to comment.