From 0d5245af30e47cdfab68672a7c78cedf63bf89f5 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 16 Nov 2014 19:56:16 +1100 Subject: [PATCH] Finish adding schema updates to initial install function --- booking.admin.inc | 12 ++++++++++-- booking.helper.inc | 6 ++++++ booking.install | 45 +++++++++++++++++++++++++++++++++++++++----- booking.register.inc | 4 +--- 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/booking.admin.inc b/booking.admin.inc index ee7a21e..59053a8 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -178,11 +178,19 @@ function booking_admin() { ); $form['misc']['booking_enable_tshirts'] = array ( '#type' => 'radios', - '#title' => t('Enable t-shirt information?'), - '#description' => t('Select whether to include tshirt sizing in the booking form.'), + '#title' => t('Enable sizing information?'), + '#description' => t('Select whether to include clothe sizing in the booking form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_tshirts', 0), ); + $form['misc']['booking_tshirts_text_definition'] = array ( + '#type' => 'textfield', + '#title' => t('Clothes Sizing Text Definition'), + '#default_value' => variable_get('booking_tshirts_text_definition', 'Preferred t-shirt size'), + '#description' => 'Text to use on registration form to request clothing size (eg t-shirt or hoodie).', + '#size' => 150, + '#maxlength' => 2000, + ); $form['misc']['booking_enable_passport'] = array ( '#type' => 'radios', '#title' => t('Enable passport information?'), diff --git a/booking.helper.inc b/booking.helper.inc index 7825940..6602dac 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -334,6 +334,12 @@ function _booking_max_dob_ts() */ function _booking_avg_age($sum, $count, $reference_ts) { + //handle condition where count is zero + if ($count == 0) + { + return "Zero"; + } + global $event; //calculate the average age timestamp $average = $sum / $count; diff --git a/booking.install b/booking.install index ed4fb72..79e6798 100644 --- a/booking.install +++ b/booking.install @@ -532,6 +532,7 @@ function booking_schema() { 'booking_committee_member' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), 'booking_welfare_required' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), 'booking_barcode' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE), + 'booking_luckynum' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), 'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), 'booking_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), 'booking_gender' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE), @@ -605,6 +606,8 @@ function booking_schema() { 'booking_passport_issue_location' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), 'booking_passport_issue_name' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), //flight info + 'booking_destination_country' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_travel_insurance' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), 'booking_outflight_bookingnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_outflight_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_outflight_origin' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), @@ -612,8 +615,7 @@ function booking_schema() { 'booking_outflight_origin_ts' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'), 'booking_outflight_connecting_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_outflight_destination' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), - 'booking_outflight_destination_ts' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), - + 'booking_outflight_destination_ts' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_rtrnflight_bookingnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_rtrnflight_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_rtrnflight_origin' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), @@ -622,7 +624,7 @@ function booking_schema() { 'booking_rtrnflight_destination' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_rtrnflight_destination_ts' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), - ), + ), 'primary key' => array('nid'), ); $schema['booking_event'] = array( @@ -747,12 +749,45 @@ function booking_schema() { 'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_studygroup_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_session_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', default => 0), - 'booking_is_leader' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), - 'booking_is_helper' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + //'booking_is_leader' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + //'booking_is_helper' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + 'booking_studygroup_role' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE, 'default' => 0), ), 'primary key' => array('sid'), ); + $schema['booking_readinggroup_definition'] = array( + 'fields' => array( + 'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_readinggroup_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_readinggroup_location' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + ), + 'primary key' => array('rid'), + ); + + $schema['booking_room_definition'] = array( + 'fields' => array( + 'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_room_location_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + 'booking_room_number' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_room_singlebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + 'booking_room_doublebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + 'booking_room_queenbeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + 'booking_room_ensuite' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), + ), + 'primary key' => array('rid'), + ); + + $schema['booking_room_mapping'] = array( + 'fields' => array( + 'mid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_roomid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + 'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + 'booking_nodeid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + 'booking_room_bedtype' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), + ), + 'primary key' => array('mid'), + ); return $schema; } diff --git a/booking.register.inc b/booking.register.inc index 929c846..5e93abb 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -208,7 +208,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) { { $form['your-details']['booking_shirt_size'] = array( '#type' => 'select', - '#title' => t('Preferred hoodie size'), + '#title' => t(variable_get('booking_tshirts_text_definition', 'Preferred hoodie size')), '#required' => FALSE, '#default_value' => variable_get('booking_shirt_size', empty($data->booking_shirt_size) ? '' : $data->booking_shirt_size), '#options' => _get_tshirt_options(), @@ -1225,8 +1225,6 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE) global $event; $studygroup_count = variable_get('booking_studygroup_count','0'); - //TODO: only add room info if the feature is enabled - $query = db_select('booking_person', 'p'); //add price info $query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');