Code to cleanup room allocations
This commit is contained in:
@@ -210,6 +210,13 @@ function booking_admin() {
|
|||||||
'#default_value' => variable_get('booking_dietary_text_definition', ''),
|
'#default_value' => variable_get('booking_dietary_text_definition', ''),
|
||||||
'#description' => 'Text to use if attendee may not specify dietary requirements (as above).',
|
'#description' => 'Text to use if attendee may not specify dietary requirements (as above).',
|
||||||
);
|
);
|
||||||
|
$form['misc']['booking_enable_roomallocations'] = array (
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#title' => t('Enable room allocations?'),
|
||||||
|
'#description' => t('Select whether to enable the management and allocation of rooms.'),
|
||||||
|
'#options' => array (0 => t('No'), t('Yes')),
|
||||||
|
'#default_value' => variable_get('booking_enable_roomallocations', 0),
|
||||||
|
);
|
||||||
$form['misc']['booking_enable_studygroups'] = array (
|
$form['misc']['booking_enable_studygroups'] = array (
|
||||||
'#type' => 'radios',
|
'#type' => 'radios',
|
||||||
'#title' => t('Enable study group calculations?'),
|
'#title' => t('Enable study group calculations?'),
|
||||||
|
@@ -422,6 +422,42 @@ function _booking_assign_attendee_group($nid, $session_id, $gender, $age, &$atte
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for cleaning up room allocations for people that have withdrawn their registration
|
||||||
|
* @param $nid - the node id for the person
|
||||||
|
* @return nothing
|
||||||
|
*/
|
||||||
|
function _booking_rooms_cleanup($nid)
|
||||||
|
{
|
||||||
|
global $event;
|
||||||
|
|
||||||
|
|
||||||
|
//first of all make sure we need to do anything
|
||||||
|
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||||
|
{
|
||||||
|
//should only be one room allocation per person, so no need to loop over the results
|
||||||
|
$room_mapping = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid AND booking_nodeid = :nid",
|
||||||
|
array(':eid' => $event->eid, ':nid' => $nid))
|
||||||
|
->fetchObject();
|
||||||
|
|
||||||
|
if ($room_mapping)
|
||||||
|
{
|
||||||
|
$message = t("Removing id !nid from room id !room.",
|
||||||
|
array('!nid' => $nid, '!room' => $room_mapping->booking_roomid)
|
||||||
|
);
|
||||||
|
watchdog('booking', $message);
|
||||||
|
drupal_set_message($message, 'status', FALSE);
|
||||||
|
|
||||||
|
db_delete('booking_room_mapping')
|
||||||
|
->condition('booking_eventid', $event->eid)
|
||||||
|
->condition('booking_nodeid', $nid)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
|
||||||
|
} //for each room
|
||||||
|
} //end check for room allocations enabled
|
||||||
|
} //end function
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for cleaning up study groups for people that have withdrawn their registration
|
* Function for cleaning up study groups for people that have withdrawn their registration
|
||||||
* @param $nid - the node id for the person who has withdrawn their registration
|
* @param $nid - the node id for the person who has withdrawn their registration
|
||||||
@@ -472,10 +508,9 @@ function _booking_studygroups_cleanup($nid)
|
|||||||
->condition('booking_node_id', $nid)
|
->condition('booking_node_id', $nid)
|
||||||
->condition('booking_studygroup_id', $group->booking_studygroup_id)
|
->condition('booking_studygroup_id', $group->booking_studygroup_id)
|
||||||
->execute();
|
->execute();
|
||||||
}
|
} //for each group
|
||||||
}
|
} //end check for study groups enabled
|
||||||
|
} //end function
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for calculating statistics of attendees
|
* Function for calculating statistics of attendees
|
||||||
|
@@ -1379,6 +1379,9 @@ function _booking_update($node) {
|
|||||||
//Remove from any study groups
|
//Remove from any study groups
|
||||||
_booking_studygroups_cleanup($node->nid);
|
_booking_studygroups_cleanup($node->nid);
|
||||||
|
|
||||||
|
//Remove from any rooms allocated
|
||||||
|
_booking_rooms_cleanup($node->nid);
|
||||||
|
|
||||||
//check if there is room on the booked-in list
|
//check if there is room on the booked-in list
|
||||||
if (_booking_check_bookings_full() == False)
|
if (_booking_check_bookings_full() == False)
|
||||||
{
|
{
|
||||||
|
@@ -194,18 +194,24 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//make a list of all attendees
|
//query for existing room allocations
|
||||||
$attendee_select[] = '';
|
$room_mapping_query = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
|
||||||
|
//$room_mapping = $room_mapping_query->fetchAll();
|
||||||
|
$room_mapping = $room_mapping_query->fetchAllAssoc('booking_nodeid');
|
||||||
|
|
||||||
$query = db_query("SELECT nid, booking_firstname, booking_lastname, booking_gender, booking_dob, booking_partner_id FROM {booking_person} " .
|
$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 order by booking_lastname, booking_firstname",
|
"where booking_event_id = :eid and booking_status=1 order by booking_lastname, booking_firstname",
|
||||||
array(':eid' => $event->eid));
|
array(':eid' => $event->eid));
|
||||||
|
|
||||||
|
//make a list of all attendees that are booked in
|
||||||
|
$attendee_select[] = '';
|
||||||
|
|
||||||
foreach($query as $row)
|
foreach($query as $row)
|
||||||
{
|
{
|
||||||
$married = $row->booking_partner_id > 0 ? ' *' : '';
|
$married = $row->booking_partner_id > 0 ? ' *' : '';
|
||||||
$age = _booking_get_age_years($row->booking_dob);
|
$age = _booking_get_age_years($row->booking_dob);
|
||||||
$attendee_select[$row->nid] = $row->booking_firstname . ' ' . $row->booking_lastname . ' ['. $age . ' ' . $row->booking_gender . ']' . $married;
|
$assigned_flag = empty($room_mapping[$row->nid]) ? '' : ' - ';
|
||||||
|
$attendee_select[$row->nid] = $assigned_flag . $row->booking_firstname . ' ' . $row->booking_lastname . ' ['. $age . ' ' . $row->booking_gender . ']' . $married;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,11 +219,9 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
|
|||||||
$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' => $location_id));
|
array(':lid' => $location_id));
|
||||||
|
|
||||||
//query for existing room allocations
|
|
||||||
$room_mapping_query = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
|
|
||||||
$room_mapping = $room_mapping_query->fetchAll();
|
|
||||||
|
|
||||||
//watchdog('booking', "<pre>Loading existing room allocations:\n@info</pre>", array('@info' => print_r( $room_mapping, true)));
|
watchdog('booking', "<pre>Loading existing room allocations:\n@info</pre>", array('@info' => print_r( $room_mapping, true)));
|
||||||
|
|
||||||
//attach the custom css
|
//attach the custom css
|
||||||
$form['#attached']['css'] = array(
|
$form['#attached']['css'] = array(
|
||||||
|
Reference in New Issue
Block a user