diff --git a/booking.rooms.inc b/booking.rooms.inc index fa90195..20df073 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -1022,64 +1022,138 @@ function booking_rooms_allocate_form_submit($form, &$form_state) { } /** - * Function for viewing room report + * Function for generating report of room allocations in a specific location */ function booking_rooms_view_form($node, &$form_state, $location_id) { global $event; + $rows = array(); + $form = array(); //verify that $location_id is a number if (! preg_match('/^[0-9]+$/', $location_id)) { - drupal_set_message("Error: Invalid room location ID '" . $location_id . "' supplied. Unable to allocate rooms.", 'error', FALSE); + drupal_set_message("Error: Invalid room location ID '" . $location_id . "' supplied. Unable to allocate rooms.", + 'error', FALSE); drupal_goto('admin/booking/rooms'); return ""; - } - - $rows = array(); - - $header = array( - 'booking_firstname' => array('data' => t('First Name'), 'field' => 'p.booking_firstname'), - 'booking_lastname' => array('data' => t('Last Name'), 'field' => 'p.booking_lastname', 'sort' => 'asc'), - 'booking_gender' => array('data' => t('Gender'), 'field' => 'p.booking_gender'), - 'booking_age' => array('data' => t('Age'), 'field' => 'p.booking_dob'), - 'booking_married' => array('data' => t('Married?'), 'field' => 'p.booking_married'), - //'booking_roomlocation' => array('data' => t('Room Location'), 'field' => 'r.booking_room_location_id'), - 'booking_room_num' => array('data' => t('Room Number'), 'field' => 'r.booking_room_number'), - 'booking_room_bedtype' => array('data' => t('Bed Type'), 'field' => 'm.booking_room_bedtype'), - 'booking_room_edit' => array('data' => t('Edit')), - ); - - $query = db_select('booking_person', 'p'); - $query->leftJoin('booking_room_mapping', 'm', 'm.booking_nodeid = p.nid'); - $query->leftJoin('booking_room_definition', 'r', 'r.rid = m.booking_roomid'); - $db_and = db_and(); - $db_and->condition('p.booking_event_id', $event->eid, '='); - $db_and->condition('p.booking_status', 1, '='); - $db_and->condition('r.booking_room_location_id', $location_id, '='); - $query->condition($db_and); - $query->fields('p')->fields('m')->fields('r'); - $table_sort = $query->extend('TableSort')->orderbyHeader($header); - $result = $table_sort->execute(); - - foreach($result as $data) - { - $rows[] = array ( - 'data' => array( - $data->booking_firstname, - $data->booking_lastname, - $data->booking_gender == 'M' ? 'Male' : 'Female', - _booking_get_age_years($data->booking_dob), - $data->booking_married == 'Y' ? 'Yes' : 'No', - //_booking_room_location_lookup($data->booking_room_location_id), - $data->booking_room_number, - _booking_room_bedtype_lookup($data->booking_room_bedtype), - l(t('Edit'), t('admin/booking/!id/edit-room', array('!id' => $data->nid))), - ), - ); - } + } $prefix = t("
Room assignment report rows:\n@info", array('@info' => print_r( $rows, true))); $result = array ( + '#attached' => array ( + 'css' => array(drupal_get_path('module', 'booking') . '/booking.css') + ), 'first_para' => array ( '#type' => 'markup', '#markup' => $prefix, @@ -1093,6 +1167,24 @@ function booking_rooms_view_form($node, &$form_state, $location_id) { ) ); - return $result; + return $result; + +} + +/** + * Function for generating a name relating to a node id + * @param $attendees - an associative array containing the possible attendees + * @param $nid - the node id of the person for which to return the formatted string + * @return string containing first name and last name relating to node id + */ +function _booking_rooms_view_formatperson(&$attendees, $nid) { + $output = "Empty"; + + if ($nid > 0 && !empty($attendees[$nid])) + { + $output = $attendees[$nid]->booking_firstname . " " . $attendees[$nid]->booking_lastname; + } + + return $output; } \ No newline at end of file