add logistics custom emails
This commit is contained in:
@@ -240,23 +240,34 @@ function _booking_partialbalance_payment_email($nid)
|
||||
* @param $email_type - select which custom email template to use
|
||||
* @return nothing
|
||||
*/
|
||||
function _booking_custom_email($nid, $email_type)
|
||||
function _booking_custom_email($nid, $email_type, $sender = 'contact')
|
||||
{
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
if ($sender == 'contact') {
|
||||
//calculate the drupal variables to use
|
||||
$email_subject_variable = 'booking_email_subject_' . $email_type;
|
||||
$email_body_variable = 'booking_email_' . $email_type;
|
||||
//calculate the from email address for a contact email
|
||||
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
||||
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
} elseif ($sender == 'logistics') {
|
||||
//calculate the drupal variables to use
|
||||
$email_subject_variable = 'booking_email_logistics_subject_' . $email_type;
|
||||
$email_body_variable = 'booking_email_logistics_' . $email_type;
|
||||
//calculate the from email address for a logistics email
|
||||
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
||||
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
}
|
||||
|
||||
//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($email_subject_variable, t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
@@ -275,7 +286,6 @@ function _booking_custom_email($nid, $email_type)
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the registrant once they move from the waiting list to the coming list
|
||||
*
|
||||
@@ -413,11 +423,11 @@ function _booking_missedpayment_email($nid)
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the attendee requesting them to complete their travel form
|
||||
* Function to generate email to be sent to the attendee with the _initial_ request to complete their travel form
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_travelform_request_email($nid)
|
||||
function _booking_travelform_initial_request_email($nid)
|
||||
{
|
||||
global $event;
|
||||
global $user;
|
||||
@@ -443,7 +453,7 @@ function _booking_travelform_request_email($nid)
|
||||
|
||||
//calculate the remaining parameters
|
||||
$to = $node->booking_email;
|
||||
$subject = token_replace(variable_get('booking_email_travel_required_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
$subject = token_replace(variable_get('booking_email_travel_initial_email_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
@@ -454,12 +464,62 @@ function _booking_travelform_request_email($nid)
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_travel_required_text'), $tokens);
|
||||
$params['body'] = token_replace(variable_get('booking_email_travel_initial_email_text'), $tokens);
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the attendee with the _reminder_ request to complete their travel form
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_travelform_reminder_request_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 travelform confirmation email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
|
||||
//load the node matching this id from the database, ignoring the cache
|
||||
$node = node_load($nid, NULL, TRUE);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
watchdog('booking', 'Sending travelform confirmation email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
|
||||
//calculate the from email address
|
||||
$from = t('!event Travel <!email>', array('!event' => $event->booking_eventname,
|
||||
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
|
||||
//calculate the remaining parameters
|
||||
$to = $node->booking_email;
|
||||
$subject = token_replace(variable_get('booking_email_travel_reminder_email_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_travel_reminder_email_text'), $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
|
||||
*
|
||||
|
@@ -155,19 +155,33 @@ function booking_emails_admin() {
|
||||
'#description' => t('Email text to send a person who missed the payment deadline'),
|
||||
'#default_value' => variable_get('booking_email_missedpayment', ''),
|
||||
);
|
||||
$form['emails']['booking_email_travel_required_subject'] = array (
|
||||
$form['emails']['booking_email_travel_initial_email_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Travel Form Required Subject'),
|
||||
'#description' => t('Subject line for email requesting attendee to complete the travel form'),
|
||||
'#title' => t('Initial Travel Form Required Subject'),
|
||||
'#description' => t('Subject line for first email requesting attendee to complete the travel form'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_travel_required_subject','[booking:eventname] Travel Details Required'),
|
||||
'#default_value' => variable_get('booking_email_travel_initial_email_subject','[booking:eventname] Travel Details Required'),
|
||||
);
|
||||
$form['emails']['booking_email_travel_required_text'] = array(
|
||||
'#title' => t('Travel Form Required Text'),
|
||||
'#description' => t('Email text requesting attendee to complete the travel form. This email will be sent from the !email email address', array('!email' => variable_get('booking_logistics_email'))),
|
||||
$form['emails']['booking_email_travel_initial_email_text'] = array(
|
||||
'#title' => t('Initial Travel Form Required Text'),
|
||||
'#description' => t('Text for first email requesting attendee to complete the travel form. This email will be sent from the !email email address', array('!email' => variable_get('booking_logistics_email'))),
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => variable_get('booking_email_travel_required_text', ''),
|
||||
'#default_value' => variable_get('booking_email_travel_initial_email_text', ''),
|
||||
);
|
||||
$form['emails']['booking_email_travel_reminder_email_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Reminder Travel Form Required Subject'),
|
||||
'#description' => t('Subject line for reminder email requesting attendee to complete the travel form'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_travel_reminder_email_subject','[booking:eventname] Travel Details Required'),
|
||||
);
|
||||
$form['emails']['booking_email_travel_reminder_email_text'] = array(
|
||||
'#title' => t('Reminder Travel Form Required Text'),
|
||||
'#description' => t('Text for reminder email requesting attendee to complete the travel form. This email will be sent from the !email email address', array('!email' => variable_get('booking_logistics_email'))),
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => variable_get('booking_email_travel_reminder_email_text', ''),
|
||||
);
|
||||
$form['emails']['booking_email_travel_complete_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -211,6 +225,34 @@ function booking_emails_admin() {
|
||||
);
|
||||
}
|
||||
|
||||
/*Text for logistics emails*/
|
||||
$form['custom-logistics-emails'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Custom Logistics Email Text Definitions',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
//add a bunch of custom emails
|
||||
//@todo add an admin variable for this
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$subject_fieldname = 'booking_email_subject_logistics_custom' . $i;
|
||||
$body_fieldname = 'booking_email_logistics_custom' . $i;
|
||||
$form['custom-logistics-emails'][$subject_fieldname] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for Logistics Custom Email ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get($subject_fieldname,'[booking:eventname]'),
|
||||
);
|
||||
$form['custom-logistics-emails'][$body_fieldname] = array(
|
||||
'#title' => t('Email text for Logistics Custom Email ' . $i),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get($body_fieldname, ''),
|
||||
);
|
||||
}
|
||||
|
||||
//let the builtin hook do all the hard work
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
@@ -237,7 +279,8 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
|
||||
$email_options_array['complete'] = 'Payment Complete Email';
|
||||
$email_options_array['withdrawal'] = 'Withdrawal Processed Email';
|
||||
$email_options_array['missedpayment'] = 'Missed Payment Email';
|
||||
$email_options_array['travelrequired'] = 'Travel Form Required Email';
|
||||
$email_options_array['initialtravelrequired'] = 'Initial Travel Form Required Email';
|
||||
$email_options_array['remindertravelrequired'] = 'Reminder Travel Form Required Email';
|
||||
$email_options_array['travelcomplete'] = 'Travel Form Complete Email';
|
||||
|
||||
//add in the custom email types
|
||||
@@ -245,6 +288,11 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
|
||||
{
|
||||
$email_options_array['custom' . $i] = variable_get('booking_email_subject_custom' . $i, $event->booking_eventname . ' custom ' . $i);
|
||||
}
|
||||
//add in the custom email types from logistics
|
||||
for ($i = 1; $i <= 5; $i++)
|
||||
{
|
||||
$email_options_array['logisticscustom' . $i] = variable_get('booking_email_subject_logistics_custom' . $i, $event->booking_eventname . ' logistics custom ' . $i);
|
||||
}
|
||||
|
||||
$form['#attached']['css'] = array(
|
||||
drupal_get_path('module', 'booking') . '/booking.css',
|
||||
@@ -384,53 +432,45 @@ function booking_manual_email_form_submit($form, &$form_state) {
|
||||
|
||||
if ($person)
|
||||
{
|
||||
if ($form_state['values']['email-type'] == 'registration')
|
||||
{
|
||||
if ($form_state['values']['email-type'] == 'registration') {
|
||||
$message = t('Processing a manual registration email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual registration email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, false, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'travelrequired')
|
||||
{
|
||||
$message = t('Processing a manual travel form request email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_request_email($key);
|
||||
elseif ($form_state['values']['email-type'] == 'initialtravelrequired') {
|
||||
$message = t('Processing a manual initial travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_initial_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'balance')
|
||||
{
|
||||
elseif ($form_state['values']['email-type'] == 'remindertravelrequired') {
|
||||
$message = t('Processing a manual reminder travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_reminder_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'balance') {
|
||||
$message = t('Processing a manual outstanding balance email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual outstanding balance email to id @info', array ('@info' => $key));
|
||||
_booking_balance_payment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'complete')
|
||||
{
|
||||
elseif ($form_state['values']['email-type'] == 'complete') {
|
||||
$message = t('Processing a manual registration complete email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual registration complete email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, true, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'travelcomplete')
|
||||
{
|
||||
elseif ($form_state['values']['email-type'] == 'travelcomplete') {
|
||||
$message = t('Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
//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')
|
||||
{
|
||||
elseif ($form_state['values']['email-type'] == 'withdrawal') {
|
||||
$message = t('Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
//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')
|
||||
{
|
||||
elseif ($form_state['values']['email-type'] == 'missedpayment') {
|
||||
$message = t('Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
//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)
|
||||
{
|
||||
elseif (strpos($form_state['values']['email-type'], 'custom') !== false) {
|
||||
$message = t('Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
//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']);
|
||||
_booking_custom_email($key, $form_state['values']['email-type'], 'contact');
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'customlogistics') !== false) {
|
||||
$message = t('Processing a @custom type email from logistics to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
_booking_custom_email($key, $form_state['values']['email-type'], 'logistics');
|
||||
}
|
||||
//increase the counter of people we've emailed
|
||||
$counter++;
|
||||
|
Reference in New Issue
Block a user