Progress on room location definition forms
This commit is contained in:
@@ -1236,6 +1236,7 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
|||||||
{
|
{
|
||||||
$query->leftJoin('booking_room_mapping', 'rm', 'p.nid = rm.booking_nodeid');
|
$query->leftJoin('booking_room_mapping', 'rm', 'p.nid = rm.booking_nodeid');
|
||||||
$query->leftJoin('booking_room_definition', 'r', 'rm.booking_roomid = r.rid');
|
$query->leftJoin('booking_room_definition', 'r', 'rm.booking_roomid = r.rid');
|
||||||
|
$query->leftJoin('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
//add the joins to flatten out study groups into columns
|
//add the joins to flatten out study groups into columns
|
||||||
@@ -1266,7 +1267,8 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
|||||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||||
{
|
{
|
||||||
$query->fields('rm', array('booking_room_bedtype'))
|
$query->fields('rm', array('booking_room_bedtype'))
|
||||||
->fields('r', array('rid', 'booking_room_location_id', 'booking_room_number'));
|
->fields('r', array('rid', 'booking_room_location_id', 'booking_room_number'))
|
||||||
|
->fields('l');
|
||||||
}
|
}
|
||||||
|
|
||||||
//now add the study group fields if applicable
|
//now add the study group fields if applicable
|
||||||
@@ -1294,7 +1296,7 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
|||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
//watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
|
watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1940,10 +1942,11 @@ function booking_view($node, $view_mode) {
|
|||||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||||
{
|
{
|
||||||
$room_heading = t("<h2>Room Allocation</h2><p>!link</p>",
|
$room_heading = t("<h2>Room Allocation</h2><p>!link</p>",
|
||||||
array('!link' => l(t('Edit Room Allocation'), t('admin/booking/!id/edit-room', array('!id' => $node->nid)))
|
array('!link' => l(t('Edit Room Allocation'), t('admin/booking/!id/edit-room', array('!id' => $node->nid)), array('query' => drupal_get_destination()) )
|
||||||
));
|
));
|
||||||
$room_rows = array();
|
$room_rows = array();
|
||||||
$room_rows[] = array(t('Room Location'), _booking_room_location_lookup($node->booking_room_location_id));
|
//$room_rows[] = array(t('Room Location'), _booking_room_location_lookup($node->booking_room_location_id));
|
||||||
|
$room_rows[] = array(t('Room Location'), $node->booking_roomlocation_descrip);
|
||||||
$room_rows[] = array(t('Room Number'), $node->booking_room_number);
|
$room_rows[] = array(t('Room Number'), $node->booking_room_number);
|
||||||
$room_rows[] = array(t('Bed Type'), _booking_room_bedtype_lookup($node->booking_room_bedtype));
|
$room_rows[] = array(t('Bed Type'), _booking_room_bedtype_lookup($node->booking_room_bedtype));
|
||||||
|
|
||||||
|
@@ -66,18 +66,21 @@ function booking_roomallocations_view_summary() {
|
|||||||
$query = db_select('booking_person', 'p');
|
$query = db_select('booking_person', 'p');
|
||||||
$query->leftJoin('booking_room_mapping', 'm', 'm.booking_nodeid = p.nid');
|
$query->leftJoin('booking_room_mapping', 'm', 'm.booking_nodeid = p.nid');
|
||||||
$query->leftJoin('booking_room_definition', 'r', 'r.rid = m.booking_roomid');
|
$query->leftJoin('booking_room_definition', 'r', 'r.rid = m.booking_roomid');
|
||||||
|
$query->leftJoin('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id');
|
||||||
$db_and = db_and();
|
$db_and = db_and();
|
||||||
$db_and->condition('p.booking_event_id', $event->eid, '=');
|
$db_and->condition('p.booking_event_id', $event->eid, '=');
|
||||||
$db_and->condition('p.booking_status', 1, '=');
|
$db_and->condition('p.booking_status', 1, '=');
|
||||||
$query->condition($db_and);
|
$query->condition($db_and);
|
||||||
$query->fields('p')->fields('m')->fields('r');
|
$query->fields('p')->fields('m')->fields('r')->fields('l');
|
||||||
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||||
$result = $table_sort->execute();
|
$result = $table_sort->execute();
|
||||||
|
|
||||||
foreach($result as $data)
|
foreach($result as $data)
|
||||||
{
|
{
|
||||||
$location_link = $data->booking_room_location_id > 0 ? _booking_room_location_lookup($data->booking_room_location_id) .
|
//$location_link = $data->booking_room_location_id > 0 ? _booking_room_location_lookup($data->booking_room_location_id) .
|
||||||
l(t(' (Edit)'), t('admin/booking/rooms/!id/assign', array('!id' => $data->booking_room_location_id))) : '';
|
// l(t(' (Edit)'), t('admin/booking/rooms/!id/assign', array('!id' => $data->booking_room_location_id))) : '';
|
||||||
|
$location_link = $data->booking_room_location_id > 0 ? $data->booking_roomlocation_descrip .
|
||||||
|
l(t(' (Edit)'), t('admin/booking/rooms/!id/assign', array('!id' => $data->booking_room_location_id)), array('query' => drupal_get_destination()) ) : '';
|
||||||
|
|
||||||
$rows[] = array (
|
$rows[] = array (
|
||||||
'data' => array(
|
'data' => array(
|
||||||
@@ -90,7 +93,7 @@ function booking_roomallocations_view_summary() {
|
|||||||
$location_link,
|
$location_link,
|
||||||
$data->booking_room_number,
|
$data->booking_room_number,
|
||||||
_booking_room_bedtype_lookup($data->booking_room_bedtype),
|
_booking_room_bedtype_lookup($data->booking_room_bedtype),
|
||||||
l(t('Change Room'), t('admin/booking/!id/edit-room', array('!id' => $data->nid))),
|
l( t('Change Room'), t('admin/booking/!id/edit-room', array('!id' => $data->nid)), array('query' => drupal_get_destination()) ),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -123,6 +126,8 @@ function booking_room_edit_form($node, &$form_state, $nid) {
|
|||||||
|
|
||||||
$form = array();
|
$form = array();
|
||||||
$room_options = array();
|
$room_options = array();
|
||||||
|
$location_options = array();
|
||||||
|
$location_options[] = "--";
|
||||||
|
|
||||||
//verify that $nid is a number
|
//verify that $nid is a number
|
||||||
if (! preg_match('/^[0-9]+$/', $nid)) {
|
if (! preg_match('/^[0-9]+$/', $nid)) {
|
||||||
@@ -149,6 +154,13 @@ function booking_room_edit_form($node, &$form_state, $nid) {
|
|||||||
//person must exist in database, load all the bits
|
//person must exist in database, load all the bits
|
||||||
$person = node_load($nid);
|
$person = node_load($nid);
|
||||||
|
|
||||||
|
//load the room locations
|
||||||
|
$locations_query = db_query("SELECT * FROM {booking_room_locations} where booking_roomlocation_active='Y'");
|
||||||
|
foreach($locations_query as $row)
|
||||||
|
{
|
||||||
|
$location_options[$row->lid] = $row->booking_roomlocation_descrip;
|
||||||
|
}
|
||||||
|
|
||||||
$prefix = t("<p>Manually assign/update room allocation for !first !last.<br /></p>",
|
$prefix = t("<p>Manually assign/update room allocation for !first !last.<br /></p>",
|
||||||
array('!first' => $person->booking_firstname, '!last' => $person->booking_lastname));
|
array('!first' => $person->booking_firstname, '!last' => $person->booking_lastname));
|
||||||
|
|
||||||
@@ -164,7 +176,7 @@ function booking_room_edit_form($node, &$form_state, $nid) {
|
|||||||
$form['booking_room_location_id'] = array(
|
$form['booking_room_location_id'] = array(
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
'#title' => t('Room Location'),
|
'#title' => t('Room Location'),
|
||||||
'#options' => _booking_room_location_lookup(),
|
'#options' => $location_options,
|
||||||
'#default_value' => $person->booking_room_location_id,
|
'#default_value' => $person->booking_room_location_id,
|
||||||
'#ajax' => array(
|
'#ajax' => array(
|
||||||
'event' => 'change',
|
'event' => 'change',
|
||||||
@@ -244,9 +256,11 @@ function booking_bedtype_ajax_callback($form, $form_state) {
|
|||||||
*/
|
*/
|
||||||
function _booking_get_roomedit_roomnum_options($selected) {
|
function _booking_get_roomedit_roomnum_options($selected) {
|
||||||
$room_options = array();
|
$room_options = array();
|
||||||
|
$room_options[] = "--";
|
||||||
|
|
||||||
$room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid",
|
$room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid",
|
||||||
array(':lid' => $selected));
|
array(':lid' => $selected));
|
||||||
|
|
||||||
foreach($room_query as $room)
|
foreach($room_query as $room)
|
||||||
{
|
{
|
||||||
$room_options[$room->booking_room_number] = $room->booking_room_number;
|
$room_options[$room->booking_room_number] = $room->booking_room_number;
|
||||||
@@ -264,7 +278,7 @@ function _booking_get_roomedit_roomnum_options($selected) {
|
|||||||
*/
|
*/
|
||||||
function _booking_get_roomedit_bedtype_options($location_id, $room_num) {
|
function _booking_get_roomedit_bedtype_options($location_id, $room_num) {
|
||||||
$bed_options = array();
|
$bed_options = array();
|
||||||
$bed_options[] = "";
|
$bed_options[] = "--";
|
||||||
|
|
||||||
$details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num",
|
$details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num",
|
||||||
array(':lid' => $location_id, ':num' => $room_num))->fetchObject();
|
array(':lid' => $location_id, ':num' => $room_num))->fetchObject();
|
||||||
@@ -311,6 +325,14 @@ function booking_room_edit_form_validate($form, &$form_state) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!isset($values['booking_room_location_id']) || !isset($values['booking_room_number']) || !isset($values['booking_room_bedtype']))
|
||||||
|
{
|
||||||
|
form_set_error('form',
|
||||||
|
t('Invalid configuration detected. Please ensure a room location, room number and bed type are all set.')
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//get the specific room definition from the database
|
//get the specific room definition from the database
|
||||||
$details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num",
|
$details = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid AND booking_room_number = :num",
|
||||||
array(':lid' => $values['booking_room_location_id'], ':num' => $values['booking_room_number']))->fetchObject();
|
array(':lid' => $values['booking_room_location_id'], ':num' => $values['booking_room_number']))->fetchObject();
|
||||||
@@ -339,6 +361,7 @@ function booking_room_edit_form_validate($form, &$form_state) {
|
|||||||
function booking_room_edit_form_submit($form, &$form_state) {
|
function booking_room_edit_form_submit($form, &$form_state) {
|
||||||
global $event;
|
global $event;
|
||||||
$values = $form_state['input'];
|
$values = $form_state['input'];
|
||||||
|
$redirect_path = "admin/config/booking/rooms";
|
||||||
|
|
||||||
//check if we should remove the room allocation
|
//check if we should remove the room allocation
|
||||||
if ($form_state['values']['op'] == 'Remove')
|
if ($form_state['values']['op'] == 'Remove')
|
||||||
@@ -355,7 +378,8 @@ function booking_room_edit_form_submit($form, &$form_state) {
|
|||||||
->condition('booking_nodeid', $values['personid'])
|
->condition('booking_nodeid', $values['personid'])
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
return;
|
|
||||||
|
//return;
|
||||||
}
|
}
|
||||||
//otherwise, continue with adding/updating the room allocation
|
//otherwise, continue with adding/updating the room allocation
|
||||||
else
|
else
|
||||||
@@ -410,6 +434,7 @@ function booking_room_edit_form_submit($form, &$form_state) {
|
|||||||
|
|
||||||
} //end operation check
|
} //end operation check
|
||||||
|
|
||||||
|
$form_state['redirect'] = $redirect_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user