'token_tree',
'#token_types' => array('booking'),
);
/*Text for emails*/
$form['emails'] = array(
'#type' => 'fieldset',
'#title' => 'Built-In Workflow Email Definitions',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
//if HTML mail is enabled, allow user to specify footer
if(variable_get('booking_enable_html_mail', 0) == 1) {
$form['emails']['booking_html_mail_footer'] = array(
'#title' => t('Footer text for HTML email'),
'#description' => t('Enter HTML to go in the footer of the email template (above the social media icons).
NOTE: No token subsitutions will be made here.'),
'#default_value' => isset(variable_get('booking_html_mail_footer')['value']) ? variable_get('booking_html_mail_footer')['value'] : variable_get('booking_html_mail_footer', '
'), '#type' => 'text_format', '#format' => 'full_html', ); } $form['emails']['booking_email_notification_text'] = array( '#title' => t('Notification Email'), '#description' => t('Email to send to the notification email address (defined in general configuration) when a person has registered'), '#default_value' => isset(variable_get('booking_email_notification_text')['value']) ? variable_get('booking_email_notification_text')['value'] : variable_get('booking_email_notification_text', '[booking:regn-summary]'), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_bookedin_text'] = array( '#title' => t('Registration Successful Email'), '#description' => t('Text to use in an email indicating the person has booked in, paid their deposit and is not on the waiting list'), '#default_value' => isset(variable_get('booking_email_bookedin_text')['value']) ? variable_get('booking_email_bookedin_text')['value'] : variable_get('booking_email_bookedin_text', $default_email_text), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_regn_complete_text'] = array( '#title' => t('Payment Complete Email'), '#description' => t('Email text to indicate a person has booked in, fully paid and is not on the waiting list. ' . 'This will be sent either at initial registration if the full amount is paid, or when the balance is paid.'), '#default_value' => isset(variable_get('booking_email_regn_complete_text')['value']) ? variable_get('booking_email_regn_complete_text')['value'] : variable_get('booking_email_regn_complete_text', $booking_email_regn_complete_text), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_waitinglist_text'] = array( '#title' => t('Registration on Waiting List Email'), '#description' => t('Email text to indicate a person has registered but is on the waiting list. ' . 'This will be sent instead of the Registration Successful or Registration Complete emails if the person is on the waiting list.'), '#default_value' => isset(variable_get('booking_email_waitinglist_text')['value']) ? variable_get('booking_email_waitinglist_text')['value'] : variable_get('booking_email_waitinglist_text', $booking_email_waitinglist_text), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_partialpayment_received_text'] = array( '#title' => t('Email text to send a person thanking them for their partial payment'), '#description' => t(''), '#default_value' => isset(variable_get('booking_email_partialpayment_received_text')['value']) ? variable_get('booking_email_partialpayment_received_text')['value'] : variable_get('booking_email_partialpayment_received_text', ''), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_paymentoutstanding_subject'] = array ( '#type' => 'textfield', '#title' => t('Balance Outstanding Email Subject'), '#description' => t('Subject line for email advising attendee they missed the payment deadline'), '#size' => 150, '#maxlength' => 300, '#default_value' => variable_get('booking_email_paymentoutstanding_subject','[booking:eventname] payment required'), ); $form['emails']['booking_email_paymentoutstanding_text'] = array( '#description' => t('Email text to send a person reminding them of how much they owe'), '#title' => t('Balance Outstanding Email Text'), '#default_value' => isset(variable_get('booking_email_paymentoutstanding_text')['value']) ? variable_get('booking_email_paymentoutstanding_text')['value'] : variable_get('booking_email_paymentoutstanding_text', $booking_email_paymentoutstanding_text), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_paymentoutstanding_married_text'] = array( '#title' => t('Email text to send a married couple reminding them of how much they both owe (only applies when combined pricing enabled)'), '#description' => t(''), '#default_value' => isset(variable_get('booking_email_paymentoutstanding_married_text')['value']) ? variable_get('booking_email_paymentoutstanding_married_text')['value'] : variable_get('booking_email_paymentoutstanding_married_text', $booking_email_paymentoutstanding_married_text), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_waitinglistpromotion'] = array( '#title' => t('Email text to send a person on the waiting list when a spot opens up for them but they have an outstanding balance.'), '#description' => t(''), '#default_value' => isset(variable_get('booking_email_waitinglistpromotion')['value']) ? variable_get('booking_email_waitinglistpromotion')['value'] : variable_get('booking_email_waitinglistpromotion', $booking_email_waitinglistpromotion), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_waitinglistpromotion_fullypaid'] = array( '#title' => t('Email text to send a person on the waiting list when a spot opens up for them and they have already fully paid.'), '#description' => t(''), '#default_value' => isset(variable_get('booking_email_waitinglistpromotion_fullypaid')['value']) ? variable_get('booking_email_waitinglistpromotion_fullypaid')['value'] : variable_get('booking_email_waitinglistpromotion_fullypaid', $booking_email_waitinglistpromotion_fullypaid), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_notcoming_demotion_subject'] = array ( '#type' => 'textfield', '#title' => t('Withdrawal Processed Email'), '#description' => 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'), '#description' => t(''), '#default_value' => isset(variable_get('booking_email_notcoming_demotion')['value']) ? variable_get('booking_email_notcoming_demotion')['value'] : variable_get('booking_email_notcoming_demotion', $booking_email_notcoming_demotion), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_missedpayment_subject'] = array ( '#type' => 'textfield', '#title' => t('Missed Payment Email Subject'), '#description' => 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('Missed Payment Email Text'), '#description' => t('Email text to send a person who missed the payment deadline'), '#default_value' => isset(variable_get('booking_email_missedpayment')['value']) ? variable_get('booking_email_missedpayment')['value'] : variable_get('booking_email_missedpayment', ''), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_travel_initial_email_subject'] = array ( '#type' => 'textfield', '#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_initial_email_subject','[booking:eventname] Travel Details Required'), ); $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'))), '#default_value' => isset(variable_get('booking_email_travel_initial_email_text')['value']) ? variable_get('booking_email_travel_initial_email_text')['value'] : variable_get('booking_email_travel_initial_email_text', ''), '#type' => $form_type, '#format' => $form_format, ); $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'))), '#default_value' => isset(variable_get('booking_email_travel_reminder_email_text')['value']) ? variable_get('booking_email_travel_reminder_email_text')['value'] : variable_get('booking_email_travel_reminder_email_text', ''), '#type' => $form_type, '#format' => $form_format, ); $form['emails']['booking_email_travel_complete_subject'] = array ( '#type' => 'textfield', '#title' => t('Travel Form Complete Subject'), '#description' => t('Subject line for email indicating a person has completed the travel form'), '#size' => 150, '#maxlength' => 300, '#default_value' => variable_get('booking_email_travel_complete_subject','[booking:eventname] Travel Details Received'), ); $form['emails']['booking_email_travel_complete_text'] = array( '#title' => t('Travel Form Complete Text'), '#description' => t('Email text to indicate a person has completed the travel form. This email will be sent from the !email email address', array('!email' => variable_get('booking_logistics_email'))), '#default_value' => isset(variable_get('booking_email_travel_complete_text')['value']) ? variable_get('booking_email_travel_complete_text')['value'] : variable_get('booking_email_travel_complete_text', ''), '#type' => $form_type, '#format' => $form_format, ); //let the builtin hook do all the hard work return system_settings_form($form, FALSE); } /** * Hook form() to use ajax to allow admin user to define custom emails that can be sent by Bookings module * * @param * @return form render array */ function booking_emails_custom_ajax_form($node, &$form_state) { global $event; $form = array(); $email_options_array = array(); $data = $node; $submit_button_disabled = TRUE; //$email_options_array = _booking_custom_email_types(); $email_options_array['NULL'] = "---"; //add in the custom email types for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++) { $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['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i, $event->booking_eventname . ' logistics custom ' . $i) . " **Logistics**"; } // Populate some default values if a selection has already been made //watchdog('booking_debug', 'booking_emails_custom_ajax_form state:
@info', array('@info' => print_r( $form_state, true))); if (!isset($form_state['input']['email-type'])) { $subject_value = ""; $body_value = ""; } else { //watchdog('booking_debug', 'booking_emails_custom_ajax_form user has selected email type ' . $form_state['input']['email-type']); $emailtype = $form_state['input']['email-type']; $subject_value = $form_state['input']['booking_email_subjectline_custom']; $body_value = $form_state['input']['booking_email_body_custom']['value']; // only enable the submit button if the email type is not the initial empty one if ($form_state['input']['email-type'] !== 'NULL') { $submit_button_disabled = FALSE; } } // Define the textareas in the form differently if HTML emails are enabled if(variable_get('booking_enable_html_mail', 0) == 1) { $form_type = 'text_format'; $form_format = 'full_html'; } else { $form_type = 'textarea'; $form_format = NULL; } $form['#prefix'] = '
@info', array('@info' => print_r( $text, true))); // TODO : Figure out what this should be if HTML emails are NOT enabled $form['form']['email-definition']['booking_email_body_custom']['value']['#value'] = $text; // TODO : Does changing submit button state here do anything? $form['form']['submit']['#disabled'] = FALSE; } else { $form['form']['email-definition']['booking_email_subjectline_custom']['#value'] = ''; $form['form']['email-definition']['booking_email_body_custom']['value']['#value'] = ''; // TODO : Does changing submit button state here do anything? $form['form']['submit']['#disabled'] = TRUE; } //watchdog('booking_debug', 'booking_emails_custom_ajax_form_callback:
@info', array('@info' => print_r( $form, true))); // Rebuild the form $form_state['rebuild'] = TRUE; return $form['form']; } /** * Process the submission for the custom email definition form */ function booking_emails_custom_ajax_form_submit($form, &$form_state) { global $event; $values = $form_state['input']; $emailtype = $values['email-type']; variable_set('booking_email_subject_' . $emailtype, $values['booking_email_subjectline_custom']); variable_set('booking_email_' . $emailtype, $values['booking_email_body_custom']); $form_state['rebuild'] = TRUE; } /** * Function to allow admin user to define custom emails that can be sent by Bookings module * * @param * @return form render array */ function booking_emails_custom_admin() { global $event; $form = array(); if(variable_get('booking_enable_html_mail', 0) == 1) { $form_type = 'text_format'; $form_format = 'full_html'; } else { $form_type = 'textarea'; $form_format = NULL; } //include the token definitions $form['tokens'] = array( '#theme' => 'token_tree', '#token_types' => array('booking'), ); /*Text for emails*/ $form['custom-emails'] = array( '#type' => 'fieldset', '#title' => 'Custom Email Text Definitions', '#collapsible' => TRUE, '#collapsed' => FALSE, ); //add a bunch of custom emails for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++) { $subject_fieldname = 'booking_email_subject_custom' . $i; $body_fieldname = 'booking_email_custom' . $i; $form['custom-emails'][$subject_fieldname] = array ( '#type' => 'textfield', '#title' => t('Subject line for Custom Email ' . $i), '#size' => 150, '#maxlength' => 300, '#default_value' => variable_get($subject_fieldname,'[booking:eventname]'), ); $form['custom-emails'][$body_fieldname] = array( '#title' => t('Email text for custom email ' . $i), '#description' => t(''), '#default_value' => isset(variable_get($body_fieldname)['value']) ? variable_get($body_fieldname)['value'] : variable_get($body_fieldname, ''), '#type' => $form_type, '#format' => $form_format, ); } //let the builtin hook do all the hard work return system_settings_form($form, FALSE); } /** * Function to allow admin user to define custom logistics emails that can be sent by Bookings module, from the logistics email address * * @param * @return form render array */ function booking_emails_customlogistics_admin() { global $event; $form = array(); if(variable_get('booking_enable_html_mail', 0) == 1) { $form_type = 'text_format'; $form_format = 'full_html'; } else { $form_type = 'textarea'; $form_format = NULL; } //include the token definitions $form['tokens'] = array( '#theme' => 'token_tree', '#token_types' => array('booking'), ); /*Text for logistics emails*/ $form['custom-logistics-emails'] = array( '#type' => 'fieldset', '#title' => 'Custom Logistics Email Text Definitions', '#collapsible' => TRUE, '#collapsed' => FALSE, ); //add a bunch of custom emails //@todo add an admin variable for this for ($i = 1; $i <= 5; $i++) { $subject_fieldname = 'booking_email_subject_customlogistics' . $i; $body_fieldname = 'booking_email_customlogistics' . $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] Logistics'), ); $form['custom-logistics-emails'][$body_fieldname] = array( '#title' => t('Email text for Logistics Custom Email ' . $i), '#description' => t(''), '#default_value' => isset(variable_get($body_fieldname)['value']) ? variable_get($body_fieldname)['value'] : variable_get($body_fieldname, ''), '#type' => $form_type, '#format' => $form_format, ); } //let the builtin hook do all the hard work return system_settings_form($form, FALSE); }