initial work on variety session report
This commit is contained in:
@@ -133,6 +133,12 @@ function booking_permission() {
|
||||
'edit room allocations' => array(
|
||||
'title' => t('Edit Room Allocations'),
|
||||
),
|
||||
'view variety sessions' => array(
|
||||
'title' => t('View Variety Sessions'),
|
||||
),
|
||||
'edit variety sessions' => array(
|
||||
'title' => t('Edit Variety Sessions'),
|
||||
),
|
||||
'create_travel_forms' => array(
|
||||
'title' => t('Create a new travel form entry'),
|
||||
),
|
||||
@@ -367,8 +373,7 @@ function booking_menu() {
|
||||
|
||||
//show flight info report only if we have passport info enabled
|
||||
//now deprecated
|
||||
if (variable_get('booking_enable_passport', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_passport', 0) == 1) {
|
||||
$items['admin/booking/flights'] = array(
|
||||
'title' => 'Booking View Flights',
|
||||
'description' => 'View Internal Flight Bookings',
|
||||
@@ -378,17 +383,7 @@ function booking_menu() {
|
||||
);
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_variety_sessions', 0) == 1)
|
||||
{
|
||||
$items['admin/config/booking/variety'] = array(
|
||||
'title' => 'Booking module variety sessions',
|
||||
'description' => 'Configure variety sessions for the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_admin'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
//'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
if (variable_get('booking_enable_variety_sessions', 0) == 1) {
|
||||
$items['variety'] = array(
|
||||
'title' => $bookingTitle . ' Variety Sessions',
|
||||
'page callback' => 'drupal_get_form',
|
||||
@@ -396,23 +391,40 @@ function booking_menu() {
|
||||
'access arguments' => array('access booking form'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
//configure variety sessions
|
||||
|
||||
$items['admin/config/booking/variety'] = array(
|
||||
'title' => 'Booking module variety sessions',
|
||||
'description' => 'Configure variety sessions for the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_admin'),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/create'] = array(
|
||||
'title' => 'Add New Variety Session Timeslot',
|
||||
'description' => 'Add variety session timeslot for the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
//'page arguments' => array('booking_price_create'),
|
||||
'page arguments' => array('booking_variety_timeslot_form', true),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/report'] = array(
|
||||
'title' => 'View Variety Session Registrations',
|
||||
'description' => 'View Variety Session Registrations for the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_sessions_view_summary', true),
|
||||
'access arguments' => array('view variety sessions'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/%/edit'] = array(
|
||||
'title' => 'Edit Variety Session Timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_timeslot_form', false, 4),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
@@ -420,7 +432,7 @@ function booking_menu() {
|
||||
'title' => 'Variety Session CSV',
|
||||
'description' => 'CSV Report of Variety Session Timeslot',
|
||||
'page callback' => 'booking_varietysessions_csv_report',
|
||||
'access arguments' => array('access administration pages'),
|
||||
'access arguments' => array('view variety sessions'),
|
||||
'page arguments' => array(4),
|
||||
//'type' => MENU_CALLBACK,
|
||||
);
|
||||
@@ -430,7 +442,7 @@ function booking_menu() {
|
||||
'description' => 'List variety sessions for the specified timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_list_session_form', 4),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'access arguments' => array('view variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
@@ -439,7 +451,7 @@ function booking_menu() {
|
||||
'description' => 'Add variety session to the specified timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_create_session_form', TRUE, 4),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
@@ -448,7 +460,7 @@ function booking_menu() {
|
||||
'description' => 'Edit variety session for the specified timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_create_session_form', FALSE, 4, 6),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
}
|
||||
@@ -459,8 +471,8 @@ function booking_menu() {
|
||||
$items['admin/config/booking/studygroups'] = array(
|
||||
'title' => 'Booking module Study Group configuration',
|
||||
'description' => 'Define and configure Study Groups for the Booking module',
|
||||
'page callback' => 'booking_studygroups_admin',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'page callback' => 'booking_studygroups_admin',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
@@ -495,8 +507,8 @@ function booking_menu() {
|
||||
$items['admin/booking/studygroups'] = array(
|
||||
'title' => 'View Study Groups',
|
||||
'description' => 'View Study Group memberships',
|
||||
'page callback' => 'booking_studygroups_view_summary',
|
||||
'access arguments' => array("view study groups"),
|
||||
'page callback' => 'booking_studygroups_view_summary',
|
||||
'access arguments' => array("view study groups"),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
@@ -505,16 +517,16 @@ function booking_menu() {
|
||||
$items['admin/booking/studygroups/report/leadershelpers'] = array(
|
||||
'title' => 'View Studygroup Leaders and Helpers',
|
||||
'description' => 'View Studygroup Leaders and Helpers',
|
||||
'page callback' => 'booking_studygroups_leadhelp_view_summary',
|
||||
'access arguments' => array("view study groups"),
|
||||
'page callback' => 'booking_studygroups_leadhelp_view_summary',
|
||||
'access arguments' => array("view study groups"),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/booking/studygroups/calculateleaders'] = array(
|
||||
'title' => 'Calculate Study Group Leaders',
|
||||
'description' => 'Calculate Study Group Leaders and Helpers',
|
||||
'page callback' => 'booking_studygroups_leaders_calculate',
|
||||
'access arguments' => array("edit study groups"),
|
||||
'page callback' => 'booking_studygroups_leaders_calculate',
|
||||
'access arguments' => array("edit study groups"),
|
||||
//'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
|
@@ -14,9 +14,8 @@ function booking_variety_admin() {
|
||||
// tabledrag example http://dropbucket.org/node/204
|
||||
$form = array ();
|
||||
$options = array ();
|
||||
//$prefix = t("<p>!link</p>",
|
||||
// array ('!link' => l('Add New Variety Timeslot', 'admin/config/booking/variety/create')));
|
||||
|
||||
$result = db_query("SELECT * from {booking_variety_timeslots}");
|
||||
|
||||
$header = array (
|
||||
'eid' => t('Event'),
|
||||
'tid' => t('Timeslot ID'),
|
||||
@@ -30,14 +29,12 @@ function booking_variety_admin() {
|
||||
'variety_session_csv' => t('CSV Report'),
|
||||
);
|
||||
|
||||
$result = db_query("SELECT * from {booking_variety_timeslots}");
|
||||
|
||||
foreach($result as $data) {
|
||||
$options[$data->tid] = array (
|
||||
'eid' => $event->booking_eventname,
|
||||
'tid' => $data->tid,
|
||||
'booking_variety_time_descrip' => $data->booking_variety_time_descrip,
|
||||
'booking_variety_status' => $data->booking_variety_status,
|
||||
'booking_variety_status' => $data->booking_variety_status == 1 ? "Enabled" : "Disabled",
|
||||
'booking_variety_start' => date("Y-m-d H:i", $data->booking_variety_start),
|
||||
'booking_variety_end' => date("Y-m-d H:i", $data->booking_variety_end),
|
||||
'variety_edit' => l('Edit Timeslot', t('admin/config/booking/variety/!tid/edit', array('!tid' => $data->tid))),
|
||||
@@ -59,13 +56,9 @@ function booking_variety_admin() {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
function booking_variety_admin_submit($form, &$form_state)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function to add a new variety session timeslot
|
||||
*/
|
||||
function booking_variety_timeslot_form($node, &$form_state, $create, $editid = 0) {
|
||||
global $event;
|
||||
$form = array ();
|
||||
@@ -155,6 +148,9 @@ function booking_variety_timeslot_form($node, &$form_state, $create, $editid = 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to submit data for a new variety session timeslot
|
||||
*/
|
||||
function booking_variety_timeslot_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
@@ -208,6 +204,9 @@ function booking_variety_timeslot_form_submit($form, &$form_state) {
|
||||
$form_state['redirect'] = array('admin/config/booking/variety');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to create or edit a variety session
|
||||
*/
|
||||
function booking_variety_create_session_form($node, &$form_state, $create = TRUE, $timeslot_id = 0, $session_id = 0) {
|
||||
global $event;
|
||||
$form = array ();
|
||||
@@ -306,6 +305,9 @@ function booking_variety_create_session_form($node, &$form_state, $create = TRUE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function submit data for a variety session timeslot
|
||||
*/
|
||||
function booking_variety_create_session_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
@@ -326,6 +328,8 @@ function booking_variety_create_session_form_submit($form, &$form_state) {
|
||||
->condition('vid', $values['booking_session_id'])
|
||||
->execute();
|
||||
|
||||
//TODO : Remove this variety session from anyone registered for it
|
||||
|
||||
drupal_set_message('Deleted variety session id ' . $values['booking_session_id'] );
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
@@ -424,6 +428,75 @@ function booking_variety_list_session_form($node, &$form_state, $timeslot_id = 0
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
$query = db_select('booking_studygroup_list', 's')
|
||||
->fields('s')
|
||||
->condition('s.booking_eventid', $event->eid, '=')
|
||||
->orderBy('sid');
|
||||
$studygroup_list = $query->execute()->fetchAllAssoc('sid');
|
||||
|
||||
//add columns for the study groups
|
||||
foreach ($studygroup_list as $group) {
|
||||
$header[] = $group->booking_studygroup_descrip;
|
||||
}
|
||||
|
||||
$person_query = db_query("SELECT * FROM {booking_person_view} WHERE booking_gender = 'M' " .
|
||||
" AND (booking_status = 1 OR booking_status = 2)" .
|
||||
" ORDER BY booking_lastname, booking_firstname")->fetchAllAssoc('nid');
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function to generate table listing all variety session registrations
|
||||
*/
|
||||
function booking_variety_sessions_view_summary() {
|
||||
global $event;
|
||||
$output = "";
|
||||
$header = array('First Name', 'Last Name');
|
||||
$rows = array();
|
||||
$attributes = array('style' => 'max-width:100%');
|
||||
|
||||
//get variety session timeslot definitions
|
||||
$timeslot_query = db_select('booking_variety_timeslots', 'v');
|
||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||
->fields('v')
|
||||
->orderBy('v.booking_variety_start');
|
||||
$timeslot_list = $timeslot_query->execute()->fetchAllAssoc('tid');
|
||||
|
||||
foreach ($timeslot_list as $timeslot) {
|
||||
$header[] = $timeslot->booking_variety_time_descrip;
|
||||
}
|
||||
|
||||
$person_query = db_query("SELECT * FROM {booking_person_view} WHERE booking_status = 1 " .
|
||||
" ORDER BY booking_lastname, booking_firstname")->fetchAllAssoc('nid');
|
||||
|
||||
//loop through each matching person
|
||||
foreach ($person_query as $person) {
|
||||
//add the name to an array for this line
|
||||
$newline = array($person->booking_firstname, $person->booking_lastname);
|
||||
$session_ids = drupal_json_decode($person->booking_variety_ids);
|
||||
|
||||
foreach ($timeslot_list as $timeslot) {
|
||||
if (isset($session_ids[$timeslot->tid])) {
|
||||
//get details of the person's variety session for this timeslot
|
||||
$sid = $session_ids[$timeslot->tid];
|
||||
$text = "Session description goes here";
|
||||
$newline[] = $text;
|
||||
}
|
||||
else {
|
||||
$newline[] = "";
|
||||
}
|
||||
} //end iterate variety session timeslot list
|
||||
//add the line to the array of rows
|
||||
$rows[] = $newline;
|
||||
} //end iterate person list
|
||||
|
||||
//output everything
|
||||
$output .= t("<h3>!event Variety Session Registrations</h3>", array('!event' => $event->booking_eventname));
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate a CSV file listing the session membership for the specified variety session timeslot
|
||||
*/
|
||||
@@ -431,7 +504,7 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
||||
global $event;
|
||||
$data = array();
|
||||
|
||||
//verify that $group_id is a number
|
||||
//verify that $timeslot_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $timeslot_id)) {
|
||||
drupal_set_message("Error: Invalid variety session timeslot ID '" . $group_id . "' supplied.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
@@ -442,14 +515,13 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
||||
$db_and = db_and();
|
||||
$db_and->condition('v.booking_eventid', $event->eid, '=');
|
||||
$db_and->condition('v.booking_variety_timeslot_id', $timeslot_id, '=');
|
||||
|
||||
$variety_sessions = db_select('booking_variety_sessions', 'v')
|
||||
->condition($db_and)
|
||||
->fields('v')
|
||||
->execute()
|
||||
->fetchAllAssoc('vid');
|
||||
|
||||
watchdog('booking_debug', 'booking_varietysessions_csv_report variety sessions: <pre>@info</pre>', array('@info' => print_r( $variety_sessions, true)));
|
||||
//watchdog('booking_debug', 'booking_varietysessions_csv_report variety sessions: <pre>@info</pre>', array('@info' => print_r( $variety_sessions, true)));
|
||||
if (! $variety_sessions) {
|
||||
drupal_set_message("Error: Could not find matching variety session timeslot. Unable to view session membership.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
@@ -457,7 +529,7 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
||||
}
|
||||
|
||||
//set options for the CSV file
|
||||
$name = 'bookings-variety-sessions-' . format_date(time(), 'custom', 'Y-m-d-His');
|
||||
$name = 'bookings-timeslot-' . $timeslot_id . '-variety-sessions-' . format_date(time(), 'custom', 'Y-m-d-His');
|
||||
$filename = file_directory_temp() . '/' . $name;
|
||||
$csv = '';
|
||||
$delimiter = ',';
|
||||
@@ -467,7 +539,7 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
||||
$delimiter_esc = preg_quote($delimiter, '/');
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
|
||||
//get the list of study group session memberships
|
||||
//get the list of variety session memberships
|
||||
$session_members_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 ORDER BY r.rid",
|
||||
|
Reference in New Issue
Block a user