Tweaks for reading groups
This commit is contained in:
@@ -234,6 +234,14 @@ function booking_admin() {
|
||||
'#maxlength' => 3,
|
||||
'#default_value' => variable_get('booking_studygroup_count','0'),
|
||||
);
|
||||
$form['misc']['booking_readinggroup_id'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Studygroup ID for the reading group'),
|
||||
'#description' => t("Set the ID for the studygroup that corresponds with the reading group. Set to zero if reading groups aren't in use."),
|
||||
'#size' => 3,
|
||||
'#maxlength' => 3,
|
||||
'#default_value' => variable_get('booking_readinggroup_id','0'),
|
||||
);
|
||||
$form['misc']['booking_csv_exclude_fields'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Fields to exclude from CSV report'),
|
||||
|
@@ -284,7 +284,7 @@ function booking_coming_page() {
|
||||
global $event;
|
||||
$output = "";
|
||||
$table = "";
|
||||
//$header = array('Name', 'Occupation', 'State');
|
||||
//$header = array('Name', 'Team Colour', 'State');
|
||||
$header = array('Name', 'State');
|
||||
$booking_limit = variable_get('booking_regn_limit','350');
|
||||
$rows = array();
|
||||
|
@@ -569,6 +569,11 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
|
||||
))
|
||||
->condition('sid', $person_groups[$key]->sid)
|
||||
->execute();
|
||||
|
||||
if ($key == 7)
|
||||
{
|
||||
booking_studygroups_process_colours();
|
||||
}
|
||||
}
|
||||
//found this entry already, so no change needed
|
||||
elseif ((!empty($person_groups[$key])) && $person_groups[$key]->booking_session_id == $value)
|
||||
@@ -592,7 +597,11 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
|
||||
//'booking_is_reserveleader' => 'N',
|
||||
'booking_studygroup_role' => 0,
|
||||
))
|
||||
->execute();
|
||||
->execute();
|
||||
if ($key == 7)
|
||||
{
|
||||
booking_studygroups_process_colours();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -967,7 +976,9 @@ function booking_studygroups_update() {
|
||||
//calculate the ratios of males to females, and various age groups
|
||||
$statistics = _booking_generate_statistics($attendees);
|
||||
$gender_ratio = ($statistics['males'] / $statistics['females']) * ($max_people / 2);
|
||||
//store them in a nice easy to access array
|
||||
//really stretch the tolerances for placement by setting this to zero
|
||||
$fudge_factor = 0;
|
||||
//store our final maximums as an array for easy access later
|
||||
$maximums = array(
|
||||
'male' => ceil($gender_ratio),
|
||||
'female' => ceil($max_people - $gender_ratio),
|
||||
@@ -1236,8 +1247,7 @@ function booking_studygroups_update() {
|
||||
//iterate over the attendee list and write to the database the session they're assigned to
|
||||
//use the multi-insert query type at https://drupal.org/node/310079
|
||||
$insert_query = db_insert('booking_studygroup_mapping')->fields(array('booking_eventid', 'booking_node_id',
|
||||
'booking_studygroup_id', 'booking_session_id', 'booking_is_leader', 'booking_is_helper',
|
||||
'booking_is_reserveleader', 'booking_studygroup_role'));
|
||||
'booking_studygroup_id', 'booking_session_id', 'booking_studygroup_role'));
|
||||
|
||||
foreach($working_list as $person)
|
||||
{
|
||||
@@ -1262,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,
|
||||
@@ -1270,7 +1280,7 @@ function booking_studygroups_update() {
|
||||
))
|
||||
->condition('sid', $mapping->sid)
|
||||
->execute();
|
||||
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1312,6 +1322,7 @@ function booking_studygroups_update() {
|
||||
|
||||
} //finished processing study groups
|
||||
|
||||
booking_studygroups_process_colours();
|
||||
//watchdog('booking', "Attendee list final version: @info", array('@info' => var_export($attendees, TRUE)));
|
||||
}
|
||||
|
||||
@@ -1443,7 +1454,7 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
|
||||
*/
|
||||
function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
||||
global $event;
|
||||
|
||||
$is_reading_group = FALSE;
|
||||
$form = array();
|
||||
$options = array();
|
||||
$last_session = "";
|
||||
@@ -1477,6 +1488,11 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
||||
drupal_goto('admin/config/booking');
|
||||
return "";
|
||||
}
|
||||
|
||||
if ($group_id == variable_get('booking_readinggroup_id','7'))
|
||||
{
|
||||
$is_reading_group = TRUE;
|
||||
}
|
||||
|
||||
$header = array(
|
||||
'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'),
|
||||
@@ -1488,6 +1504,11 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
||||
//'booking_is_reserveleader' => array('data' => t('Reserve Leader?'), 'field' => 'm.booking_is_reserveleader'),
|
||||
);
|
||||
|
||||
if ($is_reading_group == TRUE)
|
||||
{
|
||||
$header['booking_session_id']['data'] = t('Team Colour');
|
||||
}
|
||||
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->leftJoin('booking_studygroup_mapping', 'm', 'm.booking_node_id = p.nid');
|
||||
|
||||
@@ -1541,8 +1562,10 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
||||
}
|
||||
}
|
||||
|
||||
$session = $is_reading_group == TRUE ? _booking_readinggroup_colour_lookup($data->booking_session_id) : $data->booking_session_id;
|
||||
|
||||
$options[$data->nid] = array (
|
||||
'booking_session_id' => $data->booking_session_id,
|
||||
'booking_session_id' => $session,
|
||||
'booking_name' => l(t('!first !last', array('!first' => $data->booking_firstname, '!last' => $data->booking_lastname)),
|
||||
t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
|
||||
'booking_status' => _booking_status_generate($data->booking_status),
|
||||
@@ -1581,21 +1604,20 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
|
||||
function booking_studygroups_process_colours() {
|
||||
global $event;
|
||||
|
||||
//hard code this value for now - it's the id of the special study group that is actually the reading group
|
||||
$readinggroup_studygroup_id = 7;
|
||||
|
||||
//get the id of the special study group that is actually the reading group
|
||||
$readinggroup_studygroup_id = variable_get('booking_readinggroup_id','7');
|
||||
|
||||
//query for the mappings relating to $readinggroup_studygroup_id
|
||||
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid AND booking_studygroup_id = :sid",
|
||||
array(':eid' => $event->eid, ':sid' => $readinggroup_studygroup_id));
|
||||
$group_mapping = $group_mapping_query->fetchAll();
|
||||
|
||||
|
||||
foreach ($group_mapping as $mapping)
|
||||
{
|
||||
$colour = _booking_readinggroup_colour_lookup($mapping->booking_session_id);
|
||||
|
||||
drupal_set_message(t('Updating user !id to be in team !colour.',
|
||||
array('!id' => $mapping->booking_node_id, '!colour' => $colour)));
|
||||
//drupal_set_message(t('Updating user !id to be in team !colour.',
|
||||
// array('!id' => $mapping->booking_node_id, '!colour' => $colour)));
|
||||
|
||||
//run an update query
|
||||
db_update('booking_person')
|
||||
@@ -1605,4 +1627,5 @@ function booking_studygroups_process_colours() {
|
||||
->condition('nid', $mapping->booking_node_id)
|
||||
->execute();
|
||||
}
|
||||
drupal_set_message(t('Updated reading group colours'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user