Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Реализация hook_menu()
- */
- function toutput_menu()
- {
- $items=array();
- $items['stuffs'] = array(
- 'title' => 'Сотрудники',
- 'page callback' => 'toutput_staff',
- 'access arguments' => array('access content'),
- 'access callback' => TRUE,
- 'type' => MENU_NORMAL_ITEM,
- 'menu_name'=>'main-menu',
- );
- return $items;
- }
- function toutput_staff($content=NULL){
- $content = '';
- $header = array(
- array('data' => 'ID сотрудника', 'field' => 'hid'),
- array('data' => 'Имя сотрудника', 'field' => 'name'),
- array('data' => 'Должность', 'field' => 'post'),
- array('data' => 'Квалификация', 'field' => 'rank'),
- array('data' => 'Опыт', 'field' => 'exp'),
- array('data' => 'Зарплата', 'field' => 'salary'),
- );
- $query = db_select('staffs', 's')
- ->fields('s', array('hid', 'name','post','rank','exp','salary'))
- ->extend('PagerDefault')
- ->limit(10)
- ->extend('TableSort')
- ->orderByHeader($header)
- ->execute();
- $rows = array();
- foreach ($query as $staffs)
- {
- $rows[] = array(
- check_plain($staffs->hid),
- check_plain($staffs->name),
- check_plain($staffs->post),
- check_plain($staffs->rank),
- check_plain($staffs->exp),
- check_plain($staffs->salary),
- );
- }
- $content = theme('table', array('header' => $header, 'rows' => $rows));
- $content .= theme('pager');
- return $content;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement