diff --git a/booking.constants.inc b/booking.constants.inc index d238b58..1f17c0f 100644 --- a/booking.constants.inc +++ b/booking.constants.inc @@ -65,6 +65,48 @@ function _get_tshirt_options() { return $options_array; } +/** + * Helper function to look up description of studygroup role + * @param $input integer containing role id + * @return string for corresponding room location + */ +function _booking_studygroup_role_lookup($input = NULL) +{ + $role = array(); + $role[] = t('None'); + $role[] = t('Leader'); + $role[] = t('Helper'); + $role[] = t('Reserve Leader'); + + if ($input != NULL) + return $role[$input]; + else + return $role; +} + +/** + * Helper function to look up description of room location based on id + * @param $input integer containing room id + * @return string for corresponding room location + */ +function _booking_room_location_lookup($input = NULL) +{ + $location = array(); + $location[] = ''; + $location[] = t('Elpis Israel House'); + $location[] = t('Elpis Israel Ground Floor'); + $location[] = t('Golan'); + $location[] = t('Ramoth'); + $location[] = t('Jerusalem'); + $location[] = t('Bezer'); + $location[] = t('Schechem'); + $location[] = t('Kedesh'); + + if ($input != NULL) + return $location[$input]; + else + return $location; +} /** * Helper function to reliably (without using any external APIs) provide a list of options for the country field used in the registration form diff --git a/booking.helper.inc b/booking.helper.inc index 6b1a1b0..28c2912 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -638,7 +638,7 @@ function _booking_total_due($person) /** * Function to calculate the amount outstanding for a person/married couple * - * @param $nid - the node id relating to the registration node + * @param $person - the object relating to the registration node * @param $amount_paid - if we have previously calculated the amount paid, this can be passed as a value * @param $include_paypal_fees - boolean to indicate whether we want the net amount or the amount owing including paypal fees * @return amount owing as a decimal value diff --git a/booking.install b/booking.install index 02e6c5b..7277be9 100644 --- a/booking.install +++ b/booking.install @@ -306,7 +306,73 @@ function booking_update_7213() { function booking_update_7214() { $spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'); db_add_field('booking_person', 'booking_committee_member', $spec); +} + +/** +* Add table to define reading groups and rooms at rathmines +*/ +function booking_update_7215() { + //This gives a label to each reading group (ie, the colour) + $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'), + ); + + $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_ensuite' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'), + ), + 'primary key' => array('rid'), + ); + + db_create_table('booking_readinggroup_definition', $booking_readinggroup_definition); + db_create_table('booking_room_definition', $booking_room_definition); + $result = db_insert('booking_room_definition') + ->fields(array( + 'booking_room_location_id' => 0, + 'booking_room_number' => 1, + 'booking_room_singlebeds' => 2, + 'booking_room_doublebeds' => 0, + 'booking_room_ensuite' => 'N', + )) + ->execute(); +} + +/** +* Add table for mapping people to rooms and a role field to the studygroup mapping table +*/ +function booking_update_7216() { + $booking_room_mapping = array( + 'fields' => array( + '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), + ), + ); + + db_create_table('booking_room_mapping', $booking_room_mapping); + + //also add a role column to the studygroup mapping table + $spec = array('type' => 'varchar', 'length' => '100', 'not null' => FALSE, 'default' => 0); + db_add_field( 'booking_studygroup_mapping', 'booking_studygroup_role', $spec); +} + +/** +* Add queen bed option +*/ +function booking_update_7217() { + $spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0); + db_add_field('booking_room_definition', 'booking_room_queenbeds', $spec); } /** diff --git a/booking.module b/booking.module index 6a2337b..f4f8213 100644 --- a/booking.module +++ b/booking.module @@ -60,6 +60,8 @@ module_load_include('inc', 'booking', 'booking.variety'); module_load_include('inc', 'booking', 'booking.studygroups'); // Load the include for the travel form module_load_include('inc', 'booking', 'booking.travel'); +// Load the include for managing room bookings and definitions +module_load_include('inc', 'booking', 'booking.rooms'); function booking_init() { date_default_timezone_set(TIMEZONE); @@ -201,6 +203,14 @@ function booking_menu() { 'access arguments' => array('administer site configuration'), //'type' => MENU_LOCAL_TASK, ); + $items['admin/config/booking/rooms'] = array( + 'title' => 'Booking module room definitions', + 'description' => 'Configure room definitions for the Event Booking module', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('booking_rooms_define_form'), + 'access arguments' => array('administer site configuration'), + //'type' => MENU_LOCAL_TASK, + ); //pages for attendees to fill out information $items['booking'] = array( @@ -374,6 +384,17 @@ function booking_menu() { ); } + //configure rooms + $items['admin/booking/rooms/assign'] = array( + 'title' => 'Assign Rooms', + 'description' => 'Assign attendees to rooms', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('booking_rooms_allocate_form'), + 'access arguments' => array('edit bookings'), + 'type' => MENU_NORMAL_ITEM, + ); + + //Configure prices $items['admin/config/booking/prices/create'] = array( 'title' => 'Add New Price Entry', @@ -393,6 +414,7 @@ function booking_menu() { 'type' => MENU_CALLBACK, ); + //Configure events $items['admin/config/booking/events/create'] = array( 'title' => 'Add New Event', 'description' => 'Add event for the Booking module', @@ -412,6 +434,7 @@ function booking_menu() { 'type' => MENU_CALLBACK, ); + //configure variety sessions $items['admin/config/booking/variety/create'] = array( 'title' => 'Add New Variety Session Timeslot', 'description' => 'Add variety session timeslot for the Booking module', diff --git a/booking.register.inc b/booking.register.inc index 6af6d65..3825a88 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -1058,74 +1058,55 @@ function booking_form_submit($form, &$form_state) { function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE) { global $event; + $studygroup_count = variable_get('booking_studygroup_count','0'); $query = db_select('booking_person', 'p'); - //perform an inner join + //add price info $query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid'); + //add travel form info if it exists $query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid'); - //add the fields for study groups + //add the joins to flatten out study groups into columns if (variable_get('booking_enable_studygroups', 0) == 1) { - //work out how many study groups there are - //$studygroups = db_query("SELECT count(*) as numgroups from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1") - // ->fetchObject(); - //$studygroups = db_query("SELECT s.* from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1") - // ->fetchAllAssoc('sid'); - //watchdog('booking', "
Loading node studygroups query output:\n@info", array('@info' => print_r( $studygroups, true))); - - $studygroup_count = variable_get('booking_studygroup_count','0'); - - //for ($i = 1; $i <= STUDYGROUP_COUNT; $i++) for ($i = 1; $i <= $studygroup_count; $i++) { $query->leftJoin('booking_studygroup_mapping', 's' . $i, 'p.nid = s' . $i . '.booking_node_id and s' . $i . '.booking_studygroup_id = ' . $i); } + } - //filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id - if (! is_null($node_ids)) - { - $query->condition('p.nid', $node_ids, 'IN'); - } - else - { - $query->condition('p.booking_event_id', $event->eid, '='); - } + //filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id + if (! is_null($node_ids)) + { + $query->condition('p.nid', $node_ids, 'IN'); + } + else + { + $query->condition('p.booking_event_id', $event->eid, '='); + } - //add the fields we want - $query->fields('p') - ->fields('t') - ->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price')); + //add the database fields we always want to retrieve + $query->fields('p') + ->fields('t') + ->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price')); - //now add the study group fields + //now add the study group fields if applicable + if (variable_get('booking_enable_studygroups', 0) == 1) + { for ($i = 1; $i <= $studygroup_count; $i++) { //$label = "Group_" . $studygroups[$i]->booking_studygroup_descrip; $query->addField('s' . $i, 'booking_session_id', 'session' . $i); + $query->addField('s' . $i, 'booking_studygroup_role', 'session' . $i . '_role'); + $query->addField('s' . $i, 'booking_is_leader', 'session' . $i . '_leader'); $query->addField('s' . $i, 'booking_is_reserveleader', 'session' . $i . '_reserveleader'); $query->addField('s' . $i, 'booking_is_helper', 'session' . $i . '_helper'); + + } } - //not looking after study groups so don't add all the extra fields - else - { - //filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id - if (! is_null($node_ids)) - { - $query->condition('p.nid', $node_ids, 'IN'); - } - else - { - $query->condition('p.booking_event_id', $event->eid, '='); - } - - //add the fields we want - $query->fields('p') - ->fields('t') - ->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price')); - } //get the query result as either an associative array if ($fetchAssoc == TRUE) @@ -1557,13 +1538,13 @@ function booking_view($node, $view_mode) { $rows[] = array(t('Total Amount Due:'), t('!amount_paid', array('!amount_paid' => $node->booking_total_pay_reqd))); $rows[] = array(t('Refund Due:'), t('!amount_due', array('!amount_due' => $node->booking_refund_due))); $rows[] = array(t('Refund Processed:'), t('!ans', array('!ans' => ($node->booking_refund_processed == 'Y' ? 'Yes' : 'No')))); - $rows[] = array(t('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup))); if (variable_get('booking_enable_tshirts', 0) == 1) + { $rows[] = array(t('Hoodie Size:'), $node->booking_shirt_size); - - + } + $rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone))); $rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile))); $rows[] = array(t('Postal Address:'), t('!street