diff --git a/booking.helper.inc b/booking.helper.inc index e3a96e0..936525c 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -1117,6 +1117,70 @@ function _booking_travelform_email_summary($node) { return implode("\n", $rows); } +/** + * Helper function to format summary of studygroup sessions to be used as a token + */ +function _booking_studygroup_email_summary($node) { + global $event; + $rows = array(); + + //display study session data if enabled + if (variable_get('booking_enable_studygroups', 0) == 1) + { + //look up the titles of the study groups + $studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid", + array(':eid' => $event->eid)); + $studygroups = $studygroups_query->fetchAllAssoc('sid'); + + for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++) + { + //calculate the session references + $sessionid = "session" . $i; + $roleid = $sessionid . "_role"; + + //check that this study group session has been defined for this attendee + if (!empty($node->$sessionid)) + { + $rows[] = t($studygroups[$i]->booking_studygroup_descrip . " session number:\t" . $node->$sessionid); + $rows[] = t("Role:\t" . _booking_studygroup_role_lookup($node->$roleid)); + } + + } + } + + foreach ($rows as $key => $value) + $rows[$key] = wordwrap($value); + + return implode("\n", $rows); +} + +/** + * Helper function to format summary of room allocation to be used as a token + */ +function _booking_room_email_summary($node) { + global $event; + $rows = array(); + + //display study session data if enabled + if (variable_get('booking_enable_roomallocations', 0) == 1) + { + //check that this attendee has had a room allocated + if (! empty($node->rid)) + { + $rows[] = t("Room Location\t" . _booking_room_location_lookup($node->booking_room_location_id)); + $rows[] = t("Room Number\t" . $node->booking_room_number); + $rows[] = t("Bed Type\t" . _booking_room_bedtype_lookup($node->booking_room_bedtype)); + } + else + $rows[] = t("No room currently allocated."); + } + + foreach ($rows as $key => $value) + $rows[$key] = wordwrap($value); + + return implode("\n", $rows); +} + /** * @brief Generates a Universally Unique IDentifier, version 4. * diff --git a/booking.register.inc b/booking.register.inc index 5620bb7..b8436d9 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -1706,7 +1706,10 @@ function booking_view($node, $view_mode) { //display study session data if enabled if (variable_get('booking_enable_studygroups', 0) == 1) { - + $studygroup_heading = t("

Study Groups

!link

", + array('!link' => l(t('Edit Groups'), t('admin/booking/!id/edit-studygroup', array('!id' => $node->nid))) + )); + //look up the titles of the study groups $studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid", array(':eid' => $event->eid)); @@ -1725,7 +1728,7 @@ function booking_view($node, $view_mode) { } $node->content['group-heading'] = array( - '#markup' => "

Study Groups

", + '#markup' => $studygroup_heading, '#weight' => 6, ); diff --git a/booking.tokens.inc b/booking.tokens.inc index 42636c1..bff676c 100644 --- a/booking.tokens.inc +++ b/booking.tokens.inc @@ -500,6 +500,10 @@ function booking_token_info() { 'name' => t('Last Name'), 'description' => t('Last Name of the attendee.') ); + $info['tokens']['booking']['team-colour'] = array( + 'name' => t('Team Colour'), + 'description' => t('Reading group team of attendee.') + ); $info['tokens']['booking']['dietary'] = array( 'name' => t('Dietary Requirements'), 'description' => t('Specified dietary requirements of the attendee') @@ -552,6 +556,14 @@ function booking_token_info() { 'name' => t('Registration Travel Summary'), 'description' => t('Summary of travel details from user registration.') ); + $info['tokens']['booking']['studygroup-summary'] = array( + 'name' => t('Registration Study Group Summary'), + 'description' => t('Summary of allocated study groups.') + ); + $info['tokens']['booking']['room-allocation'] = array( + 'name' => t('Room Allocation'), + 'description' => t('Listing of room allocated to attendee.') + ); $info['tokens']['booking']['travel-link'] = array( 'name' => t('Travel form Link'), 'description' => t('Link to the person\'s travel form.') @@ -654,6 +666,7 @@ function booking_define_personspecific_tokens($node) $tokens = array(); $tokens['eventname'] = $event->booking_eventname; $tokens['contact-email'] = variable_get('booking_contact_email'); + $tokens['team-colour'] = ucwords($node->booking_readinggroup); $tokens['fname'] = ucwords(trim($node->booking_firstname)); $tokens['lname'] = ucwords(trim($node->booking_lastname)); $tokens['dietary'] = ucwords(trim($node->booking_dietary)); @@ -671,5 +684,8 @@ function booking_define_personspecific_tokens($node) $tokens['paypal-deposit-amount'] = _booking_deposit_amount(); $tokens['regn-summary'] = _booking_details_email_summary($node); $tokens['travel-summary'] = _booking_travelform_email_summary($node); + $tokens['studygroup-summary'] = _booking_studygroup_email_summary($node); + $tokens['room-allocation'] = _booking_room_email_summary($node); + return $tokens; } \ No newline at end of file