Added an email for missed payment processing
This commit is contained in:
@@ -280,6 +280,8 @@ function booking_manual_email()
|
||||
$email_options_array['balance'] = 'Manual Balance Outstanding';
|
||||
$email_options_array['complete'] = 'Manual Payment Complete';
|
||||
$email_options_array['travelcomplete'] = 'Manual Travel Form Complete';
|
||||
$email_options_array['withdrawal'] = 'Manual Withdrawal Processed';
|
||||
$email_options_array['missedpayment'] = 'Manual Missed Payment Email';
|
||||
|
||||
//add in the custom email types
|
||||
for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++)
|
||||
@@ -411,13 +413,23 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
{
|
||||
watchdog('booking', 'Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_confirmation_email($key);
|
||||
}
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'withdrawal')
|
||||
{
|
||||
watchdog('booking', 'Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
_booking_demoted_to_notcoming_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'missedpayment')
|
||||
{
|
||||
watchdog('booking', 'Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
_booking_missedpayment_email($key);
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'custom') !== false)
|
||||
{
|
||||
watchdog('booking', 'Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
_booking_custom_email($key, $form_state['values']['email-type']);
|
||||
}
|
||||
|
||||
//increase the counter of people we've emailed
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
@@ -324,6 +324,47 @@ function _booking_demoted_to_notcoming_email($nid)
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the attendee if they miss the payment deadline
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_missedpayment_email($nid)
|
||||
{
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//return without doing anything if we shouldn't send workflow emails
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0)
|
||||
{
|
||||
watchdog('booking', 'Not sending missed-payment email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
|
||||
//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_missedpayment_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
//$subject = t('!event withdrawal confirmation', array('!event' => $event->booking_eventname));
|
||||
$params['subject'] = $subject;
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_missedpayment'), $tokens);
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the attendee once they complete their travel form
|
||||
*
|
||||
|
@@ -1328,6 +1328,8 @@ function _booking_update($node) {
|
||||
}
|
||||
}
|
||||
|
||||
//status change triggers start here
|
||||
|
||||
//check if someone has moved to not-coming list from the booked-in list
|
||||
if ($previous_status->booking_status == 1 && $node->booking_status == 3)
|
||||
{
|
||||
@@ -1363,6 +1365,40 @@ function _booking_update($node) {
|
||||
else
|
||||
watchdog('booking', 'Still no room on the booked in list though.');
|
||||
}
|
||||
//check if someone has been demoted to the "missed payment deadline" status from being booked-in
|
||||
elseif ($previous_status->booking_status == 1 && $node->booking_status == 4)
|
||||
{
|
||||
watchdog('booking', 'Detected person moving from Booked In list to Missed Payment Deadline list.');
|
||||
|
||||
//disable this until we're sure that's what we want to do
|
||||
|
||||
/*
|
||||
//let this person know they're no longer "booked in"
|
||||
_booking_missedpayment_email($node->nid);
|
||||
|
||||
//Remove from any study groups
|
||||
_booking_studygroups_cleanup($node->nid);
|
||||
|
||||
//check if there is room on the booked-in list
|
||||
if (_booking_check_bookings_full() == False)
|
||||
{
|
||||
watchdog('booking', 'Looks like there was room on the booked in list, so lets tell the next person');
|
||||
//find the first person on the waiting list
|
||||
$temp_nid = _booking_get_waitinglist_top();
|
||||
|
||||
if ($temp_nid != -1) //-1 means there was no one on the waiting list
|
||||
{
|
||||
//update their registration status
|
||||
_booking_change_status($temp_nid,1);
|
||||
|
||||
//send them an email
|
||||
_booking_promoted_from_waitinglist_email($temp_nid);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -1453,7 +1489,7 @@ function _booking_update($node) {
|
||||
->condition('nid', $node->nid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
//end trigger processing
|
||||
}
|
||||
|
||||
function _booking_delete($node) {
|
||||
|
@@ -395,7 +395,19 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_email_notcoming_demotion', $booking_email_notcoming_demotion),
|
||||
);
|
||||
|
||||
$form['emails']['booking_email_missedpayment_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for email advising attendee they missed the payment deadline'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_missedpayment_subject','[booking:eventname] payment deadline missed'),
|
||||
);
|
||||
$form['emails']['booking_email_missedpayment'] = array(
|
||||
'#title' => t('Email text to send a person who missed the payment deadline'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_email_missedpayment', ''),
|
||||
);
|
||||
|
||||
//add a bunch of custom emails
|
||||
for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++)
|
||||
|
Reference in New Issue
Block a user