/** * Return project tickets * * @access public * @param void * @return array */ function index() { $page = (int) array_var($_GET, 'page', 1); if ($page < 0) { $page = 1; } $closed = (bool) array_var($_GET, 'closed', false); $conditions = DB::prepareString('`closed_on` ' . ($closed ? '>' : '=') . ' ? and `project_id` = ?', array(EMPTY_DATETIME, active_project()->getId())); if (!logged_user()->isMemberOfOwnerCompany()) { $conditions .= DB::prepareString(' AND `is_private` = ?', array(0)); } // if if ($closed) { $order = '`closed_on` DESC'; } else { $order = '`created_on` DESC'; } // if list($tickets, $pagination) = ProjectTickets::paginate(array('conditions' => $conditions, 'order' => $order), config_option('tickets_per_page', 25), $page); // paginate tpl_assign('closed', $closed); tpl_assign('tickets', $tickets); tpl_assign('tickets_pagination', $pagination); $this->setSidebar(get_template_path('index_sidebar', 'tickets')); }
/** * Display all tickets assigned to this user * * @layout dashboard * @param void * @return array */ function my_tickets() { $this->setLayout('dashboard'); $this->setTemplate('my_tickets'); $this->addHelper('textile'); $page = (int) array_var($_GET, 'page', 1); $category = (int) array_var($_GET, 'category', 0); $priority = array_var($_GET, 'priority', FALSE); $type = array_var($_GET, 'type', FALSE); if ($page < 0) { $page = 1; } $closed = (bool) array_var($_GET, 'closed', false); $conditions = DB::prepareString('`closed_on` ' . ($closed ? '>' : '=') . ' ?', array(EMPTY_DATETIME)); if (!logged_user()->isMemberOfOwnerCompany()) { $conditions .= DB::prepareString(' AND `is_private` = ?', array(0)); } // if if ($category > 0) { $conditions .= DB::prepareString(' AND `category_id` = ?', array($category)); } if ($priority) { $conditions .= DB::prepareString(' AND `priority` = ?', array($priority)); } if ($type) { $conditions .= DB::prepareString(' AND `type` = ?', array($type)); } if ($closed) { $order = '`project_id`, `closed_on` DESC'; } else { $order = '`project_id`, `created_on` DESC'; } // if list($tickets, $pagination) = ProjectTickets::paginate(array('conditions' => $conditions, 'order' => $order), config_option('tickets_per_page', 25), $page); // paginate tpl_assign('closed', $closed); tpl_assign('tickets', $tickets); tpl_assign('tickets_pagination', $pagination); tpl_assign('active_projects', logged_user()->getActiveProjects()); $this->setSidebar(get_template_path('index_sidebar', 'tickets')); // tpl_assign('active_projects', logged_user()->getActiveProjects()); //$this->setSidebar(get_template_path('index_sidebar', 'tickets')); }