From 41f39b6705f30cec8bffaceac24b5b3b76cff579 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 28 May 2014 12:28:23 +1000 Subject: [PATCH] Modifications so unpaid people can move to bottom of waiting list --- booking.constants.inc | 15 +++++++++++---- booking.module | 12 +++++++++--- booking.register.inc | 2 +- booking.reports.inc | 13 ++++++++++++- booking.rooms.inc | 24 ++++++++++++++++++++---- 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/booking.constants.inc b/booking.constants.inc index 81333f9..96273ac 100644 --- a/booking.constants.inc +++ b/booking.constants.inc @@ -21,14 +21,18 @@ function _booking_state_options() { * @param $input integer containing status id * @return string for corresponding booking status */ -function _booking_status_generate($input) +function _booking_status_generate($input = NULL) { $status_options[0] = t('Not Paid'); $status_options[1] = t('Booked In'); $status_options[2] = t('Waiting List'); $status_options[3] = t('No Longer Coming'); + $status_options[4] = t('Missed Payment Deadline'); - return $status_options[$input]; + if ($input != NULL) + return $status_options[$input]; + else + return $status_options; } /** * Helper function to look up booking status id based on status text @@ -37,12 +41,15 @@ function _booking_status_generate($input) */ function _booking_status_lookup($input) { + /* $status_options[0] = t('Not Paid'); $status_options[1] = t('Booked In'); $status_options[2] = t('Waiting List'); $status_options[3] = t('No Longer Coming'); - - return array_search($input, $status_options); + $status_options[4] = t('Missed Payment Deadline'); + */ + + return array_search($input, _booking_status_generate()); } /** diff --git a/booking.module b/booking.module index 61cf793..7f3c203 100644 --- a/booking.module +++ b/booking.module @@ -392,7 +392,7 @@ function booking_menu() { //configure rooms $items['admin/booking/rooms'] = array( - 'title' => 'View Rooms', + 'title' => 'View Room Locations', 'description' => 'View Room Locations', 'page callback' => 'booking_room_view_summary', 'access arguments' => array("view room allocations"), @@ -405,11 +405,17 @@ function booking_menu() { 'description' => 'Assign attendees to rooms', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_rooms_allocate_form', 3), - //'page arguments' => array('booking_rooms_allocate_form'), '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', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('booking_rooms_view_form', 3), + 'access arguments' => array('view room allocations'), + ); //Configure prices $items['admin/config/booking/prices/create'] = array( diff --git a/booking.register.inc b/booking.register.inc index 624fe59..d15ab49 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -151,7 +151,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) { $form['your-details']['booking_status'] = array( '#type' => 'radios', '#title' => t('Registration Status'), - '#options' => $status_options, + '#options' => _booking_status_generate(), '#default_value' => !empty($data->booking_status) ? $data->booking_status : '', ); diff --git a/booking.reports.inc b/booking.reports.inc index 77d511e..71e43a6 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -371,6 +371,7 @@ function booking_waitinglist_page() { $booking_limit = variable_get('booking_regn_limit','350'); $rows = array(); + /* $result = db_query('SELECT DISTINCT nid, booking_firstname, booking_lastname, booking_state, booking_readinggroup, booking_country FROM ( SELECT p.nid, p.booking_firstname, p.booking_lastname, p.booking_state, p.booking_country, p.booking_readinggroup, pay.booking_payment_date @@ -379,7 +380,17 @@ function booking_waitinglist_page() { ) AS booking ORDER BY booking_payment_date', array(':eid' => $event->eid)); - + */ + + $result = db_query('SELECT DISTINCT nid, booking_firstname, booking_lastname, booking_state, booking_readinggroup, booking_country, booking_status + FROM ( + SELECT p.nid, p.booking_firstname, p.booking_lastname, p.booking_state, p.booking_country, p.booking_readinggroup, pay.booking_payment_date, p.booking_status + FROM {booking_person} p, {booking_payment} pay + WHERE booking_event_id = :eid and p.nid = pay.booking_person_nid and ( booking_status = 2 or booking_status = 4) + ) AS booking + ORDER BY booking_status, booking_payment_date', + array(':eid' => $event->eid)); + //watchdog('booking', "Who's coming query: @info", array('@info' => var_export($result, TRUE))); foreach ($result as $person) { diff --git a/booking.rooms.inc b/booking.rooms.inc index 2f93e50..4e2324a 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -312,19 +312,27 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) { $j = 0; for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) { - $row = _booking_clone_array($default_row); + $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' => (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0, + '#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' => (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0, - )); + '#value' => $default, + )); + + //add this row to the table $options[$counter++] = $row; } @@ -450,4 +458,12 @@ function booking_rooms_allocate_form_submit($form, &$form_state) { } //each room } //each bed type +} + +/** + * Function for viewing room report + */ +function booking_rooms_view_form($node, &$form_state, $location_id) { + global $event; + } \ No newline at end of file