continue work on manual allocation flag
This commit is contained in:
@@ -702,14 +702,9 @@ function booking_studygroups_calculate() {
|
|||||||
// $session_count[$i] = 0;
|
// $session_count[$i] = 0;
|
||||||
|
|
||||||
//search for the leaders and helpers for this study group
|
//search for the leaders and helpers for this study group
|
||||||
foreach ($group_mapping as $person)
|
foreach ($group_mapping as $person) {
|
||||||
{
|
|
||||||
//if ($person->booking_studygroup_id == $group->sid && ($person->booking_is_leader == 'Y' || $person->booking_is_helper == 'Y' ||
|
|
||||||
// $person->booking_is_reserveleader == 'Y'))
|
|
||||||
|
|
||||||
//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
|
||||||
if ($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0)
|
if ($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0) {
|
||||||
{
|
|
||||||
drupal_set_message(t('Leader/helper with id !id assigned to session !session (currently with !num people).',
|
drupal_set_message(t('Leader/helper 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'])
|
||||||
@@ -723,8 +718,7 @@ function booking_studygroups_calculate() {
|
|||||||
$spouse_id = $working_list[$person->booking_node_id]->booking_partner_id;
|
$spouse_id = $working_list[$person->booking_node_id]->booking_partner_id;
|
||||||
$bf_gf_id = $working_list[$person->booking_node_id]->booking_bf_gf_nid;
|
$bf_gf_id = $working_list[$person->booking_node_id]->booking_bf_gf_nid;
|
||||||
|
|
||||||
if ($spouse_id > 0)
|
if ($spouse_id > 0) {
|
||||||
{
|
|
||||||
drupal_set_message(t('Spouse with id !id assigned to session !session (currently with !num people).',
|
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,
|
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'])
|
||||||
@@ -733,8 +727,7 @@ function booking_studygroups_calculate() {
|
|||||||
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
||||||
_booking_assign_attendee_group($spouse_id, $person->booking_session_id, 'female', $age, $working_list, $session_count);
|
_booking_assign_attendee_group($spouse_id, $person->booking_session_id, 'female', $age, $working_list, $session_count);
|
||||||
}
|
}
|
||||||
elseif ($bf_gf_id > 0)
|
elseif ($bf_gf_id > 0) {
|
||||||
{
|
|
||||||
drupal_set_message(t('BF/GF with id !id assigned to session !session (currently with !num people).',
|
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,
|
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'])
|
||||||
@@ -765,8 +758,9 @@ function booking_studygroups_calculate() {
|
|||||||
//iterate over the attendee list
|
//iterate over the attendee list
|
||||||
while ($it->valid()) {
|
while ($it->valid()) {
|
||||||
//cycle the session counter if we already reached the end
|
//cycle the session counter if we already reached the end
|
||||||
if ($i > $group->booking_num_group_sessions)
|
if ($i > $group->booking_num_group_sessions) {
|
||||||
$i = 1;
|
$i = 1;
|
||||||
|
}
|
||||||
|
|
||||||
//get the current attendee element
|
//get the current attendee element
|
||||||
$current = $it->current();
|
$current = $it->current();
|
||||||
@@ -842,19 +836,16 @@ function booking_studygroups_calculate() {
|
|||||||
$insert_query = db_insert('booking_studygroup_mapping')->fields(array('booking_eventid', 'booking_node_id',
|
$insert_query = db_insert('booking_studygroup_mapping')->fields(array('booking_eventid', 'booking_node_id',
|
||||||
'booking_studygroup_id', 'booking_session_id', 'booking_studygroup_role'));
|
'booking_studygroup_id', 'booking_session_id', 'booking_studygroup_role'));
|
||||||
|
|
||||||
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 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
|
||||||
|
|
||||||
$found = FALSE;
|
$found = FALSE;
|
||||||
foreach ($group_mapping as $mapping)
|
foreach ($group_mapping as $mapping) {
|
||||||
{
|
|
||||||
//check if we can find a study group session already for this user and this study group (eg Monday Tuesday or Wednesday)
|
//check if we can find a study group session already for this user and this study group (eg Monday Tuesday or Wednesday)
|
||||||
if ($person->nid == $mapping->booking_node_id && $group->sid == $mapping->booking_studygroup_id)
|
if ($person->nid == $mapping->booking_node_id && $group->sid == $mapping->booking_studygroup_id) {
|
||||||
{
|
|
||||||
$found = TRUE;
|
$found = TRUE;
|
||||||
|
|
||||||
//drupal_set_message(t('Found existing study group session for user id !id. Running update query on table id !sid to set session id to !session',
|
//drupal_set_message(t('Found existing study group session for user id !id. Running update query on table id !sid to set session id to !session',
|
||||||
@@ -1048,115 +1039,119 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//search for the leaders helpers, spouses and boyfriend/girlfriend for this study group to pre-allocate
|
//search for the leaders helpers, spouses and boyfriend/girlfriend for this study group to pre-allocate
|
||||||
foreach ($group_mapping as $person)
|
foreach ($group_mapping as $person) {
|
||||||
{
|
|
||||||
//dereference a bunch of fields we'll be using
|
//dereference a bunch of fields we'll be using
|
||||||
$committee_flag = $working_list[$person->booking_node_id]->booking_committee_member;
|
$committee_flag = $working_list[$person->booking_node_id]->booking_committee_member;
|
||||||
|
$manually_allocated_flag = $working_list[$person->booking_node_id]->booking_session_manually_allocated;
|
||||||
$spouse_id = $working_list[$person->booking_node_id]->booking_partner_id;
|
$spouse_id = $working_list[$person->booking_node_id]->booking_partner_id;
|
||||||
$bf_gf_id = $working_list[$person->booking_node_id]->booking_bf_gf_nid;
|
$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';
|
$gender = $working_list[$person->booking_node_id]->booking_gender == 'M' ? 'male' : 'female';
|
||||||
$session_id = $person->booking_session_id;
|
$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 the study group id matches the group we're currently looking at
|
||||||
//or if the group id matches, they are a committee member and this is the readings group
|
if ($person->booking_studygroup_id == $group->sid) {
|
||||||
//if (($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0) ||
|
//if they have a role defined
|
||||||
// ($person->booking_studygroup_id == $group->sid && $committee_flag == 'Y' && $group->sid == $reading_group_id))
|
//or if they are a committee member and this is the readings group
|
||||||
if (($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0) ||
|
//or if the manually allocated flag is set
|
||||||
($person->booking_studygroup_id == $group->sid && $committee_flag == 'Y' && $group->booking_is_readinggroup == 'Y'))
|
//then make sure they stay where they are
|
||||||
{
|
if (($person->booking_studygroup_role > 0) ||
|
||||||
$calculation_messages[] = t('Leader/helper/committee with id !id assigned to session !session (currently with !num people).',
|
($committee_flag == 'Y' && $group->booking_is_readinggroup == 'Y') ||
|
||||||
array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
|
($manually_allocated_flag == 'Y')) {
|
||||||
'!num' => $session_count[$person->booking_session_id]['total'])
|
|
||||||
);
|
|
||||||
|
|
||||||
//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);
|
|
||||||
_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
|
$calculation_messages[] = t('Leader/helper/committee with id !id assigned to session !session (currently with !num people).',
|
||||||
if ($spouse_id > 0)
|
array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
|
||||||
{
|
|
||||||
//also mark their spouse as allocated to this group
|
|
||||||
$calculation_messages[] = 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'])
|
'!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, $calculation_messages);
|
|
||||||
}
|
|
||||||
elseif ($bf_gf_id > 0)
|
|
||||||
{
|
|
||||||
//also mark their boyfriend/girlfriend as allocated to this group
|
|
||||||
$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,
|
|
||||||
'!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, $calculation_messages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//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
|
//mark this position as being used
|
||||||
$calculation_messages[] = t('Married person with id !id assigned to session !session (currently with !num people).',
|
$working_list[$person->booking_node_id]->booking_studygroup_role = $person->booking_studygroup_role;
|
||||||
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);
|
$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, $calculation_messages);
|
_booking_assign_attendee_group($person->booking_node_id, $session_id, 'male', $age, $working_list, $session_count, $calculation_messages);
|
||||||
|
|
||||||
//also mark their spouse as allocated to this group
|
//make sure the leader/helper's partner gets updated now, otherwise they could still end up in different groups
|
||||||
$calculation_messages[] = t('Spouse with id !id assigned to session !session (currently with !num people).',
|
if ($spouse_id > 0)
|
||||||
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
{
|
||||||
'!num' => $session_count[$person->booking_session_id]['total'])
|
//also mark their spouse as allocated to this group
|
||||||
);
|
$calculation_messages[] = t('Spouse with id !id assigned to session !session (currently with !num people).',
|
||||||
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
||||||
$spouse_gender = $working_list[$spouse_id]->booking_gender == 'M' ? 'male' : 'female';
|
'!num' => $session_count[$person->booking_session_id]['total'])
|
||||||
_booking_assign_attendee_group($spouse_id, $session_id, $spouse_gender, $age, $working_list, $session_count, $calculation_messages);
|
);
|
||||||
}
|
$age = _booking_get_age_years($working_list[$spouse_id]->booking_dob);
|
||||||
elseif ($bf_gf_id > 0)
|
$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, $calculation_messages);
|
||||||
//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;
|
|
||||||
}
|
}
|
||||||
|
elseif ($bf_gf_id > 0)
|
||||||
|
{
|
||||||
|
//also mark their boyfriend/girlfriend as allocated to this group
|
||||||
|
$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,
|
||||||
|
'!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, $calculation_messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//anyone else already assigned to this group previously
|
||||||
|
elseif ($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
|
||||||
|
$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,
|
||||||
|
'!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, $session_id, $gender, $age, $working_list, $session_count, $calculation_messages);
|
||||||
|
|
||||||
|
//also mark their spouse as allocated to this group
|
||||||
|
$calculation_messages[] = 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, $calculation_messages);
|
||||||
|
}
|
||||||
|
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
|
//mark this person as allocated to this group
|
||||||
$calculation_messages[] = 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, $calculation_messages);
|
_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
|
||||||
$calculation_messages[] = 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, $calculation_messages);
|
_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
|
||||||
{
|
{
|
||||||
$working_list[$person->booking_node_id]->session = $session_id;
|
$working_list[$person->booking_node_id]->session = $session_id;
|
||||||
}
|
}
|
||||||
} //end looking at people with spouse or bf/gf
|
} //end looking at people with spouse or bf/gf
|
||||||
|
} //end checking for matching study group id
|
||||||
} //end searching for people to pre-allocate
|
} //end searching for people to pre-allocate
|
||||||
|
|
||||||
//watchdog('booking', "<pre>Attendee list working copy after pre-processing:\n@info</pre>", array('@info' => print_r( $working_list, true)));
|
//watchdog('booking', "<pre>Attendee list working copy after pre-processing:\n@info</pre>", array('@info' => print_r( $working_list, true)));
|
||||||
|
Reference in New Issue
Block a user