Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. function myid_print_user_page_form($form, &$form_state)
  2. {
  3. $form = array();
  4. $form['myid_print']['option'] = array(
  5. '#type' => 'select',
  6. '#options' => array(
  7. 0 => t('All'),
  8. 1 => t("Printed ID's"),
  9. 2 => t("Unprinted ID's"),
  10. ),
  11. '#default_value' => 0,
  12. '#ajax' => array(
  13. 'callback' => 'myid_print_all_submitted_id_callback',
  14. 'wrapper' => 'myid_table_wrapper',
  15. ),
  16. );
  17.  
  18. // Build the sortable table header.
  19. $header = array(
  20. 'id_number' => array('data' => t('ID Number'), 'field' => 'id_number','sort' => 'asc'),
  21. 'student' => array('data' => t('Student'), 'field' => 'student', 'sort' => 'asc')
  22. );
  23.  
  24. //Get the node data.
  25.  
  26. $query = db_select('student', 't1',array('target' => 'import'));
  27. $result = $query
  28. ->fields('t1', array('studid','lastname', 'firstname', 'middlename', 'extname'))
  29. ->condition('t1.id_status',1,'=')
  30. ->distinct()
  31. ->execute();
  32.  
  33. //Build the rows.
  34. $rows = array();
  35. foreach($result as $record){
  36. $rows[$record->studid] = array(
  37. 'id_number' => $record->studid,
  38. 'student' => $record->firstname . ' ' . $record->middlename . ' ' . $record->lastname . ' ' . $record->extname,
  39. );
  40. }
  41.  
  42. //Build the table
  43. $form['table'] = array(
  44. '#theme' => 'table',
  45. '#header' => $header,
  46. '#rows' => $rows,
  47. '#prefix' => '<div id="myid_table_wrapper">',
  48. '#suffix' => '</div>',
  49. );
  50. return $form;
  51. }
  52.  
  53. function myid_print_all_submitted_id_callback($form, $form_state)
  54. {
  55. //Do query here and put the query results in the table.
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement