diff --git a/booking.admin.inc b/booking.admin.inc index 356a7bd..f33b053 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -242,6 +242,13 @@ function booking_admin() { '#maxlength' => 3, '#default_value' => variable_get('booking_readinggroup_id','0'), ); + $form['misc']['booking_publish_readinggroups'] = array ( + '#type' => 'radios', + '#title' => t('Display reading group colours on the Who\'s Coming page?'), + '#description' => t('Select whether to publish reading group colours.'), + '#options' => array (0 => t('No'), t('Yes')), + '#default_value' => variable_get('booking_publish_readinggroups', 0), + ); $form['misc']['booking_csv_exclude_fields'] = array ( '#type' => 'textfield', '#title' => t('Fields to exclude from CSV report'), diff --git a/booking.helper.inc b/booking.helper.inc index da2db51..9d5af32 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -395,24 +395,44 @@ function _booking_shuffle_assoc($list) { */ function _booking_assign_attendee_group($nid, $session_id, $gender, $age, &$attendee_list, &$session_count) { + $previous_session = 0; + //check for valid attendee if (empty($nid)) { drupal_set_message(t('Attempting to process a non-existent node id.')); return; } + //check if this person had already been processsed + if ($attendee_list[$nid]->processed == 1 && $attendee_list[$nid]->session > 0) + { + drupal_set_message(t('Detected re-assignment of id !id previously assigned to session !session.', + array('!id' => $nid, '!session' => $attendee_list[$nid]->session) + )); + + $previous_session = $attendee_list[$nid]->session; + + //update previous session totals + $session_count[$previous_session][$gender]--; + $session_count[$previous_session]['total']--; + if ($age < 20) + $session_count[$previous_session]['under20']--; + elseif($age >= 20 && $age < 25) + $session_count[$previous_session]['20to25']--; + else + $session_count[$previous_session]['over25']--; + } + //mark this person as processed in the working list $attendee_list[$nid]->processed = 1; $attendee_list[$nid]->session = $session_id; - + //record the category of person $session_count[$session_id][$gender]++; $session_count[$session_id]['total']++; - //record the age bracket - //$age = _booking_get_age_years($attendee_list[$nid]->booking_dob); - + //process ages if ($age < 20) $session_count[$session_id]['under20']++; elseif($age >= 20 && $age < 25) diff --git a/booking.reports.inc b/booking.reports.inc index 8ecfc6d..8bf79f7 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -284,10 +284,18 @@ function booking_coming_page() { global $event; $output = ""; $table = ""; - //$header = array('Name', 'Team Colour', 'State'); - $header = array('Name', 'State'); $booking_limit = variable_get('booking_regn_limit','350'); $rows = array(); + + //work out whether to include the team colour in this page + if (variable_get('booking_publish_readinggroups', 0) == 1) + { + $header = array('Name', 'Team Colour', 'State'); + } + else + { + $header = array('Name', 'State'); + } if (variable_get('booking_auto_show_on_lists', 1) == 1) { @@ -333,14 +341,29 @@ function booking_coming_page() { //watchdog('booking', "Who's coming query: @info", array('@info' => var_export($result, TRUE))); - foreach ($result as $person) { - $rows[] = array( - t('!first !last', array('!first' => ucwords($person->booking_firstname), - '!last' => ucwords($person->booking_lastname))), - //only for when we have readings groups - //t('!group',array('!group' => $person->booking_readinggroup)), - t('!state', array('!state' => ($person->booking_country === variable_get('booking_default_country')) ? $person->booking_state : $person->booking_country)), - ); + foreach ($result as $person) + { + $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 (variable_get('booking_publish_readinggroups', 0) == 1) + { + $rows[] = array( + t('!first !last', array('!first' => ucwords($person->booking_firstname), + '!last' => ucwords($person->booking_lastname))), + t('!group',array('!group' => $person->booking_readinggroup)), + t('!state', array('!state' => $state)), + ); + } + //don't publish reading group information + else + { + $rows[] = array( + t('!first !last', array('!first' => ucwords($person->booking_firstname), + '!last' => ucwords($person->booking_lastname))), + t('!state', array('!state' => $state)), + ); + } } //watchdog('booking', "Who's coming formatted: @info", array('@info' => var_export($rows, TRUE))); diff --git a/booking.studygroups.inc b/booking.studygroups.inc index c35336e..17f7ec5 100644 --- a/booking.studygroups.inc +++ b/booking.studygroups.inc @@ -965,7 +965,7 @@ function booking_studygroups_update() { $firstgroup = reset($studygroups); $limit = variable_get('booking_regn_limit','500'); //be a bit more lenient with maximums to avoid excessive re-arrangement of groups - $fudge_factor = 3; + $fudge_factor = 1; $max_people = (int) ($limit / $firstgroup->booking_num_group_sessions) + $fudge_factor; //select all the attendees booked in @@ -1272,7 +1272,7 @@ function booking_studygroups_update() { '!role' => $person->booking_studygroup_role))); //update the entry - /* + db_update('booking_studygroup_mapping') ->fields(array( 'booking_session_id' => $person->session, @@ -1280,7 +1280,7 @@ function booking_studygroups_update() { )) ->condition('sid', $mapping->sid) ->execute(); - */ + } else { @@ -1296,8 +1296,8 @@ function booking_studygroups_update() { //if we didn't find an existing record, add it to the list to insert if (! $found && $person->session <> 0) { - //drupal_set_message(t('Found no existing study group session for user id !id. Adding to list of inserts.', - // array('!id' => $person->nid, '!sid' => $mapping->sid, '!session' => $person->session))); + drupal_set_message(t('Found no existing study group session for user id !id. Adding to list of inserts.', + array('!id' => $person->nid, '!sid' => $mapping->sid, '!session' => $person->session))); $record = array( 'booking_eventid' => $event->eid, @@ -1310,7 +1310,7 @@ function booking_studygroups_update() { } } - //$insert_query->execute(); + $insert_query->execute(); //watchdog('booking', "
Session statistics list:\n@info
", array('@info' => print_r( $session_count, true)));