Further tweaks for reading groups

This commit is contained in:
2014-06-19 13:07:03 +10:00
parent 478d093bb9
commit 1293dae510
2 changed files with 38 additions and 12 deletions

View File

@@ -101,6 +101,7 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id)
'booking_assign_helper_session' => array('data' => t('Helper Session')),
'booking_assign_reserveleader_session' => array('data' => t('Reserve Leader Session')),
'booking_currently_leadhelp' => array('data' => t('Currently leading/helping')),
'booking_group_edit' => array('data' => t('Edit')),
);
$query = db_select('booking_person', 'p');
@@ -113,11 +114,12 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id)
//also restrict to males from the current event
$db_and = db_and();
$db_and->condition('p.booking_event_id', $event->eid, '=');
$db_and->condition('p.booking_gender', 'M', '=');
//$db_and->condition('p.booking_gender', 'M', '=');
$db_and->condition($db_or);
$query->condition($db_and);
$query->fields('p');
//$query->groupBy('booking_gender');
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
$result = $table_sort->execute();
@@ -174,7 +176,8 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id)
'#value' => $assigned_role == 3 ? $session_id : 0,
)
),
'booking_currently_leadhelp' => $role_listing,
'booking_currently_leadhelp' => $role_listing,
'booking_group_edit' => l(t('Edit'), t('admin/booking/!id/edit-studygroup', array('!id' => $data->nid))),
);
}
@@ -384,9 +387,11 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
$form = array ();
$options = array ();
$rows = array ();
$session_options = array();
$readinggroup_options = array();
$session_options[0] = '';
$readinggroup_options[0] = '';
//verify that $nid is a number
if (! preg_match('/^[0-9]+$/', $nid)) {
@@ -426,9 +431,10 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
for ($i = 1; $i <= $num_sessions; $i++)
{
$session_options[$i] = $i;
$readinggroup_options[$i] = _booking_readinggroup_colour_lookup($i);
}
$session_options['Remove'] = 'Remove';
$readinggroup_options['Remove'] = 'Remove';
//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));
@@ -465,12 +471,21 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
*/
}
$options[] = array (
if ($group->sid == variable_get('booking_readinggroup_id','7'))
{
$options = $readinggroup_options;
}
else
{
$options = $session_options;
}
$rows[] = array (
'booking_studygroup_descrip' => $group->booking_studygroup_descrip,
'booking_current_session_id' => $default == '' ? 'Not Set' : $role . $default,
'booking_session_id' => array('data' => array(
'#type' => 'select',
'#options' => $session_options,
'#options' => $options,
'#value' => $default,
'#name' => 'booking_assign_sessionid[' . $group->sid . ']',
)
@@ -489,7 +504,7 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
$form['table'] = array (
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#options' => $rows,
);
$form['submit'] = array (
'#type' => 'submit',
@@ -1065,16 +1080,19 @@ function booking_studygroups_update() {
//search for the leaders helpers, spouses and boyfriend/girlfriend for this study group to pre-allocate
foreach ($group_mapping as $person)
{
//get any potential spouse or boyfriend/girlfriend
//dereference a bunch of fields we'll be using
$committee_flag = $working_list[$person->booking_node_id]->booking_committee_member;
$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
if ($person->booking_studygroup_id == $group->sid && $person->booking_studygroup_role > 0)
//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 == variable_get('booking_readinggroup_id','7')))
{
drupal_set_message(t('Leader/helper with id !id assigned to session !session (currently with !num people).',
drupal_set_message(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'])
));