start implementing stored waiting list position
This commit is contained in:
@@ -236,6 +236,26 @@ function _booking_get_waitinglist_top()
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to retrieve all the people on the waiting list
|
||||
*/
|
||||
function _booking_get_waitinglist()
|
||||
{
|
||||
global $event;
|
||||
|
||||
// Taken from the Waiting List page, not very optimised
|
||||
$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 p.booking_eventid = :eid and p.nid = pay.booking_person_nid and ( p.booking_status = 2 or p.booking_status = 4)
|
||||
) AS booking
|
||||
ORDER BY booking_status, booking_payment_date',
|
||||
array(':eid' => $event->eid));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to update the status of a registration
|
||||
*/
|
||||
|
@@ -760,6 +760,16 @@ function booking_update_7250() {
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add field to store waiting list position
|
||||
*/
|
||||
function booking_update_7251() {
|
||||
$spec = array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_waitlist_pos', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom cache table
|
||||
*/
|
||||
@@ -852,6 +862,7 @@ function booking_schema() {
|
||||
'booking_gender' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE),
|
||||
'booking_dob' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
|
||||
'booking_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
|
||||
'booking_waitlist_pos' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
|
||||
'booking_committee_member' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
'booking_welfare_required' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
'booking_barcode' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE),
|
||||
|
@@ -612,6 +612,9 @@ function booking_update($node) {
|
||||
else {
|
||||
watchdog('booking', 'Still no room on the booked in list though.');
|
||||
}
|
||||
|
||||
// Update waiting list positions
|
||||
_booking_waitinglist_update_trigger();
|
||||
}
|
||||
//check if someone has moved to booked-in list from waiting-list
|
||||
elseif ($previous_status->booking_status == 2 && $node->booking_status == 1) {
|
||||
@@ -637,6 +640,8 @@ function booking_update($node) {
|
||||
$waitinglist_nid = _booking_get_waitinglist_top();
|
||||
}
|
||||
|
||||
// Update waiting list positions
|
||||
_booking_waitinglist_update_trigger();
|
||||
}
|
||||
//check if someone has been demoted to the "missed payment deadline" status from being booked-in
|
||||
elseif ($previous_status->booking_status == 1 && $node->booking_status == 4) {
|
||||
@@ -783,6 +788,26 @@ function booking_delete($node) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to update the waiting list position for everyone on the waiting list
|
||||
*/
|
||||
function _booking_waitinglist_update_trigger()
|
||||
{
|
||||
global $event;
|
||||
$waiting_list = _booking_get_waitinglist();
|
||||
$counter = 1;
|
||||
|
||||
foreach ($waiting_list as $person) {
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_waitlist_pos' => $counter++,
|
||||
))
|
||||
->condition('nid', $person->nid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function booking_view($node, $view_mode) {
|
||||
global $event;
|
||||
|
Reference in New Issue
Block a user