add email preview
This commit is contained in:
@@ -267,6 +267,22 @@ function booking_manual_email_form($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
/*
|
||||
create hidden form element that we will populate with JSON data via ajax
|
||||
create select element defining the pre-selections available
|
||||
create submit button that calls ajax to update hidden form element, then calls ajax to check the checkboxes based on the hidden form element
|
||||
|
||||
info on turning JSON data back to array
|
||||
http://stackoverflow.com/questions/29076219/javascript-storing-array-of-objects-in-hidden-field
|
||||
|
||||
ajax references:
|
||||
http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
https://www.drupal.org/node/1028410
|
||||
https://www.drupal.org/node/2046693
|
||||
|
||||
jquery to check the checkboxes:
|
||||
http://jsfiddle.net/nanoquantumtech/dnhwz/
|
||||
*/
|
||||
$form = array();
|
||||
$options = array();
|
||||
$preselection_options = array();
|
||||
@@ -335,26 +351,13 @@ function booking_manual_email_form($form, &$form_state)
|
||||
'#required' => TRUE,
|
||||
'#default_value' => 'NULL',
|
||||
'#options' => $email_options_array,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => '_booking_email_get_preview_callback',
|
||||
'wrapper' => 'booking_email_preview_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
//@todo
|
||||
/*
|
||||
create hidden form element that we will populate with JSON data via ajax
|
||||
create select element defining the pre-selections available
|
||||
create submit button that calls ajax to update hidden form element, then calls ajax to check the checkboxes based on the hidden form element
|
||||
|
||||
info on turning JSON data back to array
|
||||
http://stackoverflow.com/questions/29076219/javascript-storing-array-of-objects-in-hidden-field
|
||||
|
||||
ajax references:
|
||||
http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
https://www.drupal.org/node/1028410
|
||||
https://www.drupal.org/node/2046693
|
||||
|
||||
jquery to check the checkboxes:
|
||||
http://jsfiddle.net/nanoquantumtech/dnhwz/
|
||||
*/
|
||||
|
||||
$form['booking-email-default-ids'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => "[]",
|
||||
@@ -375,7 +378,14 @@ function booking_manual_email_form($form, &$form_state)
|
||||
'callback' => '_booking_email_get_default_selection_callback',
|
||||
'wrapper' => 'booking_email_default_ids_wrapper',
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
$form['booking-email-preview'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => "<p>Preview Email</p><pre>Blah</pre>",
|
||||
'#prefix' => '<div id="booking_email_preview_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
@@ -469,6 +479,69 @@ function booking_manual_email_form($form, &$form_state)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update preview of email that will be sent
|
||||
*
|
||||
*/
|
||||
function _booking_email_get_preview_callback($form, $form_state) {
|
||||
global $event;
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><pre>";
|
||||
$markup_post = "</pre></div>";
|
||||
$text = "";
|
||||
$emailtype = $form_state['values']['email-type'];
|
||||
|
||||
switch ($emailtype) {
|
||||
case "registration":
|
||||
$text = variable_get('booking_email_bookedin_text');
|
||||
break;
|
||||
}
|
||||
/*
|
||||
if ($form_state['values']['email-type'] == 'registration') {
|
||||
$message = t('Processing a manual registration email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, false, true);
|
||||
}
|
||||
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));
|
||||
_booking_balance_payment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'complete') {
|
||||
$message = t('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') {
|
||||
$message = t('Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_confirmation_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'withdrawal') {
|
||||
$message = t('Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
_booking_demoted_to_notcoming_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'missedpayment') {
|
||||
$message = t('Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
_booking_missedpayment_email($key);
|
||||
}
|
||||
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');
|
||||
}
|
||||
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));
|
||||
_booking_custom_email($key, $form_state['values']['email-type'], 'contact');
|
||||
}
|
||||
*/
|
||||
|
||||
//generate html that will be used to update div booking_email_preview_wrapper
|
||||
return $markup_pre . $text . $markup_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update hidden form value with default checkbox details
|
||||
*
|
||||
|
Reference in New Issue
Block a user