Merge branch 'master' of gitlab.coadcorp.com:drupal/booking

This commit is contained in:
Nathan Coad
2016-07-21 07:41:34 +10:00
15 changed files with 441 additions and 277 deletions

View File

@@ -4,8 +4,7 @@
* The administration menu implementations for the booking module configuration pages * The administration menu implementations for the booking module configuration pages
*/ */
function booking_admin() function booking_admin() {
{
$form = array(); $form = array();
//regenerate all our menu hooks when loading this form //regenerate all our menu hooks when loading this form
@@ -239,7 +238,13 @@ function booking_admin()
'#options' => array(0 => t('No'), t('Yes')), '#options' => array(0 => t('No'), t('Yes')),
'#default_value' => variable_get('booking_friendly_csv_groupnames', 0), '#default_value' => variable_get('booking_friendly_csv_groupnames', 0),
); );
$form['features']['booking_studygroup_csv_ages'] = array(
'#type' => 'radios',
'#title' => t('Include ages in study group CSV export?'),
'#description' => t('Select whether to inclde ages for attendees when exporting study groups to CSV.'),
'#options' => array(0 => t('No'), t('Yes')),
'#default_value' => variable_get('booking_studygroup_csv_ages', 0),
);
$form['misc'] = array( $form['misc'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => 'Configuration Options' '#title' => 'Configuration Options'
@@ -564,7 +569,7 @@ $form['management']['booking_import_include_fields_dynamic'] = array(
//return system_settings_form($form); //return system_settings_form($form);
//make sure we update our custom sql view every time we change something on the admin page //make sure we update our custom sql view every time we change something on the admin page
$form = system_settings_form($form); $form = system_settings_form($form);
$form['#submit'][] = '_booking_node_create_mysqlview'; //$form['#submit'][] = '_booking_node_create_mysqlview';
return $form; return $form;
} }

View File

@@ -108,18 +108,20 @@ function _get_tshirt_options() {
* @param $input integer containing role id * @param $input integer containing role id
* @return string for corresponding role * @return string for corresponding role
*/ */
function _booking_studygroup_role_lookup($input = NULL) function _booking_studygroup_role_lookup($input = NULL) {
{
$role = array(); $role = array();
$role[] = t('No Role'); $role[] = t('No Role');
$role[] = t('Leader'); $role[] = t('Leader');
$role[] = t('Helper'); $role[] = t('Helper');
$role[] = t('Reserve Leader'); $role[] = t('Reserve Leader');
$role[] = t('Reserve Helper');
if ($input != NULL)
if ($input != NULL) {
return $role[$input]; return $role[$input];
else }
else {
return $role; return $role;
}
} }
/** /**

View File

@@ -1,15 +1,32 @@
#leader-row {background: #6495ED;} #leader-row {background: #6495ED;}
#helper-row {background: #9dd781;} #helper-row {background: #9dd781;}
#reserveleader-row {background: #d4dc5c;} #reserveleader-row {background: #d4dc5c;}
#new-group-row {border-top: thick double #ff0000;} #reservehelper-row {background: #d4dc5c;}
#leader-new-group-row {background: #6495ED; border-top: thick double #ff0000;} /*
#helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;} tr.leader-row.odd {background: #6495ED;}
#reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;} tr.leader-row.even {background: #6495ED;}
tr.helper-row.odd {background: #9dd781;}
tr.helper-row.even {background: #9dd781;}
tr.reserveleader-row.odd {background: #d4dc5c;}
tr.reserveleader-row.even {background: #d4dc5c;}
tr.reservehelper-row.odd {background: #d4dc5c;}
tr.reservehelper-row.even {background: #d4dc5c;}
*/
#new-group-row {border-top: thick double black;}
#leader-new-group-row {background: #6495ED; border-top: thick double black;}
#helper-new-group-row {background: #9dd781; border-top: thick double black;}
#reserveleader-new-group-row {background: #d4dc5c; border-top: thick double black;}
#reservehelper-new-group-row {background: #d4dc5c; border-top: thick double black;}
/* test for email page*/ /* test for email page*/
/* tr.normal-row.odd {} */ /* tr.normal-row.odd {} */
/* tr.normal-row.even {} */ /* tr.normal-row.even {} */
tr.welfare-row.odd {background: #c3e06c;} tr.welfare-row.odd {background: #c3e06c;}
tr.welfare-row.even {background: #c3e06c;} tr.welfare-row.even {background: #c3e06c;}
tr.flying-row.odd {background: #c3e06c;}
tr.flying-row.even {background: #e5f2c0;}
tr.accomm-row.odd {background: #ffb380;}
tr.accomm-row.even {background: #ffb380;}
div#booking_email_preselection_suffix_wrapper { div#booking_email_preselection_suffix_wrapper {
margin-bottom: 10px; margin-bottom: 10px;
} }

View File

@@ -1538,58 +1538,35 @@ function _booking_leader_helper_email_summary($node) {
$found = FALSE; $found = FALSE;
//display study session data if enabled //display study session data if enabled
if (variable_get('booking_enable_studygroups', 0) == 1) if (variable_get('booking_enable_studygroups', 0) == 1) {
{
//look up the titles of the study groups //look up the titles of the study groups
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid", $studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
array(':eid' => $event->eid)); array(':eid' => $event->eid));
$studygroups = $studygroups_query->fetchAllAssoc('sid'); $studygroups = $studygroups_query->fetchAllAssoc('sid');
//for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++) foreach ($studygroups as $studygroup) {
//for ($i = 1; $i <= count($studygroups); $i++)
foreach ($studygroups as $studygroup)
{
//don't print info about the readings groups //don't print info about the readings groups
//if ($i == variable_get('booking_readinggroup_id','7')) if ($studygroup->booking_is_readinggroup == 'Y') {
// continue;
//if ($studygroups[$i]->booking_is_readinggroup == 'Y')
// continue;
if ($studygroup->booking_is_readinggroup == 'Y')
continue; continue;
}
//calculate the session references //calculate the session references
//$sessionid = "session" . $i;
$sessionid = "session" . $studygroup->sid; $sessionid = "session" . $studygroup->sid;
$roleid = $sessionid . "_role"; $roleid = $sessionid . "_role";
$otherperson_name = "TBA"; $otherperson_name = "TBA";
$otherperson_email = ""; $otherperson_email = "";
$otherperson_phone = ""; $otherperson_phone = "";
//check that this study group session has been defined for this attendee and that they //check that this study group session has been defined for this attendee and that they have a role to perform
if (!empty($node->$sessionid) && $node->$roleid > 0) if (!empty($node->$sessionid) && $node->$roleid > 0) {
{
/*
//make sure we only add this prefix text once, as soon as we've found a matching role
if ($found == FALSE)
{
$found = TRUE;
$rows[] = t("You have been assigned to perform the following roles for study groups:");
}
*/
//TODO: use a function for this.
//if they're a leader or reserver leader, then the matching person is the helper //if they're a leader or reserver leader, then the matching person is the helper
if ($node->$roleid == 1 || $node->$roleid == 3) if ($node->$roleid == 1 || $node->$roleid == 3) {
{
$role = "Leader"; $role = "Leader";
$otherrole = "Helper"; $otherrole = "Helper";
$otherrole_id = 2; $otherrole_id = 2;
} }
//otherwise the matching person is the leader //otherwise the matching person is the leader
else else {
{
$role = "Helper"; $role = "Helper";
$otherrole = "Leader"; $otherrole = "Leader";
$otherrole_id = 1; $otherrole_id = 1;
@@ -1606,26 +1583,26 @@ function _booking_leader_helper_email_summary($node) {
//watchdog('booking', "<pre>Other person for studygroup !group and role !role result:\n@info</pre>", //watchdog('booking', "<pre>Other person for studygroup !group and role !role result:\n@info</pre>",
// array('!group' => $studygroup->sid, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true))); // array('!group' => $studygroup->sid, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true)));
foreach ($otherperson as $other) //create the text for the token
{ foreach ($otherperson as $other) {
$otherperson_name = $other->booking_firstname . ' ' . $other->booking_lastname; $otherperson_name = $other->booking_firstname . ' ' . $other->booking_lastname;
$otherperson_email = $other->booking_email; $otherperson_email = $other->booking_email;
$otherperson_phone = $other->booking_mobile; $otherperson_phone = $other->booking_mobile;
} }
$rows[] = t('!role for !descrip (section !id). Your !otherrole is !other. You can contact them on !phone or !email.', $rows[] = t('!role for !descrip. Your !otherrole is !other. You can contact them on !phone or !email.',
array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip, array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip,
'!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email, '!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
)); ));
} }
} }
} }
foreach ($rows as $key => $value) //format the output to be used in an email
foreach ($rows as $key => $value) {
$rows[$key] = wordwrap($value); $rows[$key] = wordwrap($value);
}
return implode("\n", $rows); return implode("\n", $rows);
} }
@@ -1657,6 +1634,43 @@ function _booking_room_email_summary($node) {
return implode("\n", $rows); return implode("\n", $rows);
} }
/**
* Helper function to create the mean, median, mode or average of an array
* @see http://www.phpsnips.com/45/Mean,-Median,-Mode,-Range-Of-An-Array
*/
function _booking_mmmr($array, $output = 'mean'){
if(!is_array($array)) {
return FALSE;
}
else {
switch($output){
case 'mean':
$count = count($array);
$sum = array_sum($array);
$total = $sum / $count;
break;
case 'median':
rsort($array);
$middle = round(count($array) / 2);
$total = $array[$middle-1];
break;
case 'mode':
$v = array_count_values($array);
arsort($v);
foreach($v as $k => $v){$total = $k; break;}
break;
case 'range':
sort($array);
$sml = $array[0];
rsort($array);
$lrg = $array[0];
$total = $lrg - $sml;
break;
}
return $total;
}
}
/** /**
* @brief Generates a Universally Unique IDentifier, version 4. * @brief Generates a Universally Unique IDentifier, version 4.
* *

View File

@@ -585,6 +585,26 @@ function booking_update_7237() {
_booking_node_create_mysqlview(); _booking_node_create_mysqlview();
} }
/**
* Add description field to room definitions
*/
function booking_update_7238() {
$spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE);
db_add_field('booking_room_definition', 'booking_room_description', $spec);
//update the view to match the new table definition
_booking_node_create_mysqlview();
}
/**
* Change room number field in room definitions to integer
*/
function booking_update_7239() {
$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0);
db_change_field('booking_room_definition', 'booking_room_number', 'booking_room_number', $spec);
//update the view to match the new table definition
_booking_node_create_mysqlview();
}
/** /**
* Implementation of hook_install(). * Implementation of hook_install().
*/ */
@@ -916,11 +936,12 @@ function booking_schema() {
'fields' => array( 'fields' => array(
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), '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_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_number' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
'booking_room_singlebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), '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_doublebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
'booking_room_queenbeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0), 'booking_room_queenbeds' => 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'), 'booking_room_ensuite' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
'booking_room_description' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE),
), ),
'primary key' => array('rid'), 'primary key' => array('rid'),
); );

View File

@@ -324,6 +324,14 @@ function booking_menu() {
'access arguments' => array('access reports'), 'access arguments' => array('access reports'),
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
); );
$items['admin/booking/travel'] = array(
'title' => 'Booking Travel Summary',
'description' => "List people's travel details",
'page callback' => 'booking_report_travel',
'access arguments' => array('access reports'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/booking/manual-email'] = array( $items['admin/booking/manual-email'] = array(
'title' => 'Manually Email People', 'title' => 'Manually Email People',
@@ -432,11 +440,10 @@ function booking_menu() {
} }
//configure study groups //configure study groups
if (variable_get('booking_enable_studygroups', 0) == 1) if (variable_get('booking_enable_studygroups', 0) == 1) {
{
//the config pages for study groups //the config pages for study groups
$items['admin/config/booking/studygroups'] = array( $items['admin/config/booking/studygroups'] = array(
'title' => 'Booking Module Study Group Configuration', 'title' => 'Booking module Study Group configuration',
'description' => 'Define and configure Study Groups for the Booking module', 'description' => 'Define and configure Study Groups for the Booking module',
'page callback' => 'booking_studygroups_admin', 'page callback' => 'booking_studygroups_admin',
'access arguments' => array('administer site configuration'), 'access arguments' => array('administer site configuration'),
@@ -575,7 +582,7 @@ function booking_menu() {
//config pages //config pages
$items['admin/config/booking/rooms'] = array( $items['admin/config/booking/rooms'] = array(
'title' => 'Booking module room definitions', 'title' => 'Booking module room definitions',
'description' => 'View and Configure room definitions for the Event Booking module', 'description' => 'View and configure Room Definitions for the Booking module',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('booking_rooms_view_definitions'), 'page arguments' => array('booking_rooms_view_definitions'),
'access arguments' => array('administer site configuration'), 'access arguments' => array('administer site configuration'),

View File

@@ -762,7 +762,7 @@ function booking_view($node, $view_mode) {
} }
$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('Node ID to keep separate:'), $node->booking_keepseparate_id); $rows[] = array(t('Node ID to keep separate:'), $node->booking_keepseparate_id == 0 ? 'N/A' : $node->booking_keepseparate_id);
$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)));
$rows[] = array(t('Postal Address:'), t('!street<br />!suburb !state !code<br />!country', $rows[] = array(t('Postal Address:'), t('!street<br />!suburb !state !code<br />!country',

View File

@@ -279,7 +279,8 @@ function booking_report_summary() {
)); ));
$output .= t("<h3>Ages</h3>"); $output .= t("<h3>Ages</h3>");
$output .= t("<p>The combined average age at the start of the week will be !average.<br />The male average age will be !maleaverage.<br />The female average age will be !femaleaverage.</p>", $output .= t("<p>The combined average age at the start of the week will be !average.<br />The male average age will be !maleaverage.<br />The female average age will be !femaleaverage.</p>",
array('!average' => _booking_avg_age($dob_total, $male_count + $female_count, $event->booking_event_start), '!maleaverage' => _booking_avg_age($male_dob_total, $male_count, $event->booking_event_start), array('!average' => _booking_avg_age($dob_total, $male_count + $female_count, $event->booking_event_start),
'!maleaverage' => _booking_avg_age($male_dob_total, $male_count, $event->booking_event_start),
'!femaleaverage' => _booking_avg_age($female_dob_total, $female_count, $event->booking_event_start) '!femaleaverage' => _booking_avg_age($female_dob_total, $female_count, $event->booking_event_start)
)); ));
$output .= t("<h3>Finances</h3>"); $output .= t("<h3>Finances</h3>");
@@ -427,6 +428,107 @@ function booking_report_flight_details() {
return $result; return $result;
} }
/**
* List everyone's travel info
*/
function booking_report_travel() {
global $event;
//$form = array();
$prefix = t("<h2>Travel Details</h2>");
//define sorting information with the header
//as per http://www.drup-all.com/blog/table-sort-pagination-drupal-7
$header = array();
$header[] = array('data' => t('Name'), 'field' => 'booking_lastname');
//$header[] = array('data' => t('Edit'), 'field' => 'nid', 'sort' => 'asc');
$header[] = array('data' => t('State'), 'field' => 'booking_state');
$header[] = array('data' => t('Transport Type'), 'field' => 'booking_transport_type');
$header[] = array('data' => t('Catching train from airport?'), 'field' => 'booking_transport_from_morriset_reqd');
$header[] = array('data' => t('Inbound Flight'), 'field' => 'booking_flightnum_inbound');
$header[] = array('data' => t('Inbound Time'), 'field' => 'booking_flight_datetime_inbound');
$header[] = array('data' => t('Outbound Flight'), 'field' => 'booking_flightnum_outbound');
$header[] = array('data' => t('Outbound Time'), 'field' => 'booking_flight_datetime_outbound');
$header[] = array('data' => t('Accommodation Before?'), 'field' => 'booking_accom_before_reqd');
$header[] = array('data' => t('Accommodation After?'), 'field' => 'booking_accom_after_reqd');
//get travel info from database
$query = db_select('booking_person', 'p');
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
//include people either booked in or on the waiting list or hosts, that belong to the current event id
$db_or = db_or();
$db_or->condition('p.booking_status', 1, '=');
$db_or->condition('p.booking_status', 2, '=');
$db_or->condition('p.booking_status', 5, '=');
$db_and = db_and()->condition('p.booking_eventid', $event->eid, '=')->condition($db_or);
$query->condition($db_and);
$query->fields('p')->fields('t');
//allow user to sort columns
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
$result = $table_sort->execute();
foreach ($result as $person) {
$this_row = array();
//define the row for this person
//$this_row[] = $travel_link = l(t('Travel'), t('node/!id', array('!id' => $person->tid)));
//$this_row[] = l(t('Edit !id', array('!id' => $person->nid)), t('node/!id/edit', array('!id' => $person->nid)));
$this_row[] = l(t('!first !last', array('!first' => ucwords($person->booking_firstname), '!last' => ucwords($person->booking_lastname))),
t('node/!id', array('!id' => $person->tid))
);
$this_row[] = t('!state', array('!state' => $person->booking_state));
//$this_row[] = _booking_status_generate($person->booking_status);
$class = $person->booking_transport_type == 'Flying' ? "flying-row" : "normal-row";
//calculate the travel link
if ($person->tid > 0) {
//$travel_link = l(t('Travel'), t('node/!id/edit', array('!id' => $person->tid)));
$this_row[] = t('!transport', array('!transport' => $person->booking_transport_type));
$this_row[] = t('!train', array('!train' => $person->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No'));
$this_row[] = t('!inflightnum', array('!inflightnum' => $person->booking_flightnum_inbound));
$this_row[] = t('!inflighttime', array('!inflighttime' =>
$person->booking_flight_datetime_inbound == 0 ? '' : format_date($person->booking_flight_datetime_inbound, 'custom', 'd/m/Y H:i')));
$this_row[] = t('!outflightnum', array('!outflightnum' => $person->booking_flightnum_outbound));
$this_row[] = t('!outflighttime', array('!outflighttime' =>
$person->booking_flight_datetime_outbound == 0 ? '' : format_date($person->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i')));
$this_row[] = t('!beforeaccom', array('!beforeaccom' => $person->booking_accom_before_reqd == 1 ? 'Yes' : 'No'));
$this_row[] = t('!afteraccom', array('!afteraccom' => $person->booking_accom_after_reqd == 1 ? 'Yes' : 'No'));
//mark people requiring accommodation in a different colour so they stand out more
if ($person->booking_accom_before_reqd == 1 || $person->booking_accom_after_reqd == 1) {
$class = "accomm-row";
}
}
else {
$this_row[] = "N/A";
//put in empty fields to fill up the table columns
for ($i = 0; $i < 7; $i++) {
$this_row[] = "";
}
}
$rows[] = array('data' => $this_row, 'class' => array($class));
}
$result = array (
'#attached' => array (
'css' => array(drupal_get_path('module', 'booking') . '/booking.css')
),
'first_para' => array (
'#type' => 'markup',
'#markup' => $prefix,
),
'table' => array (
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array('id' => 'sort-table'),
//'#sticky' => FALSE,
)
);
return $result;
}
function booking_coming_page() { function booking_coming_page() {
global $event; global $event;
@@ -437,21 +539,17 @@ function booking_coming_page() {
$rows = array(); $rows = array();
//work out whether to include the team colour in this page //work out whether to include the team colour in this page
if (variable_get('booking_publish_readinggroups', 0) == 1) if (variable_get('booking_publish_readinggroups', 0) == 1) {
{
$header = array('Name', 'Team Colour', 'State'); $header = array('Name', 'Team Colour', 'State');
} }
else else {
{
$header = array('Name', 'State'); $header = array('Name', 'State');
} }
//if configuration is set to show on lists even when no payment has been made, then include booking status of 0 (unpaid) or 1 (booked in) //if configuration is set to show on lists even when no payment has been made, then include booking status of 0 (unpaid) or 1 (booked in)
//also ensure any committee members always show //also ensure any committee members always show
if (variable_get('booking_auto_show_on_lists', 1) == 1) if (variable_get('booking_auto_show_on_lists', 1) == 1) {
{
$or = db_or()->condition('p.booking_status', 0)->condition('p.booking_status', 1)>condition('p.booking_committee_member', 'Y'); $or = db_or()->condition('p.booking_status', 0)->condition('p.booking_status', 1)>condition('p.booking_committee_member', 'Y');
$result = db_select('booking_person', 'p') $result = db_select('booking_person', 'p')
->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country')) ->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country'))
->condition($or) ->condition($or)
@@ -461,13 +559,10 @@ function booking_coming_page() {
->orderBy('booking_lastname') ->orderBy('booking_lastname')
->orderBy('booking_firstname') ->orderBy('booking_firstname')
->execute(); ->execute();
} }
else else {
{
//payment must be made before someone will show up as booked in, but also include any committee member that might not have paid //payment must be made before someone will show up as booked in, but also include any committee member that might not have paid
$or = db_or()->condition('p.booking_status', 1)->condition('p.booking_committee_member', 'Y'); $or = db_or()->condition('p.booking_status', 1)->condition('p.booking_committee_member', 'Y');
$result = db_select('booking_person', 'p') $result = db_select('booking_person', 'p')
->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country')) ->fields('p', array('booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country'))
->condition($or) ->condition($or)
@@ -479,13 +574,11 @@ function booking_coming_page() {
->execute(); ->execute();
} }
foreach ($result as $person) foreach ($result as $person) {
{
$state = $person->booking_country === variable_get('booking_default_country') ? $person->booking_state : $person->booking_country; $state = $person->booking_country === variable_get('booking_default_country') ? $person->booking_state : $person->booking_country;
//if we're allowed to publish reading groups, specify them in the array element //if we're allowed to publish reading groups, specify them in the array element
if (variable_get('booking_publish_readinggroups', 0) == 1) if (variable_get('booking_publish_readinggroups', 0) == 1) {
{
$rows[] = array( $rows[] = array(
t('!first !last', array('!first' => ucwords($person->booking_firstname), t('!first !last', array('!first' => ucwords($person->booking_firstname),
'!last' => ucwords($person->booking_lastname))), '!last' => ucwords($person->booking_lastname))),
@@ -494,8 +587,7 @@ function booking_coming_page() {
); );
} }
//don't publish reading group information //don't publish reading group information
else else {
{
$rows[] = array( $rows[] = array(
t('!first !last', array('!first' => ucwords($person->booking_firstname), t('!first !last', array('!first' => ucwords($person->booking_firstname),
'!last' => ucwords($person->booking_lastname))), '!last' => ucwords($person->booking_lastname))),
@@ -508,15 +600,12 @@ function booking_coming_page() {
//output the results //output the results
//check there were some bookings //check there were some bookings
if (count($rows) > 0) if (count($rows) > 0) {
{ if (count($rows) >= $booking_limit) {
if (count($rows) >= $booking_limit)
{
//there is a waiting list //there is a waiting list
$output .= token_replace(variable_get('booking_whoscoming_pre_waitlist_text'), booking_define_tokens()); $output .= token_replace(variable_get('booking_whoscoming_pre_waitlist_text'), booking_define_tokens());
} }
else else {
{
//there's no waiting list //there's no waiting list
$output .= token_replace(variable_get('booking_whoscoming_pre_text'), booking_define_tokens()); $output .= token_replace(variable_get('booking_whoscoming_pre_text'), booking_define_tokens());
} }
@@ -524,8 +613,7 @@ function booking_coming_page() {
//theme the table of registrations //theme the table of registrations
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
} }
else else {
{
//no bookings //no bookings
$output .= token_replace(variable_get('booking_whoscoming_pre_noregistrations_text'), booking_define_tokens()); $output .= token_replace(variable_get('booking_whoscoming_pre_noregistrations_text'), booking_define_tokens());
} }

View File

@@ -419,18 +419,18 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
drupal_goto('admin/booking/rooms'); drupal_goto('admin/booking/rooms');
return ""; return "";
} }
//@todo reduce the number of queries by using some joins
$location_description = db_query("SELECT booking_roomlocation_descrip FROM {booking_room_locations} where lid = :id", $location_description = db_query("SELECT booking_roomlocation_descrip FROM {booking_room_locations} where lid = :id",
array(':id' => $location_id)) array(':id' => $location_id))
->fetchObject(); ->fetchObject();
//use the query result to include a human friendly group name
//$prefix = t("<h2>Room Allocations for !room</h2>", array('!room' => _booking_room_location_lookup($location_id))); $prefix = t("<h2>Room Allocations for !room</h2>", array('!room' => $location_description->booking_roomlocation_descrip));
$prefix = t("<h2>Room Allocations for !room</h2>", array('!room' => $location_description->booking_roomlocation_descrip));
//query for room definitions //query for room definitions
$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 ORDER BY booking_room_number",
array(':lid' => $location_id)); array(':lid' => $location_id));
//query for existing room allocations //query for existing room allocations
$room_mapping_query = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid", $room_mapping_query = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid",
array(':eid' => $event->eid)); array(':eid' => $event->eid));
@@ -444,110 +444,98 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
array(':eid' => $event->eid))->fetchAllAssoc('nid'); array(':eid' => $event->eid))->fetchAllAssoc('nid');
//define the header //define the header
$header = array ( $header = array(
'booking_room_number' => array('data' => t('Room Number')), 'booking_room_number' => array('data' => t('Room Number')),
'booking_room_description' => array('data' => t('Room Label')),
'booking_room_ensuite' => array('data' => t('Ensuite?')),
'booking_room_singlebed' => array('data' => t('Single Bed')), 'booking_room_singlebed' => array('data' => t('Single Bed')),
'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')),
'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')), '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_p1' => array('data' => t('Queen Bed Person 1')),
'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')), 'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')),
); );
//define the default fields in a table row
$default_row = array();
$default_row['booking_room_number'] = "";
$default_row['booking_room_description'] = "";
$default_row['booking_room_ensuite'] = "";
$default_row['booking_room_singlebed'] = "";
$default_row['booking_room_doublebed_p1'] = "";
$default_row['booking_room_doublebed_p2'] = "";
$default_row['booking_room_queenbed_p1'] = "";
$default_row['booking_room_queenbed_p2'] = "";
foreach ($room_query as $data) foreach ($room_query as $data) {
{ //create a row that contains just the room location and number and the custom css id for a separating line between the rooms
$new_row = _booking_clone_array($default_row);
$new_row['booking_room_number'] = $data->booking_room_number;
$new_row['booking_room_description'] = $data->booking_room_description;
$new_row['booking_room_ensuite'] = $data->booking_room_ensuite == 'Y' ? "Yes" : "No";
$rows[] = array(
'data' => $new_row,
'id' => array("new-group-row"),
);
//load the existing bed mappings for this room //load the existing bed mappings for this room
$existing_beds = array(); $existing_beds = array();
for ($i = 1; $i <= 3; $i++) for ($i = 1; $i <= 3; $i++) {
{ foreach ($room_mapping as $mapping) {
foreach ($room_mapping as $mapping)
{
//check that the room id in the mapping table matches the room that we're currently adding to the table //check that the room id in the mapping table matches the room that we're currently adding to the table
//and also the bed type matches the first dimension in the array //and also the bed type matches the first dimension in the array
if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) {
{
$existing_beds[$i][] = $mapping->booking_nodeid; $existing_beds[$i][] = $mapping->booking_nodeid;
} }
} }
} } //end creating existing room mappings for this room
//create a row that contains just the room location and number
$rows[] = array (
'data' => array(
$data->booking_room_number,
"",
"",
"",
"",
"",
),
'id' => array("new-group-row"),
);
//create an additional row for each single bed //create an additional row for each single bed
for ($i = 0; $i < $data->booking_room_singlebeds; $i++) for ($i = 0; $i < $data->booking_room_singlebeds; $i++) {
{
//retrieve the default value if one exists //retrieve the default value if one exists
$nid = (!empty($existing_beds[1][$i])) ? $existing_beds[1][$i] : 0; $nid = (!empty($existing_beds[1][$i])) ? $existing_beds[1][$i] : 0;
$new_row = _booking_clone_array($default_row);
$rows[] = array ( $new_row['booking_room_singlebed'] = _booking_rooms_view_formatperson($attendees, $nid);
'data' => array( $rows[] = array(
"", 'data' => $new_row,
_booking_rooms_view_formatperson($attendees, $nid), );
"",
"",
"",
"",
),
);
} }
//create an additional row for each double bed //create an additional row for each double bed
//$j is our counter that increments twice as fast as $i to cater for both beds //$j is our counter that increments twice as fast as $i to cater for both beds
$j = 0; $j = 0;
for ($i = 0; $i < $data->booking_room_doublebeds; $i++) for ($i = 0; $i < $data->booking_room_doublebeds; $i++) {
{ $new_row = _booking_clone_array($default_row);
$rows[] = array ( $new_row['booking_room_doublebed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0);
'data' => array( $new_row['booking_room_doublebed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0);
"", $rows[] = array(
"", 'data' => $new_row,
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0), );
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0),
"",
"",
),
);
} }
//create an additional row for each queen bed //create an additional row for each queen bed
//$j is our counter that increments twice as fast as $i to cater for both beds //$j is our counter that increments twice as fast as $i to cater for both beds
$j = 0; $j = 0;
for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) {
{ $new_row = _booking_clone_array($default_row);
$rows[] = array ( $new_row['booking_room_queenbed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0);
'data' => array( $new_row['booking_room_queenbed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0);
"", $rows[] = array(
"", 'data' => $new_row,
"",
"",
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0),
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0),
),
); );
} }
} //end room iteration loop
}
//watchdog('booking', "<pre>Room assignment report rows:\n@info</pre>", array('@info' => print_r( $rows, true))); //watchdog('booking', "<pre>Room assignment report rows:\n@info</pre>", array('@info' => print_r( $rows, true)));
$result = array ( $result = array(
'#attached' => array ( '#attached' => array(
'css' => array(drupal_get_path('module', 'booking') . '/booking.css') 'css' => array(drupal_get_path('module', 'booking') . '/booking.css')
), ),
'first_para' => array ( 'first_para' => array(
'#type' => 'markup', '#type' => 'markup',
'#markup' => $prefix, '#markup' => $prefix,
), ),
'table' => array ( 'table' => array(
'#theme' => 'table', '#theme' => 'table',
'#header' => $header, '#header' => $header,
'#rows' => $rows, '#rows' => $rows,
@@ -570,8 +558,7 @@ function _booking_rooms_view_formatperson(&$attendees, $nid) {
$output = "Empty"; $output = "Empty";
if ($nid > 0 && !empty($attendees[$nid])) if ($nid > 0 && !empty($attendees[$nid])) {
{
$output = $attendees[$nid]->booking_firstname . " " . $attendees[$nid]->booking_lastname; $output = $attendees[$nid]->booking_firstname . " " . $attendees[$nid]->booking_lastname;
} }

View File

@@ -225,18 +225,20 @@ function booking_rooms_view_definitions() {
$definition_query->join('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id'); $definition_query->join('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id');
$definition_query->condition('l.booking_roomlocation_active', 'Y', '=') $definition_query->condition('l.booking_roomlocation_active', 'Y', '=')
->fields('r') ->fields('r')
->fields('l'); ->fields('l')
->orderBy('lid')->orderBy('booking_room_number');
$definition_result = $definition_query->execute(); $definition_result = $definition_query->execute();
$location_header = array ( $location_header = array (
'booking_roomlocation_descrip' => t('Location Description'), 'booking_roomlocation_descrip' => t('Location Description'),
'booking_roomlocation_active' => t('Location Active?'), 'booking_roomlocation_active' => t('Location Active?'),
'booking_location_edit' => t('Edit Location'), 'booking_location_edit' => t('Edit Location'),
); );
$definition_header = array ( $definition_header = array (
'booking_room_location_description' => t('Room Location'), 'booking_room_location_description' => t('Room Location'),
'booking_room_number' => t('Room Number'), 'booking_room_number' => t('Room Number'),
'booking_room_description' => t('Room Description'),
'booking_room_singlebeds' => t('Number Single Beds'), 'booking_room_singlebeds' => t('Number Single Beds'),
'booking_room_doublebeds' => t('Number Double Beds'), 'booking_room_doublebeds' => t('Number Double Beds'),
'booking_room_queenbeds' => t('Number Queen Beds'), 'booking_room_queenbeds' => t('Number Queen Beds'),
@@ -244,8 +246,7 @@ function booking_rooms_view_definitions() {
'booking_room_edit' => t('Edit Room'), 'booking_room_edit' => t('Edit Room'),
); );
foreach($location_result as $data) foreach($location_result as $data) {
{
$location_rows[] = array ( $location_rows[] = array (
$data->booking_roomlocation_descrip, $data->booking_roomlocation_descrip,
$data->booking_roomlocation_active == 'Y' ? 'Yes' : 'No', $data->booking_roomlocation_active == 'Y' ? 'Yes' : 'No',
@@ -253,12 +254,12 @@ function booking_rooms_view_definitions() {
); );
} }
foreach($definition_result as $data) foreach($definition_result as $data) {
{
$definition_rows[] = array ( $definition_rows[] = array (
//_booking_room_location_lookup($data->booking_room_location_id), //_booking_room_location_lookup($data->booking_room_location_id),
$data->booking_roomlocation_descrip, $data->booking_roomlocation_descrip,
$data->booking_room_number, $data->booking_room_number,
$data->booking_room_description,
$data->booking_room_singlebeds, $data->booking_room_singlebeds,
$data->booking_room_doublebeds, $data->booking_room_doublebeds,
$data->booking_room_queenbeds, $data->booking_room_queenbeds,
@@ -309,33 +310,30 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
$query = db_query("SELECT * FROM {booking_room_locations} where booking_roomlocation_active='Y'"); $query = db_query("SELECT * FROM {booking_room_locations} where booking_roomlocation_active='Y'");
foreach($query as $row) foreach($query as $row) {
{
$location_options[$row->lid] = $row->booking_roomlocation_descrip; $location_options[$row->lid] = $row->booking_roomlocation_descrip;
} }
if ($create == true) if ($create == true) {
{
$data = $node; $data = $node;
$prefix = t("<p>Create new room defintion.</p>"); $prefix = t("<p>Create new room defintion.</p>");
//watchdog('booking', 'Creating new room definition: @info', array ('@info' => var_export($node, TRUE))); //watchdog('booking', 'Creating new room definition: @info', array ('@info' => var_export($node, TRUE)));
} }
else else {
{
//verify that $editid is a number //verify that $editid is a number
if (! preg_match('/^[0-9]+$/', $room_id)) { if (! preg_match('/^[0-9]+$/', $room_id)) {
drupal_set_message("Error: Invalid room ID supplied. Unable to update room definition.", 'error', FALSE); drupal_set_message("Error: Invalid room ID supplied. Unable to update room definition.", 'error', FALSE);
drupal_goto('admin/config/booking/rooms'); drupal_goto('admin/config/booking/rooms');
return ""; return "";
} }
//$data = $form_state['input'];
$data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id",
array(':id' => $room_id))
->fetchObject();
$prefix = t("<p>Update the room defintions.</p>"); $prefix = t("<p>Update the room defintions.</p>");
//$data = $form_state['input'];
$data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id", array(':id' => $room_id))
->fetchObject();
//add this to the form in a hidden field so we can update the right price //add this to the form in a hidden field so we can update the right price
$form['booking_rid'] = array ( $form['booking_rid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $room_id, '#value' => $room_id,
); );
@@ -343,15 +341,14 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
} }
//create the options array for bed counts //create the options array for bed counts
for ($i = 0; $i <= 15; $i++) for ($i = 0; $i <= 15; $i++) {
$bedcount_options[$i] = $i; $bedcount_options[$i] = $i;
}
//define the form for adding to the room definitions //define the form for adding to the room definitions
if(!isset($form_state['storage']['confirm'])) { if(!isset($form_state['storage']['confirm'])) {
$form[] = array ( $form[] = array (
'first_heading' => array ( 'first_heading' => array(
'#type' => 'markup', '#type' => 'markup',
'#markup' => $prefix, '#markup' => $prefix,
), ),
@@ -363,26 +360,33 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
'#options' => $location_options, '#options' => $location_options,
'#default_value' => !empty($data->booking_room_location_id) ? $data->booking_room_location_id : '' '#default_value' => !empty($data->booking_room_location_id) ? $data->booking_room_location_id : ''
); );
$form['booking_room_number'] = array ( $form['booking_room_number'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Specify room number'), '#title' => t('Specify room number'),
'#size' => 5, '#size' => 5,
'#maxlength' => 10, '#maxlength' => 10,
'#default_value' => !empty($data->booking_room_number) ? $data->booking_room_number : '', '#default_value' => !empty($data->booking_room_number) ? $data->booking_room_number : '',
); );
$form['booking_room_singlebeds'] = array ( $form['booking_room_description'] = array(
'#type' => 'textfield',
'#title' => t('Specify room label (not mandatory)'),
'#size' => 50,
'#maxlength' => 100,
'#default_value' => !empty($data->booking_room_description) ? $data->booking_room_description : '',
);
$form['booking_room_singlebeds'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Specify number of single beds'), '#title' => t('Specify number of single beds'),
'#options' => $bedcount_options, '#options' => $bedcount_options,
'#default_value' => !empty($data->booking_room_singlebeds) ? $data->booking_room_singlebeds : '', '#default_value' => !empty($data->booking_room_singlebeds) ? $data->booking_room_singlebeds : '',
); );
$form['booking_room_doublebeds'] = array ( $form['booking_room_doublebeds'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Specify number of double beds'), '#title' => t('Specify number of double beds'),
'#options' => $bedcount_options, '#options' => $bedcount_options,
'#default_value' => !empty($data->booking_room_doublebeds) ? $data->booking_room_doublebeds : '', '#default_value' => !empty($data->booking_room_doublebeds) ? $data->booking_room_doublebeds : '',
); );
$form['booking_room_queenbeds'] = array ( $form['booking_room_queenbeds'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Specify number of queen beds'), '#title' => t('Specify number of queen beds'),
'#options' => $bedcount_options, '#options' => $bedcount_options,
@@ -394,21 +398,18 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
'#default_value' => (!empty($data->booking_room_ensuite) && $data->booking_room_ensuite == 'Y') ? 1 : 0, '#default_value' => (!empty($data->booking_room_ensuite) && $data->booking_room_ensuite == 'Y') ? 1 : 0,
); );
if ($create == true) if ($create == true) {
{ $form['submit'] = array(
$form['submit'] = array
(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Add Room'), '#value' => t('Add Room'),
); );
} else { }
$form['Update'] = array else {
( $form['Update'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Update Room'), '#value' => t('Update Room'),
); );
$form['Delete'] = array $form['Delete'] = array(
(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Delete Room'), '#value' => t('Delete Room'),
); );
@@ -418,12 +419,22 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
'form' => $form, 'form' => $form,
); );
} }
else else {
{
return confirm_form($form, "Are you sure you wish to delete room definition with id " . $room_id . "?", return confirm_form($form, "Are you sure you wish to delete room definition with id " . $room_id . "?",
current_path(), NULL, "Delete Room"); current_path(), NULL, "Delete Room");
} }
}
/**
* Validate the form for adding room definitions
*/
function booking_rooms_definition_form_validate($form, $form_state) {
//make sure room number is numerical
$values = $form_state['input'];
if (! is_numeric($values['booking_room_number'])) {
form_set_error('booking_room_number', t('Room number must be numeric. If you need to use a more descriptive label, please use the room label field.'));
}
} }
/** /**
@@ -437,30 +448,28 @@ function booking_rooms_definition_form_submit($form, &$form_state) {
//watchdog('booking', "<pre>Room definition submission:\n@info</pre>", array('@info' => print_r( $form_state, true))); //watchdog('booking', "<pre>Room definition submission:\n@info</pre>", array('@info' => print_r( $form_state, true)));
//if we're deleting, add the confirmation to the form if it hasn't been defined yet //if we're deleting, add the confirmation to the form if it hasn't been defined yet
if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm']))) if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm']))) {
{
//watchdog('booking', "<pre>Room deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true))); //watchdog('booking', "<pre>Room deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
$form_state['storage']['confirm'] = TRUE; $form_state['storage']['confirm'] = TRUE;
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
} }
elseif ($form_state['values']['op'] == 'Delete Room') elseif ($form_state['values']['op'] == 'Delete Room') {
{
//delete the room //delete the room
watchdog('booking', "Deleting room ID !rid", array('!rid' => $values['booking_rid'])); watchdog('booking', "Deleting room ID !rid", array('!rid' => $values['booking_rid']));
db_delete('booking_room_definition') db_delete('booking_room_definition')
->condition('rid', $values['booking_rid']) ->condition('rid', $values['booking_rid'])
->execute(); ->execute();
drupal_set_message('Deleted room id ' . $values['booking_rid'] ); drupal_set_message('Deleted room id ' . $values['booking_rid'] );
$form_state['redirect'] = $redirect_path; $form_state['redirect'] = $redirect_path;
} }
elseif ($form_state['values']['op'] == 'Update Room') elseif ($form_state['values']['op'] == 'Update Room') {
{
$result = db_update('booking_room_definition') $result = db_update('booking_room_definition')
->fields(array( ->fields(array(
'booking_room_location_id' => $values['booking_room_location_id'], 'booking_room_location_id' => $values['booking_room_location_id'],
'booking_room_number' => $values['booking_room_number'], 'booking_room_number' => $values['booking_room_number'],
'booking_room_description' => $values['booking_room_description'],
'booking_room_singlebeds' => $values['booking_room_singlebeds'], 'booking_room_singlebeds' => $values['booking_room_singlebeds'],
'booking_room_doublebeds' => $values['booking_room_doublebeds'], 'booking_room_doublebeds' => $values['booking_room_doublebeds'],
'booking_room_queenbeds' => $values['booking_room_queenbeds'], 'booking_room_queenbeds' => $values['booking_room_queenbeds'],
@@ -475,8 +484,9 @@ function booking_rooms_definition_form_submit($form, &$form_state) {
{ {
db_insert('booking_room_definition') db_insert('booking_room_definition')
->fields(array( ->fields(array(
'booking_room_location_id' => $values['booking_room_location_id'], 'booking_room_location_id' => $values['booking_room_location_id'],
'booking_room_number' => $values['booking_room_number'], 'booking_room_number' => $values['booking_room_number'],
'booking_room_description' => $values['booking_room_description'],
'booking_room_singlebeds' => $values['booking_room_singlebeds'], 'booking_room_singlebeds' => $values['booking_room_singlebeds'],
'booking_room_doublebeds' => $values['booking_room_doublebeds'], 'booking_room_doublebeds' => $values['booking_room_doublebeds'],
'booking_room_queenbeds' => $values['booking_room_queenbeds'], 'booking_room_queenbeds' => $values['booking_room_queenbeds'],

View File

@@ -71,6 +71,8 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
$header = array ( $header = array (
'booking_room_location' => array('data' => t('Room Location'), 'field' => 'booking_room_location_id'), 'booking_room_location' => array('data' => t('Room Location'), 'field' => 'booking_room_location_id'),
'booking_room_number' => array('data' => t('Room Number')), 'booking_room_number' => array('data' => t('Room Number')),
'booking_room_description' => array('data' => t('Room Label')),
'booking_room_ensuite' => array('data' => t('Ensuite?')),
'booking_room_singlebed' => array('data' => t('Single Bed')), 'booking_room_singlebed' => array('data' => t('Single Bed')),
'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')), 'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')),
'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')), 'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')),
@@ -97,24 +99,22 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
$default_row = array(); $default_row = array();
$default_row['booking_room_location'] = ""; $default_row['booking_room_location'] = "";
$default_row['booking_room_number'] = ""; $default_row['booking_room_number'] = "";
$default_row['booking_room_description'] = "";
$default_row['booking_room_ensuite'] = "";
$default_row['booking_room_singlebed'] = ""; $default_row['booking_room_singlebed'] = "";
$default_row['booking_room_doublebed_p1'] = ""; $default_row['booking_room_doublebed_p1'] = "";
$default_row['booking_room_doublebed_p2'] = ""; $default_row['booking_room_doublebed_p2'] = "";
$default_row['booking_room_queenbed_p1'] = ""; $default_row['booking_room_queenbed_p1'] = "";
$default_row['booking_room_queenbed_p2'] = ""; $default_row['booking_room_queenbed_p2'] = "";
foreach ($room_query as $data) foreach ($room_query as $data) {
{
//create an array representing the existing bed mappings for this room //create an array representing the existing bed mappings for this room
$existing_beds = array(); $existing_beds = array();
for ($i = 1; $i <= 3; $i++) for ($i = 1; $i <= 3; $i++) {
{ foreach ($room_mapping as $mapping) {
foreach ($room_mapping as $mapping)
{
//check that the room id in the mapping table matches the room that we're currently adding to the table //check that the room id in the mapping table matches the room that we're currently adding to the table
//and also the bed type matches the first dimension in the array //and also the bed type matches the first dimension in the array
if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) {
{
$existing_beds[$i][] = $mapping->booking_lastname . ', ' . $mapping->booking_firstname . ' [' . $mapping->booking_nodeid . ']'; $existing_beds[$i][] = $mapping->booking_lastname . ', ' . $mapping->booking_firstname . ' [' . $mapping->booking_nodeid . ']';
} }
} }
@@ -125,6 +125,8 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
//$new_row['booking_room_location'] = _booking_room_location_lookup($data->booking_room_location_id); //$new_row['booking_room_location'] = _booking_room_location_lookup($data->booking_room_location_id);
$new_row['booking_room_location'] = $data->booking_roomlocation_descrip; $new_row['booking_room_location'] = $data->booking_roomlocation_descrip;
$new_row['booking_room_number'] = $data->booking_room_number; $new_row['booking_room_number'] = $data->booking_room_number;
$new_row['booking_room_description'] = $data->booking_room_description;
$new_row['booking_room_ensuite'] = $data->booking_room_ensuite == 'Y' ? "Yes" : "No";
$form['rooms']['#rows'][$counter++] = array( $form['rooms']['#rows'][$counter++] = array(
'data' => $new_row, 'data' => $new_row,
'id' => array("new-group-row"), 'id' => array("new-group-row"),

View File

@@ -2,11 +2,9 @@
/** /**
* @file * @file
* Functions for calculating leaders and helpers for discussion groups * Functions for automatically calculating leaders and helpers for discussion groups
*/ */
/** /**
* Function for calculating and assigning leaders and helpers to active study group sessions * Function for calculating and assigning leaders and helpers to active study group sessions
*/ */
@@ -66,20 +64,16 @@ function _booking_get_next_studygroup($type, $studygroups) {
$count = count($studygroups) - 1; $count = count($studygroups) - 1;
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++) {
{
$group = $studygroups[$i]; $group = $studygroups[$i];
$leader = $group->leader_nid; $leader = $group->leader_nid;
//watchdog('booking_debug', "<pre>Study Group Element at index $i:\n@info</pre>", array('@info' => print_r( $group, true))); //watchdog('booking_debug', "<pre>Study Group Element at index $i:\n@info</pre>", array('@info' => print_r( $group, true)));
//watchdog('booking_debug', "<pre>Study Group Leader NID at index $i:\n@info</pre>", array('@info' => var_dump($group))); //watchdog('booking_debug', "<pre>Study Group Leader NID at index $i:\n@info</pre>", array('@info' => var_dump($group)));
if ($leader == 0) if ($leader == 0) {
{
return $i; return $i;
} }
} }
} }
/** /**
@@ -101,9 +95,7 @@ function _booking_studygroups_retrieve_eligible_people() {
$bookedin_result = $query->execute(); $bookedin_result = $query->execute();
//iterate over the attendee associative array and add some fields //iterate over the attendee associative array and add some fields
foreach ($bookedin_result as $person) foreach ($bookedin_result as $person) {
{
$person->processed = 0; $person->processed = 0;
$person->leading = array(); $person->leading = array();
$person->helping = array(); $person->helping = array();
@@ -124,9 +116,7 @@ function _booking_studygroups_retrieve_eligible_people() {
array(':eid' => $event->eid)); array(':eid' => $event->eid));
//iterate over the attendee associative array and add some fields //iterate over the attendee associative array and add some fields
foreach ($result2 as $person) foreach ($result2 as $person){
{
$person->processed = 0; $person->processed = 0;
$person->leading = array(); $person->leading = array();
$person->helping = array(); $person->helping = array();
@@ -156,11 +146,9 @@ function _booking_studygroups_retrieve_groups() {
//assume they all have the same number of sessions //assume they all have the same number of sessions
//$num_sessions = $studygroup->booking_num_group_sessions; //$num_sessions = $studygroup->booking_num_group_sessions;
foreach ($group_mapping as $group) foreach ($group_mapping as $group) {
{
//watchdog('booking_debug', "<pre>Study Group Element:\n@info</pre>", array('@info' => print_r( $group, true))); //watchdog('booking_debug', "<pre>Study Group Element:\n@info</pre>", array('@info' => print_r( $group, true)));
for ($i = 1; $i <= 16; $i++) for ($i = 1; $i <= 16; $i++) {
{
$new_group = clone $group; $new_group = clone $group;
$new_group->session_id = $i; $new_group->session_id = $i;
@@ -235,7 +223,8 @@ function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) {
'sid' => array('data' => t('Study Group Session ID'), 'field' => 'sid'), 'sid' => array('data' => t('Study Group Session ID'), 'field' => 'sid'),
'booking_assign_leader' => array('data' => t('Leader')), 'booking_assign_leader' => array('data' => t('Leader')),
'booking_assign_helper' => array('data' => t('Helper')), 'booking_assign_helper' => array('data' => t('Helper')),
'booking_assign_reserveleader' => array('data' => t('Reserve Leader')), 'booking_assign_reserveleader' => array('data' => t('Reserve Leader')),
'booking_assign_reservehelper' => array('data' => t('Reserve Helper')),
); );
//attach the custom css //attach the custom css
@@ -278,8 +267,8 @@ function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) {
//create an array representing the existing leaders/helpers for this group //create an array representing the existing leaders/helpers for this group
$existing_leaders = array(); $existing_leaders = array();
foreach ($session_members as $person) { foreach ($session_members as $person) {
$existing_leaders[$person->booking_session_id][$person->booking_studygroup_role] = $person->booking_lastname $existing_leaders[$person->booking_session_id][$person->booking_studygroup_role] =
. ', ' . $person->booking_firstname . ' [' . $person->booking_node_id . ']'; $person->booking_lastname . ', ' . $person->booking_firstname . ' [' . $person->booking_node_id . ']';
} }
//create the rows for the individual sessions (instances really) of this study group //create the rows for the individual sessions (instances really) of this study group
@@ -318,29 +307,47 @@ function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) {
'#autocomplete_path' => 'booking/studygroups/autocomplete', '#autocomplete_path' => 'booking/studygroups/autocomplete',
'#value' => (!empty($existing_leaders[$i][3])) ? $existing_leaders[$i][3] : '', '#value' => (!empty($existing_leaders[$i][3])) ? $existing_leaders[$i][3] : '',
'#attributes' => array('style' => array('width:200px')), '#attributes' => array('style' => array('width:200px')),
); );
$reservehelper = array (
'#id' => 'booking-studygroup-reservehelper-' . $i,
'#type' => 'textfield',
'#title' => 'Name',
'#title_display' => 'invisible',
'#name' => 'booking_studygroup_reservehelper[' . $i . ']',
'#size' => 100,
'#autocomplete_path' => 'booking/studygroups/autocomplete',
'#value' => (!empty($existing_leaders[$i][4])) ? $existing_leaders[$i][4] : '',
'#attributes' => array('style' => array('width:200px')),
);
$form['studygroups'][$i] = array( $form['studygroups'][$i] = array(
'booking-studygroup-leader' => &$leader, 'booking-studygroup-leader' => &$leader,
'booking-studygroup-helper' => &$helper, 'booking-studygroup-helper' => &$helper,
'booking-studygroup-reserveleader' => &$reserveleader, 'booking-studygroup-reserveleader' => &$reserveleader,
'booking-studygroup-reservehelper' => &$reservehelper,
); );
$new_row = array(); $new_row = array();
//handle readings group differently
if ($studygroup->booking_is_readinggroup == 'Y') { if ($studygroup->booking_is_readinggroup == 'Y') {
$new_row['sid'] = _booking_readinggroup_colour_lookup($i); $new_row['sid'] = _booking_readinggroup_colour_lookup($i);
} }
//non readings groups just show the session ID
else { else {
$new_row['sid'] = $i; $new_row['sid'] = $i;
} }
$new_row['booking_studygroup_leader'] = array('data' => &$leader); $new_row['booking_studygroup_leader'] = array('data' => &$leader);
$new_row['booking_studygroup_helper'] = array('data' => &$helper); $new_row['booking_studygroup_helper'] = array('data' => &$helper);
$new_row['booking_studygroup_reserveleader'] = array('data' => &$reserveleader); $new_row['booking_studygroup_reserveleader'] = array('data' => &$reserveleader);
$new_row['booking_studygroup_reservehelper'] = array('data' => &$reservehelper);
$form['studygroups']['#rows'][$i] = $new_row; $form['studygroups']['#rows'][$i] = $new_row;
//clean up references
unset($leader); unset($leader);
unset($helper); unset($helper);
unset($reserveleader); unset($reserveleader);
unset($reservehelper);
} }
//record whether this was a reading group, so we can update colours if necessary //record whether this was a reading group, so we can update colours if necessary
@@ -376,6 +383,7 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
'booking_studygroup_leader' => 1, 'booking_studygroup_leader' => 1,
'booking_studygroup_helper' => 2, 'booking_studygroup_helper' => 2,
'booking_studygroup_reserveleader' => 3, 'booking_studygroup_reserveleader' => 3,
'booking_studygroup_reservehelper' => 4,
); );
//iterate over the different role types //iterate over the different role types

View File

@@ -23,6 +23,7 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id)
1 => "leader-row", 1 => "leader-row",
2 => "helper-row", 2 => "helper-row",
3 => "reserveleader-row", 3 => "reserveleader-row",
4 => "reservehelper-row",
); );
//verify that $group_id is a number //verify that $group_id is a number
@@ -126,8 +127,7 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id)
$assigned_role = $role; $assigned_role = $role;
$session_id = $group->booking_session_id; $session_id = $group->booking_session_id;
//list any role for this current group //list any role for this current group
if ($role > 0) if ($role > 0) {
{
$text = _booking_studygroup_role_lookup($role); $text = _booking_studygroup_role_lookup($role);
$role_listing .= "<b>" . $text . "</b> group " . $group->booking_studygroup_id . " #" . $group->booking_session_id . "; "; $role_listing .= "<b>" . $text . "</b> group " . $group->booking_studygroup_id . " #" . $group->booking_session_id . "; ";
$class = $class_array[$role]; $class = $class_array[$role];
@@ -400,8 +400,7 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
//retrieve the number of study group sessions, assume they all have the same number of sessions //retrieve the number of study group sessions, assume they all have the same number of sessions
$num_sessions = reset($studygroups)->booking_num_group_sessions; $num_sessions = reset($studygroups)->booking_num_group_sessions;
//create the array for our html select fields //create the array for our html select fields
for ($i = 1; $i <= $num_sessions; $i++) for ($i = 1; $i <= $num_sessions; $i++) {
{
$session_options[$i] = $i; $session_options[$i] = $i;
$readinggroup_options[$i] = _booking_readinggroup_colour_lookup($i); $readinggroup_options[$i] = _booking_readinggroup_colour_lookup($i);
} }
@@ -500,9 +499,10 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
function booking_studygroups_edit_form_submit($form, &$form_state) { function booking_studygroups_edit_form_submit($form, &$form_state) {
global $event; global $event;
$counter = 0; $counter = 0;
$checkboxes = $form_state['values']['table']; //$checkboxes = $form_state['values']['table'];
$studygroup_ids = $form_state['values']['booking_assign_sessionid']; $studygroup_ids = $form_state['values']['booking_assign_sessionid'];
$values = $form_state['input']; $values = $form_state['input'];
$update_messages = array();
//check that $values['personid'] is a number //check that $values['personid'] is a number
if (! preg_match('/^[0-9]+$/', $values['personid'])) { if (! preg_match('/^[0-9]+$/', $values['personid'])) {
@@ -536,7 +536,7 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
} }
//check to see if we need to remove a study group mapping //check to see if we need to remove a study group mapping
if (! empty($person_groups[$key]) && $value == 'Remove') { if (! empty($person_groups[$key]) && $value == 'Remove') {
watchdog('booking', "Removing an existing Study Group session id: @id from group @group.\n<pre>@info</pre>", $update_messages[] = t("Removing an existing Study Group session id: @id from group @group.\n<pre>@info</pre>",
array('@id' => $value, '@group' => $key, '@info' => print_r( $person_groups[$key], true))); array('@id' => $value, '@group' => $key, '@info' => print_r( $person_groups[$key], true)));
$num_deleted = db_delete('booking_studygroup_mapping') $num_deleted = db_delete('booking_studygroup_mapping')
@@ -545,7 +545,7 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
} }
//check for an existing study group mapping to change //check for an existing study group mapping to change
elseif ((!empty($person_groups[$key])) && $person_groups[$key]->booking_session_id != $value) { elseif ((!empty($person_groups[$key])) && $person_groups[$key]->booking_session_id != $value) {
watchdog('booking', "Updating Study Group session from: @key to @value for id @id", $update_messages[] = t( "Updating Study Group session from: @key to @value for id @id",
array('@key' => $person_groups[$key]->booking_session_id, '@value' => $value, '@id' => $nid)); array('@key' => $person_groups[$key]->booking_session_id, '@value' => $value, '@id' => $nid));
db_update('booking_studygroup_mapping') db_update('booking_studygroup_mapping')
@@ -567,12 +567,12 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
} }
//found this entry already, so no change needed //found this entry already, so no change needed
elseif ((!empty($person_groups[$key])) && $person_groups[$key]->booking_session_id == $value) { elseif ((!empty($person_groups[$key])) && $person_groups[$key]->booking_session_id == $value) {
watchdog('booking', "Study Group @group session already set to @session.", $update_messages[] = t("Study Group @group session already set to @session.",
array('@group' => $key, '@session' => $value)); array('@group' => $key, '@session' => $value));
} }
//no previously defined value, so add a new entry to the mapping table //no previously defined value, so add a new entry to the mapping table
else { else {
watchdog('booking', "Adding Study Group session id: @id for group @group.", array('@id' => $value, '@group' => $key)); $update_messages[] = t("Adding Study Group session id: @id for group @group.", array('@id' => $value, '@group' => $key));
db_insert('booking_studygroup_mapping') db_insert('booking_studygroup_mapping')
->fields(array( ->fields(array(
@@ -593,8 +593,12 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
} }
} //end new value check } //end new value check
} //end valid data check } //end valid data check
} //end checkbox loop } //end select dropdown loop
} //output messages to watchdog
$final_message = t('Finished processing study groups for person id !id.', array('!id' => $nid));
drupal_set_message($final_message);
watchdog('booking', "<pre>" . $final_message . "\n" . implode("\n", $update_messages) . "</pre>");
} //end function
/** /**
* Function for calculating who belongs to which study group * Function for calculating who belongs to which study group
@@ -1267,6 +1271,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
1 => "leader-row", 1 => "leader-row",
2 => "helper-row", 2 => "helper-row",
3 => "reserveleader-row", 3 => "reserveleader-row",
4 => "reservehelper-row",
); );
//attach the custom css //attach the custom css
@@ -1336,11 +1341,9 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
$class = $class_array[$data->booking_studygroup_role]; $class = $class_array[$data->booking_studygroup_role];
//only add the lines separating groups if we're sorting by the session id //only add the lines separating groups if we're sorting by the session id
if ($sort['sql'] == "m.booking_session_id") if ($sort['sql'] == "m.booking_session_id") {
{
//Add a different id for first entry of new session, with a border-top to distinguish it //Add a different id for first entry of new session, with a border-top to distinguish it
if ($last_session <> $data->booking_session_id) if ($last_session <> $data->booking_session_id) {
{
switch ($data->booking_studygroup_role) { switch ($data->booking_studygroup_role) {
case 1: case 1:
$class = "leader-new-group-row"; $class = "leader-new-group-row";
@@ -1351,6 +1354,9 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
case 3: case 3:
$class = "reserveleader-new-group-row"; $class = "reserveleader-new-group-row";
break; break;
case 4:
$class = "reservehelper-new-group-row";
break;
default: default:
$class = "new-group-row"; $class = "new-group-row";
@@ -1360,7 +1366,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
$session = $group->booking_is_readinggroup == 'Y' ? _booking_readinggroup_colour_lookup($data->booking_session_id) : $data->booking_session_id; $session = $group->booking_is_readinggroup == 'Y' ? _booking_readinggroup_colour_lookup($data->booking_session_id) : $data->booking_session_id;
$rows[] = array ( $rows[] = array(
'data' => array( 'data' => array(
$session, $session,
l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)), l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
@@ -1382,14 +1388,6 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
} }
$prefix = t("<h2>Study Group !descrip</h2>", array('!descrip' => $group->booking_studygroup_descrip)); $prefix = t("<h2>Study Group !descrip</h2>", array('!descrip' => $group->booking_studygroup_descrip));
/*
$form['table'] = array (
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
//'#attributes' => array('id' => 'sort-table'),
);
*/
return array ( return array (
'#attached' => array ( '#attached' => array (
'css' => array(drupal_get_path('module', 'booking') . '/booking.css') 'css' => array(drupal_get_path('module', 'booking') . '/booking.css')
@@ -1404,8 +1402,7 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
'#rows' => $rows, '#rows' => $rows,
'#attributes' => array('id' => 'sort-table'), '#attributes' => array('id' => 'sort-table'),
//'#sticky' => FALSE, //'#sticky' => FALSE,
) )
//'form' => $form,
); );
} }

View File

@@ -38,7 +38,6 @@ function booking_studygroups_admin() {
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)); $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
return $output; return $output;
} }
/** /**
@@ -175,7 +174,9 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
} }
/**
* Process addition/update/delete of a studygroup definition
*/
function booking_studygroups_define_form_submit($form, &$form_state) { function booking_studygroups_define_form_submit($form, &$form_state) {
global $event; global $event;

View File

@@ -49,8 +49,13 @@ function booking_studygroups_csv_report($group_id) {
if (! isset($data[$member->booking_session_id])) { if (! isset($data[$member->booking_session_id])) {
$data[$member->booking_session_id] = array(); $data[$member->booking_session_id] = array();
} }
// lookup the name and role for this entry in the study group session // lookup the name and role for this entry in the study group session and optionally include age
$text = array($member->booking_firstname, $member->booking_lastname, '[' . _booking_get_age_years($member->booking_dob) .']'); if (variable_get('booking_studygroup_csv_ages', 0) == 1) {
$text = array($member->booking_firstname, $member->booking_lastname, '[' . _booking_get_age_years($member->booking_dob) .']');
}
else {
$text = array($member->booking_firstname, $member->booking_lastname);
}
//add their role if they're leading/helping etc //add their role if they're leading/helping etc
if ($member->booking_studygroup_role > 0) { if ($member->booking_studygroup_role > 0) {
array_push($text, '(' . _booking_studygroup_role_lookup($member->booking_studygroup_role) . ')'); array_push($text, '(' . _booking_studygroup_role_lookup($member->booking_studygroup_role) . ')');