Example #1
0
 /**
  * Displays a list of records
  *
  * @return	void
  */
 public function displayTask()
 {
     // Get paging variables
     $this->view->filters = array('limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'open' => Request::getState($this->_option . '.' . $this->_controller . '.open', 'open', -1, 'int'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'open'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'DESC'));
     $this->view->filters['start'] = $this->view->filters['limit'] != 0 ? floor($this->view->filters['start'] / $this->view->filters['limit']) * $this->view->filters['limit'] : 0;
     $obj = new Tables\Status($this->database);
     // Record count
     $this->view->total = $obj->find('count', $this->view->filters);
     // Fetch results
     $this->view->rows = $obj->find('list', $this->view->filters);
     // Output the HTML
     $this->view->display();
 }
Example #2
0
 /**
  * Get a count of or list of ticket statuses
  *
  * @param      string  $rtrn    Data to return state in [count, list]
  * @param      array   $filters Filters to apply to the query
  * @param      boolean $clear   Clear data cache?
  * @return     mixed
  */
 public function statuses($rtrn = 'all', $filters = array(), $clear = false)
 {
     static $statuses;
     if (!isset($statuses) || $clear) {
         $tbl = new Tables\Status($this->_db);
         if (!isset($filters['sort'])) {
             $filters['sort'] = 'id';
             $filters['sort_Dir'] = 'ASC';
         }
         $statuses = array();
         if ($rows = $tbl->find('list', $filters)) {
             foreach ($rows as $row) {
                 $statuses[] = new Status($row);
             }
         }
     }
     switch (strtolower($rtrn)) {
         case 'open':
             $results = array();
             foreach ($statuses as $status) {
                 if ($status->get('open')) {
                     $results[] = $status;
                 }
             }
             break;
         case 'closed':
             $results = array();
             foreach ($statuses as $status) {
                 if (!$status->get('open')) {
                     $results[] = $status;
                 }
             }
             break;
         case 'all':
         default:
             $results = $statuses;
             break;
     }
     return new ItemList($results);
 }