|
|
@@ -12,8 +12,8 @@ function booking_studygroups_view_summary() {
|
|
|
|
|
|
|
|
|
|
|
|
global $event;
|
|
|
|
global $event;
|
|
|
|
$output = "";
|
|
|
|
$output = "";
|
|
|
|
$header = array('Link','Study Group', 'Session Count', 'Select Leaders');
|
|
|
|
$header = array('Study Group', 'Session Count', 'View', 'Select Leaders', 'Auto-Update');
|
|
|
|
$attributes = array('style' => 'max-width:40%');
|
|
|
|
$attributes = array('style' => 'max-width:50%');
|
|
|
|
|
|
|
|
|
|
|
|
//get study groups
|
|
|
|
//get study groups
|
|
|
|
$query = db_select('booking_studygroup_list', 's')
|
|
|
|
$query = db_select('booking_studygroup_list', 's')
|
|
|
@@ -23,10 +23,11 @@ function booking_studygroups_view_summary() {
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($result as $group) {
|
|
|
|
foreach ($result as $group) {
|
|
|
|
$rows[] = array(
|
|
|
|
$rows[] = array(
|
|
|
|
l(t('View', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/view', array('!id' => $group->sid))),
|
|
|
|
|
|
|
|
$group->booking_studygroup_descrip,
|
|
|
|
$group->booking_studygroup_descrip,
|
|
|
|
$group->booking_num_group_sessions,
|
|
|
|
$group->booking_num_group_sessions,
|
|
|
|
|
|
|
|
l(t('View', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/view', array('!id' => $group->sid))),
|
|
|
|
l(t('Edit Leaders/Helpers', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/selectleaders', array('!id' => $group->sid))),
|
|
|
|
l(t('Edit Leaders/Helpers', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/selectleaders', array('!id' => $group->sid))),
|
|
|
|
|
|
|
|
l(t('Auto Update', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/update', array('!id' => $group->sid))),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -571,8 +572,8 @@ 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",
|
|
|
|
watchdog('booking', "Updating Study Group session from: @key to @value for id @id",
|
|
|
|
array('@key' => $person_groups[$key]->booking_session_id, '@value' => $value));
|
|
|
|
array('@key' => $person_groups[$key]->booking_session_id, '@value' => $value, '@id' => $nid));
|
|
|
|
|
|
|
|
|
|
|
|
db_update('booking_studygroup_mapping')
|
|
|
|
db_update('booking_studygroup_mapping')
|
|
|
|
->fields(array(
|
|
|
|
->fields(array(
|
|
|
@@ -962,7 +963,7 @@ function booking_studygroups_calculate() {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Function for calculating who belongs to which study group
|
|
|
|
* Function for calculating who belongs to which study group
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function booking_studygroups_update() {
|
|
|
|
function booking_studygroups_update($node, &$form_state, $sid) {
|
|
|
|
global $event;
|
|
|
|
global $event;
|
|
|
|
|
|
|
|
|
|
|
|
//master attendee list
|
|
|
|
//master attendee list
|
|
|
@@ -971,11 +972,34 @@ function booking_studygroups_update() {
|
|
|
|
$working_list = array();
|
|
|
|
$working_list = array();
|
|
|
|
//create an array to keep track of the number of people in each session for each group
|
|
|
|
//create an array to keep track of the number of people in each session for each group
|
|
|
|
$session_count = array();
|
|
|
|
$session_count = array();
|
|
|
|
|
|
|
|
//the form to return
|
|
|
|
|
|
|
|
$form = array();
|
|
|
|
|
|
|
|
$calculation_messages = array();
|
|
|
|
|
|
|
|
$update_messages = array();
|
|
|
|
|
|
|
|
$prefix = "";
|
|
|
|
|
|
|
|
$intro_text = "";
|
|
|
|
|
|
|
|
$reading_group_id = variable_get('booking_readinggroup_id','7');
|
|
|
|
|
|
|
|
|
|
|
|
//select all the study groups for this event id
|
|
|
|
//verify that $nid is a number
|
|
|
|
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
|
|
|
|
if (! preg_match('/^[0-9]+$/', $sid)) {
|
|
|
|
|
|
|
|
drupal_set_message("Error: Invalid group ID '" . $sid . "' supplied. Unable to update study group session.", 'error', FALSE);
|
|
|
|
|
|
|
|
drupal_goto('admin/booking/studygroups');
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//select the study group for the supplied ID
|
|
|
|
|
|
|
|
//$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
|
|
|
|
|
|
|
|
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE sid = :sid", array(':sid' => $sid));
|
|
|
|
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
|
|
|
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//throw an error if we got no groups
|
|
|
|
|
|
|
|
if (! $studygroups)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
drupal_set_message("Error: Unable to find group with corresponding ID '" . $sid . "'.", 'error', FALSE);
|
|
|
|
|
|
|
|
drupal_goto('admin/booking/studygroups');
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//calculate the max number of attendees in a group
|
|
|
|
//calculate the max number of attendees in a group
|
|
|
|
$firstgroup = reset($studygroups);
|
|
|
|
$firstgroup = reset($studygroups);
|
|
|
|
$limit = variable_get('booking_regn_limit','500');
|
|
|
|
$limit = variable_get('booking_regn_limit','500');
|
|
|
@@ -983,7 +1007,7 @@ function booking_studygroups_update() {
|
|
|
|
$fudge_factor = 1;
|
|
|
|
$fudge_factor = 1;
|
|
|
|
$max_people = (int) ($limit / $firstgroup->booking_num_group_sessions) + $fudge_factor;
|
|
|
|
$max_people = (int) ($limit / $firstgroup->booking_num_group_sessions) + $fudge_factor;
|
|
|
|
|
|
|
|
|
|
|
|
//select all the attendees booked in
|
|
|
|
//select all the attendees for this event
|
|
|
|
$query = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid",
|
|
|
|
$query = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid",
|
|
|
|
array(':eid' => $event->eid));
|
|
|
|
array(':eid' => $event->eid));
|
|
|
|
$attendees = $query->fetchAllAssoc('nid');
|
|
|
|
$attendees = $query->fetchAllAssoc('nid');
|
|
|
@@ -1002,13 +1026,8 @@ function booking_studygroups_update() {
|
|
|
|
'over25' => ceil(($statistics['over25'] / $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.',
|
|
|
|
|
|
|
|
array('!20s' => $maximums['under20'], '!low20s' => $maximums['20to25'], '!high20s' => $maximums['over25'],
|
|
|
|
|
|
|
|
'!males' => $maximums['male'], '!females' => $maximums['female'], '!max' => $max_people)
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//select any entries already in the mapping table
|
|
|
|
//select any entries already in the mapping table
|
|
|
|
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid));
|
|
|
|
$group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid AND booking_studygroup_id = :sid", array(':eid' => $event->eid, ':sid' => $sid));
|
|
|
|
$group_mapping = $group_mapping_query->fetchAllAssoc('sid');
|
|
|
|
$group_mapping = $group_mapping_query->fetchAllAssoc('sid');
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Move this to a helper function
|
|
|
|
//TODO: Move this to a helper function
|
|
|
@@ -1054,8 +1073,13 @@ function booking_studygroups_update() {
|
|
|
|
//process each study group (eg Monday Tuesday Wednesday etc)
|
|
|
|
//process each study group (eg Monday Tuesday Wednesday etc)
|
|
|
|
foreach ($studygroups as $group)
|
|
|
|
foreach ($studygroups as $group)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
drupal_set_message(t('Processing study group !group with !sessions sessions.',
|
|
|
|
|
|
|
|
array('!group' => $group->booking_studygroup_descrip, '!sessions' => $group->booking_num_group_sessions)));
|
|
|
|
$prefix .= t('<h2>Processing study group !group with !sessions sessions</h2>',
|
|
|
|
|
|
|
|
array('!group' => $group->booking_studygroup_descrip, '!sessions' => $group->booking_num_group_sessions));
|
|
|
|
|
|
|
|
$prefix .= t('<p>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.</p>',
|
|
|
|
|
|
|
|
array('!20s' => $maximums['under20'], '!low20s' => $maximums['20to25'], '!high20s' => $maximums['over25'],
|
|
|
|
|
|
|
|
'!males' => $maximums['male'], '!females' => $maximums['female'], '!max' => $max_people)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
//create a temporary copy of the attendee list to work with for this study group
|
|
|
|
//create a temporary copy of the attendee list to work with for this study group
|
|
|
|
$working_list = array();
|
|
|
|
$working_list = array();
|
|
|
@@ -1090,39 +1114,40 @@ function booking_studygroups_update() {
|
|
|
|
//if the study group id matches the group we're currently looking at, and they have a role defined
|
|
|
|
//if the study group id matches the group we're currently looking at, and they have a role defined
|
|
|
|
//or if the group id matches, they are a committee member and this is the readings group
|
|
|
|
//or if the group id matches, they are a committee member and this is the readings group
|
|
|
|
if (($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0) ||
|
|
|
|
if (($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0) ||
|
|
|
|
($person->booking_studygroup_id == $group->sid && $committee_flag == 'Y' && $group->sid == variable_get('booking_readinggroup_id','7')))
|
|
|
|
($person->booking_studygroup_id == $group->sid && $committee_flag == 'Y' && $group->sid == $reading_group_id))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
drupal_set_message(t('Leader/helper/committee with id !id assigned to session !session (currently with !num people).',
|
|
|
|
$calculation_messages[] = t('Leader/helper/committee with id !id assigned to session !session (currently with !num people).',
|
|
|
|
array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
|
|
|
|
array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
));
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
//mark this position as being used
|
|
|
|
//mark this position as being used
|
|
|
|
|
|
|
|
$working_list[$person->booking_node_id]->booking_studygroup_role = $person->booking_studygroup_role;
|
|
|
|
$age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob);
|
|
|
|
$age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob);
|
|
|
|
_booking_assign_attendee_group($person->booking_node_id, $session_id, 'male', $age, $working_list, $session_count);
|
|
|
|
_booking_assign_attendee_group($person->booking_node_id, $session_id, 'male', $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
|
|
|
|
|
|
|
|
//make sure the leader/helper's partner gets updated now, otherwise they could still end up in different groups
|
|
|
|
//make sure the leader/helper's partner gets updated now, otherwise they could still end up in different groups
|
|
|
|
if ($spouse_id > 0)
|
|
|
|
if ($spouse_id > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//also mark their spouse as allocated to this group
|
|
|
|
//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).',
|
|
|
|
$calculation_messages[] = t('Spouse with id !id assigned to session !session (currently with !num people).',
|
|
|
|
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
|
|
|
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
));
|
|
|
|
);
|
|
|
|
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
|
|
|
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
|
|
|
$spouse_gender = $working_list[$spouse_id]->booking_gender == 'M' ? 'male' : 'female';
|
|
|
|
$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);
|
|
|
|
_booking_assign_attendee_group($spouse_id, $session_id, $spouse_gender, $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($bf_gf_id > 0)
|
|
|
|
elseif ($bf_gf_id > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//also mark their boyfriend/girlfriend as allocated to this group
|
|
|
|
//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).',
|
|
|
|
$calculation_messages[] = t('BF/GF with id !id assigned to session !session (currently with !num people).',
|
|
|
|
array('!id' => $bf_gf_id, '!session' => $person->booking_session_id,
|
|
|
|
array('!id' => $bf_gf_id, '!session' => $person->booking_session_id,
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
));
|
|
|
|
);
|
|
|
|
$age = _booking_get_age_years($working_list[$bf_gf_id]->booking_dob);
|
|
|
|
$age = _booking_get_age_years($working_list[$bf_gf_id]->booking_dob);
|
|
|
|
$bfgf_gender = $working_list[$bf_gf_id]->booking_gender == 'M' ? 'male' : 'female';
|
|
|
|
$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);
|
|
|
|
_booking_assign_attendee_group($bf_gf_id, $session_id, $bfgf_gender, $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -1138,21 +1163,21 @@ function booking_studygroups_update() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//mark this person as allocated to this group
|
|
|
|
//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).',
|
|
|
|
$calculation_messages[] = 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,
|
|
|
|
array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
));
|
|
|
|
);
|
|
|
|
$age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob);
|
|
|
|
$age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob);
|
|
|
|
_booking_assign_attendee_group($person->booking_node_id, $session_id, $gender, $age, $working_list, $session_count);
|
|
|
|
_booking_assign_attendee_group($person->booking_node_id, $session_id, $gender, $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
|
|
|
|
|
|
|
|
//also mark their spouse as allocated to this group
|
|
|
|
//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).',
|
|
|
|
$calculation_messages[] = t('Spouse with id !id assigned to session !session (currently with !num people).',
|
|
|
|
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
|
|
|
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
));
|
|
|
|
);
|
|
|
|
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
|
|
|
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
|
|
|
$spouse_gender = $working_list[$spouse_id]->booking_gender == 'M' ? 'male' : 'female';
|
|
|
|
$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);
|
|
|
|
_booking_assign_attendee_group($spouse_id, $session_id, $spouse_gender, $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($bf_gf_id > 0)
|
|
|
|
elseif ($bf_gf_id > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@@ -1163,21 +1188,21 @@ function booking_studygroups_update() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//mark this person as allocated to this group
|
|
|
|
//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).',
|
|
|
|
$calculation_messages[] = 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,
|
|
|
|
array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
));
|
|
|
|
);
|
|
|
|
$age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob);
|
|
|
|
$age = _booking_get_age_years($working_list[$person->booking_node_id]->booking_dob);
|
|
|
|
_booking_assign_attendee_group($person->booking_node_id, $session_id, $gender, $age, $working_list, $session_count);
|
|
|
|
_booking_assign_attendee_group($person->booking_node_id, $session_id, $gender, $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
|
|
|
|
|
|
|
|
//also mark their boyfriend/girlfriend as allocated to this group
|
|
|
|
//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).',
|
|
|
|
$calculation_messages[] = t('BF/GF with id !id assigned to session !session (currently with !num people).',
|
|
|
|
array('!id' => $bf_gf_id, '!session' => $person->booking_session_id,
|
|
|
|
array('!id' => $bf_gf_id, '!session' => $person->booking_session_id,
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
|
|
));
|
|
|
|
);
|
|
|
|
$age = _booking_get_age_years($working_list[$bf_gf_id]->booking_dob);
|
|
|
|
$age = _booking_get_age_years($working_list[$bf_gf_id]->booking_dob);
|
|
|
|
$bfgf_gender = $working_list[$bf_gf_id]->booking_gender == 'M' ? 'male' : 'female';
|
|
|
|
$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);
|
|
|
|
_booking_assign_attendee_group($bf_gf_id, $session_id, $bfgf_gender, $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//for anyone else, just record what session they're currently in
|
|
|
|
//for anyone else, just record what session they're currently in
|
|
|
|
else
|
|
|
|
else
|
|
|
@@ -1234,19 +1259,19 @@ function booking_studygroups_update() {
|
|
|
|
$age_type = 'over25';
|
|
|
|
$age_type = 'over25';
|
|
|
|
|
|
|
|
|
|
|
|
//make sure this person is going to fit in with our calculated gender ratios
|
|
|
|
//make sure this person is going to fit in with our calculated gender ratios
|
|
|
|
_booking_loop_carefully($session_count, $gender, $start, $maximums[$gender], $group->booking_num_group_sessions, 3);
|
|
|
|
_booking_loop_carefully($session_count, $gender, $start, $maximums[$gender], $group->booking_num_group_sessions, 3, $calculation_messages);
|
|
|
|
|
|
|
|
|
|
|
|
//make sure this person is going to fit in with our calculated age ratios
|
|
|
|
//make sure this person is going to fit in with our calculated age ratios
|
|
|
|
_booking_loop_carefully($session_count, $age_type, $start, $maximums[$age_type], $group->booking_num_group_sessions, 3);
|
|
|
|
_booking_loop_carefully($session_count, $age_type, $start, $maximums[$age_type], $group->booking_num_group_sessions, 3, $calculation_messages);
|
|
|
|
|
|
|
|
|
|
|
|
//check for maximum group size
|
|
|
|
//check for maximum group size
|
|
|
|
_booking_loop_carefully($session_count, 'total', $start, $max_people, $group->booking_num_group_sessions, 4);
|
|
|
|
_booking_loop_carefully($session_count, 'total', $start, $max_people, $group->booking_num_group_sessions, 4, $calculation_messages);
|
|
|
|
|
|
|
|
|
|
|
|
drupal_set_message(t('Assigning person with id !id with gender !gender and age group !age to session !session (currently with !num people).',
|
|
|
|
$calculation_messages[] = t('Assigning person with id !id with gender !gender and age group !age to session !session (currently with !num people).',
|
|
|
|
array('!id' => $it->key(), '!session' => $start, '!num' => $session_count[$start]['total'], '!gender' => $gender, '!age' => $age_type )
|
|
|
|
array('!id' => $it->key(), '!session' => $start, '!num' => $session_count[$start]['total'], '!gender' => $gender, '!age' => $age_type )
|
|
|
|
));
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
_booking_assign_attendee_group($it->key(), $start, $gender, $age, $working_list, $session_count);
|
|
|
|
_booking_assign_attendee_group($it->key(), $start, $gender, $age, $working_list, $session_count, $calculation_messages);
|
|
|
|
|
|
|
|
|
|
|
|
} //end processed check
|
|
|
|
} //end processed check
|
|
|
|
|
|
|
|
|
|
|
@@ -1269,7 +1294,7 @@ function booking_studygroups_update() {
|
|
|
|
|
|
|
|
|
|
|
|
foreach($working_list as $person)
|
|
|
|
foreach($working_list as $person)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//watchdog('booking', "<pre>Working list person:\n@info</pre>", array('@info' => print_r( $person, true)));
|
|
|
|
//watchdog('booking', "<pre>Working list role person:\n@info</pre>", array('@info' => print_r( $person, true)));
|
|
|
|
|
|
|
|
|
|
|
|
//check to update existing records rather than inserting new one
|
|
|
|
//check to update existing records rather than inserting new one
|
|
|
|
// if already in $group_mapping then just run an update query here
|
|
|
|
// if already in $group_mapping then just run an update query here
|
|
|
@@ -1283,14 +1308,17 @@ function booking_studygroups_update() {
|
|
|
|
$found = TRUE;
|
|
|
|
$found = TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
//if the existing session is not the same as our newly calculated session, run an update query
|
|
|
|
//if the existing session is not the same as our newly calculated session, run an update query
|
|
|
|
if ($mapping->booking_session_id !== $person->session)
|
|
|
|
if ($mapping->booking_session_id !== $person->session && $group->sid != $reading_group_id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
drupal_set_message(t('Found existing study group session for user !id. Changing old session !old to !session. Role id is !role',
|
|
|
|
$message = t('Found existing study group session for user !id (!name). Changing old session !old to !session. Role id is !role',
|
|
|
|
array('!id' => $person->nid, '!old' => $mapping->booking_session_id, '!session' => $person->session,
|
|
|
|
array('!id' => $person->nid, '!old' => $mapping->booking_session_id, '!session' => $person->session,
|
|
|
|
'!role' => $person->booking_studygroup_role)));
|
|
|
|
'!role' => $person->booking_studygroup_role, '!name' => $person->booking_firstname . " " . $person->booking_lastname));
|
|
|
|
|
|
|
|
$update_messages[] = $message;
|
|
|
|
|
|
|
|
//drupal_set_message($message, 'status', FALSE);
|
|
|
|
|
|
|
|
watchdog('booking', $message);
|
|
|
|
|
|
|
|
|
|
|
|
//update the entry
|
|
|
|
//update the entry
|
|
|
|
|
|
|
|
/*
|
|
|
|
db_update('booking_studygroup_mapping')
|
|
|
|
db_update('booking_studygroup_mapping')
|
|
|
|
->fields(array(
|
|
|
|
->fields(array(
|
|
|
|
'booking_session_id' => $person->session,
|
|
|
|
'booking_session_id' => $person->session,
|
|
|
@@ -1298,7 +1326,27 @@ function booking_studygroups_update() {
|
|
|
|
))
|
|
|
|
))
|
|
|
|
->condition('sid', $mapping->sid)
|
|
|
|
->condition('sid', $mapping->sid)
|
|
|
|
->execute();
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
elseif ($mapping->booking_session_id !== $person->session && $group->sid == $reading_group_id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$message = t('Found existing reading group session for user !id (!name). 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, '!name' => $person->booking_firstname . " " . $person->booking_lastname));
|
|
|
|
|
|
|
|
$update_messages[] = $message;
|
|
|
|
|
|
|
|
//drupal_set_message($message, 'status', FALSE);
|
|
|
|
|
|
|
|
watchdog('booking', $message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//update the entry
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
db_update('booking_studygroup_mapping')
|
|
|
|
|
|
|
|
->fields(array(
|
|
|
|
|
|
|
|
'booking_session_id' => $person->session,
|
|
|
|
|
|
|
|
'booking_studygroup_role' => $person->booking_studygroup_role,
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
->condition('sid', $mapping->sid)
|
|
|
|
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@@ -1314,8 +1362,13 @@ function booking_studygroups_update() {
|
|
|
|
//if we didn't find an existing record, add it to the list to insert
|
|
|
|
//if we didn't find an existing record, add it to the list to insert
|
|
|
|
if (! $found && $person->session <> 0)
|
|
|
|
if (! $found && $person->session <> 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
drupal_set_message(t('Found no existing study group session for user id !id. Adding to list of inserts.',
|
|
|
|
$message = t('Found no existing study group session for user id !id (!name). Adding to list of inserts.',
|
|
|
|
array('!id' => $person->nid, '!sid' => $mapping->sid, '!session' => $person->session)));
|
|
|
|
array('!id' => $person->nid, '!sid' => $mapping->sid, '!session' => $person->session,
|
|
|
|
|
|
|
|
'!name' => $person->booking_firstname . " " . $person->booking_lastname
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
//drupal_set_message($message, 'status', FALSE);
|
|
|
|
|
|
|
|
$update_messages[] = $message;
|
|
|
|
|
|
|
|
watchdog('booking', $message);
|
|
|
|
|
|
|
|
|
|
|
|
$record = array(
|
|
|
|
$record = array(
|
|
|
|
'booking_eventid' => $event->eid,
|
|
|
|
'booking_eventid' => $event->eid,
|
|
|
@@ -1328,7 +1381,7 @@ function booking_studygroups_update() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$insert_query->execute();
|
|
|
|
//$insert_query->execute();
|
|
|
|
|
|
|
|
|
|
|
|
//watchdog('booking', "<pre>Session statistics list:\n@info</pre>", array('@info' => print_r( $session_count, true)));
|
|
|
|
//watchdog('booking', "<pre>Session statistics list:\n@info</pre>", array('@info' => print_r( $session_count, true)));
|
|
|
|
|
|
|
|
|
|
|
@@ -1340,8 +1393,44 @@ function booking_studygroups_update() {
|
|
|
|
|
|
|
|
|
|
|
|
} //finished processing study groups
|
|
|
|
} //finished processing study groups
|
|
|
|
|
|
|
|
|
|
|
|
booking_studygroups_process_colours();
|
|
|
|
//make sure to update team colours if necessary
|
|
|
|
|
|
|
|
if ($sid == $reading_group_id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
booking_studygroups_process_colours();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//watchdog('booking', "Attendee list final version: @info", array('@info' => var_export($attendees, TRUE)));
|
|
|
|
//watchdog('booking', "Attendee list final version: @info", array('@info' => var_export($attendees, TRUE)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$form['log'] = array(
|
|
|
|
|
|
|
|
'#type' => 'fieldset',
|
|
|
|
|
|
|
|
'#title' => 'Calculated Actions',
|
|
|
|
|
|
|
|
'#collapsible' => TRUE,
|
|
|
|
|
|
|
|
'#collapsed' => TRUE,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$form['log']['messages'] = array(
|
|
|
|
|
|
|
|
'#type' => 'item',
|
|
|
|
|
|
|
|
'#title' => '',
|
|
|
|
|
|
|
|
'#markup' => "<p>" . implode("<br />\n", $calculation_messages) . "</p>",
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$form['result'] = array(
|
|
|
|
|
|
|
|
'#type' => 'fieldset',
|
|
|
|
|
|
|
|
'#title' => 'Generated Updates',
|
|
|
|
|
|
|
|
'#collapsible' => TRUE,
|
|
|
|
|
|
|
|
'#collapsed' => FALSE,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$form['result']['messages'] = array(
|
|
|
|
|
|
|
|
'#type' => 'item',
|
|
|
|
|
|
|
|
'#title' => '',
|
|
|
|
|
|
|
|
'#markup' => "<p>" . implode("<br />\n", $update_messages) . "</p>",
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return array (
|
|
|
|
|
|
|
|
'first_para' => array (
|
|
|
|
|
|
|
|
'#type' => 'markup',
|
|
|
|
|
|
|
|
'#markup' => $prefix,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
'form' => $form,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|