diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index 64f4c1473c856bbf15cfd6a444880aa60c43ebab..b711e8bd02df1c405b6e4fd5ba13929202c2dfc3 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -94,6 +94,29 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { } } + $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' => implode(', ', $participant['participant.fee_level']), + 'role' => implode(', ', $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); diff --git a/templates/CRM/Contribute/Form/ContributionView.tpl b/templates/CRM/Contribute/Form/ContributionView.tpl index 751cb143869c9476186d810dae29e006a01a0be4..c3b0f1e22725bdfd5e741bb8ef9ff1dcce25ddb8 100644 --- a/templates/CRM/Contribute/Form/ContributionView.tpl +++ b/templates/CRM/Contribute/Form/ContributionView.tpl @@ -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> diff --git a/templates/CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl b/templates/CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl new file mode 100644 index 0000000000000000000000000000000000000000..770447483589f192dc18689438ef9f4229606359 --- /dev/null +++ b/templates/CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl @@ -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>