diff --git a/booking.emails_admin.inc b/booking.emails_admin.inc index 30415aa..f79be45 100644 --- a/booking.emails_admin.inc +++ b/booking.emails_admin.inc @@ -248,7 +248,6 @@ function booking_emails_workflow_admin() { return system_settings_form($form, FALSE); } -// TODO : Use ajax to select email definition instead of drawing so many WYSIWYG text editors which take ages to load /** * Hook form() to use ajax to allow admin user to define custom emails that can be sent by Bookings module * @@ -258,9 +257,11 @@ function booking_emails_workflow_admin() { function booking_emails_custom_ajax_form($node, &$form_state) { global $event; $form = array(); + $email_options_array = array(); $data = $node; //$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); @@ -279,9 +280,6 @@ function booking_emails_custom_ajax_form($node, &$form_state) { $form_type = 'textarea'; $form_format = NULL; } - - //$form_type = 'textarea'; - //$form_format = NULL; $form['email-type'] = array( '#type' => 'select', @@ -320,7 +318,7 @@ function booking_emails_custom_ajax_form($node, &$form_state) { $form['submit'] = array( '#type' => 'submit', - '#value' => t('Submit'), + '#value' => t('Save'), ); return array ( @@ -345,17 +343,30 @@ function booking_emails_custom_ajax_form_callback($form, &$form_state) { $text = variable_get('booking_email_' . $emailtype, ''); $text = isset($text['format']) ? $text['value'] : $text; - watchdog('booking_debug', 'custom text:
@info
', array('@info' => print_r( $text, true))); + //watchdog('booking_debug', 'custom text:
@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; } - watchdog('booking_debug', 'booking_emails_custom_ajax_form_callback:
@info
', array('@info' => print_r( $form, 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']['email-definition']; } +/** + * 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']); +} + /** * Function to allow admin user to define custom emails that can be sent by Bookings module *