Added beginning code for room allocation, changing studygroup role field
This commit is contained in:
@@ -65,6 +65,48 @@ function _get_tshirt_options() {
|
|||||||
return $options_array;
|
return $options_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to look up description of studygroup role
|
||||||
|
* @param $input integer containing role id
|
||||||
|
* @return string for corresponding room location
|
||||||
|
*/
|
||||||
|
function _booking_studygroup_role_lookup($input = NULL)
|
||||||
|
{
|
||||||
|
$role = array();
|
||||||
|
$role[] = t('None');
|
||||||
|
$role[] = t('Leader');
|
||||||
|
$role[] = t('Helper');
|
||||||
|
$role[] = t('Reserve Leader');
|
||||||
|
|
||||||
|
if ($input != NULL)
|
||||||
|
return $role[$input];
|
||||||
|
else
|
||||||
|
return $role;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to look up description of room location based on id
|
||||||
|
* @param $input integer containing room id
|
||||||
|
* @return string for corresponding room location
|
||||||
|
*/
|
||||||
|
function _booking_room_location_lookup($input = NULL)
|
||||||
|
{
|
||||||
|
$location = array();
|
||||||
|
$location[] = '';
|
||||||
|
$location[] = t('Elpis Israel House');
|
||||||
|
$location[] = t('Elpis Israel Ground Floor');
|
||||||
|
$location[] = t('Golan');
|
||||||
|
$location[] = t('Ramoth');
|
||||||
|
$location[] = t('Jerusalem');
|
||||||
|
$location[] = t('Bezer');
|
||||||
|
$location[] = t('Schechem');
|
||||||
|
$location[] = t('Kedesh');
|
||||||
|
|
||||||
|
if ($input != NULL)
|
||||||
|
return $location[$input];
|
||||||
|
else
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to reliably (without using any external APIs) provide a list of options for the country field used in the registration form
|
* Helper function to reliably (without using any external APIs) provide a list of options for the country field used in the registration form
|
||||||
|
@@ -638,7 +638,7 @@ function _booking_total_due($person)
|
|||||||
/**
|
/**
|
||||||
* Function to calculate the amount outstanding for a person/married couple
|
* Function to calculate the amount outstanding for a person/married couple
|
||||||
*
|
*
|
||||||
* @param $nid - the node id relating to the registration node
|
* @param $person - the object relating to the registration node
|
||||||
* @param $amount_paid - if we have previously calculated the amount paid, this can be passed as a value
|
* @param $amount_paid - if we have previously calculated the amount paid, this can be passed as a value
|
||||||
* @param $include_paypal_fees - boolean to indicate whether we want the net amount or the amount owing including paypal fees
|
* @param $include_paypal_fees - boolean to indicate whether we want the net amount or the amount owing including paypal fees
|
||||||
* @return amount owing as a decimal value
|
* @return amount owing as a decimal value
|
||||||
|
@@ -306,7 +306,73 @@ function booking_update_7213() {
|
|||||||
function booking_update_7214() {
|
function booking_update_7214() {
|
||||||
$spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N');
|
$spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N');
|
||||||
db_add_field('booking_person', 'booking_committee_member', $spec);
|
db_add_field('booking_person', 'booking_committee_member', $spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add table to define reading groups and rooms at rathmines
|
||||||
|
*/
|
||||||
|
function booking_update_7215() {
|
||||||
|
//This gives a label to each reading group (ie, the colour)
|
||||||
|
$booking_readinggroup_definition = array(
|
||||||
|
'fields' => array(
|
||||||
|
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
|
'booking_readinggroup_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||||
|
'booking_readinggroup_location' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||||
|
),
|
||||||
|
'primary key' => array('rid'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$booking_room_definition = array(
|
||||||
|
'fields' => array(
|
||||||
|
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
|
'booking_room_location_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
|
'booking_room_number' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||||
|
'booking_room_singlebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
|
'booking_room_doublebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
|
'booking_room_ensuite' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||||
|
),
|
||||||
|
'primary key' => array('rid'),
|
||||||
|
);
|
||||||
|
|
||||||
|
db_create_table('booking_readinggroup_definition', $booking_readinggroup_definition);
|
||||||
|
db_create_table('booking_room_definition', $booking_room_definition);
|
||||||
|
|
||||||
|
$result = db_insert('booking_room_definition')
|
||||||
|
->fields(array(
|
||||||
|
'booking_room_location_id' => 0,
|
||||||
|
'booking_room_number' => 1,
|
||||||
|
'booking_room_singlebeds' => 2,
|
||||||
|
'booking_room_doublebeds' => 0,
|
||||||
|
'booking_room_ensuite' => 'N',
|
||||||
|
))
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add table for mapping people to rooms and a role field to the studygroup mapping table
|
||||||
|
*/
|
||||||
|
function booking_update_7216() {
|
||||||
|
$booking_room_mapping = array(
|
||||||
|
'fields' => array(
|
||||||
|
'booking_roomid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
|
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
|
'booking_nodeid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
db_create_table('booking_room_mapping', $booking_room_mapping);
|
||||||
|
|
||||||
|
//also add a role column to the studygroup mapping table
|
||||||
|
$spec = array('type' => 'varchar', 'length' => '100', 'not null' => FALSE, 'default' => 0);
|
||||||
|
db_add_field( 'booking_studygroup_mapping', 'booking_studygroup_role', $spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add queen bed option
|
||||||
|
*/
|
||||||
|
function booking_update_7217() {
|
||||||
|
$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0);
|
||||||
|
db_add_field('booking_room_definition', 'booking_room_queenbeds', $spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -60,6 +60,8 @@ module_load_include('inc', 'booking', 'booking.variety');
|
|||||||
module_load_include('inc', 'booking', 'booking.studygroups');
|
module_load_include('inc', 'booking', 'booking.studygroups');
|
||||||
// Load the include for the travel form
|
// Load the include for the travel form
|
||||||
module_load_include('inc', 'booking', 'booking.travel');
|
module_load_include('inc', 'booking', 'booking.travel');
|
||||||
|
// Load the include for managing room bookings and definitions
|
||||||
|
module_load_include('inc', 'booking', 'booking.rooms');
|
||||||
|
|
||||||
function booking_init() {
|
function booking_init() {
|
||||||
date_default_timezone_set(TIMEZONE);
|
date_default_timezone_set(TIMEZONE);
|
||||||
@@ -201,6 +203,14 @@ function booking_menu() {
|
|||||||
'access arguments' => array('administer site configuration'),
|
'access arguments' => array('administer site configuration'),
|
||||||
//'type' => MENU_LOCAL_TASK,
|
//'type' => MENU_LOCAL_TASK,
|
||||||
);
|
);
|
||||||
|
$items['admin/config/booking/rooms'] = array(
|
||||||
|
'title' => 'Booking module room definitions',
|
||||||
|
'description' => 'Configure room definitions for the Event Booking module',
|
||||||
|
'page callback' => 'drupal_get_form',
|
||||||
|
'page arguments' => array('booking_rooms_define_form'),
|
||||||
|
'access arguments' => array('administer site configuration'),
|
||||||
|
//'type' => MENU_LOCAL_TASK,
|
||||||
|
);
|
||||||
|
|
||||||
//pages for attendees to fill out information
|
//pages for attendees to fill out information
|
||||||
$items['booking'] = array(
|
$items['booking'] = array(
|
||||||
@@ -374,6 +384,17 @@ function booking_menu() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//configure rooms
|
||||||
|
$items['admin/booking/rooms/assign'] = array(
|
||||||
|
'title' => 'Assign Rooms',
|
||||||
|
'description' => 'Assign attendees to rooms',
|
||||||
|
'page callback' => 'drupal_get_form',
|
||||||
|
'page arguments' => array('booking_rooms_allocate_form'),
|
||||||
|
'access arguments' => array('edit bookings'),
|
||||||
|
'type' => MENU_NORMAL_ITEM,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//Configure prices
|
//Configure prices
|
||||||
$items['admin/config/booking/prices/create'] = array(
|
$items['admin/config/booking/prices/create'] = array(
|
||||||
'title' => 'Add New Price Entry',
|
'title' => 'Add New Price Entry',
|
||||||
@@ -393,6 +414,7 @@ function booking_menu() {
|
|||||||
'type' => MENU_CALLBACK,
|
'type' => MENU_CALLBACK,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Configure events
|
||||||
$items['admin/config/booking/events/create'] = array(
|
$items['admin/config/booking/events/create'] = array(
|
||||||
'title' => 'Add New Event',
|
'title' => 'Add New Event',
|
||||||
'description' => 'Add event for the Booking module',
|
'description' => 'Add event for the Booking module',
|
||||||
@@ -412,6 +434,7 @@ function booking_menu() {
|
|||||||
'type' => MENU_CALLBACK,
|
'type' => MENU_CALLBACK,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//configure variety sessions
|
||||||
$items['admin/config/booking/variety/create'] = array(
|
$items['admin/config/booking/variety/create'] = array(
|
||||||
'title' => 'Add New Variety Session Timeslot',
|
'title' => 'Add New Variety Session Timeslot',
|
||||||
'description' => 'Add variety session timeslot for the Booking module',
|
'description' => 'Add variety session timeslot for the Booking module',
|
||||||
|
@@ -1058,73 +1058,54 @@ function booking_form_submit($form, &$form_state) {
|
|||||||
function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
||||||
{
|
{
|
||||||
global $event;
|
global $event;
|
||||||
|
$studygroup_count = variable_get('booking_studygroup_count','0');
|
||||||
|
|
||||||
$query = db_select('booking_person', 'p');
|
$query = db_select('booking_person', 'p');
|
||||||
//perform an inner join
|
//add price info
|
||||||
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
|
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
|
||||||
|
//add travel form info if it exists
|
||||||
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
||||||
|
|
||||||
//add the fields for study groups
|
//add the joins to flatten out study groups into columns
|
||||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||||
{
|
{
|
||||||
//work out how many study groups there are
|
|
||||||
//$studygroups = db_query("SELECT count(*) as numgroups from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1")
|
|
||||||
// ->fetchObject();
|
|
||||||
//$studygroups = db_query("SELECT s.* from {booking_studygroup_list} s INNER JOIN {booking_event} e ON s.booking_eventid = e.eid WHERE e.booking_event_active = 1")
|
|
||||||
// ->fetchAllAssoc('sid');
|
|
||||||
//watchdog('booking', "<pre>Loading node studygroups query output:\n@info</pre>", array('@info' => print_r( $studygroups, true)));
|
|
||||||
|
|
||||||
$studygroup_count = variable_get('booking_studygroup_count','0');
|
|
||||||
|
|
||||||
//for ($i = 1; $i <= STUDYGROUP_COUNT; $i++)
|
|
||||||
for ($i = 1; $i <= $studygroup_count; $i++)
|
for ($i = 1; $i <= $studygroup_count; $i++)
|
||||||
{
|
{
|
||||||
$query->leftJoin('booking_studygroup_mapping', 's' . $i,
|
$query->leftJoin('booking_studygroup_mapping', 's' . $i,
|
||||||
'p.nid = s' . $i . '.booking_node_id and s' . $i . '.booking_studygroup_id = ' . $i);
|
'p.nid = s' . $i . '.booking_node_id and s' . $i . '.booking_studygroup_id = ' . $i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
|
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
|
||||||
if (! is_null($node_ids))
|
if (! is_null($node_ids))
|
||||||
{
|
{
|
||||||
$query->condition('p.nid', $node_ids, 'IN');
|
$query->condition('p.nid', $node_ids, 'IN');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$query->condition('p.booking_event_id', $event->eid, '=');
|
$query->condition('p.booking_event_id', $event->eid, '=');
|
||||||
}
|
}
|
||||||
|
|
||||||
//add the fields we want
|
//add the database fields we always want to retrieve
|
||||||
$query->fields('p')
|
$query->fields('p')
|
||||||
->fields('t')
|
->fields('t')
|
||||||
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
|
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
|
||||||
|
|
||||||
//now add the study group fields
|
//now add the study group fields if applicable
|
||||||
|
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||||
|
{
|
||||||
for ($i = 1; $i <= $studygroup_count; $i++)
|
for ($i = 1; $i <= $studygroup_count; $i++)
|
||||||
{
|
{
|
||||||
//$label = "Group_" . $studygroups[$i]->booking_studygroup_descrip;
|
//$label = "Group_" . $studygroups[$i]->booking_studygroup_descrip;
|
||||||
$query->addField('s' . $i, 'booking_session_id', 'session' . $i);
|
$query->addField('s' . $i, 'booking_session_id', 'session' . $i);
|
||||||
|
$query->addField('s' . $i, 'booking_studygroup_role', 'session' . $i . '_role');
|
||||||
|
|
||||||
$query->addField('s' . $i, 'booking_is_leader', 'session' . $i . '_leader');
|
$query->addField('s' . $i, 'booking_is_leader', 'session' . $i . '_leader');
|
||||||
$query->addField('s' . $i, 'booking_is_reserveleader', 'session' . $i . '_reserveleader');
|
$query->addField('s' . $i, 'booking_is_reserveleader', 'session' . $i . '_reserveleader');
|
||||||
$query->addField('s' . $i, 'booking_is_helper', 'session' . $i . '_helper');
|
$query->addField('s' . $i, 'booking_is_helper', 'session' . $i . '_helper');
|
||||||
}
|
|
||||||
}
|
|
||||||
//not looking after study groups so don't add all the extra fields
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
|
|
||||||
if (! is_null($node_ids))
|
|
||||||
{
|
|
||||||
$query->condition('p.nid', $node_ids, 'IN');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query->condition('p.booking_event_id', $event->eid, '=');
|
|
||||||
}
|
|
||||||
|
|
||||||
//add the fields we want
|
|
||||||
$query->fields('p')
|
}
|
||||||
->fields('t')
|
|
||||||
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the query result as either an associative array
|
//get the query result as either an associative array
|
||||||
@@ -1557,12 +1538,12 @@ function booking_view($node, $view_mode) {
|
|||||||
$rows[] = array(t('Total Amount Due:'), t('!amount_paid', array('!amount_paid' => $node->booking_total_pay_reqd)));
|
$rows[] = array(t('Total Amount Due:'), t('!amount_paid', array('!amount_paid' => $node->booking_total_pay_reqd)));
|
||||||
$rows[] = array(t('Refund Due:'), t('!amount_due', array('!amount_due' => $node->booking_refund_due)));
|
$rows[] = array(t('Refund Due:'), t('!amount_due', array('!amount_due' => $node->booking_refund_due)));
|
||||||
$rows[] = array(t('Refund Processed:'), t('!ans', array('!ans' => ($node->booking_refund_processed == 'Y' ? 'Yes' : 'No'))));
|
$rows[] = array(t('Refund Processed:'), t('!ans', array('!ans' => ($node->booking_refund_processed == 'Y' ? 'Yes' : 'No'))));
|
||||||
|
|
||||||
$rows[] = array(t('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup)));
|
$rows[] = array(t('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup)));
|
||||||
|
|
||||||
if (variable_get('booking_enable_tshirts', 0) == 1)
|
if (variable_get('booking_enable_tshirts', 0) == 1)
|
||||||
|
{
|
||||||
$rows[] = array(t('Hoodie Size:'), $node->booking_shirt_size);
|
$rows[] = array(t('Hoodie Size:'), $node->booking_shirt_size);
|
||||||
|
}
|
||||||
|
|
||||||
$rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone)));
|
$rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone)));
|
||||||
$rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile)));
|
$rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile)));
|
||||||
@@ -1574,7 +1555,7 @@ function booking_view($node, $view_mode) {
|
|||||||
$rows[] = array(t('Ecclesia:'), t('!ecclesia', array('!ecclesia' => $node->booking_ecclesia)));
|
$rows[] = array(t('Ecclesia:'), t('!ecclesia', array('!ecclesia' => $node->booking_ecclesia)));
|
||||||
$rows[] = array(t('Baptised:'), t('!ans', array('!ans' => ($node->booking_baptised == 'Y' ? 'Yes' : 'No'))));
|
$rows[] = array(t('Baptised:'), t('!ans', array('!ans' => ($node->booking_baptised == 'Y' ? 'Yes' : 'No'))));
|
||||||
$rows[] = array(t('Married:'), t('!ans', array('!ans' => ($node->booking_married == 'Y' ? 'Yes' : 'No'))));
|
$rows[] = array(t('Married:'), t('!ans', array('!ans' => ($node->booking_married == 'Y' ? 'Yes' : 'No'))));
|
||||||
//$rows[] = array(t("If married, attending partner's name:"), t('!name', array('!name' => $node->booking_partner_name)));
|
|
||||||
$rows[] = array(t('Linked Partner:'), t($partner_name));
|
$rows[] = array(t('Linked Partner:'), t($partner_name));
|
||||||
$rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf));
|
$rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf));
|
||||||
$rows[] = array(t('Emergency Contact Name:'), $node->booking_guardian_name);
|
$rows[] = array(t('Emergency Contact Name:'), $node->booking_guardian_name);
|
||||||
@@ -1673,10 +1654,14 @@ function booking_view($node, $view_mode) {
|
|||||||
|
|
||||||
for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
||||||
{
|
{
|
||||||
$role = "";
|
|
||||||
|
|
||||||
//calculate the session references
|
//calculate the session references
|
||||||
$sessionid = "session" . $i;
|
$sessionid = "session" . $i;
|
||||||
|
$roleid = $sessionid . "_role";
|
||||||
|
/*
|
||||||
|
$role = "";
|
||||||
|
|
||||||
|
|
||||||
$leaderid = $sessionid . "_leader";
|
$leaderid = $sessionid . "_leader";
|
||||||
$helperid = $sessionid . "_helper";
|
$helperid = $sessionid . "_helper";
|
||||||
$reserveleaderid = $sessionid . "_reserveleader";
|
$reserveleaderid = $sessionid . "_reserveleader";
|
||||||
@@ -1687,9 +1672,10 @@ function booking_view($node, $view_mode) {
|
|||||||
$role = "Helper";
|
$role = "Helper";
|
||||||
elseif ($node->$reserveleaderid == 'Y')
|
elseif ($node->$reserveleaderid == 'Y')
|
||||||
$role = "Reserve Leader";
|
$role = "Reserve Leader";
|
||||||
|
*/
|
||||||
|
|
||||||
$group_rows[] = array(t('<b>' . $studygroups[$i]->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
|
$group_rows[] = array(t('<b>' . $studygroups[$i]->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
|
||||||
$group_rows[] = array(t('Role'), $role);
|
$group_rows[] = array(t('Role'), _booking_studygroup_role_lookup($node->$roleid));
|
||||||
}
|
}
|
||||||
|
|
||||||
$node->content['group-heading'] = array(
|
$node->content['group-heading'] = array(
|
||||||
|
@@ -543,7 +543,7 @@ function booking_csv_report() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//handle more exact dates
|
//handle more exact dates
|
||||||
if ($key == 'booking_timestamp') {
|
if ($key == 'booking_timestamp' || $key == 'booking_flight_datetime_inbound' || $key == 'booking_flight_datetime_outbound') {
|
||||||
$output[] = format_date($value, 'custom', 'd/m/Y H:i');
|
$output[] = format_date($value, 'custom', 'd/m/Y H:i');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
292
booking.rooms.inc
Normal file
292
booking.rooms.inc
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Functions to handle room allocation and administration for the booking module
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to define the form for configuring room definitions and also display existing room definitions
|
||||||
|
*/
|
||||||
|
function booking_rooms_define_form() {
|
||||||
|
global $event;
|
||||||
|
$form = array();
|
||||||
|
$bedcount_options = array();
|
||||||
|
|
||||||
|
//create the options array for bed counts
|
||||||
|
for ($i = 0; $i <= 15; $i++)
|
||||||
|
$bedcount_options[$i] = $i;
|
||||||
|
|
||||||
|
//define the form for adding to the room definitions
|
||||||
|
|
||||||
|
$form[] = array (
|
||||||
|
'first_heading' => array (
|
||||||
|
'#type' => 'markup',
|
||||||
|
'#markup' => "<h2>Add Room</h2>",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['booking_room_location_id'] = array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#title' => t('Choose room location'),
|
||||||
|
'#options' => _booking_room_location_lookup(),
|
||||||
|
);
|
||||||
|
$form['booking_room_number'] = array (
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('Specify room number'),
|
||||||
|
'#size' => 5,
|
||||||
|
'#maxlength' => 10,
|
||||||
|
'#default_value' => !empty($data->booking_room_number) ? $data->booking_room_number : '',
|
||||||
|
);
|
||||||
|
$form['booking_room_singlebeds'] = array (
|
||||||
|
'#type' => 'select',
|
||||||
|
'#title' => t('Specify number of single beds'),
|
||||||
|
'#options' => $bedcount_options,
|
||||||
|
'#default_value' => !empty($data->booking_room_singlebeds) ? $data->booking_room_singlebeds : '',
|
||||||
|
);
|
||||||
|
$form['booking_room_doublebeds'] = array (
|
||||||
|
'#type' => 'select',
|
||||||
|
'#title' => t('Specify number of double beds'),
|
||||||
|
'#options' => $bedcount_options,
|
||||||
|
'#default_value' => !empty($data->booking_room_doublebeds) ? $data->booking_room_doublebeds : '',
|
||||||
|
);
|
||||||
|
$form['booking_room_queenbeds'] = array (
|
||||||
|
'#type' => 'select',
|
||||||
|
'#title' => t('Specify number of queen beds'),
|
||||||
|
'#options' => $bedcount_options,
|
||||||
|
'#default_value' => !empty($data->booking_room_queenbeds) ? $data->booking_room_queenbeds : '',
|
||||||
|
);
|
||||||
|
$form['booking_room_ensuite'] = array(
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => t('Tick if this room has an ensuite'),
|
||||||
|
'#default_value' => (!empty($data->booking_room_ensuite) && $data->booking_room_ensuite == 'Y') ? 1 : 0,
|
||||||
|
);
|
||||||
|
$form['submit'] = array
|
||||||
|
(
|
||||||
|
'#type' => 'submit',
|
||||||
|
'#value' => t('Add Room'),
|
||||||
|
);
|
||||||
|
|
||||||
|
//display the existing room definitions
|
||||||
|
$form[] = array (
|
||||||
|
'first_heading' => array (
|
||||||
|
'#type' => 'markup',
|
||||||
|
'#markup' => "<h2>Room Definitions</h2>",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$header = array (
|
||||||
|
'booking_room_location_description' => t('Room Location'),
|
||||||
|
'booking_room_number' => t('Room Number'),
|
||||||
|
'booking_room_singlebeds' => t('Number Single Beds'),
|
||||||
|
'booking_room_doublebeds' => t('Number Double Beds'),
|
||||||
|
'booking_room_queenbeds' => t('Number Queen Beds'),
|
||||||
|
'booking_room_ensuite' => t('Ensuite?'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = db_query("SELECT * from {booking_room_definition}");
|
||||||
|
|
||||||
|
foreach($result as $data)
|
||||||
|
{
|
||||||
|
$options[$data->rid] = array
|
||||||
|
(
|
||||||
|
'booking_room_location_description' => _booking_room_location_lookup($data->booking_room_location_id),
|
||||||
|
'booking_room_number' => $data->booking_room_number,
|
||||||
|
'booking_room_singlebeds' => $data->booking_room_singlebeds,
|
||||||
|
'booking_room_doublebeds' => $data->booking_room_doublebeds,
|
||||||
|
'booking_room_queenbeds' => $data->booking_room_queenbeds,
|
||||||
|
'booking_room_ensuite' => $data->booking_room_ensuite == 'Y' ? 'Yes' : 'No',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form['table'] = array (
|
||||||
|
'#type' => 'tableselect',
|
||||||
|
'#header' => $header,
|
||||||
|
'#options' => $options,
|
||||||
|
'#multiple' => false,
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
$form['Delete'] = array
|
||||||
|
(
|
||||||
|
'#type' => 'submit',
|
||||||
|
'#value' => t('Delete'),
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
return array (
|
||||||
|
'form' => $form,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the form for adding room definitions
|
||||||
|
*/
|
||||||
|
function booking_rooms_define_form_submit($form, &$form_state) {
|
||||||
|
global $event;
|
||||||
|
$values = $form_state['input'];
|
||||||
|
|
||||||
|
if ($form_state['values']['op'] == 'Add Room')
|
||||||
|
{
|
||||||
|
db_insert('booking_room_definition')
|
||||||
|
->fields(array(
|
||||||
|
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||||
|
'booking_room_number' => $values['booking_room_number'],
|
||||||
|
'booking_room_singlebeds' => $values['booking_room_singlebeds'],
|
||||||
|
'booking_room_doublebeds' => $values['booking_room_doublebeds'],
|
||||||
|
'booking_room_queenbeds' => $values['booking_room_queenbeds'],
|
||||||
|
'booking_room_ensuite' => $values['booking_room_ensuite'] == 1 ? 'Y' : 'N',
|
||||||
|
))
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for allocating rooms
|
||||||
|
*/
|
||||||
|
function booking_rooms_allocate_form() {
|
||||||
|
global $event;
|
||||||
|
$form = array();
|
||||||
|
$attendee_select = array();
|
||||||
|
$options = array();
|
||||||
|
$counter = 0;
|
||||||
|
|
||||||
|
//make a list of all attendees
|
||||||
|
$attendee_select[] = '';
|
||||||
|
|
||||||
|
$query = db_query("SELECT nid, booking_firstname, booking_lastname FROM {booking_person} " .
|
||||||
|
"where booking_event_id = :eid and booking_status=1 order by booking_lastname, booking_firstname",
|
||||||
|
array(':eid' => $event->eid));
|
||||||
|
|
||||||
|
foreach($query as $row)
|
||||||
|
$attendee_select[$row->nid] = $row->booking_firstname . ' ' . $row->booking_lastname;
|
||||||
|
|
||||||
|
//query for room definitions
|
||||||
|
$room_query = db_query("SELECT * FROM {booking_room_definition}");
|
||||||
|
|
||||||
|
//attach the custom css
|
||||||
|
$form['#attached']['css'] = array(
|
||||||
|
drupal_get_path('module', 'booking') . '/booking.css',
|
||||||
|
);
|
||||||
|
|
||||||
|
//define the header
|
||||||
|
$header = array (
|
||||||
|
'booking_room_location' => array('data' => t('Room Location'), 'field' => 'booking_room_location_id'),
|
||||||
|
'booking_room_number' => array('data' => t('Room Number')),
|
||||||
|
'booking_room_singlebed' => array('data' => t('Single Bed')),
|
||||||
|
'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')),
|
||||||
|
'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')),
|
||||||
|
'booking_room_queenbed_p1' => array('data' => t('Queen Bed Person 1')),
|
||||||
|
'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($room_query as $data)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
$row = array (
|
||||||
|
'data' => array(
|
||||||
|
_booking_room_location_lookup($data->booking_room_location_id),
|
||||||
|
$data->booking_room_number,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
//create a row that contains just the room location and number
|
||||||
|
$row = array();
|
||||||
|
$row['booking_room_location'] = _booking_room_location_lookup($data->booking_room_location_id);
|
||||||
|
$row['booking_room_number'] = $data->booking_room_number;
|
||||||
|
$row['booking_room_singlebed'] = "";
|
||||||
|
$row['booking_room_doublebed_p1'] = "";
|
||||||
|
$row['booking_room_doublebed_p2'] = "";
|
||||||
|
$row['booking_room_queenbed_p1'] = "";
|
||||||
|
$row['booking_room_queenbed_p2'] = "";
|
||||||
|
$row['#attributes'] = array('id' => array("new-group-row"));
|
||||||
|
|
||||||
|
$options[$counter++] = $row;
|
||||||
|
|
||||||
|
//create an additional row for each single bed
|
||||||
|
for ($i = 1; $i <= $data->booking_room_singlebeds; $i++)
|
||||||
|
{
|
||||||
|
$row = array();
|
||||||
|
$row['booking_room_location'] = "";
|
||||||
|
$row['booking_room_number'] = "";
|
||||||
|
$row['booking_room_singlebed'] = array('data' => array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => $attendee_select,
|
||||||
|
'#name' => 'booking_room_singlebed[' . $data->rid . '][' . $i . ']',
|
||||||
|
));
|
||||||
|
$row['booking_room_doublebed_p1'] = "";
|
||||||
|
$row['booking_room_doublebed_p2'] = "";
|
||||||
|
$row['booking_room_queenbed_p1'] = "";
|
||||||
|
$row['booking_room_queenbed_p2'] = "";
|
||||||
|
$options[$counter++] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
//create an additional row for each double bed
|
||||||
|
for ($i = 1; $i <= $data->booking_room_doublebeds; $i++)
|
||||||
|
{
|
||||||
|
$row = array();
|
||||||
|
$row['booking_room_location'] = "";
|
||||||
|
$row['booking_room_number'] = "";
|
||||||
|
$row['booking_room_singlebed'] = "";
|
||||||
|
$row['booking_room_doublebed_p1'] = array('data' => array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => $attendee_select,
|
||||||
|
'#name' => 'booking_room_doublebed_p1[' . $data->rid . '][' . $i . ']',
|
||||||
|
));
|
||||||
|
$row['booking_room_doublebed_p2'] = array('data' => array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => $attendee_select,
|
||||||
|
'#name' => 'booking_room_doublebed_p2[' . $data->rid . '][' . $i . ']',
|
||||||
|
));
|
||||||
|
$row['booking_room_queenbed_p1'] = "";
|
||||||
|
$row['booking_room_queenbed_p2'] = "";
|
||||||
|
$options[$counter++] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
//create an additional row for each queen bed
|
||||||
|
for ($i = 1; $i <= $data->booking_room_queenbeds; $i++)
|
||||||
|
{
|
||||||
|
$row = array();
|
||||||
|
$row['booking_room_location'] = "";
|
||||||
|
$row['booking_room_number'] = "";
|
||||||
|
$row['booking_room_singlebed'] = "";
|
||||||
|
$row['booking_room_doublebed_p1'] = "";
|
||||||
|
$row['booking_room_doublebed_p2'] = "";
|
||||||
|
$row['booking_room_queenbed_p1'] = array('data' => array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => $attendee_select,
|
||||||
|
'#name' => 'booking_room_queenbed_p1[' . $data->rid . '][' . $i . ']',
|
||||||
|
));
|
||||||
|
$row['booking_room_queenbed_p2'] = array('data' => array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => $attendee_select,
|
||||||
|
'#name' => 'booking_room_queenbed_p2[' . $data->rid . '][' . $i . ']',
|
||||||
|
));
|
||||||
|
$options[$counter++] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$form['table'] = array (
|
||||||
|
'#type' => 'tableselect',
|
||||||
|
'#header' => $header,
|
||||||
|
'#options' => $options,
|
||||||
|
'#empty' => t('No attendees found.'),
|
||||||
|
);
|
||||||
|
|
||||||
|
//so we can access the dropdown elements
|
||||||
|
$form['booking_room_singlebeds'] = array( '#type' => 'value', );
|
||||||
|
$form['booking_room_doublebeds'] = array( '#type' => 'value', );
|
||||||
|
|
||||||
|
$form['submit'] = array (
|
||||||
|
'#type' => 'submit',
|
||||||
|
'#value' => t('Submit'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return array (
|
||||||
|
'form' => $form,
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@@ -1155,6 +1155,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
|||||||
$header = array(
|
$header = array(
|
||||||
'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'),
|
'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'),
|
||||||
'booking_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname'),
|
'booking_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname'),
|
||||||
|
'booking_status' => array('data' => t('Booking Status'), 'field' => 'p.booking_status'),
|
||||||
'booking_is_leader' => array('data' => t('Leader?'), 'field' => 'm.booking_is_leader'),
|
'booking_is_leader' => array('data' => t('Leader?'), 'field' => 'm.booking_is_leader'),
|
||||||
'booking_is_helper' => array('data' => t('Helper?'), 'field' => 'm.booking_is_helper'),
|
'booking_is_helper' => array('data' => t('Helper?'), 'field' => 'm.booking_is_helper'),
|
||||||
'booking_is_reserveleader' => array('data' => t('Reserve Leader?'), 'field' => 'm.booking_is_reserveleader'),
|
'booking_is_reserveleader' => array('data' => t('Reserve Leader?'), 'field' => 'm.booking_is_reserveleader'),
|
||||||
@@ -1212,6 +1213,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
|||||||
'booking_session_id' => $data->booking_session_id,
|
'booking_session_id' => $data->booking_session_id,
|
||||||
'booking_name' => l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
|
'booking_name' => l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
|
||||||
t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
||||||
|
'booking_status' => _booking_status_generate($data->booking_status),
|
||||||
'booking_is_leader' => $data->booking_is_leader == 'Y' ? 'Yes' : 'No',
|
'booking_is_leader' => $data->booking_is_leader == 'Y' ? 'Yes' : 'No',
|
||||||
'booking_is_helper' => $data->booking_is_helper == 'Y' ? 'Yes' : 'No',
|
'booking_is_helper' => $data->booking_is_helper == 'Y' ? 'Yes' : 'No',
|
||||||
'booking_is_reserveleader' => $data->booking_is_reserveleader == 'Y' ? 'Yes' : 'No',
|
'booking_is_reserveleader' => $data->booking_is_reserveleader == 'Y' ? 'Yes' : 'No',
|
||||||
|
Reference in New Issue
Block a user