diff --git a/booking.admin.inc b/booking.admin.inc index 462634e..3be66d4 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -286,6 +286,7 @@ function booking_manual_email() $prefix = t("
Send a manual email to people registered for this event.
"); $email_options_array = array(); $email_options_array['registration'] = 'Manual Registration'; + $email_options_array['travelrequired'] = 'Manual Travel Form Required'; $email_options_array['balance'] = 'Manual Balance Outstanding'; $email_options_array['complete'] = 'Manual Payment Complete'; $email_options_array['travelcomplete'] = 'Manual Travel Form Complete'; @@ -413,6 +414,11 @@ function booking_manual_email_submit($form, &$form_state) { watchdog('booking', 'Processing a manual registration email to id @info', array ('@info' => $key)); _booking_registration_email($key, false, true); } + if ($form_state['values']['email-type'] == 'travelrequired') + { + watchdog('booking', 'Processing a manual travel form request email to id @info', array ('@info' => $key)); + _booking_travelform_request_email($key); + } elseif ($form_state['values']['email-type'] == 'balance') { watchdog('booking', 'Processing a manual outstanding balance email to id @info', array ('@info' => $key)); diff --git a/booking.emails.inc b/booking.emails.inc index 04f1e1a..5039c3a 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -365,6 +365,49 @@ function _booking_missedpayment_email($nid) drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); } +/** + * Function to generate email to be sent to the attendee requesting them to complete their travel form + * + * @param $nid - the registration node + */ +function _booking_travelform_request_email($nid) +{ + global $event; + global $user; + $language = user_preferred_language($user); + + //return without doing anything if we shouldn't send workflow emails + if (variable_get('booking_auto_workflow_email', 0) == 0) + { + watchdog('booking', 'Not sending travelform confirmation email since that feature is currently disabled.'); + return; + } + + //load the node matching this id from the database, ignoring the cache + $node = node_load($nid, NULL, TRUE); + $tokens = booking_define_personspecific_tokens($node); + + watchdog('booking', 'Sending travelform confirmation email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname)); + + //calculate the from email address + $from = t('!event Travel ', array('!event' => $event->booking_eventname, + '!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from'))) + )); + + //calculate the remaining parameters + $to = $node->booking_email; + $subject = token_replace(variable_get('booking_email_travel_required_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens); + + $params['subject'] = $subject; + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); + + //retrieve the body of the email + $params['body'] = token_replace(variable_get('booking_email_travel_required_text'), $tokens); + + //send the email + drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); +} + /** * Function to generate email to be sent to the attendee once they complete their travel form * diff --git a/booking.rooms.inc b/booking.rooms.inc index 88edaa9..442f59c 100644 --- a/booking.rooms.inc +++ b/booking.rooms.inc @@ -55,6 +55,7 @@ function booking_roomallocations_view_summary() { 'booking_gender' => array('data' => t('Gender'), 'field' => 'p.booking_gender'), 'booking_age' => array('data' => t('Age'), 'field' => 'p.booking_dob'), 'booking_married' => array('data' => t('Married?'), 'field' => 'p.booking_married'), + 'booking_room_request' => array('data' => t('Requested Roommates'), 'field' => 'p.booking_room_mate1'), 'booking_roomlocation' => array('data' => t('Room Location'), 'field' => 'r.booking_room_location_id'), 'booking_room_num' => array('data' => t('Room Number'), 'field' => 'r.booking_room_number'), 'booking_room_bedtype' => array('data' => t('Bed Type'), 'field' => 'm.booking_room_bedtype'), @@ -74,6 +75,9 @@ function booking_roomallocations_view_summary() { foreach($result as $data) { + $location_link = $data->booking_room_location_id > 0 ? _booking_room_location_lookup($data->booking_room_location_id) . + l(t(' (Edit)'), t('admin/booking/rooms/!id/assign', array('!id' => $data->booking_room_location_id))) : ''; + $rows[] = array ( 'data' => array( $data->booking_firstname, @@ -81,10 +85,11 @@ function booking_roomallocations_view_summary() { $data->booking_gender == 'M' ? 'Male' : 'Female', _booking_get_age_years($data->booking_dob), $data->booking_married == 'Y' ? 'Yes' : 'No', - _booking_room_location_lookup($data->booking_room_location_id), + $data->booking_room_mate1, + $location_link, $data->booking_room_number, _booking_room_bedtype_lookup($data->booking_room_bedtype), - l(t('Edit'), t('admin/booking/!id/edit-room', array('!id' => $data->nid))), + l(t('Change Room'), t('admin/booking/!id/edit-room', array('!id' => $data->nid))), ), ); } diff --git a/booking.studygroups.inc b/booking.studygroups.inc index 3e542b1..e19c618 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -971,9 +971,9 @@ function booking_studygroups_update() { $maximums = array( 'male' => ceil($gender_ratio), 'female' => ceil($max_people - $gender_ratio), - 'under20' => ceil(($statistics['under20'] / $limit) * ($max_people)), - '20to25' => ceil(($statistics['20to25'] / $limit) * ($max_people)), - 'over25' => ceil(($statistics['over25'] / $limit) * ($max_people)), + 'under20' => ceil(($statistics['under20'] / $limit) * ($max_people - $fudge_factor)), + '20to25' => ceil(($statistics['20to25'] / $limit) * ($max_people - $fudge_factor)), + 'over25' => ceil(($statistics['over25'] / $limit) * ($max_people - $fudge_factor)), ); drupal_set_message(t('Aiming for !males males, !females females in group. Made up of !20s under 20, !low20s between 20 and 25, and !high20s over 25. Total count in group is !max.', @@ -1058,6 +1058,7 @@ function booking_studygroups_update() { $spouse_id = $working_list[$person->booking_node_id]->booking_partner_id; $bf_gf_id = $working_list[$person->booking_node_id]->booking_bf_gf_nid; $gender = $working_list[$person->booking_node_id]->booking_gender == 'M' ? 'male' : 'female'; + $session_id = $person->booking_session_id; //if the study group id matches the group we're currently looking at, and they have a role defined if ($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0) @@ -1069,20 +1070,51 @@ function booking_studygroups_update() { //mark this position as being used $age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob); - _booking_assign_attendee_group($person->booking_node_id, $person->booking_session_id, 'male', $age, $working_list, $session_count); + _booking_assign_attendee_group($person->booking_node_id, $session_id, 'male', $age, $working_list, $session_count); + + //make sure the leader/helper's partner gets updated now, otherwise they could still end up in different groups + if ($spouse_id > 0) + { + //also mark their spouse as allocated to this group + drupal_set_message(t('Spouse with id !id assigned to session !session (currently with !num people).', + array('!id' => $spouse_id, '!session' => $person->booking_session_id, + '!num' => $session_count[$person->booking_session_id]['total']) + )); + $age = _booking_get_age_years($working_list[$spouse_id]->booking_dob); + $spouse_gender = $working_list[$spouse_id]->booking_gender == 'M' ? 'male' : 'female'; + _booking_assign_attendee_group($spouse_id, $session_id, $spouse_gender, $age, $working_list, $session_count); + } + elseif ($bf_gf_id > 0) + { + //also mark their boyfriend/girlfriend as allocated to this group + drupal_set_message(t('BF/GF with id !id assigned to session !session (currently with !num people).', + array('!id' => $bf_gf_id, '!session' => $person->booking_session_id, + '!num' => $session_count[$person->booking_session_id]['total']) + )); + $age = _booking_get_age_years($working_list[$bf_gf_id]->booking_dob); + $bfgf_gender = $working_list[$bf_gf_id]->booking_gender == 'M' ? 'male' : 'female'; + _booking_assign_attendee_group($bf_gf_id, $session_id, $bfgf_gender, $age, $working_list, $session_count); + } + } //anyone else already assigned to this group previously elseif ($person->booking_studygroup_id == $group->sid && $working_list[$person->booking_node_id]->processed == 0) - { + { if ($spouse_id > 0) { + //if the spouse has already been processed due to being a leader or helper, use that session + if ($working_list[$spouse_id]->processed == 1) + { + $session_id = $working_list[$spouse_id]->session; + } + //mark this person as allocated to this group drupal_set_message(t('Married person with id !id assigned to session !session (currently with !num people).', array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id, '!num' => $session_count[$person->booking_session_id]['total']) )); $age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob); - _booking_assign_attendee_group($person->booking_node_id, $person->booking_session_id, $gender, $age, $working_list, $session_count); + _booking_assign_attendee_group($person->booking_node_id, $session_id, $gender, $age, $working_list, $session_count); //also mark their spouse as allocated to this group drupal_set_message(t('Spouse with id !id assigned to session !session (currently with !num people).', @@ -1091,17 +1123,23 @@ function booking_studygroups_update() { )); $age = _booking_get_age_years($working_list[$spouse_id]->booking_dob); $spouse_gender = $working_list[$spouse_id]->booking_gender == 'M' ? 'male' : 'female'; - _booking_assign_attendee_group($spouse_id, $person->booking_session_id, $spouse_gender, $age, $working_list, $session_count); + _booking_assign_attendee_group($spouse_id, $session_id, $spouse_gender, $age, $working_list, $session_count); } elseif ($bf_gf_id > 0) { + //if the bf/gf has already been processed due to being a leader or helper, use that session + if ($working_list[$bf_gf_id]->processed == 1) + { + $session_id = $working_list[$bf_gf_id]->session; + } + //mark this person as allocated to this group drupal_set_message(t('Person with id !id in relationship assigned to session !session (currently with !num people).', array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id, '!num' => $session_count[$person->booking_session_id]['total']) )); $age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob); - _booking_assign_attendee_group($person->booking_node_id, $person->booking_session_id, $gender, $age, $working_list, $session_count); + _booking_assign_attendee_group($person->booking_node_id, $session_id, $gender, $age, $working_list, $session_count); //also mark their boyfriend/girlfriend as allocated to this group drupal_set_message(t('BF/GF with id !id assigned to session !session (currently with !num people).', @@ -1110,12 +1148,12 @@ function booking_studygroups_update() { )); $age = _booking_get_age_years($working_list[$bf_gf_id]->booking_dob); $bfgf_gender = $working_list[$bf_gf_id]->booking_gender == 'M' ? 'male' : 'female'; - _booking_assign_attendee_group($bf_gf_id, $person->booking_session_id, $bfgf_gender, $age, $working_list, $session_count); + _booking_assign_attendee_group($bf_gf_id, $session_id, $bfgf_gender, $age, $working_list, $session_count); } //for anyone else, just record what session they're currently in else { - $working_list[$person->booking_node_id]->session = $person->booking_session_id; + $working_list[$person->booking_node_id]->session = $session_id; } } //end looking at people with spouse or bf/gf } //end searching for people to pre-allocate @@ -1220,9 +1258,11 @@ function booking_studygroups_update() { if ($mapping->booking_session_id !== $person->session) { drupal_set_message(t('Found existing study group session for user !id. Changing old session !old to !session. Role id is !role', - array('!id' => $person->nid, '!old' => $mapping->booking_session_id, '!session' => $person->session, '!role' => $person->booking_studygroup_role))); + array('!id' => $person->nid, '!old' => $mapping->booking_session_id, '!session' => $person->session, + '!role' => $person->booking_studygroup_role))); //update the entry + db_update('booking_studygroup_mapping') ->fields(array( 'booking_session_id' => $person->session, @@ -1230,7 +1270,7 @@ function booking_studygroups_update() { )) ->condition('sid', $mapping->sid) ->execute(); - + } else { diff --git a/booking.tokens.inc b/booking.tokens.inc index a92c2c8..d20697b 100644 --- a/booking.tokens.inc +++ b/booking.tokens.inc @@ -355,6 +355,19 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text '#description' => t(''), '#default_value' => variable_get('booking_email_waitinglist_text', $booking_email_waitinglist_text), ); + $form['emails']['booking_email_travel_required_subject'] = array ( + '#type' => 'textfield', + '#title' => t('Subject line for email requesting attendee to complete the travel form'), + '#size' => 150, + '#maxlength' => 300, + '#default_value' => variable_get('booking_email_travel_required_subject','[booking:eventname] Travel Details Required'), + ); + $form['emails']['booking_email_travel_required_text'] = array( + '#title' => t('Email text requesting attendee to complete the travel form.'), + '#type' => 'textarea', + '#description' => t(''), + '#default_value' => variable_get('booking_email_travel_required_text', ''), + ); $form['emails']['booking_email_travel_complete_subject'] = array ( '#type' => 'textfield', '#title' => t('Subject line for email indicating a person has completed the travel form'),