From 5e8877705484ebe66afe5948344a00eaf0ca4ba6 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sat, 15 Feb 2014 21:27:58 +1100 Subject: [PATCH] Travel form bugfixes --- booking.install | 23 ++++++++++++++++++++++- booking.module | 2 ++ booking.tokens.inc | 8 +++++++- booking.travel.inc | 33 ++++++++++++++++++++------------- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/booking.install b/booking.install index e6fb9c6..3be5cb4 100644 --- a/booking.install +++ b/booking.install @@ -399,7 +399,8 @@ function booking_schema() { //relationships 'booking_married' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE), 'booking_partner_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE), - 'booking_partner_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'), + 'booking_partner_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'), + 'booking_bf_gf' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE), 'booking_room_mate1' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_room_mate2' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), //helping areas @@ -496,6 +497,26 @@ function booking_schema() { ), 'primary key' => array('vid'), ); + + $schema['booking_travel'] = array( + 'fields' => array( + 'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_person_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_transport_type' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE), + 'booking_transport_from_morriset_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_transport_to_morriset_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_flightnum_inbound' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE), + 'booking_flight_datetime_inbound' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + 'booking_flightnum_outbound' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE), + 'booking_flight_datetime_outbound' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), + 'booking_accom_before_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_accom_before_staying_with' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + 'booking_accom_after_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_accom_after_staying_with' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), + ), + 'primary key' => array('tid'), + ); + return $schema; } diff --git a/booking.module b/booking.module index 6bfecac..e7925c8 100644 --- a/booking.module +++ b/booking.module @@ -55,6 +55,8 @@ module_load_include('inc', 'booking', 'booking.import_data'); module_load_include('inc', 'booking', 'booking.variety'); // Load the include for study group configuration module_load_include('inc', 'booking', 'booking.studygroups'); +// Load the include for the travel form +module_load_include('inc', 'booking', 'booking.travel'); function booking_init() { date_default_timezone_set(TIMEZONE); diff --git a/booking.tokens.inc b/booking.tokens.inc index 5a7cb77..ed5e822 100644 --- a/booking.tokens.inc +++ b/booking.tokens.inc @@ -289,11 +289,17 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text '#collapsed' => TRUE, ); $form['travel']['booking_travelform_page'] = array( - '#title' => t('Text to use at the start of the travel form.'), + '#title' => t('Text to use at the start of the travel form for a non-married person.'), '#type' => 'textarea', '#description' => t(''), '#default_value' => variable_get('booking_travelform_page', ''), ); + $form['travel']['booking_travelform_married_page'] = array( + '#title' => t('Text to use at the start of the travel form for a married couple. Only applies if combined pricing is enabled.'), + '#type' => 'textarea', + '#description' => t(''), + '#default_value' => variable_get('booking_travelform_married_page', ''), + ); $form['travel']['booking_travelform_completed_page'] = array( '#title' => t('Text to use on the travel form if the form has already been submitted.'), '#type' => 'textarea', diff --git a/booking.travel.inc b/booking.travel.inc index 9cc5c5d..6e89e38 100644 --- a/booking.travel.inc +++ b/booking.travel.inc @@ -16,11 +16,18 @@ function booking_travel_page() { } //fetch details about the person + /* $person = db_query("SELECT * FROM {booking_person} " . "WHERE booking_tempid = :tempid ", array(':tempid' => arg(1))) ->fetchObject(); - + */ + $person = db_query("SELECT p.*, t.* from {booking_person} p " . + "left outer join {booking_travel} t on p.nid = t.booking_person_nid " . + "where p.booking_event_id = :eid AND p.booking_tempid = :tempid", + array(':tempid' => arg(1), ':eid' => $event->eid)) + ->fetchObject(); + if ($person) { $tokens = booking_define_personspecific_tokens($person); @@ -36,26 +43,26 @@ function booking_travel_page() { if ($travelform) { + /* $output .= t("


Hi !firstname !lastname. Our records indicate you or your spouse have already completed the travel details form for !event. " . "Please contact us if you need change any of your travel details.

", array('!firstname' => $person->booking_firstname, '!lastname' => $person->booking_lastname, '!event' => $event->booking_eventname)); + */ + $output = token_replace(variable_get('booking_travelform_completed_page'), $tokens); $return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output)); } //they haven't submitted a travel form yet else { - $output = token_replace(variable_get('booking_travelform_page'), $tokens); - - - //check for married couple - //if ($person->booking_partner_id > 0) { - // $output .= t("


Hi Mr and Mrs !lastname. Please enter your travel details for !event below.

", - // array('!lastname' => $person->booking_lastname, '!event' => $event->booking_eventname)); - //} - //else { - // $output .= t("


Hi !firstname !lastname. Please enter your travel details for !event below.

", - // array('!firstname' => $person->booking_firstname, '!lastname' => $person->booking_lastname, '!event' => $event->booking_eventname)); - //} + //Output different text if this is for a married couple + if ((variable_get('booking_enable_combined_pricing', 0) == 1) && $person->booking_partner_id > 0) + { + $output = token_replace(variable_get('booking_travelform_married_page'), $tokens); + } + else + { + $output = token_replace(variable_get('booking_travelform_page'), $tokens); + } $return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output)); $return_array[] = array('form' => drupal_get_form('travel_form', true, $person->nid));