Skip to content

Commit

Permalink
Merge pull request #30625 from francescbassas/participant-print
Browse files Browse the repository at this point in the history
Improve UX for "Print Name Badges" and "PDF letter - print for participant"
  • Loading branch information
mattwire authored Aug 26, 2024
2 parents edbd7d3 + 38f52be commit 5b253eb
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
14 changes: 8 additions & 6 deletions CRM/Event/Form/Task/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
29 changes: 28 additions & 1 deletion CRM/Event/Form/Task/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions CRM/Event/xml/Menu/Event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
<is_ssl>true</is_ssl>
<weight>820</weight>
</item>
<item>
<path>civicrm/event/participant/print</path>
<title>ts('PDF letter - print for participants')</title>
<page_callback>CRM_Event_Form_Task_PDF</page_callback>
<access_arguments>access CiviEvent</access_arguments>
</item>
<item>
<path>civicrm/event/badge</path>
<title>Print Event Name Badge</title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions templates/CRM/Event/Form/ParticipantView.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<strong><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=$contactId"}" title="{ts}View contact record{/ts}">{$displayName|escape}</a></strong>
<div>
<a class="action-item crm-hover-button" href="{crmURL p='civicrm/event/badge' q="reset=1&context=view&id=$participantId&cid=$contactId"}"><i class="crm-i fa-print" aria-hidden="true"></i> {ts}Print Name Badge{/ts}</a>
<a class="action-item crm-hover-button" href="{crmURL p='civicrm/event/participant/print' q="reset=1&context=view&id=$participantId&cid=$contactId"}"><i class="crm-i fa-print" aria-hidden="true"></i> {ts}PDF letter - print for participant{/ts}</a>
</div>
</td>
</tr>
Expand Down

0 comments on commit 5b253eb

Please sign in to comment.