add logistics custom emails

This commit is contained in:
2016-05-31 18:21:05 +10:00
parent a7f474ec56
commit 333cfa38c4
2 changed files with 153 additions and 53 deletions

View File

@@ -155,20 +155,34 @@ 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',
'#title' => t('Travel Form Complete Subject'),
@@ -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,7 +288,12 @@ 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,54 +432,46 @@ 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'] == 'balance')
{
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'] == '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++;
//store info about the email