work on better custom email definition form
This commit is contained in:
@@ -1,5 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Helper function to provide a list of custom email types for editing/sending manually
|
||||
*/
|
||||
function _booking_custom_email_types() {
|
||||
$email_options_array = array();
|
||||
$email_options_array['NULL'] = "---";
|
||||
$email_options_array['registration'] = 'Registration Successful Email';
|
||||
$email_options_array['balance'] = 'Balance Outstanding Email';
|
||||
$email_options_array['complete'] = 'Payment Complete Email';
|
||||
$email_options_array['withdrawal'] = 'Withdrawal Processed Email';
|
||||
$email_options_array['waitinglistpromotion'] = 'Position Available (Balance outstanding)';
|
||||
$email_options_array['waitinglistpromotionfullypaid'] = 'Position Available (Fully Paid)';
|
||||
$email_options_array['missedpayment'] = 'Missed Payment 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
|
||||
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**";
|
||||
}
|
||||
|
||||
return $email_options_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to provide a list of options for the state field of the registration form
|
||||
*/
|
||||
|
@@ -248,6 +248,108 @@ 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
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_emails_custom_ajax_form($node, &$form_state) {
|
||||
global $event;
|
||||
$form = array();
|
||||
$data = $node;
|
||||
|
||||
//$email_options_array = _booking_custom_email_types();
|
||||
//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**";
|
||||
}
|
||||
|
||||
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['email-type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Email Type'),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => 'NULL',
|
||||
'#options' => $email_options_array,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => 'booking_emails_custom_ajax_form_callback',
|
||||
'wrapper' => 'booking_emails_custom_fieldset_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['email-definition'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Email Definition',
|
||||
'#prefix' => '<div id="booking_emails_custom_fieldset_wrapper">',
|
||||
'#suffix' => '</div>'
|
||||
);
|
||||
|
||||
$form['email-definition']['booking_email_subjectline_custom'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for Custom Email'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => isset($form_state['values']['booking_email_subjectline_custom']) ? $form_state['values']['booking_email_subjectline_custom'] : '',
|
||||
);
|
||||
$form['email-definition']['booking_email_body_custom'] = array(
|
||||
'#title' => t('Email text for custom email'),
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset($form_state['values']['booking_email_body_custom']) ? $form_state['values']['booking_email_body_custom'] : '',
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function to display the custom email definition for form booking_emails_custom_ajax_form
|
||||
*/
|
||||
function booking_emails_custom_ajax_form_callback($form, &$form_state) {
|
||||
global $event;
|
||||
$text = "";
|
||||
$data = $form_state['input'];
|
||||
|
||||
//check the selected email type
|
||||
//configure the input text field and textarea based on select field
|
||||
$emailtype = $form_state['input']['email-type'];
|
||||
if (strpos($emailtype, 'custom') !== false) {
|
||||
$subject = variable_get('booking_email_subject_' . $emailtype, '');
|
||||
$form['form']['email-definition']['booking_email_subjectline_custom']['#default_value'] = $subject;
|
||||
|
||||
$text = variable_get('booking_email_' . $emailtype, '');
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
$form['form']['email-definition']['booking_email_body_custom']['#default_value'] = $text;
|
||||
}
|
||||
|
||||
// Rebuild the form
|
||||
$form_state['rebuild'] = TRUE;
|
||||
return $form['form'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to allow admin user to define custom emails that can be sent by Bookings module
|
||||
*
|
||||
|
@@ -206,6 +206,17 @@ function booking_menu() {
|
||||
'weight' => -98,
|
||||
//'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/emails/definitions'] = array(
|
||||
'title' => 'Booking module ajax custom email definitions',
|
||||
'description' => 'Configure custom emails used by the Booking module via AJAX',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_emails_custom_ajax_form'),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'file' => 'booking.emails_admin.inc',
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/emails/custom'] = array(
|
||||
'title' => 'Booking module custom email definitions',
|
||||
'description' => 'Configure custom emails used by the Booking module',
|
||||
@@ -346,7 +357,7 @@ function booking_menu() {
|
||||
//'page arguments' => array('booking_manual_email'),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
);
|
||||
|
||||
$items['admin/booking/manual-payments'] = array(
|
||||
'title' => 'Manual Payment Processing',
|
||||
|
@@ -553,12 +553,12 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
||||
array(':eid' => $event->eid));
|
||||
$session_members = $session_members_query->fetchAll();
|
||||
|
||||
watchdog('booking_debug', 'booking_varietysessions_csv_report session members: <pre>@info</pre>', array('@info' => print_r( $session_members, true)));
|
||||
//watchdog('booking_debug', 'booking_varietysessions_csv_report session members: <pre>@info</pre>', array('@info' => print_r( $session_members, true)));
|
||||
|
||||
//generate the row data
|
||||
foreach ($session_members as $member) {
|
||||
$session_ids = drupal_json_decode($member->booking_variety_ids);
|
||||
watchdog('booking_debug', 'booking_varietysessions_csv_report person session ids: <pre>@info</pre>', array('@info' => print_r( $session_ids, true)));
|
||||
//watchdog('booking_debug', 'booking_varietysessions_csv_report person session ids: <pre>@info</pre>', array('@info' => print_r( $session_ids, true)));
|
||||
|
||||
//get the session id that matches our timeslot
|
||||
$sid = $session_ids[$timeslot_id];
|
||||
|
Reference in New Issue
Block a user