formatting fixes

This commit is contained in:
Nathan Coad
2016-06-03 12:05:12 +10:00
parent ae79dbbc51
commit 9f02b2de6b

View File

@@ -287,6 +287,20 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
$preselection_options['bookedin'] = 'Status of Booked In'; $preselection_options['bookedin'] = 'Status of Booked In';
$preselection_options['test'] = 'Testing'; $preselection_options['test'] = 'Testing';
$header = array(
'booking_nid' => array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
'booking_name' => array('data' => t('Name'), 'field' => 'booking_lastname'),
'booking_gender' => array('data' => t('Gender'), 'field' => 'booking_gender'),
'booking_email' => array('data' => t('Email'), 'field' => 'booking_email'),
'booking_state' => array('data' => t('State'), 'field' => 'booking_state'),
'booking_status' => array('data' => t('Status'), 'field' => 'booking_status'),
'amount_paid' => array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'),
'booking_fully_paid' => array('data' => t('Fully paid?'), 'field' => 'booking_payment_complete'),
'welfare_required' => array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'),
'travel_form' => array('data' => t('Travel Submitted?'), 'field' => 'tid'),
);
//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++)
{ {
@@ -297,6 +311,7 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
{ {
$email_options_array['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i, $event->booking_eventname . ' logistics custom ' . $i); $email_options_array['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i, $event->booking_eventname . ' logistics custom ' . $i);
} }
/*
//add some indication of which people have been pre-selected, if any //add some indication of which people have been pre-selected, if any
if ($input_option == 'unpaid') { if ($input_option == 'unpaid') {
$prefix .= t("<p><b>Pre-selecting people with outstanding payments.</b></p>"); $prefix .= t("<p><b>Pre-selecting people with outstanding payments.</b></p>");
@@ -304,6 +319,7 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
elseif ($input_option == 'bookedin') { elseif ($input_option == 'bookedin') {
$prefix .= t("<p><b>Pre-selecting only people with a status of booked-in.</b></p>"); $prefix .= t("<p><b>Pre-selecting only people with a status of booked-in.</b></p>");
} }
*/
//attach css so we can customise colours for some people //attach css so we can customise colours for some people
$form['#attached']['css'] = array( $form['#attached']['css'] = array(
drupal_get_path('module', 'booking') . '/booking.css', drupal_get_path('module', 'booking') . '/booking.css',
@@ -363,20 +379,7 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
'#value' => t('Send Email'), '#value' => t('Send Email'),
); );
$header = array( //query the database for studygroup info if it is enabled
'booking_nid' => array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
'booking_name' => array('data' => t('Name'), 'field' => 'booking_lastname'),
'booking_gender' => array('data' => t('Gender'), 'field' => 'booking_gender'),
'booking_email' => array('data' => t('Email'), 'field' => 'booking_email'),
'booking_state' => array('data' => t('State'), 'field' => 'booking_state'),
'booking_status' => array('data' => t('Status'), 'field' => 'booking_status'),
'amount_paid' => array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'),
'booking_fully_paid' => array('data' => t('Fully paid?'), 'field' => 'booking_payment_complete'),
'welfare_required' => array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'),
'travel_form' => array('data' => t('Travel Submitted?'), 'field' => 'tid'),
);
if (variable_get('booking_enable_studygroups', 0) == 1) if (variable_get('booking_enable_studygroups', 0) == 1)
{ {
//select entries from the study groups mapping table //select entries from the study groups mapping table
@@ -389,23 +392,24 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
$header['group_roles'] = array('data' => t('Group Role')); $header['group_roles'] = array('data' => t('Group Role'));
} }
//query for attendee data
$query = db_select('booking_person', 'p'); $query = db_select('booking_person', 'p');
$query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id'); $query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id');
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid'); $query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
$query->fields('p') $query->fields('p')
->fields('pr', array('booking_price', 'booking_late_price')) ->fields('pr', array('booking_price', 'booking_late_price'))
->fields('t') ->fields('t')
->condition('p.booking_eventid', $event->eid, '='); ->condition('p.booking_eventid', $event->eid, '=');
//make the result user-sortable
$table_sort = $query->extend('TableSort')->orderbyHeader($header); $table_sort = $query->extend('TableSort')->orderbyHeader($header);
$result = $table_sort->execute(); $result = $table_sort->execute();
foreach($result as $data) //generate the tableselect data
{ foreach($result as $data) {
$group_text = ""; $group_text = "";
$class = $data->booking_welfare_required == 'Y' ? "welfare-row" : "normal-row"; $class = $data->booking_welfare_required == 'Y' ? "welfare-row" : "normal-row";
$options[$data->nid] = array ( $options[$data->nid] = array (
'#attributes' => array('class' => array($class)),
'booking_nid' => l(t('!id', array('!id' => $data->nid)), t('node/!id', array('!id' => $data->nid))), 'booking_nid' => l(t('!id', array('!id' => $data->nid)), t('node/!id', array('!id' => $data->nid))),
'booking_name' => $data->booking_firstname . " " . $data->booking_lastname, 'booking_name' => $data->booking_firstname . " " . $data->booking_lastname,
'booking_gender' => $data->booking_gender == 'M' ? 'Male' : 'Female', 'booking_gender' => $data->booking_gender == 'M' ? 'Male' : 'Female',
@@ -416,10 +420,12 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
'amount_reqd' => $data->booking_total_pay_reqd, 'amount_reqd' => $data->booking_total_pay_reqd,
'booking_fully_paid' => $data->booking_payment_complete == 'Y' ? 'Yes' : 'No', 'booking_fully_paid' => $data->booking_payment_complete == 'Y' ? 'Yes' : 'No',
'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No', 'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No',
'travel_form' => $data->tid > 0 ? 'Yes' : 'No',
'#attributes' => array('class' => array($class)),
); );
//add optional columns if those features are enabled
if (variable_get('booking_enable_travelform', 0) == 1) {
$options[$data->nid]['travel_form'] => $data->tid > 0 ? 'Yes' : 'No';
}
if (variable_get('booking_enable_studygroups', 0) == 1) { if (variable_get('booking_enable_studygroups', 0) == 1) {
foreach ($group_mapping as $group) { foreach ($group_mapping as $group) {
$role = $group->booking_studygroup_role; $role = $group->booking_studygroup_role;
@@ -430,6 +436,7 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
} }
$options[$data->nid]['group_roles'] = $group_text; $options[$data->nid]['group_roles'] = $group_text;
} }
/*
//handle any checkbox pre-selection for this attendee //handle any checkbox pre-selection for this attendee
if ($input_option == 'unpaid') { if ($input_option == 'unpaid') {
$values[$data->nid] = ($data->booking_payment_complete == 'Y' || $data->booking_status != 1) ? FALSE : TRUE; $values[$data->nid] = ($data->booking_payment_complete == 'Y' || $data->booking_status != 1) ? FALSE : TRUE;
@@ -437,6 +444,7 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
elseif ($input_option == 'bookedin') { elseif ($input_option == 'bookedin') {
$values[$data->nid] = $data->booking_status == 1 ? TRUE : FALSE; $values[$data->nid] = $data->booking_status == 1 ? TRUE : FALSE;
} }
*/
} }
$form['table'] = array ( $form['table'] = array (
@@ -451,7 +459,7 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
//watchdog('booking_debug', "<pre>Manual email form default values\n@info</pre>", array('@info' => print_r( $values, true))); //watchdog('booking_debug', "<pre>Manual email form default values\n@info</pre>", array('@info' => print_r( $values, true)));
//watchdog('booking_debug', "<pre>Manual email form table\n@info</pre>", array('@info' => print_r( $form['table'], true))); //watchdog('booking_debug', "<pre>Manual email form table\n@info</pre>", array('@info' => print_r( $form['table'], true)));
$form['submit'] = array ( $form['submit-bottom'] = array (
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Send Email'), '#value' => t('Send Email'),
); );
@@ -482,26 +490,40 @@ function _booking_email_get_default_selection_callback($form, $form_state) {
$selection = $form_state['values']['booking-email-preselection']; $selection = $form_state['values']['booking-email-preselection'];
//load nodes //load nodes
$people = booking_load_query(NULL, TRUE); $people = booking_load_query(NULL, TRUE);
//populate $defaults based on type of selection //populate $defaults based on type of selection
foreach ($people as $person) { foreach ($people as $person) {
if ($selection == 'bookedin' && $person->booking_status == 1) { switch ($selection) {
$defaults[] = $person->nid; case 'bookedin':
} if ($person->booking_status == 1) {
elseif ($selection == 'test' && $person->booking_lastname == 'Coad') { $defaults[] = $person->nid;
$defaults[] = $person->nid; }
} break;
} case 'unpaid':
//set return value via drupal_json_encode($var) if ($person->booking_payment_complete == 'Y' || $person->booking_status != 1) {
$defaults[] = $person->nid;
}
break;
case 'test':
if ($person->booking_lastname == 'Coad') {
$defaults[] = $person->nid;
}
break;
} //end switch
} //loop attendees
//create new hidden form element to return
$replacementform_data['booking-email-default-ids'] = array ( $replacementform_data['booking-email-default-ids'] = array (
'#type' => 'hidden', '#type' => 'hidden',
'#value' => drupal_json_encode($defaults), '#value' => drupal_json_encode($defaults), //encode the data as json so we can process it with jQuery
'#prefix' => '<div id="booking_email_default_ids_wrapper">', '#prefix' => '<div id="booking_email_default_ids_wrapper">',
'#suffix' => '</div>', '#suffix' => '</div>',
'#attributes' => array('id' => 'booking_email_default_ids'), '#attributes' => array('id' => 'booking_email_default_ids'),
); );
$output_html = render($replacementform_data['booking-email-default-ids']); $output_html = render($replacementform_data['booking-email-default-ids']);
watchdog('booking_debug', "<pre>Manual Email ajax html\n@info</pre>", array('@info' => print_r( $output_html, true))); //watchdog('booking_debug', "<pre>Manual Email ajax html\n@info</pre>", array('@info' => print_r( $output_html, true)));
//return a sequence of commands to run
return array( return array(
'#type' => 'ajax', '#type' => 'ajax',
'#commands' => array( '#commands' => array(