Skip to content

Commit

Permalink
make email optional, make fields optional
Browse files Browse the repository at this point in the history
  • Loading branch information
larssandergreen committed Dec 20, 2022
1 parent 514497b commit cb470bc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 16 deletions.
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

0 comments on commit cb470bc

Please sign in to comment.