Advertisement
Guest User

corjeque

a guest
Apr 14th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Реализация hook_menu()
  4.  */
  5. function toutput_menu()
  6. {
  7.     $items=array();
  8.     $items['stuffs'] = array(
  9.         'title' => 'Сотрудники',
  10.         'page callback' => 'toutput_staff',
  11.         'access arguments' => array('access content'),
  12.          'access callback' => TRUE,
  13.         'type' => MENU_NORMAL_ITEM,
  14.         'menu_name'=>'main-menu',      
  15.     );
  16.  return $items;
  17. }
  18.  
  19.  
  20.  
  21. function toutput_staff($content=NULL){
  22.     $content = '';
  23.    
  24.     $header = array(
  25.     array('data' => 'ID сотрудника',     'field' => 'hid'),
  26.     array('data' => 'Имя сотрудника',   'field' => 'name'),
  27.     array('data' => 'Должность',         'field' => 'post'),
  28.     array('data' => 'Квалификация',      'field' => 'rank'),
  29.     array('data' => 'Опыт',              'field' => 'exp'),
  30.     array('data' => 'Зарплата',          'field' => 'salary'),
  31.    
  32.     );
  33.    
  34.     $query = db_select('staffs', 's')
  35.     ->fields('s', array('hid', 'name','post','rank','exp','salary'))
  36.     ->extend('PagerDefault')
  37.     ->limit(10)
  38.     ->extend('TableSort')
  39.     ->orderByHeader($header)
  40.     ->execute();
  41.    
  42.    
  43.    
  44.    
  45.     $rows = array();
  46.        
  47.    
  48.  
  49.     foreach ($query as $staffs)
  50.         {
  51.         $rows[] = array(
  52.             check_plain($staffs->hid),
  53.             check_plain($staffs->name),
  54.             check_plain($staffs->post),
  55.             check_plain($staffs->rank),
  56.             check_plain($staffs->exp),
  57.             check_plain($staffs->salary),
  58.     );
  59. }
  60.  
  61.     $content = theme('table', array('header' => $header, 'rows' => $rows));
  62.     $content .= theme('pager');
  63.      
  64.      return $content;
  65.    
  66. }  
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement