diff --git a/booking.emails.inc b/booking.emails.inc index b0088de..8f43d12 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -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 ', 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) diff --git a/booking.register.inc b/booking.register.inc index 76d3a79..19ff4f5 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -1209,7 +1209,10 @@ function _booking_update($node) { if ($previous_status->booking_status == 1 && $node->booking_status == 3) { 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) diff --git a/booking.tokens.inc b/booking.tokens.inc index e386b55..e0e8ed9 100644 --- a/booking.tokens.inc +++ b/booking.tokens.inc @@ -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 = "

Thanks for filling out the registration form.

\n" . "

To complete your booking, please make a payment of $[booking:payment-required] into the following bank account
\n" . " Account Name: blah
\n BSB: blah
\n Account Number: blah

\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++)