From 38f52beb523dca14ac3f71095ba580724e0ccab6 Mon Sep 17 00:00:00 2001 From: Francesc Bassas i Bullich Date: Fri, 5 Jul 2024 19:08:44 +0200 Subject: [PATCH] Improve UX for "Print Name Badges" and "PDF letter - print for participant" --- CRM/Event/Form/Task/Badge.php | 14 +++++---- CRM/Event/Form/Task/PDF.php | 29 ++++++++++++++++++- CRM/Event/xml/Menu/Event.xml | 6 ++++ ...SavedSearch_Contact_Summary_Events.mgd.php | 24 +++++++++++++++ templates/CRM/Event/Form/ParticipantView.tpl | 1 + 5 files changed, 67 insertions(+), 7 deletions(-) diff --git a/CRM/Event/Form/Task/Badge.php b/CRM/Event/Form/Task/Badge.php index 0e1d02fb964d..e10d4ef4f223 100644 --- a/CRM/Event/Form/Task/Badge.php +++ b/CRM/Event/Form/Task/Badge.php @@ -48,7 +48,7 @@ class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task { */ public function preProcess() { $this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); - if ($this->_context == 'view') { + if ($this->_context == 'view' || $this->_context == 'participant') { $this->_single = TRUE; $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); @@ -57,11 +57,13 @@ public function preProcess() { $this->_componentClause = " civicrm_participant.id = $participantID "; $this->assign('totalSelectedParticipants', 1); - // also set the user context to send back to view page - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/participant', - "reset=1&action=view&id={$participantID}&cid={$contactID}" - )); + if ($this->_context == 'view') { + // also set the user context to send back to view page + $session = CRM_Core_Session::singleton(); + $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/participant', + "reset=1&action=view&id={$participantID}&cid={$contactID}" + )); + } } else { parent::preProcess(); diff --git a/CRM/Event/Form/Task/PDF.php b/CRM/Event/Form/Task/PDF.php index 0f0d25436f4f..461e712063ae 100644 --- a/CRM/Event/Form/Task/PDF.php +++ b/CRM/Event/Form/Task/PDF.php @@ -42,12 +42,39 @@ class CRM_Event_Form_Task_PDF extends CRM_Event_Form_Task { public $_cid = NULL; public $_activityId = NULL; + /** + * The context this page is being rendered in + * + * @var string + */ + protected $_context; + /** * Build all the data structures needed to build the form. */ public function preProcess() { $this->preProcessPDF(); - parent::preProcess(); + $this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); + if ($this->_context == 'view' || $this->_context == 'participant') { + $this->_single = TRUE; + + $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); + $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); + $this->_participantIds = [$participantID]; + $this->_componentClause = " civicrm_participant.id = $participantID "; + $this->assign('totalSelectedParticipants', 1); + + if ($this->_context == 'view') { + // also set the user context to send back to view page + $session = CRM_Core_Session::singleton(); + $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/participant', + "reset=1&action=view&id={$participantID}&cid={$contactID}" + )); + } + } + else { + parent::preProcess(); + } $this->assign('single', $this->_single); } diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml index cafa3b3bb513..dec80ca5f748 100644 --- a/CRM/Event/xml/Menu/Event.xml +++ b/CRM/Event/xml/Menu/Event.xml @@ -153,6 +153,12 @@ true 820 + + civicrm/event/participant/print + ts('PDF letter - print for participants') + CRM_Event_Form_Task_PDF + access CiviEvent + civicrm/event/badge Print Event Name Badge diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Contact_Summary_Events.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Contact_Summary_Events.mgd.php index 9e22f84c52dc..a1b59c29c137 100644 --- a/ext/civicrm_admin_ui/managed/SavedSearch_Contact_Summary_Events.mgd.php +++ b/ext/civicrm_admin_ui/managed/SavedSearch_Contact_Summary_Events.mgd.php @@ -219,6 +219,30 @@ 'action' => '', 'join' => '', ], + [ + "path" => "civicrm/event/badge?reset=1&context=participant&id=[id]&cid=[contact_id]", + "icon" => "fa-id-badge", + "text" => E::ts("Print Name Badge"), + "style" => "default", + "condition" => [], + "task" => "", + "entity" => "", + "action" => "", + "join" => "", + "target" => "crm-popup", + ], + [ + "path" => "civicrm/event/participant/print?reset=1&context=participant&id=[id]&cid=[contact_id]", + "icon" => "fa-print", + "text" => E::ts("PDF letter - print for participants"), + "style" => "default", + "condition" => [], + "task" => "", + "entity" => "", + "action" => "", + "join" => "", + "target" => "crm-popup", + ], ], 'type' => 'menu', 'alignment' => 'text-right', diff --git a/templates/CRM/Event/Form/ParticipantView.tpl b/templates/CRM/Event/Form/ParticipantView.tpl index 0b154deeb3dc..fb0f02bcecb3 100644 --- a/templates/CRM/Event/Form/ParticipantView.tpl +++ b/templates/CRM/Event/Form/ParticipantView.tpl @@ -31,6 +31,7 @@ {$displayName|escape}
{ts}Print Name Badge{/ts} + {ts}PDF letter - print for participant{/ts}