Ensure travel form complies with admin options about dietary requirements and room mates
This commit is contained in:
@@ -846,9 +846,13 @@ function _booking_travelform_email_summary($node) {
|
||||
$rows[] = t('Accommodation before Study Week Required: !value', array('!value' => $node->booking_accom_before_reqd == 1 ? 'Yes' : 'No'));
|
||||
$rows[] = t('Accommodation after Study Week Required: !value', array('!value' => $node->booking_accom_after_reqd == 1 ? 'Yes' : 'No'));
|
||||
//fields from booking_person
|
||||
$rows[] = t('Special Dietary Requirements: ' . $node->booking_dietary);
|
||||
$rows[] = t('Special Medical Conditions: ' . $node->booking_medical_conditions);
|
||||
if (variable_get('booking_enable_dietary', 0) == 1)
|
||||
$rows[] = t('Special Dietary Requirements: ' . $node->booking_dietary);
|
||||
if (variable_get('booking_enable_roommate', 0) == 1)
|
||||
$rows[] = t('Special Medical Conditions: ' . $node->booking_medical_conditions);
|
||||
$rows[] = t('Boyfriend/Girlfriend: ' . $bf_gf);
|
||||
$rows[] = t('Requested room mate(s): ' . $node->booking_room_mate1);
|
||||
|
||||
|
||||
foreach ($rows as $key => $value)
|
||||
$rows[$key] = wordwrap($value);
|
||||
|
@@ -32,7 +32,7 @@ function booking_travel_page() {
|
||||
{
|
||||
$tokens = booking_define_personspecific_tokens($person);
|
||||
|
||||
watchdog('booking', 'Checking for existing travel form for: @info', array('@info' => var_export($person, TRUE)));
|
||||
//watchdog('booking', 'Checking for existing travel form for: @info', array('@info' => var_export($person, TRUE)));
|
||||
|
||||
//check for an existing travel form
|
||||
$travelform = db_query("SELECT tid " .
|
||||
@@ -78,27 +78,25 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
||||
$booking_dietary = '';
|
||||
$booking_medical_conditions = '';
|
||||
$booking_bf_gf_nid = '';
|
||||
$booking_roommate = '';
|
||||
|
||||
$person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id, booking_room_mate1 " .
|
||||
"FROM {booking_person} " .
|
||||
"WHERE nid = :nid ",
|
||||
array(':nid' => $nid <> 0 ? $nid : $data->booking_person_nid))
|
||||
->fetchObject();
|
||||
|
||||
if (!empty($node))
|
||||
{
|
||||
$data = $node;
|
||||
//watchdog('booking', 'Travel form loading data from saved node: @info', array('@info' => var_export($node, TRUE)));
|
||||
//check for existing booking_person data to use in the form
|
||||
$person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id " .
|
||||
"FROM {booking_person} " .
|
||||
"WHERE nid = :nid ",
|
||||
array(':nid' => $data->booking_person_nid))
|
||||
->fetchObject();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = $form_state['input'];
|
||||
//check for existing booking_person data to use in the form
|
||||
$person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id " .
|
||||
"FROM {booking_person} " .
|
||||
"WHERE nid = :nid ",
|
||||
array(':nid' => $nid))
|
||||
->fetchObject();
|
||||
//watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE)));
|
||||
}
|
||||
|
||||
@@ -108,6 +106,7 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
||||
$booking_medical_conditions = $person->booking_medical_conditions;
|
||||
//an empty value is zero in this case
|
||||
$booking_bf_gf_nid = $person->booking_bf_gf_nid == 0 ? '' : $person->booking_bf_gf_nid;
|
||||
$booking_roommate = $person->booking_room_mate1;
|
||||
}
|
||||
|
||||
$transport_type_options = array(
|
||||
@@ -254,12 +253,16 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Special Requirements',
|
||||
);
|
||||
$form['requirements']['booking_dietary'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Special dietary requirements?'),
|
||||
'#maxlength' => 180,
|
||||
'#default_value' => !empty($data->booking_dietary) ? $data->booking_dietary : $booking_dietary,
|
||||
);
|
||||
//only show the dietary field if we're allowed to
|
||||
if (variable_get('booking_enable_dietary', 0) == 1)
|
||||
{
|
||||
$form['requirements']['booking_dietary'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Special dietary requirements?'),
|
||||
'#maxlength' => 180,
|
||||
'#default_value' => !empty($data->booking_dietary) ? $data->booking_dietary : $booking_dietary,
|
||||
);
|
||||
}
|
||||
$form['requirements']['booking_medical_conditions'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Please describe any medical condition we need to know about.'),
|
||||
@@ -267,8 +270,18 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0)
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : $booking_medical_conditions,
|
||||
);
|
||||
//only show the room mate field if we're allowed to
|
||||
if (variable_get('booking_enable_roommate', 0) == 1)
|
||||
{
|
||||
$form['requirements']['booking_room_mate1'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('I would like to share a room with'),
|
||||
'#maxlength' => 200,
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : $booking_roommate,
|
||||
);
|
||||
}
|
||||
//only show this field if this person isn't married
|
||||
//TODO: Get their registration ID instead of their name
|
||||
if ((variable_get('booking_enable_combined_pricing', 0) == 1) && $person->booking_partner_id == 0)
|
||||
{
|
||||
$form['requirements']['booking_bf_gf_nid'] = array(
|
||||
@@ -343,7 +356,7 @@ function travel_form_submit($form, &$form_state) {
|
||||
}
|
||||
|
||||
//fetch details about the person
|
||||
$person = db_query("SELECT nid as personid, booking_tempid, booking_firstname, booking_lastname, booking_partner_id " .
|
||||
$person = db_query("SELECT nid as personid, booking_tempid, booking_firstname, booking_lastname, booking_partner_id, booking_dietary, booking_room_mate1 " .
|
||||
"FROM {booking_person} " .
|
||||
"WHERE nid = :nid ",
|
||||
array(':nid' => $values['personid']))
|
||||
@@ -376,10 +389,13 @@ function travel_form_submit($form, &$form_state) {
|
||||
//$node->booking_accom_after_staying_with = $values['booking_accom_after_staying_with'];
|
||||
|
||||
//booking_person related fields
|
||||
$node->booking_dietary = $values['booking_dietary'];
|
||||
$node->booking_medical_conditions = $values['booking_medical_conditions'];
|
||||
$node->booking_bf_gf_nid = empty($values['booking_bf_gf_nid']) ? 0 : $values['booking_bf_gf_nid'];
|
||||
|
||||
//optional fields
|
||||
$node->booking_dietary = variable_get('booking_enable_dietary', 0) == 1 ? $values['booking_dietary'] : $person->booking_dietary;
|
||||
$node->booking_room_mate1 = variable_get('booking_enable_roommate', 0) == 1 ? $values['booking_room_mate1'] : $person->booking_room_mate1;
|
||||
|
||||
//watchdog('booking', "<pre>Travel data to save:\n@info</pre>", array('@info' => print_r( $node, true)));
|
||||
|
||||
//store the node
|
||||
@@ -451,6 +467,7 @@ function travel_insert($node)
|
||||
'booking_dietary' => $node->booking_dietary,
|
||||
'booking_medical_conditions' => $node->booking_medical_conditions,
|
||||
'booking_bf_gf_nid' => $node->booking_bf_gf_nid,
|
||||
'booking_room_mate1' => $node->booking_room_mate1,
|
||||
))
|
||||
->condition('nid', $node->booking_person_nid)
|
||||
->execute();
|
||||
@@ -486,6 +503,7 @@ function travel_update($node)
|
||||
'booking_dietary' => $node->booking_dietary,
|
||||
'booking_medical_conditions' => $node->booking_medical_conditions,
|
||||
'booking_bf_gf_nid' => $node->booking_bf_gf_nid,
|
||||
'booking_room_mate1' => $node->booking_room_mate1,
|
||||
))
|
||||
->condition('nid', $node->booking_person_nid)
|
||||
->execute();
|
||||
@@ -541,7 +559,7 @@ function travel_view($node, $view_mode) {
|
||||
$rows[] = array(t('Special Dietary Requirements:'), $node->booking_dietary);
|
||||
$rows[] = array(t('Special Medical Conditions:'), $node->booking_medical_conditions);
|
||||
$rows[] = array(t('Boyfriend/Girlfriend:'), $bf_gf);
|
||||
|
||||
$rows[] = array(t('Requested Room mate(s):'), $node->booking_room_mate1);
|
||||
$node->content['details'] = array(
|
||||
'#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
|
||||
'#weight' => 1,
|
||||
|
Reference in New Issue
Block a user