Auto email people moving from bookedin/waiting list to not-coming list

This commit is contained in:
2014-01-20 23:57:25 +11:00
parent dfe767983a
commit 3811b15094
3 changed files with 65 additions and 5 deletions

View File

@@ -148,8 +148,8 @@ function _booking_balance_payment_email($nid)
//send the email
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
//drupal_mail('booking', 'registration_mail_bal_outstanding', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))),
// $language, $params, $from);
drupal_mail('booking', 'registration_mail_bal_outstanding', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))),
$language, $params, $from);
drupal_mail('booking', 'registration_mail_bal_outstanding', 'it@coadcorp.com', $language, $params, $from);
}
@@ -219,7 +219,7 @@ function _booking_promoted_from_waitinglist_email($nid)
$params['subject'] = $subject;
//retrieve the body of the email
$params['body'] = token_replace(variable_get($booking_email_waitinglistpromotion), $tokens);
$params['body'] = token_replace(variable_get('booking_email_waitinglistpromotion'), $tokens);
//send the email
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
@@ -229,6 +229,42 @@ function _booking_promoted_from_waitinglist_email($nid)
}
/**
* Function to generate email to be sent to the attendee once they pull out and move to the not-coming list
*
* @param $nid - the registration node
*/
function _booking_demoted_to_notcoming_email($nid)
{
global $event;
global $user;
$language = user_preferred_language($user);
//load the node matching this id
$node = node_load($nid);
$tokens = booking_define_personspecific_tokens($node);
//calculate the from email address
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
));
//calculate the remaining parameters
$to = $node->booking_email;
$subject = token_replace(variable_get($booking_email_notcoming_demotion_subject, t('!event', array('!event' => $event->booking_eventname))), $tokens);
//$subject = t('!event withdrawal confirmation', array('!event' => $event->booking_eventname));
$params['subject'] = $subject;
//retrieve the body of the email
$params['body'] = token_replace(variable_get('booking_email_notcoming_demotion'), $tokens);
//send the email
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
drupal_mail('booking', 'booking_email_custom', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))),
$language, $params, $from);
drupal_mail('booking', 'booking_email_custom', 'it@coadcorp.com', $language, $params, $from);
}
/*
function _booking_promoted_from_waitinglist_email_old($nid)

View File

@@ -1210,6 +1210,9 @@ function _booking_update($node) {
{
watchdog('booking', 'Detected person moving from Booked In list to No Longer Coming');
//let this person know their request has been processed
_booking_demoted_to_notcoming_email($node->nid);
//check if there is room on the booked-in list
if (_booking_check_bookings_full() == False)
{
@@ -1229,6 +1232,13 @@ function _booking_update($node) {
else
watchdog('booking', 'Still no room on the booked in list though.');
}
//if someone is moving to the not-coming list from the waiting list
elseif ($previous_status->booking_status == 2 && $node->booking_status == 3)
{
watchdog('booking', 'Detected person moving from waiting list to No Longer Coming');
//let this person know their request has been processed
_booking_demoted_to_notcoming_email($node->nid);
}
//if we're not automatically sending emails on registration
//and someone moved from not-paid to booked-in (ie, manual payment process)
elseif (variable_get('booking_auto_confirm_email', 0) == 0 && $previous_status->booking_status == 0 && $node->booking_status == 1)

View File

@@ -88,7 +88,7 @@ function booking_tokens_admin() {
"and you will not receive the confirmation email until that has occurred.\n" .
"Please don't hesitate to contact us if you have any queries by replying to this email. We look forward to seeing you, God Willing, at [booking:eventname]\n" .
"Love in Jesus,\n[booking:eventname] Registrations Team.";
$booking_email_notcoming_demotion = "";
$booking_confirmation_text = "<p>Thanks for filling out the registration form.</p>\n" .
"<p>To complete your booking, please make a payment of <strong>$[booking:payment-required]</strong> into the following bank account<br />\n" .
"&nbsp;Account Name: blah<br />\n&nbsp;BSB: blah<br />\n&nbsp;Account Number: blah</p>\n" .
@@ -321,6 +321,20 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text
'#description' => t(''),
'#default_value' => variable_get('booking_email_waitinglistpromotion', $booking_email_waitinglistpromotion),
);
$form['emails']['booking_email_notcoming_demotion_subject'] = array (
'#type' => 'textfield',
'#title' => t('Subject line for email advising attendee their withdrawal has been processed'),
'#size' => 150,
'#maxlength' => 300,
'#default_value' => variable_get('booking_email_notcoming_demotion_subject','[booking:eventname] withdrawal processed'),
);
$form['emails']['booking_email_notcoming_demotion'] = array(
'#title' => t('Email text to send a person who withdraws their registration'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_email_notcoming_demotion', $booking_email_notcoming_demotion),
);
//add a bunch of custom emails
for ($i = 1; $i <= CUSTOM_EMAIL_COUNT; $i++)