Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make event registration cancellation email optional for back office cancellation #25207

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions CRM/Event/Form/SelfSvcUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ public function buildQuickForm() {
'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();
}
Expand Down Expand Up @@ -283,14 +287,19 @@ public function cancelParticipant($params) {
$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;
Expand Down
16 changes: 12 additions & 4 deletions templates/CRM/Event/Form/SelfSvcTransfer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@
<tr>
<th>{ts}Current<br />Participant{/ts}</th>
<th>{ts}Event{/ts}</th>
<th>{ts}Fee Level{/ts}</th>
<th>{ts}Amount{/ts}</th>
{if !empty($details.fee_level)}
<th>{ts}Fee Level{/ts}</th>
{/if}
{if !empty($details.fee_amount)}
<th>{ts}Amount{/ts}</th>
{/if}
<th>{ts}Registered{/ts}</th>
<th>{ts}Status{/ts}</th>
<th>{ts}Role{/ts}</th>
</tr>
<tr class="crm-selfsvctransfer-form-details">
<td>{$details.name}</td>
<td>{$details.title}<br />{$details.event_start_date|truncate:10:''|crmDate}</td>
<td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
<td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
{if !empty($details.fee_level)}
<td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
{/if}
{if !empty($details.fee_amount)}
<td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
{/if}
<td>{$details.register_date|truncate:10:''|crmDate}</td>
<td>{$details.status}</td>
<td class="crm-participant-participant_role">{$details.role}</td>
Expand Down
30 changes: 26 additions & 4 deletions templates/CRM/Event/Form/SelfSvcUpdate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@
<tr>
<th>{ts}Participant{/ts}</th>
<th>{ts}Event{/ts}</th>
<th>{ts}Fee Level{/ts}</th>
<th>{ts}Amount{/ts}</th>
{if !empty($details.fee_level)}
<th>{ts}Fee Level{/ts}</th>
{/if}
{if !empty($details.fee_amount)}
<th>{ts}Amount{/ts}</th>
{/if}
<th>{ts}Registered{/ts}</th>
<th>{ts}Status{/ts}</th>
<th>{ts}Role{/ts}</th>
</tr>
<tr class="crm-selfsvcupdate-form-details">
<td>{$details.name}</td><td>{$details.title}<br />{$details.event_start_date|truncate:10:''|crmDate}</td>
<td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
<td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
{if !empty($details.fee_level)}
<td class="crm-participant-participant_fee_level">{$details.fee_level}</td>
{/if}
{if !empty($details.fee_amount)}
<td class="right nowrap crm-paticipant-participant_fee_amount">{$details.fee_amount}</td>
{/if}
<td>{$details.register_date|truncate:10:''|crmDate}</td>
<td>{$details.status}</td><td class="crm-participant-participant_role">{$details.role}</td>
</tr>
Expand All @@ -31,17 +39,31 @@
<div class="content">{$form.action.html}</div>
<div class="clear"></div>
</div>
{if array_key_exists('is_confirmation_email', $form)}
<div class="crm-public-form-item crm-section" id="is-confirmation-email-section" style="display: none;">
<div class="label">{$form.is_confirmation_email.label}</div>
<div class="content">{$form.is_confirmation_email.html}</div>
<div class="clear"></div>
</div>
{/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
{literal}
<script type="text/javascript">
var contributionID = {/literal}'{$contributionId}'{literal};
var isConfirmationEmail = {/literal}'array_key_exists("is_confirmation_email", $form)'{literal};
CRM.$(function($) {
$('#action').on('change', function() {
selected = $(this).find("option:selected").text();
if (selected == 'Cancel' && contributionID) {
CRM.alert('{/literal}{ts escape='js'}Cancellations are not refundable.{/ts}{literal}', 'Warning', 'alert');
}
if ($('#action').val() == 2 && isConfirmationEmail) {
$('#is-confirmation-email-section').show();
} else {
$('#is-confirmation-email-section').hide();
}

});
});
</script>
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/CRM/Event/Form/SelfSvcUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function testForm(): void {
$form = $this->getFormObject('CRM_Event_Form_SelfSvcUpdate', [
'email' => 'new@example.org',
'action' => 2,
'is_confirmation_email' => 1,
]);
$form->buildForm();
$form->postProcess();
Expand Down