From 1daa1b50a236f8c7dcf10e35cad66b0f96a7812b Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Tue, 8 Feb 2022 21:36:01 +0000 Subject: [PATCH] dev/user-interface#45 Show associated participants on contributionView form --- CRM/Contribute/Form/ContributionView.php | 23 +++++++++++++++++++ .../CRM/Contribute/Form/ContributionView.tpl | 8 +++++++ ...ContributionViewAssociatedParticipants.tpl | 16 +++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 templates/CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index 64f4c1473c85..b711e8bd02df 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -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' => 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 751cb143869c..c3b0f1e22725 100644 --- a/templates/CRM/Contribute/Form/ContributionView.tpl +++ b/templates/CRM/Contribute/Form/ContributionView.tpl @@ -87,6 +87,14 @@ {/if} + {if $associatedParticipants} + + {ts}Associated participants{/ts} + + {include file="CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl" associatedParticipants=$associatedParticipants} + + + {/if} {if $invoicing && $tax_amount} {ts 1=$taxTerm}Total %1 Amount{/ts} diff --git a/templates/CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl b/templates/CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl new file mode 100644 index 000000000000..770447483589 --- /dev/null +++ b/templates/CRM/Contribute/Form/ContributionViewAssociatedParticipants.tpl @@ -0,0 +1,16 @@ + + + + + + + + {foreach from=$associatedParticipants item="participant"} + + + + + + {/foreach} + +
{ts}Participant{/ts}{ts}Role{/ts}{ts}Fee{/ts}
{$participant.participantName|escape}{$participant.role|escape}{$participant.fee|escape}