add submit for email ajax form
This commit is contained in:
@@ -248,7 +248,6 @@ function booking_emails_workflow_admin() {
|
|||||||
return system_settings_form($form, FALSE);
|
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
|
* 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) {
|
function booking_emails_custom_ajax_form($node, &$form_state) {
|
||||||
global $event;
|
global $event;
|
||||||
$form = array();
|
$form = array();
|
||||||
|
$email_options_array = array();
|
||||||
$data = $node;
|
$data = $node;
|
||||||
|
|
||||||
//$email_options_array = _booking_custom_email_types();
|
//$email_options_array = _booking_custom_email_types();
|
||||||
|
$email_options_array['NULL'] = "---";
|
||||||
//add in the custom email types
|
//add in the custom email types
|
||||||
for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++) {
|
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);
|
$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_type = 'textarea';
|
||||||
$form_format = NULL;
|
$form_format = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$form_type = 'textarea';
|
|
||||||
//$form_format = NULL;
|
|
||||||
|
|
||||||
$form['email-type'] = array(
|
$form['email-type'] = array(
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
@@ -320,7 +318,7 @@ function booking_emails_custom_ajax_form($node, &$form_state) {
|
|||||||
|
|
||||||
$form['submit'] = array(
|
$form['submit'] = array(
|
||||||
'#type' => 'submit',
|
'#type' => 'submit',
|
||||||
'#value' => t('Submit'),
|
'#value' => t('Save'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return array (
|
return array (
|
||||||
@@ -345,17 +343,30 @@ function booking_emails_custom_ajax_form_callback($form, &$form_state) {
|
|||||||
|
|
||||||
$text = variable_get('booking_email_' . $emailtype, '');
|
$text = variable_get('booking_email_' . $emailtype, '');
|
||||||
$text = isset($text['format']) ? $text['value'] : $text;
|
$text = isset($text['format']) ? $text['value'] : $text;
|
||||||
watchdog('booking_debug', 'custom text: <pre>@info</pre>', array('@info' => print_r( $text, true)));
|
//watchdog('booking_debug', 'custom text: <pre>@info</pre>', 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;
|
$form['form']['email-definition']['booking_email_body_custom']['value']['#value'] = $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdog('booking_debug', 'booking_emails_custom_ajax_form_callback: <pre>@info</pre>', array('@info' => print_r( $form, true)));
|
//watchdog('booking_debug', 'booking_emails_custom_ajax_form_callback: <pre>@info</pre>', array('@info' => print_r( $form, true)));
|
||||||
|
|
||||||
// Rebuild the form
|
// Rebuild the form
|
||||||
$form_state['rebuild'] = TRUE;
|
$form_state['rebuild'] = TRUE;
|
||||||
return $form['form']['email-definition'];
|
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
|
* Function to allow admin user to define custom emails that can be sent by Bookings module
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user