From 1c6bc4ef1533932c1a0dff54cb71f50ab5a6b262 Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Tue, 20 Dec 2022 13:51:25 -0700 Subject: [PATCH] optional email for cancellations --- CRM/Event/Form/SelfSvcUpdate.php | 25 +++++++++++----- templates/CRM/Event/Form/SelfSvcTransfer.tpl | 16 +++++++--- templates/CRM/Event/Form/SelfSvcUpdate.tpl | 30 ++++++++++++++++--- .../CRM/Event/Form/SelfSvcUpdateTest.php | 1 + 4 files changed, 56 insertions(+), 16 deletions(-) diff --git a/CRM/Event/Form/SelfSvcUpdate.php b/CRM/Event/Form/SelfSvcUpdate.php index ed1055eb49..269b3534f3 100644 --- a/CRM/Event/Form/SelfSvcUpdate.php +++ b/CRM/Event/Form/SelfSvcUpdate.php @@ -167,6 +167,10 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { 'name' => ts('Submit'), ], ]); + if ($this->isBackoffice && $this->_contact_email) { + $isConfirmationEmail = $this->addElement('checkbox', 'is_confirmation_email', ts('Send confirmation email?')); + $isConfirmationEmail->setValue(1); + } $this->addFormRule(['CRM_Event_Form_SelfSvcUpdate', 'formRule'], $this); parent::buildQuickForm(); } @@ -283,14 +287,19 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); //send a 'cancelled' email to user, and cc the event's cc_confirm email - CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_participant_id, - $participantDetails[$this->_participant_id], - $eventDetails[$this->_event_id], - NULL, - 'Cancelled' - ); - $statusMsg = ts('Event registration information for %1 has been updated.', [1 => $this->_contact_name]); - $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', [1 => $this->_contact_email]); + $statusMsg = ts('Event registration for %1 has been cancelled.', [1 => $this->_contact_name]); + if (empty($this->isBackoffice) || array_key_exists('is_confirmation_email', $params)) { + $emailSent = FALSE; + $emailSent = CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_participant_id, + $participantDetails[$this->_participant_id], + $eventDetails[$this->_event_id], + NULL, + 'Cancelled' + ); + if ($emailSent) { + $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', [1 => $this->_contact_email]); + } + } CRM_Core_Session::setStatus($statusMsg, ts('Thanks'), 'success'); if (!empty($this->isBackoffice)) { return; diff --git a/templates/CRM/Event/Form/SelfSvcTransfer.tpl b/templates/CRM/Event/Form/SelfSvcTransfer.tpl index 8b501d4f7f..20e1ba3a15 100644 --- a/templates/CRM/Event/Form/SelfSvcTransfer.tpl +++ b/templates/CRM/Event/Form/SelfSvcTransfer.tpl @@ -12,8 +12,12 @@ {ts}Current
Participant{/ts} {ts}Event{/ts} - {ts}Fee Level{/ts} - {ts}Amount{/ts} + {if !empty($details.fee_level)} + {ts}Fee Level{/ts} + {/if} + {if !empty($details.fee_amount)} + {ts}Amount{/ts} + {/if} {ts}Registered{/ts} {ts}Status{/ts} {ts}Role{/ts} @@ -21,8 +25,12 @@ {$details.name} {$details.title}
{$details.event_start_date|truncate:10:''|crmDate} - {$details.fee_level} - {$details.fee_amount} + {if !empty($details.fee_level)} + {$details.fee_level} + {/if} + {if !empty($details.fee_amount)} + {$details.fee_amount} + {/if} {$details.register_date|truncate:10:''|crmDate} {$details.status} {$details.role} diff --git a/templates/CRM/Event/Form/SelfSvcUpdate.tpl b/templates/CRM/Event/Form/SelfSvcUpdate.tpl index b3f68c223d..85f1fe5ef0 100644 --- a/templates/CRM/Event/Form/SelfSvcUpdate.tpl +++ b/templates/CRM/Event/Form/SelfSvcUpdate.tpl @@ -12,16 +12,24 @@ {ts}Participant{/ts} {ts}Event{/ts} - {ts}Fee Level{/ts} - {ts}Amount{/ts} + {if !empty($details.fee_level)} + {ts}Fee Level{/ts} + {/if} + {if !empty($details.fee_amount)} + {ts}Amount{/ts} + {/if} {ts}Registered{/ts} {ts}Status{/ts} {ts}Role{/ts} {$details.name}{$details.title}
{$details.event_start_date|truncate:10:''|crmDate} - {$details.fee_level} - {$details.fee_amount} + {if !empty($details.fee_level)} + {$details.fee_level} + {/if} + {if !empty($details.fee_amount)} + {$details.fee_amount} + {/if} {$details.register_date|truncate:10:''|crmDate} {$details.status}{$details.role} @@ -31,17 +39,31 @@
{$form.action.html}
+ {if array_key_exists('is_confirmation_email', $form)} + + {/if}
{include file="CRM/common/formButtons.tpl" location="bottom"}
{literal} diff --git a/tests/phpunit/CRM/Event/Form/SelfSvcUpdateTest.php b/tests/phpunit/CRM/Event/Form/SelfSvcUpdateTest.php index c372eb3b41..26f2f39818 100644 --- a/tests/phpunit/CRM/Event/Form/SelfSvcUpdateTest.php +++ b/tests/phpunit/CRM/Event/Form/SelfSvcUpdateTest.php @@ -23,6 +23,7 @@ class CRM_Event_Form_SelfSvcUpdateTest extends CiviUnitTestCase { $form = $this->getFormObject('CRM_Event_Form_SelfSvcUpdate', [ 'email' => 'new@example.org', 'action' => 2, + 'is_confirmation_email' => 1, ]); $form->buildForm(); $form->postProcess(); -- 2.25.1