continue work on manual allocation flag
This commit is contained in:
@@ -702,14 +702,9 @@ function booking_studygroups_calculate() {
|
||||
// $session_count[$i] = 0;
|
||||
|
||||
//search for the leaders and helpers for this study group
|
||||
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'))
|
||||
|
||||
foreach ($group_mapping as $person) {
|
||||
//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).',
|
||||
array('!id' => $person->booking_node_id, '!session' => $person->booking_session_id,
|
||||
'!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;
|
||||
$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).',
|
||||
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
||||
'!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);
|
||||
_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).',
|
||||
array('!id' => $bf_gf_id, '!session' => $person->booking_session_id,
|
||||
'!num' => $session_count[$person->booking_session_id]['total'])
|
||||
@@ -765,8 +758,9 @@ function booking_studygroups_calculate() {
|
||||
//iterate over the attendee list
|
||||
while ($it->valid()) {
|
||||
//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;
|
||||
}
|
||||
|
||||
//get the current attendee element
|
||||
$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',
|
||||
'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)));
|
||||
|
||||
//check to update existing records rather than inserting new one
|
||||
// if already in $group_mapping then just run an update query here
|
||||
|
||||
$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)
|
||||
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;
|
||||
|
||||
//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,22 +1039,25 @@ 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
|
||||
foreach ($group_mapping as $person)
|
||||
{
|
||||
foreach ($group_mapping as $person) {
|
||||
//dereference a bunch of fields we'll be using
|
||||
$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;
|
||||
$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
|
||||
//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) ||
|
||||
// ($person->booking_studygroup_id == $group->sid && $committee_flag == 'Y' && $group->sid == $reading_group_id))
|
||||
if (($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0) ||
|
||||
($person->booking_studygroup_id == $group->sid && $committee_flag == 'Y' && $group->booking_is_readinggroup == 'Y'))
|
||||
{
|
||||
//if the study group id matches the group we're currently looking at
|
||||
if ($person->booking_studygroup_id == $group->sid) {
|
||||
//if they have a role defined
|
||||
//or if they are a committee member and this is the readings group
|
||||
//or if the manually allocated flag is set
|
||||
//then make sure they stay where they are
|
||||
if (($person->booking_studygroup_role > 0) ||
|
||||
($committee_flag == 'Y' && $group->booking_is_readinggroup == 'Y') ||
|
||||
($manually_allocated_flag == 'Y')) {
|
||||
|
||||
$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,
|
||||
'!num' => $session_count[$person->booking_session_id]['total'])
|
||||
@@ -1099,7 +1093,7 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
}
|
||||
}
|
||||
//anyone else already assigned to this group previously
|
||||
elseif ($person->booking_studygroup_id == $group->sid && $working_list[$person->booking_node_id]->processed == 0)
|
||||
elseif ($working_list[$person->booking_node_id]->processed == 0)
|
||||
{
|
||||
if ($spouse_id > 0)
|
||||
{
|
||||
@@ -1157,6 +1151,7 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
$working_list[$person->booking_node_id]->session = $session_id;
|
||||
}
|
||||
} //end looking at people with spouse or bf/gf
|
||||
} //end checking for matching study group id
|
||||
} //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)));
|
||||
|
Reference in New Issue
Block a user