Skip to content

Commit

Permalink
allow negative self-service hours
Browse files Browse the repository at this point in the history
event civicrm#34 message improvement

fixes to message template

fixes
  • Loading branch information
MegaphoneJon committed Aug 30, 2020
1 parent c21ad4f commit a54cf42
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,8 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F
'conference_sessions' => $sessions,
'credit_card_number' => CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $participantParams)),
'credit_card_exp_date' => CRM_Utils_Date::mysqlToIso(CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $participantParams))),
'selfcancelxfer_time' => abs($values['event']['selfcancelxfer_time']),
'selfservice_preposition' => $values['event']['selfcancelxfer_time'] < 0 ? 'after' : 'before',
]);

// CRM-13890 : NOTE wait list condition need to be given so that
Expand Down
8 changes: 6 additions & 2 deletions CRM/Event/BAO/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,6 @@ public static function formatFieldsAndSetProfileDefaults($contactId, &$form) {
* Evaluate whether a participant record is eligible for self-service transfer/cancellation. If so,
* return additional participant/event details.
*
* TODO: This function fails when the "hours until self-service" is less than zero.
* @param int $participantId
* @param string $url
* @param bool $isBackOffice
Expand Down Expand Up @@ -1930,7 +1929,12 @@ public static function getSelfServiceEligibility(int $participantId, string $url
$cancelDeadline = (new Datetime($start_date))->sub($cancelInterval);
if ($timenow > $cancelDeadline) {
$details['eligible'] = FALSE;
$details['ineligible_message'] = ts("Registration for this event cannot be cancelled or transferred less than %1 hours prior to the event's start time. Contact the event organizer if you have questions.", [1 => $time_limit]);
// Change the language of the status message based on whether the waitlist time limit is positive or negative.
$afterOrPrior = $time_limit < 0 ? 'after' : 'prior';
$moreOrLess = $time_limit < 0 ? 'more' : 'less';
$details['ineligible_message'] = ts("Registration for this event cannot be cancelled or transferred %1 than %2 hours %3 to the event's start time. Contact the event organizer if you have questions.",
[1 => $moreOrLess, 2 => $cancelHours, 3 => $afterOrPrior]);

}
}
return $details;
Expand Down
10 changes: 10 additions & 0 deletions CRM/Upgrade/Incremental/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ protected function getTemplateUpdates() {
['name' => 'contribution_invoice_receipt', 'type' => 'html'],
],
],
[
'version' => '5.30.alpha1',
'upgrade_descriptor' => ts('Support negative hours for cancellation/transfer'),
'templates' => [
['name' => 'participant_confirm', 'type' => 'html'],
['name' => 'participant_confirm', 'type' => 'text'],
['name' => 'event_online_receipt', 'type' => 'html'],
['name' => 'event_online_receipt', 'type' => 'text'],
],
],

];
}
Expand Down
3 changes: 3 additions & 0 deletions CRM/Upgrade/Incremental/sql/5.30.alpha1.mysql.tpl
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{* file to handle db changes in 5.30.alpha1 during upgrade *}
-- Allow self-service/transfer to have a negative time.
ALTER TABLE civicrm_event MODIFY COLUMN selfcancelxfer_time INT;

2 changes: 1 addition & 1 deletion templates/CRM/Event/Form/ManageEvent/Registration.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@
{ts}Cancellation or Transfer Time Limit{/ts}
{/htxt}
{htxt id="id-selfcancelxfer_time"}
{ts}Number of hours prior to event start date to allow self-service cancellation or transfer. Enter 0 (or leave empty) to allow cancellation or transfer up until the event has started.{/ts}
{ts}Number of hours prior to event start date to allow self-service cancellation or transfer. Enter a negative number of hours to allow cancellation after the event starts. Enter 0 (or leave empty) to allow cancellation or transfer up until the event has started.{/ts}
{/htxt}
9 changes: 9 additions & 0 deletions tests/phpunit/CRM/Event/BAO/ParticipantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,15 @@ public function selfServiceScenarios() {
'isBackOffice' => FALSE,
'successExpected' => FALSE,
];
// Cancellation deadline is < 0 hours
$scenarios[] = [
'selfSvcEnabled' => 1,
'selfSvcHours' => -12,
'hoursToEvent' => 4,
'participantStatusId' => 1,
'isBackOffice' => FALSE,
'successExpected' => TRUE,
];
return $scenarios;
}

Expand Down
2 changes: 1 addition & 1 deletion xml/schema/Event/Event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@
</field>
<field>
<name>selfcancelxfer_time</name>
<type>int unsigned</type>
<type>int</type>
<default>0</default>
<title>Self-service Cancellation or Transfer Time</title>
<comment>Number of hours prior to event start date to allow self-service cancellation or transfer.</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@
{if $event.allow_selfcancelxfer }
<tr>
<td colspan="2" {$valueStyle}>
{ts 1=$event.selfcancelxfer_time}You may transfer your registration to another participant or cancel your registration up to %1 hours before the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}<br />
{ts 1=$selfcancelxfer_time 2=$selfservice_preposition}You may transfer your registration to another participant or cancel your registration up to %1 hours %2 the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}<br />
{capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&pid=`$participant.id`&{contact.checksum}" h=0 a=1 fe=1}{/capture}
<a href="{$selfService}">{ts}Click here to transfer or cancel your registration.{/ts}</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ You were registered by: {$payer.name}
{/if}

{if $event.allow_selfcancelxfer }
{ts 1=$event.selfcancelxfer_time}You may transfer your registration to another participant or cancel your registration up to %1 hours before the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}
{ts 1=$selfcancelxfer_time 2=$selfservice_preposition}You may transfer your registration to another participant or cancel your registration up to %1 hours %2 the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}
{capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&pid=`$participant.id`&{contact.checksum}" h=0 a=1 fe=1}{/capture}
{ts}Transfer or cancel your registration:{/ts} {$selfService}
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
{if $event.allow_selfcancelxfer }
<tr>
<td colspan="2" {$valueStyle}>
{ts 1=$event.selfcancelxfer_time}You may transfer your registration to another participant or cancel your registration up to %1 hours before the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}<br />
{ts 1=$selfcancelxfer_time 2=$selfservice_preposition}You may transfer your registration to another participant or cancel your registration up to %1 hours %2 the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}<br />
{capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&pid=`$participant.id`&{contact.checksum}" h=0 a=1 fe=1}{/capture}
<a href="{$selfService}">{ts}Click here to transfer or cancel your registration.{/ts}</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Click this link to go to a web page where you can confirm your registration onli
{$confirmUrl}
{/if}
{if $event.allow_selfcancelxfer }
{ts 1=$event.selfcancelxfer_time}You may transfer your registration to another participant or cancel your registration up to %1 hours before the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}
{ts 1=$selfcancelxfer_time 2=$selfservice_preposition}You may transfer your registration to another participant or cancel your registration up to %1 hours %2 the event.{/ts} {if $totalAmount}{ts}Cancellations are not refundable.{/ts}{/if}
{capture assign=selfService}{crmURL p='civicrm/event/selfsvcupdate' q="reset=1&pid=`$participant.id`&{contact.checksum}" h=0 a=1 fe=1}{/capture}
{ts}Transfer or cancel your registration:{/ts} {$selfService}
{/if}
Expand Down

0 comments on commit a54cf42

Please sign in to comment.