@info
', array('@info' => print_r( $form, true))); // --- Update the wrapper for booking ID validity --- //verify that user-entered data is a number if (! preg_match('/^[0-9]+$/', $data['booking_nid'])) { watchdog('booking_debug', "
booking_variety_session_callback non-numerical input
"); $markup = '
' . 'You have not entered a valid booking reference number.
'; $commands[] = ajax_command_replace('#booking_variety_regn_feedback_wrapper', $markup); } // Perform lookup on barcode to make sure it matches someone attending the current event $db_and = db_and(); $db_and->condition('p.booking_eventid', $event->eid, '='); $db_and->condition('p.booking_status', 1, '='); $db_and->condition('p.nid', $data['booking_nid'], '='); $query = db_select('booking_person', 'p'); $query->condition($db_and) ->fields('p'); $person = $query->execute() ->fetchObject(); if ($person) { watchdog('booking_debug', "
booking_variety_session_callback found valid attendee
"); $markup = '
' . 'Matched booking reference number.
'; $commands[] = ajax_command_replace('#booking_variety_regn_feedback_wrapper', $markup); } else { watchdog('booking_debug', "
booking_variety_session_callback did not find valid attendee
"); $markup = '
' . 'You have not entered a valid booking reference number.
'; $commands[] = ajax_command_replace('#booking_variety_regn_feedback_wrapper', $markup); } // --- Update the wrapper for available variety sessions --- // 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) { $fieldname = 'select-variety-' . $timeslot->tid; $options = _booking_get_variety_timeslot_options($timeslot->tid); watchdog('booking_debug', 'Timeslot @tid form state value:
@info
', array('@tid' => $timeslot->tid, '@info' => print_r($form_state['values'], true))); watchdog('booking_debug', 'Setting timeslot @tid default value to @value', array( '@tid' => $timeslot->tid, '@value' => isset($form_state['values'][$fieldname]) ? $form_state['values'][$fieldname] : 0) ); //re-create the form element for this timeslot $form['variety-sessions'][$fieldname] = array( '#type' => 'select', '#title' => t('Rebuilt Variety Session: ' . $timeslot->booking_variety_time_descrip), '#required' => TRUE, '#options' => $options, '#prefix' => '
', '#suffix' => '
', '#default_value' => 1, ); //$form['variety-sessions'][$fieldname]['#options'] = $options; //$form['variety-sessions'][$fieldname]['#title'] = t('Rebuilt Variety Session: ' . $timeslot->booking_variety_time_descrip); // 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_state['rebuild'] = TRUE; return array('#type' => 'ajax', '#commands' => $commands); //$page = array('#type' => 'ajax', '#commands' => $commands); //ajax_deliver($page); } /** * Callback function to verify if barcode was valid */ function booking_variety_regn_callback($form, &$form_state) { global $event; //$node = $form_state['values']['form_id']; $data = $form_state['input']; watchdog('booking', '
booking_variety_regn_callback validation:\n@info
', array('@info' => print_r( $data, true))); //verify that user-entered data is a number if (! preg_match('/^[0-9]+$/', $data['booking_nid'])) { watchdog('booking_debug', "
booking_variety_regn_callback non-numerical input
"); return '
' . 'You have not entered a valid booking reference number.
'; } // Perform lookup on barcode to make sure it matches someone attending the current event $db_and = db_and(); $db_and->condition('p.booking_eventid', $event->eid, '='); $db_and->condition('p.booking_status', 1, '='); $db_and->condition('p.nid', $data['booking_nid'], '='); $query = db_select('booking_person', 'p'); $query->condition($db_and) ->fields('p'); $person = $query->execute() ->fetchObject(); if ($person) { watchdog('booking_debug', "
booking_variety_regn_callback  found valid attendee
"); return '
' . 'Matched booking reference number.
'; } else { watchdog('booking_debug', "
booking_variety_regn_callback did not find valid attendee
"); return '
' . 'You have not entered a valid booking reference number.
'; } }