work on form to edit registration for variety sessions
This commit is contained in:
@@ -462,6 +462,14 @@ function booking_menu() {
|
|||||||
'access arguments' => array('edit variety sessions'),
|
'access arguments' => array('edit variety sessions'),
|
||||||
'type' => MENU_CALLBACK,
|
'type' => MENU_CALLBACK,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$items['admin/config/booking/variety/registration/%/edit'] = array(
|
||||||
|
'title' => 'Edit Variety Session Registration',
|
||||||
|
'page callback' => 'drupal_get_form',
|
||||||
|
'page arguments' => array('booking_variety_regn_edit_form', 5),
|
||||||
|
'access arguments' => array('edit variety sessions'),
|
||||||
|
'type' => MENU_CALLBACK,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//configure study groups
|
//configure study groups
|
||||||
|
@@ -457,6 +457,8 @@ function booking_variety_sessions_view_summary() {
|
|||||||
foreach ($timeslot_list as $timeslot) {
|
foreach ($timeslot_list as $timeslot) {
|
||||||
$header[] = $timeslot->booking_variety_time_descrip;
|
$header[] = $timeslot->booking_variety_time_descrip;
|
||||||
}
|
}
|
||||||
|
// Add a link at the end to edit a variety session registration
|
||||||
|
$header[] = "Edit Session Registrations";
|
||||||
|
|
||||||
$person_query = db_query("SELECT * FROM {booking_person_view} WHERE booking_status = 1 " .
|
$person_query = db_query("SELECT * FROM {booking_person_view} WHERE booking_status = 1 " .
|
||||||
" ORDER BY booking_lastname, booking_firstname")->fetchAllAssoc('nid');
|
" ORDER BY booking_lastname, booking_firstname")->fetchAllAssoc('nid');
|
||||||
@@ -472,9 +474,9 @@ function booking_variety_sessions_view_summary() {
|
|||||||
//get details of the person's variety session for this timeslot
|
//get details of the person's variety session for this timeslot
|
||||||
$vid = $session_ids[$timeslot->tid];
|
$vid = $session_ids[$timeslot->tid];
|
||||||
|
|
||||||
watchdog('booking_debug', 'Person @nid in timeslot @tid registered for session id @vid', array(
|
//watchdog('booking_debug', 'Person @nid in timeslot @tid registered for session id @vid', array(
|
||||||
'@nid' => $person->nid, '@tid' => $timeslot->tid, '@vid' => $vid,
|
// '@nid' => $person->nid, '@tid' => $timeslot->tid, '@vid' => $vid,
|
||||||
));
|
//));
|
||||||
|
|
||||||
// in case the person is somehow registered for a session that no longer exists
|
// in case the person is somehow registered for a session that no longer exists
|
||||||
if (isset($sessions[$vid])) {
|
if (isset($sessions[$vid])) {
|
||||||
@@ -483,13 +485,14 @@ function booking_variety_sessions_view_summary() {
|
|||||||
else {
|
else {
|
||||||
$text = "";
|
$text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$newline[] = $text;
|
$newline[] = $text;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$newline[] = "";
|
$newline[] = "";
|
||||||
}
|
}
|
||||||
} //end iterate variety session timeslot list
|
} //end iterate variety session timeslot list
|
||||||
|
$newline[] = l('Edit', t('admin/config/booking/variety/!tid/csv', array('!tid' => $data->tid))),
|
||||||
|
|
||||||
//add the line to the array of rows
|
//add the line to the array of rows
|
||||||
$rows[] = $newline;
|
$rows[] = $newline;
|
||||||
} //end iterate person list
|
} //end iterate person list
|
||||||
@@ -610,3 +613,99 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
|||||||
print $csv;
|
print $csv;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the admin form for editing variety session registrations
|
||||||
|
*/
|
||||||
|
function booking_variety_regn_edit_form($node, &$form_state, $variety_regn_id)
|
||||||
|
{
|
||||||
|
global $event;
|
||||||
|
$form = array();
|
||||||
|
$data = $node;
|
||||||
|
$redirect_path = "admin/config/booking/variety/report";
|
||||||
|
$prefix = "<h3>Edit variety session registration for user</p>"
|
||||||
|
|
||||||
|
//verify that $variety_regn_id is a number
|
||||||
|
if (! preg_match('/^[0-9]+$/', $variety_regn_id)) {
|
||||||
|
drupal_set_message("Error: Invalid variety session registration ID supplied. Unable to update variety session registration for user.", 'error', FALSE);
|
||||||
|
drupal_goto($redirect_path);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$variety_session_query = db_query("SELECT r.*, p.* FROM {booking_variety_regn} r
|
||||||
|
inner join {booking_person} p on p.nid = r.booking_person_nid
|
||||||
|
WHERE p.booking_eventid = :eid AND r.booking_person_nid = :rid",
|
||||||
|
array(':eid' => $event->eid, ':rid' => $variety_regn_id));
|
||||||
|
$session_details = $variety_session_query->fetchAll();
|
||||||
|
|
||||||
|
if (! $session_details) {
|
||||||
|
drupal_set_message("Error: Unable to find matching variety session registration ID. Unable to update variety session registration for user.", 'error', FALSE);
|
||||||
|
drupal_goto($redirect_path);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$session_ids = drupal_json_decode($session_details->booking_variety_ids);
|
||||||
|
|
||||||
|
// Query the variety timeslot table so we know how many select elements to create
|
||||||
|
$timeslot_query = db_select('booking_variety_timeslots', 'v');
|
||||||
|
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||||
|
->fields('v')
|
||||||
|
->orderBy('v.booking_variety_start');
|
||||||
|
$timeslot_result = $timeslot_query->execute();
|
||||||
|
|
||||||
|
|
||||||
|
//define the form for variety session configuration if we're not deleting a session
|
||||||
|
if(!isset($form_state['storage']['confirm'])) {
|
||||||
|
$form[] = array (
|
||||||
|
'first_heading' => array(
|
||||||
|
'#type' => 'markup',
|
||||||
|
'#markup' => $prefix,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
//add this to the form in a hidden field so we can update the right event
|
||||||
|
$form['rid'] = array (
|
||||||
|
'#type' => 'hidden',
|
||||||
|
'#value' => $variety_regn_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['variety-sessions'] = array(
|
||||||
|
'#type' => 'fieldset',
|
||||||
|
'#title' => 'Select Variety Sessions',
|
||||||
|
'#prefix' => '<div id="booking_variety_session_fieldset_wrapper">',
|
||||||
|
'#suffix' => '</div>'
|
||||||
|
);
|
||||||
|
|
||||||
|
//for each entry in the variety timeslot table, create a new form select item
|
||||||
|
foreach($timeslot_result as $timeslot) {
|
||||||
|
$fieldname = 'select-variety-' . $timeslot->tid;
|
||||||
|
|
||||||
|
//create the form element for this timeslot
|
||||||
|
$form['variety-sessions'][$fieldname] = array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||||
|
'#required' => TRUE,
|
||||||
|
'#default_value' => isset($form_state['values'][$fieldname]) ? $form_state['values'][$fieldname] : $session_ids[$timeslot->$tid],
|
||||||
|
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form['Update'] = array(
|
||||||
|
'#type' => 'submit',
|
||||||
|
'#value' => t('Update Session Registration'),
|
||||||
|
);
|
||||||
|
$form['Delete'] = array(
|
||||||
|
'#type' => 'submit',
|
||||||
|
'#value' => t('Delete Session Registration'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return array (
|
||||||
|
'form' => $form,
|
||||||
|
);
|
||||||
|
} //end checking for delete confirmation
|
||||||
|
else {
|
||||||
|
return confirm_form($form, "Are you sure you wish to delete all variety session registrations for id " . $variety_regn_id . "?",
|
||||||
|
current_path(), NULL, "Delete Session");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user