commence work on manual allocation flag

This commit is contained in:
Nathan Coad
2016-06-23 16:25:55 +10:00
parent ccac5cd293
commit f7c5a15108
3 changed files with 46 additions and 28 deletions

View File

@@ -566,6 +566,15 @@ function booking_update_7235() {
//update the view to match the new table definition //update the view to match the new table definition
_booking_node_create_mysqlview(); _booking_node_create_mysqlview();
} }
/**
* Add flag to indicate a studygroup session has been manually assigned
*/
function booking_update_7236() {
$spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N');
db_add_field('booking_studygroup_mapping', 'booking_session_manually_allocated', $spec);
//update the view to match the new table definition
_booking_node_create_mysqlview();
}
/** /**
* Implementation of hook_install(). * Implementation of hook_install().
@@ -877,11 +886,13 @@ function booking_schema() {
'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_studygroup_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_studygroup_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_session_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'default' => 0), 'booking_session_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'default' => 0),
'booking_session_manually_allocated' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
'booking_studygroup_role' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE, 'default' => 0), 'booking_studygroup_role' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE, 'default' => 0),
), ),
'primary key' => array('sid'), 'primary key' => array('sid'),
); );
//this table isn't currently in use
$schema['booking_readinggroup_definition'] = array( $schema['booking_readinggroup_definition'] = array(
'fields' => array( 'fields' => array(
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),

View File

@@ -343,6 +343,12 @@ function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) {
unset($reserveleader); unset($reserveleader);
} }
//record whether this was a reading group, so we can update colours if necessary
$form['booking_readinggroup'] = array (
'#type' => 'hidden',
'#value' => $studygroup->booking_is_readinggroup,
);
//close out the form //close out the form
$form['submit'] = array ( $form['submit'] = array (
'#type' => 'submit', '#type' => 'submit',
@@ -454,6 +460,11 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
} //iterate session } //iterate session
} //iterate role type } //iterate role type
//do we need to update colours for reading group?
if ($form_state['values']['booking_readinggroup']) == 'Y') {
booking_studygroups_process_colours();
}
$final_message = "Made $counter updates leader/helper roles for study group id $group_id. Changing one person to another counts as two updates."; $final_message = "Made $counter updates leader/helper roles for study group id $group_id. Changing one person to another counts as two updates.";
drupal_set_message($final_message, 'status', FALSE); drupal_set_message($final_message, 'status', FALSE);
watchdog('booking', "<pre>" . $final_message . "\n" . implode("\n", $update_messages) . "</pre>"); watchdog('booking', "<pre>" . $final_message . "\n" . implode("\n", $update_messages) . "</pre>");

View File

@@ -560,6 +560,7 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
foreach ($reading_groups as $group) { foreach ($reading_groups as $group) {
if ($group->sid == $key) { if ($group->sid == $key) {
booking_studygroups_process_colours(); booking_studygroups_process_colours();
break;
} }
} }
} }
@@ -585,6 +586,7 @@ function booking_studygroups_edit_form_submit($form, &$form_state) {
foreach ($reading_groups as $group) { foreach ($reading_groups as $group) {
if ($group->sid == $key) { if ($group->sid == $key) {
booking_studygroups_process_colours(); booking_studygroups_process_colours();
break;
} }
} }
} //end new value check } //end new value check
@@ -1550,7 +1552,7 @@ function booking_studygroups_printview_form($node, &$form_state, $group_id) {
*/ */
function booking_studygroups_view_form($node, &$form_state, $group_id) { function booking_studygroups_view_form($node, &$form_state, $group_id) {
global $event; global $event;
$is_reading_group = FALSE; //$is_reading_group = FALSE;
$form = array(); $form = array();
$options = array(); $options = array();
$rows = array(); $rows = array();
@@ -1580,18 +1582,12 @@ function booking_studygroups_view_form($node, &$form_state, $group_id) {
array(':eid' => $event->eid, ':sid' => $group_id)) array(':eid' => $event->eid, ':sid' => $group_id))
->fetchObject(); ->fetchObject();
if (! $group) if (! $group) {
{
drupal_set_message("Error: Could not find matching study group ID. Unable to view group membership.", 'error', FALSE); drupal_set_message("Error: Could not find matching study group ID. Unable to view group membership.", 'error', FALSE);
drupal_goto('admin/config/booking'); drupal_goto('admin/config/booking');
return ""; return "";
} }
/*
if ($group_id == variable_get('booking_readinggroup_id','7'))
{
$is_reading_group = TRUE;
}
*/
$header = array( $header = array(
'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'), 'booking_session_id' => array('data' => t('Study Group Session'), 'field' => 'm.booking_session_id', 'sort' => 'asc'),
'booking_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname'), 'booking_name' => array('data' => t('Name'), 'field' => 'p.booking_lastname'),