From 7d1494ed8a7fb4756f0aa0b4bbe20cf85bc92603 Mon Sep 17 00:00:00 2001
From: Nathan Coad In your registration details, you indicated that you were married. Please note that both you and your spouse must pay a deposit and book in individually, " .
- "although the total married couple of $!fee only needs to be paid once. Unfortunately the bookings for !event have reached the maximum number of attendees. " .
- "If you wish to reserve your place on the waiting list at number !waitnum, please pay the deposit using this paypal button: If you wish to only pay your deposit for !event at this stage, please click on this paypal button:
",
- array('!event' => $event->booking_eventname, '!waitnum' => $waitinglist_query->num_ppl - variable_get('booking_regn_limit', 350) + 1));
- }
- else
- {
- $output .= t("
",
- array('!event' => $event->booking_eventname));
- }
-
- //Paypal form for paying the deposit only
- $output .= t('
Otherwise, you can submit the full payment of $!price via the paypal button below to complete your booking as a !price_descrip.
", - array('!price' => $person->booking_price, '!price_descrip' => $person->booking_price_descrip)); - $output .= t(''); - } - - //cheque information - $output .= t(""); - $output .= t("
Paypal is the preferred method of payment, but if you absolutely cannot pay via paypal, please send a cheque to the following address. "); - $output .= t("Cheques should be made payable to "Study Week".
"); - $output .= t("!event
6 School Parade
PADSTOW NSW 2211
Australia
Please include with the cheque the name you used when registering (!name), and your registration id (!id). You will not receive an email confirming your place until the cheque is received and processed.
", - array('!name' => $person->booking_lastname . ', ' . $person->booking_firstname, '!id' => $person->nid)); - return $output; -}*/ diff --git a/booking.module b/booking.module index 934a9fa..95f0f04 100644 --- a/booking.module +++ b/booking.module @@ -67,6 +67,7 @@ module_load_include('inc', 'booking', 'booking.studygroup_leaders'); module_load_include('inc', 'booking', 'booking.travel'); // Load the include for managing room bookings and definitions module_load_include('inc', 'booking', 'booking.rooms'); +module_load_include('inc', 'booking', 'booking.test_rooms'); // Load the include for room layout definitions module_load_include('inc', 'booking', 'booking.rooms_admin'); @@ -596,6 +597,15 @@ function booking_menu() { //'type' => MENU_NORMAL_ITEM, ); + $items['admin/booking/rooms/test/%/assign'] = array( + 'title' => 'Assign Rooms', + 'description' => 'Assign attendees to rooms', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('booking_rooms_allocate_test_form', 4), + 'access arguments' => array('edit room allocations'), + //'type' => MENU_NORMAL_ITEM, + ); + $items['admin/booking/rooms/%/view'] = array( 'title' => 'View Allocated Rooms', 'description' => 'Assign attendees to rooms', diff --git a/booking.test_rooms.inc b/booking.test_rooms.inc new file mode 100644 index 0000000..799ac96 --- /dev/null +++ b/booking.test_rooms.inc @@ -0,0 +1,192 @@ + $event->eid)); + //$room_mapping = $room_mapping_query->fetchAll(); + $room_mapping = $room_mapping_query->fetchAllAssoc('booking_nodeid'); + + //query for room definitions + $room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid ORDER BY CAST(booking_room_number as SIGNED INTEGER) ASC", + array(':lid' => $location_id)); + + //query for attendees + $query = db_query("SELECT nid, booking_firstname, booking_lastname, booking_gender, booking_dob, booking_partner_id " . + " FROM {booking_person} " . + " WHERE booking_event_id = :eid and (booking_status=1 or booking_status=5) order by booking_lastname, booking_firstname", + array(':eid' => $event->eid)); + + //make a list of all attendees that are booked in + $attendee_select[] = ''; + + foreach($query as $row) + { + $married = $row->booking_partner_id > 0 ? ' *' : ''; + $age = _booking_get_age_years($row->booking_dob); + $assigned_flag = empty($room_mapping[$row->nid]) ? '' : ' - '; + $attendee_select[$row->nid] = $assigned_flag . $row->booking_lastname . ', ' . $row->booking_firstname . ' ' . ' ['. $age . ' ' . $row->booking_gender . ']' . $married; + + } + + //watchdog('booking', "Loading existing room allocations:\n@info", array('@info' => print_r( $room_mapping, true))); + + //attach the custom css + $form['#attached']['css'] = array( + drupal_get_path('module', 'booking') . '/booking.css', + ); + + //define the header + $header = array ( + 'booking_room_location' => array('data' => t('Room Location'), 'field' => 'booking_room_location_id'), + 'booking_room_number' => array('data' => t('Room Number')), + 'booking_room_singlebed' => array('data' => t('Single Bed')), + 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), + 'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')), + 'booking_room_queenbed_p1' => array('data' => t('Queen Bed Person 1')), + 'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')), + ); + + $default_row = array(); + $default_row['booking_room_location'] = ""; + $default_row['booking_room_number'] = ""; + $default_row['booking_room_singlebed'] = ""; + $default_row['booking_room_doublebed_p1'] = ""; + $default_row['booking_room_doublebed_p2'] = ""; + $default_row['booking_room_queenbed_p1'] = ""; + $default_row['booking_room_queenbed_p2'] = ""; + + foreach ($room_query as $data) + { + //load the existing bed mappings for this room + $existing_beds = array(); + for ($i = 1; $i <= 3; $i++) + { + foreach ($room_mapping as $mapping) + { + //check that the room id in the mapping table matches the room that we're currently adding to the table + //and also the bed type matches the first dimension in the array + if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) + { + $existing_beds[$i][] = $mapping->booking_nodeid; + } + } + } + + //watchdog('booking', "
Existing bed mappings:\n@info", array('@info' => print_r( $existing_beds, true))); + + //create a row that contains just the room location and number + $row = _booking_clone_array($default_row); + $row['booking_room_location'] = _booking_room_location_lookup($data->booking_room_location_id); + $row['booking_room_number'] = $data->booking_room_number; + $row['#attributes'] = array('id' => array("new-group-row")); + $options[$counter++] = $row; + + //create an additional row for each single bed + for ($i = 0; $i < $data->booking_room_singlebeds; $i++) + { + //retrieve the default value if one exists + $default = (!empty($existing_beds[1][$i])) ? $existing_beds[1][$i] : 0; + + $row = _booking_clone_array($default_row); + $row['booking_room_singlebed'] = array('data' => array( + '#type' => 'select', + '#options' => $attendee_select, + '#name' => 'booking_room_singlebed[' . $data->rid . '][' . $i . ']', + '#value' => $default, + )); + $options[$counter++] = $row; + } + + //create an additional row for each double bed + //$j is our counter that increments twice as fast as $i to cater for both beds + $j = 0; + for ($i = 0; $i < $data->booking_room_doublebeds; $i++) + { + $row = _booking_clone_array($default_row); + $row['booking_room_doublebed_p1'] = array('data' => array( + '#type' => 'select', + '#options' => $attendee_select, + '#name' => 'booking_room_doublebed_p1[' . $data->rid . '][' . $i . ']', + '#value' => (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0, + )); + $row['booking_room_doublebed_p2'] = array('data' => array( + '#type' => 'select', + '#options' => $attendee_select, + '#name' => 'booking_room_doublebed_p2[' . $data->rid . '][' . $i . ']', + '#value' => (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0, + )); + $options[$counter++] = $row; + } + + //create an additional row for each queen bed + //$j is our counter that increments twice as fast as $i to cater for both beds + $j = 0; + for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) + { + $row = _booking_clone_array($default_row); + $default = (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0; + + $row['booking_room_queenbed_p1'] = array('data' => array( + '#type' => 'select', + '#options' => $attendee_select, + '#name' => 'booking_room_queenbed_p1[' . $data->rid . '][' . $i . ']', + '#value' => $default, + )); + + //find the default for the second bed + $default = (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0; + + $row['booking_room_queenbed_p2'] = array('data' => array( + '#type' => 'select', + '#options' => $attendee_select, + '#name' => 'booking_room_queenbed_p2[' . $data->rid . '][' . $i . ']', + '#value' => $default, + )); + + //add this row to the table + $options[$counter++] = $row; + } + + } + + $form['table'] = array ( + '#type' => 'tableselect', + '#header' => $header, + '#options' => $options, + '#empty' => t('No rooms found for this room location id.'), + ); + + //so we can access the dropdown elements + $form['booking_room_singlebed'] = array( '#type' => 'value' ); + $form['booking_room_queenbed_p1'] = array( '#type' => 'value' ); + $form['booking_room_queenbed_p2'] = array( '#type' => 'value' ); + $form['booking_room_doublebed_p1'] = array( '#type' => 'value' ); + $form['booking_room_doublebed_p2'] = array( '#type' => 'value' ); + + $form['submit'] = array ( + '#type' => 'submit', + '#value' => t('Submit'), + ); + + return array ( + 'form' => $form, + ); + +}