test
This commit is contained in:
@@ -13,9 +13,15 @@ function booking_variety_regn_form($node, &$form_state)
|
|||||||
$form = array ();
|
$form = array ();
|
||||||
$data = $node;
|
$data = $node;
|
||||||
|
|
||||||
$query = db_query("SELECT * FROM {booking_variety_times} WHERE booking_eventid = :eid AND booking_variety_status = 1",
|
//$query = db_query("SELECT * FROM {booking_variety_times} WHERE booking_eventid = :eid AND booking_variety_status = 1",
|
||||||
array(':eid' => $event->eid));
|
// array(':eid' => $event->eid));
|
||||||
|
|
||||||
|
// Query the variety timeslot table
|
||||||
|
$timeslot_query = db_select('booking_variety_times', 'v');
|
||||||
|
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||||
|
->fields('v')
|
||||||
|
->orderBy('v.booking_variety_start');
|
||||||
|
$result = $timeslot_query->execute();
|
||||||
|
|
||||||
$form['booking_variety_regn_feedback_wrapper'] = array(
|
$form['booking_variety_regn_feedback_wrapper'] = array(
|
||||||
'#markup' => '<div id="booking_variety_regn_feedback_wrapper" class="form-item">Please enter your booking number from your lanyard.</div>',
|
'#markup' => '<div id="booking_variety_regn_feedback_wrapper" class="form-item">Please enter your booking number from your lanyard.</div>',
|
||||||
@@ -28,27 +34,31 @@ function booking_variety_regn_form($node, &$form_state)
|
|||||||
'#default_value' => !empty($data->booking_nid) ? $data->booking_nid : '',
|
'#default_value' => !empty($data->booking_nid) ? $data->booking_nid : '',
|
||||||
'#ajax' => array(
|
'#ajax' => array(
|
||||||
'event' => 'change',
|
'event' => 'change',
|
||||||
'wrapper' => 'booking_variety_regn_feedback_wrapper',
|
//'wrapper' => 'booking_variety_regn_feedback_wrapper',
|
||||||
'callback' => 'booking_variety_regn_callback',
|
//'callback' => 'booking_variety_regn_callback',
|
||||||
|
'wrapper' => 'booking_variety_session_wrapper',
|
||||||
|
'callback' => 'booking_variety_session_callback',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
//for each entry in the variety timeslot table, create a new form select item
|
// TODO: Update the whole form when booking ID is updated
|
||||||
$timeslot_query = db_select('booking_variety_times', 'v');
|
$form['variety-sessions'] = array(
|
||||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
'#type' => 'fieldset',
|
||||||
->fields('v')
|
'#title' => 'Select Variety Sessions',
|
||||||
->orderBy('v.booking_variety_start');
|
'#prefix' => '<div id="booking_variety_session_wrapper">',
|
||||||
$result = $timeslot_query->execute();
|
'#suffix' => '</div>',
|
||||||
|
);
|
||||||
|
|
||||||
|
//for each entry in the variety timeslot table, create a new form select item
|
||||||
foreach($result as $timeslot) {
|
foreach($result as $timeslot) {
|
||||||
//create the form element for this timeslot
|
//create the form element for this timeslot
|
||||||
$form['select-variety-' . $timeslot->tid] = array(
|
$form['variety-sessions']['select-variety-' . $timeslot->tid] = array(
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||||
'#required' => TRUE,
|
'#required' => TRUE,
|
||||||
'#default_value' => '',
|
'#default_value' => '',
|
||||||
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form['submit'] = array(
|
$form['submit'] = array(
|
||||||
@@ -61,6 +71,41 @@ function booking_variety_regn_form($node, &$form_state)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function booking_variety_session_callback($form, &$form_state) {
|
||||||
|
global $event;
|
||||||
|
//$node = $form_state['values']['form_id'];
|
||||||
|
$data = $form_state['input'];
|
||||||
|
watchdog('booking_debug', 'booking_variety_session_callback:<br /><pre>@info</pre>', array('@info' => print_r( $data, true)));
|
||||||
|
$commands = array();
|
||||||
|
|
||||||
|
// Query the variety timeslot table
|
||||||
|
$timeslot_query = db_select('booking_variety_times', 'v');
|
||||||
|
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||||
|
->fields('v')
|
||||||
|
->orderBy('v.booking_variety_start');
|
||||||
|
$result = $timeslot_query->execute();
|
||||||
|
|
||||||
|
//for each entry in the variety timeslot table, create a new form select item
|
||||||
|
foreach($result as $timeslot) {
|
||||||
|
|
||||||
|
$commands[] = ajax_command_replace('#select-variety-' . $timeslot->tid, drupal_render($form['variety-sessions']['select-variety-' . $timeslot->tid]));
|
||||||
|
/*
|
||||||
|
//create the form element for this timeslot
|
||||||
|
$form['variety-sessions']['select-variety-' . $timeslot->tid] = array(
|
||||||
|
'#type' => 'select',
|
||||||
|
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||||
|
'#required' => TRUE,
|
||||||
|
'#default_value' => '',
|
||||||
|
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_state['rebuild'] = TRUE;
|
||||||
|
return array('#type' => 'ajax', '#commands' => $commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to calculate available variety sessions for ajax enabled form booking_variety_regn_form()
|
* Function to calculate available variety sessions for ajax enabled form booking_variety_regn_form()
|
||||||
* @param $timeslot_id - the timeslot ID to query
|
* @param $timeslot_id - the timeslot ID to query
|
||||||
|
Reference in New Issue
Block a user