Updates to studygroups manual assign form
This commit is contained in:
@@ -409,17 +409,30 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
|
||||
//create a new row for each group
|
||||
foreach ($studygroups as $group)
|
||||
{
|
||||
$default = '';
|
||||
$role = '';
|
||||
|
||||
//retrieve the current session id for this group if defined already
|
||||
$default = empty($person_groups[$group->sid]) ? '' : $person_groups[$group->sid]->booking_session_id;
|
||||
if (! empty($person_groups[$group->sid]))
|
||||
{
|
||||
$default = $person_groups[$group->sid]->booking_session_id;
|
||||
//check if the person has an assigned role for this session
|
||||
if ($person_groups[$group->sid]->booking_is_leader == 'Y')
|
||||
$role = "Leader Session #";
|
||||
elseif ($person_groups[$group->sid]->booking_is_helper == 'Y')
|
||||
$role = "Helper Session #";
|
||||
elseif ($person_groups[$group->sid]->booking_is_reserveleader == 'Y')
|
||||
$role = "Reserve Leader Session #";
|
||||
}
|
||||
|
||||
$options[] = array (
|
||||
'booking_studygroup_descrip' => $group->booking_studygroup_descrip,
|
||||
'booking_current_session_id' => $default,
|
||||
'booking_current_session_id' => $default == '' ? 'Not Set' : $role . $default,
|
||||
'booking_session_id' => array('data' => array(
|
||||
'#type' => 'select',
|
||||
'#options' => $session_options,
|
||||
'#value' => $default,
|
||||
'#name' => 'booking_assign_sessionid[' . $nid . ']',
|
||||
'#name' => 'booking_assign_sessionid[' . $group->sid . ']',
|
||||
)
|
||||
),
|
||||
);
|
||||
@@ -429,6 +442,10 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
|
||||
$form['booking_assign_sessionid'] = array( '#type' => 'value', );
|
||||
|
||||
//generate the render array
|
||||
$form['personid'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $nid,
|
||||
);
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $header,
|
||||
@@ -449,6 +466,39 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the submission to manually assign study group sessions for a person
|
||||
*/
|
||||
function booking_studygroups_edit_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$counter = 0;
|
||||
$checkboxes = $form_state['values']['table'];
|
||||
$studygroup_sessionids = $form_state['values']['booking_assign_sessionid'];
|
||||
$values = $form_state['input'];
|
||||
|
||||
//check that $values['personid'] is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['personid'])) {
|
||||
//parameter from url is not what we were expecting
|
||||
drupal_set_message("Error: Invalid form data supplied. Please use the contact us form to let us know.", 'error', FALSE);
|
||||
return "";
|
||||
}
|
||||
$nid = $values['personid'];
|
||||
|
||||
watchdog('booking', "<pre>Study Groups Edit submission:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
|
||||
//select the groups this person is already assigned to, indexed by studygroup id
|
||||
$person_groups_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid AND booking_node_id = :nid",
|
||||
array(':eid' => $event->eid, ':nid' => $nid));
|
||||
$person_groups = $person_groups_query->fetchAllAssoc('booking_studygroup_id');
|
||||
|
||||
//TODO:
|
||||
//
|
||||
//loop through $studygroup_sessionids
|
||||
//compare each value to $person_groups
|
||||
//if there is a difference, update the table
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function for defining the number of study group sessions
|
||||
|
Reference in New Issue
Block a user