Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myid_print_user_page_form($form, &$form_state)
- {
- $form = array();
- $form['myid_print']['option'] = array(
- '#type' => 'select',
- '#options' => array(
- 0 => t('All'),
- 1 => t("Printed ID's"),
- 2 => t("Unprinted ID's"),
- ),
- '#default_value' => 0,
- '#ajax' => array(
- 'callback' => 'myid_print_all_submitted_id_callback',
- 'wrapper' => 'myid_table_wrapper',
- ),
- );
- // Build the sortable table header.
- $header = array(
- 'id_number' => array('data' => t('ID Number'), 'field' => 'id_number','sort' => 'asc'),
- 'student' => array('data' => t('Student'), 'field' => 'student', 'sort' => 'asc')
- );
- //Get the node data.
- $query = db_select('student', 't1',array('target' => 'import'));
- $result = $query
- ->fields('t1', array('studid','lastname', 'firstname', 'middlename', 'extname'))
- ->condition('t1.id_status',1,'=')
- ->distinct()
- ->execute();
- //Build the rows.
- $rows = array();
- foreach($result as $record){
- $rows[$record->studid] = array(
- 'id_number' => $record->studid,
- 'student' => $record->firstname . ' ' . $record->middlename . ' ' . $record->lastname . ' ' . $record->extname,
- );
- }
- //Build the table
- $form['table'] = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#prefix' => '<div id="myid_table_wrapper">',
- '#suffix' => '</div>',
- );
- return $form;
- }
- function myid_print_all_submitted_id_callback($form, $form_state)
- {
- //Do query here and put the query results in the table.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement