tidy up and variety validation work
This commit is contained in:
@@ -93,7 +93,7 @@ function booking_update_7201() {
|
|||||||
* Add table for variety sessions
|
* Add table for variety sessions
|
||||||
*/
|
*/
|
||||||
function booking_update_7202() {
|
function booking_update_7202() {
|
||||||
$booking_variety_options = array(
|
$booking_variety_sessions = array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
@@ -105,7 +105,7 @@ function booking_update_7202() {
|
|||||||
),
|
),
|
||||||
'primary key' => array('vid'),
|
'primary key' => array('vid'),
|
||||||
);
|
);
|
||||||
$booking_variety_times = array(
|
$booking_variety_timeslots = array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
@@ -127,8 +127,8 @@ function booking_update_7202() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
db_create_table('booking_variety_options', $booking_variety_options);
|
db_create_table('booking_variety_sessions', $booking_variety_sessions);
|
||||||
db_create_table('booking_variety_times', $booking_variety_times);
|
db_create_table('booking_variety_timeslots', $booking_variety_timeslots);
|
||||||
db_create_table('booking_variety_regn', $booking_variety_regn);
|
db_create_table('booking_variety_regn', $booking_variety_regn);
|
||||||
|
|
||||||
//TODO: create tables for variety session timeslots and variety session registrations (map user to variety session id)
|
//TODO: create tables for variety session timeslots and variety session registrations (map user to variety session id)
|
||||||
@@ -781,6 +781,17 @@ function booking_update_7253() {
|
|||||||
_booking_node_create_mysqlview();
|
_booking_node_create_mysqlview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change booking_variety_regn field type and rename some tables
|
||||||
|
*/
|
||||||
|
function booking_update_7254() {
|
||||||
|
$spec = array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE);
|
||||||
|
db_change_field('booking_variety_regn', 'booking_variety_id', 'booking_variety_ids', $spec);
|
||||||
|
db_rename_table('booking_variety_times', 'booking_variety_timeslots');
|
||||||
|
db_rename_table('booking_variety_options', 'booking_variety_sessions');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_install().
|
* Implementation of hook_install().
|
||||||
*/
|
*/
|
||||||
@@ -1047,7 +1058,7 @@ function booking_schema() {
|
|||||||
'primary key' => array('payid'),
|
'primary key' => array('payid'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$schema['booking_variety_options'] = array(
|
$schema['booking_variety_sessions'] = array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
@@ -1060,7 +1071,7 @@ function booking_schema() {
|
|||||||
'primary key' => array('vid'),
|
'primary key' => array('vid'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$schema['booking_variety_times'] = array(
|
$schema['booking_variety_timeslots'] = array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||||
@@ -1075,7 +1086,7 @@ function booking_schema() {
|
|||||||
$schema['booking_variety_regn'] = array(
|
$schema['booking_variety_regn'] = 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'),
|
||||||
'booking_variety_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
'booking_variety_ids' => array('type' => 'varchar', 'length' => '1000', 'not null' => TRUE),
|
||||||
'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'),
|
||||||
),
|
),
|
||||||
'primary key' => array('rid'),
|
'primary key' => array('rid'),
|
||||||
|
@@ -408,7 +408,7 @@ function booking_menu() {
|
|||||||
'type' => MENU_LOCAL_ACTION,
|
'type' => MENU_LOCAL_ACTION,
|
||||||
);
|
);
|
||||||
|
|
||||||
$items['admin/config/booking/variety/%/edit'] = array(
|
$items['admin/config/booking/variety/%/edit'] = array(
|
||||||
'title' => 'Edit Variety Session Timeslot',
|
'title' => 'Edit Variety Session Timeslot',
|
||||||
'page callback' => 'drupal_get_form',
|
'page callback' => 'drupal_get_form',
|
||||||
'page arguments' => array('booking_variety_timeslot_form', false, 4),
|
'page arguments' => array('booking_variety_timeslot_form', false, 4),
|
||||||
@@ -416,6 +416,14 @@ function booking_menu() {
|
|||||||
'type' => MENU_CALLBACK,
|
'type' => MENU_CALLBACK,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$items['admin/config/booking/variety/%/csv'] = array(
|
||||||
|
'title' => 'Variety Session CSV',
|
||||||
|
'description' => 'CSV Report of Variety Session Timeslot',
|
||||||
|
'page callback' => 'booking_varietysessions_csv_report',
|
||||||
|
'page arguments' => array(4),
|
||||||
|
//'type' => MENU_CALLBACK,
|
||||||
|
);
|
||||||
|
|
||||||
$items['admin/config/booking/variety/%/session/list'] = array(
|
$items['admin/config/booking/variety/%/session/list'] = array(
|
||||||
'title' => 'List Variety Sessions',
|
'title' => 'List Variety Sessions',
|
||||||
'description' => 'List variety sessions for the specified timeslot',
|
'description' => 'List variety sessions for the specified timeslot',
|
||||||
|
1519
booking.reports.inc
1519
booking.reports.inc
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@ function booking_variety_admin()
|
|||||||
'variety_session_add' => t('Add Session'),
|
'variety_session_add' => t('Add Session'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = db_query("SELECT * from {booking_variety_times}");
|
$result = db_query("SELECT * from {booking_variety_timeslots}");
|
||||||
|
|
||||||
foreach($result as $data)
|
foreach($result as $data)
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ function booking_variety_timeslot_form($node, &$form_state, $create, $editid = 0
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = db_select ('booking_variety_times', 'v')
|
$data = db_select ('booking_variety_timeslots', 'v')
|
||||||
->condition('v.tid', $editid, '=')
|
->condition('v.tid', $editid, '=')
|
||||||
->fields('v')
|
->fields('v')
|
||||||
->execute()
|
->execute()
|
||||||
@@ -165,7 +165,7 @@ function booking_variety_timeslot_form_submit($form, &$form_state) {
|
|||||||
|
|
||||||
if ($form_state['values']['op'] == 'Create')
|
if ($form_state['values']['op'] == 'Create')
|
||||||
{
|
{
|
||||||
db_insert('booking_variety_times')
|
db_insert('booking_variety_timeslots')
|
||||||
->fields(array(
|
->fields(array(
|
||||||
'booking_eventid' => $event->eid,
|
'booking_eventid' => $event->eid,
|
||||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||||
@@ -183,7 +183,7 @@ function booking_variety_timeslot_form_submit($form, &$form_state) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_deleted = db_delete('booking_variety_times')
|
$num_deleted = db_delete('booking_variety_timeslots')
|
||||||
->condition('tid', $values['tid'])
|
->condition('tid', $values['tid'])
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ function booking_variety_timeslot_form_submit($form, &$form_state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//update the event
|
//update the event
|
||||||
db_update('booking_variety_times')
|
db_update('booking_variety_timeslots')
|
||||||
->fields(array (
|
->fields(array (
|
||||||
'booking_eventid' => $event->eid,
|
'booking_eventid' => $event->eid,
|
||||||
'booking_variety_time_descrip' => $values['booking_variety_time_descrip'],
|
'booking_variety_time_descrip' => $values['booking_variety_time_descrip'],
|
||||||
@@ -230,7 +230,7 @@ function booking_variety_create_session_form($node, &$form_state, $timeslot_id =
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$data = db_select ('booking_variety_times', 'v')
|
$data = db_select ('booking_variety_timeslots', 'v')
|
||||||
->condition('v.tid', $editid, '=')
|
->condition('v.tid', $editid, '=')
|
||||||
->fields('v')
|
->fields('v')
|
||||||
->execute()
|
->execute()
|
||||||
@@ -286,7 +286,7 @@ function booking_variety_create_session_form_submit($form, &$form_state) {
|
|||||||
global $event;
|
global $event;
|
||||||
$values = $form_state['input'];
|
$values = $form_state['input'];
|
||||||
|
|
||||||
db_insert('booking_variety_options')
|
db_insert('booking_variety_sessions')
|
||||||
->fields(array(
|
->fields(array(
|
||||||
'booking_eventid' => $event->eid,
|
'booking_eventid' => $event->eid,
|
||||||
'booking_variety_timeslot_id' => $values['tid'],
|
'booking_variety_timeslot_id' => $values['tid'],
|
||||||
@@ -317,8 +317,8 @@ function booking_variety_list_session_form($node, &$form_state, $timeslot_id = 0
|
|||||||
$prefix = t("<p>!link</p>",
|
$prefix = t("<p>!link</p>",
|
||||||
array ('!link' => l('Add New Variety Session', "admin/config/booking/variety/$timeslot_id/session/create")));
|
array ('!link' => l('Add New Variety Session', "admin/config/booking/variety/$timeslot_id/session/create")));
|
||||||
|
|
||||||
$query = db_select ('booking_variety_options', 'v');
|
$query = db_select ('booking_variety_sessions', 'v');
|
||||||
$query->join('booking_variety_times', 't', 'v.booking_variety_timeslot_id = t.tid');
|
$query->join('booking_variety_timeslots', 't', 'v.booking_variety_timeslot_id = t.tid');
|
||||||
$query->condition('v.booking_variety_timeslot_id', $timeslot_id, '=')
|
$query->condition('v.booking_variety_timeslot_id', $timeslot_id, '=')
|
||||||
->fields('v')
|
->fields('v')
|
||||||
->fields('t', array('booking_variety_time_descrip'));
|
->fields('t', array('booking_variety_time_descrip'));
|
||||||
@@ -368,3 +368,121 @@ function booking_variety_edit_session_form()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to generate a CSV file listing the session membership for the specified variety session timeslot
|
||||||
|
*/
|
||||||
|
function booking_varietysessions_csv_report($timeslot_id) {
|
||||||
|
global $event;
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
//verify that $group_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/booking/studygroups');
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - UPDATE FROM HERE ON!
|
||||||
|
|
||||||
|
//retrieve the name of the study group for the specified ID
|
||||||
|
$group = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid and sid = :sid",
|
||||||
|
array(':eid' => $event->eid, ':sid' => $group_id))
|
||||||
|
->fetchObject();
|
||||||
|
|
||||||
|
if (! $group)
|
||||||
|
{
|
||||||
|
drupal_set_message("Error: Could not find matching study group ID. Unable to view group membership.", 'error', FALSE);
|
||||||
|
drupal_goto('admin/booking/studygroups');
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//set options for the CSV file
|
||||||
|
$name = 'bookings-studygroup-' . $group->booking_studygroup_descrip . '-' . format_date(time(), 'custom', 'Y-m-d-His');
|
||||||
|
$filename = file_directory_temp() . '/' . $name;
|
||||||
|
$csv = '';
|
||||||
|
$delimiter = ',';
|
||||||
|
$enclosure = '"';
|
||||||
|
$encloseAll = true;
|
||||||
|
$nullToMysqlNull = true;
|
||||||
|
$delimiter_esc = preg_quote($delimiter, '/');
|
||||||
|
$enclosure_esc = preg_quote($enclosure, '/');
|
||||||
|
|
||||||
|
//get the list of study group session memberships
|
||||||
|
$session_members_query = db_query("SELECT m.*, p.* FROM {booking_studygroup_mapping} m
|
||||||
|
inner join {booking_person} p on p.nid = m.booking_node_id
|
||||||
|
WHERE m.booking_studygroup_id = :sid ORDER BY m.booking_session_id, m.booking_studygroup_role DESC, p.booking_lastname",
|
||||||
|
array(':sid' => $group_id));
|
||||||
|
$session_members = $session_members_query->fetchAll();
|
||||||
|
|
||||||
|
//generate the row data
|
||||||
|
foreach ($session_members as $member) {
|
||||||
|
if (! isset($data[$member->booking_session_id])) {
|
||||||
|
$data[$member->booking_session_id] = array();
|
||||||
|
}
|
||||||
|
// lookup the name and role for this entry in the study group session and optionally include age
|
||||||
|
if (variable_get('booking_studygroup_csv_ages', 0) == 1) {
|
||||||
|
$text = array($member->booking_firstname, $member->booking_lastname, '[' . _booking_get_age_years($member->booking_dob) .']');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$text = array($member->booking_firstname, $member->booking_lastname);
|
||||||
|
}
|
||||||
|
//add their role if they're leading/helping etc
|
||||||
|
if ($member->booking_studygroup_role > 0) {
|
||||||
|
array_push($text, '(' . _booking_studygroup_role_lookup($member->booking_studygroup_role) . ')');
|
||||||
|
}
|
||||||
|
//also tag committee members
|
||||||
|
if ($member->booking_committee_member == 'Y') {
|
||||||
|
array_push($text, '(committee)');
|
||||||
|
}
|
||||||
|
//add the spaces and put this element in the right array
|
||||||
|
$data[$member->booking_session_id][] = implode(' ', $text);
|
||||||
|
|
||||||
|
}
|
||||||
|
//watchdog('booking_debug', "<pre>Study Group CSV Report\n@info</pre>", array('@info' => print_r( $data_array, true)));
|
||||||
|
|
||||||
|
//calculate the CSV layout
|
||||||
|
$header_array = array_keys($data);
|
||||||
|
$maximums = array();
|
||||||
|
$column_headings = array();
|
||||||
|
foreach ($header_array as $column) {
|
||||||
|
$maximums[] = count($data[$column]);
|
||||||
|
//make the column headings a bit more user friendly
|
||||||
|
if ($group->booking_is_readinggroup == 'Y') {
|
||||||
|
$column_headings[] = _booking_readinggroup_colour_lookup($column);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$column_headings[] = "Session " . $column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//add the column headings to the CSV
|
||||||
|
$header = implode( $delimiter, $column_headings );
|
||||||
|
$csv .= $header . "\n";
|
||||||
|
|
||||||
|
//generate each row for the CSV
|
||||||
|
for ($i = 0; $i < max($maximums); $i++) {
|
||||||
|
$output = array();
|
||||||
|
foreach ($header_array as $column) {
|
||||||
|
$field = isset($data[$column][$i]) ? $data[$column][$i] : '';
|
||||||
|
|
||||||
|
//enclose $field if necessary
|
||||||
|
if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field ) ) {
|
||||||
|
$output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$output[] = $field;
|
||||||
|
}
|
||||||
|
} //loop through columns
|
||||||
|
$row = implode($delimiter, $output) . "\n";
|
||||||
|
$csv .= $row;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//output the CSV to the browser
|
||||||
|
drupal_add_http_header("Content-type", "application/octet-stream; charset=utf-8");
|
||||||
|
drupal_add_http_header("Content-Disposition", "attachment; filename=" . $name . ".csv");
|
||||||
|
print $csv;
|
||||||
|
exit(0);
|
||||||
|
}
|
@@ -14,14 +14,14 @@ function booking_variety_regn_form($node, &$form_state)
|
|||||||
$data = $node;
|
$data = $node;
|
||||||
|
|
||||||
// Query the variety timeslot table
|
// Query the variety timeslot table
|
||||||
$timeslot_query = db_select('booking_variety_times', 'v');
|
$timeslot_query = db_select('booking_variety_timeslots', 'v');
|
||||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||||
->fields('v')
|
->fields('v')
|
||||||
->orderBy('v.booking_variety_start');
|
->orderBy('v.booking_variety_start');
|
||||||
$result = $timeslot_query->execute();
|
$result = $timeslot_query->execute();
|
||||||
|
|
||||||
$form['#prefix'] = '<div id="booking_variety_session_form_wrapper">';
|
//$form['#prefix'] = '<div id="booking_variety_session_form_wrapper">';
|
||||||
$form['#suffix'] = '</div>';
|
//$form['#suffix'] = '</div>';
|
||||||
|
|
||||||
$form['identity'] = array(
|
$form['identity'] = array(
|
||||||
'#type' => 'fieldset',
|
'#type' => 'fieldset',
|
||||||
@@ -93,13 +93,14 @@ function _booking_get_variety_timeslot_options($timeslot_id) {
|
|||||||
$session_options = array();
|
$session_options = array();
|
||||||
$session_options[] = "--";
|
$session_options[] = "--";
|
||||||
|
|
||||||
$session_query = db_query("SELECT * FROM {booking_variety_options} WHERE booking_variety_timeslot_id = :tid AND booking_variety_status = 1",
|
$session_query = db_query("SELECT * FROM {booking_variety_sessions} WHERE booking_variety_timeslot_id = :tid AND booking_variety_status = 1",
|
||||||
array(':tid' => $timeslot_id));
|
array(':tid' => $timeslot_id));
|
||||||
|
|
||||||
// Only add sessions that aren't full to the return result
|
// Only add sessions that aren't full to the return result
|
||||||
foreach($session_query as $session) {
|
foreach($session_query as $session) {
|
||||||
if ($session->booking_variety_regncount < $session->booking_variety_maxsize) {
|
$available_spots = $session->booking_variety_maxsize - $session->booking_variety_regncount;
|
||||||
$session_options[$session->vid] = $session->booking_variety_descrip;
|
if ($available_spots > 0) {
|
||||||
|
$session_options[$session->vid] = $session->booking_variety_descrip . " [" . $available_spots . " spots]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//watchdog('booking_debug', "<pre>Variety Session Options:\n@info</pre>", array('@info' => print_r( $session_options, true)));
|
//watchdog('booking_debug', "<pre>Variety Session Options:\n@info</pre>", array('@info' => print_r( $session_options, true)));
|
||||||
@@ -124,8 +125,6 @@ function booking_variety_regn_form_validate($form, &$form_state) {
|
|||||||
$values = $form_state['input'];
|
$values = $form_state['input'];
|
||||||
//watchdog('booking_debug', 'booking_variety_regn_form_submit: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
//watchdog('booking_debug', 'booking_variety_regn_form_submit: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
||||||
|
|
||||||
//TODO : Check that the booking number is valid for this event
|
|
||||||
|
|
||||||
//verify that user-entered data is a number
|
//verify that user-entered data is a number
|
||||||
if (! preg_match('/^[0-9]+$/', $values['booking_nid'])) {
|
if (! preg_match('/^[0-9]+$/', $values['booking_nid'])) {
|
||||||
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
||||||
@@ -146,6 +145,29 @@ function booking_variety_regn_form_validate($form, &$form_state) {
|
|||||||
if (! $person) {
|
if (! $person) {
|
||||||
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Check there is still space available in the selected variety sessions ---
|
||||||
|
|
||||||
|
//get a list of timeslot IDs from matching form values
|
||||||
|
$variety_timeslot_ids = preg_filter('/^select-variety-(\d+)/', '$1', array_keys( $values ));
|
||||||
|
|
||||||
|
//query the sessions table
|
||||||
|
$sessions_query = db_query("SELECT * FROM {booking_variety_sessions} WHERE booking_eventid = :eid",
|
||||||
|
array(':eid' => $event->eid));
|
||||||
|
$sessions = $sessions_query->fetchAllAssoc('vid');
|
||||||
|
|
||||||
|
watchdog('booking_debug', 'booking_variety_regn_form_validate sessions query: <pre>@info</pre>', array('@info' => print_r( $sessions, true)));
|
||||||
|
|
||||||
|
//check there is still room
|
||||||
|
foreach ($variety_timeslot_ids as $id) {
|
||||||
|
$selected_session_id = $values['select-variety-' . $id];
|
||||||
|
|
||||||
|
if ($sessions[$selected_session_id]->booking_variety_regncount < $sessions[$selected_session_id]->booking_variety_maxsize) {
|
||||||
|
watchdog('booking_debug', 'Still room in session ' . $selected_session_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,4 +177,7 @@ function booking_variety_regn_form_submit($form, &$form_state) {
|
|||||||
global $event;
|
global $event;
|
||||||
$values = $form_state['input'];
|
$values = $form_state['input'];
|
||||||
watchdog('booking_debug', 'booking_variety_regn_form_submit: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
watchdog('booking_debug', 'booking_variety_regn_form_submit: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
||||||
|
|
||||||
|
//use an update query for the regncount field
|
||||||
|
//based on update booking_variety_sessions set booking_variety_regncount = booking_variety_regncount+1 where vid = 1;
|
||||||
}
|
}
|
@@ -48,7 +48,7 @@ function booking_variety_session_callback($form, &$form_state) {
|
|||||||
|
|
||||||
// --- Update the wrapper for available variety sessions ---
|
// --- Update the wrapper for available variety sessions ---
|
||||||
// Query the variety timeslot table
|
// Query the variety timeslot table
|
||||||
$timeslot_query = db_select('booking_variety_times', 'v');
|
$timeslot_query = db_select('booking_variety_timeslots', 'v');
|
||||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||||
->fields('v')
|
->fields('v')
|
||||||
->orderBy('v.booking_variety_start');
|
->orderBy('v.booking_variety_start');
|
||||||
@@ -81,7 +81,7 @@ function booking_variety_session_callback($form, &$form_state) {
|
|||||||
//$form['variety-sessions'][$fieldname]['#title'] = t('Rebuilt Variety Session: ' . $timeslot->booking_variety_time_descrip);
|
//$form['variety-sessions'][$fieldname]['#title'] = t('Rebuilt Variety Session: ' . $timeslot->booking_variety_time_descrip);
|
||||||
|
|
||||||
// Tell drupal to update the wrapper for this field
|
// Tell drupal to update the wrapper for this field
|
||||||
$commands[] = ajax_command_replace('#booking_variety_session_' . $timeslot->tid . '_wrapper', drupal_render($form['variety-sessions'][$fieldname]));
|
$commands[] = ajax_command_replace('#booking_variety_session_' . $timeslot->tid . '_wrapper', drupal_render($form['form']['variety-sessions'][$fieldname]));
|
||||||
//$commands[] = ajax_command_replace('#booking_variety_session_' . $timeslot->tid . '_wrapper', drupal_render($form));
|
//$commands[] = ajax_command_replace('#booking_variety_session_' . $timeslot->tid . '_wrapper', drupal_render($form));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user