/** * Apply user filters to hour lists * * @param midcom_core_query $query The query object to work on */ public function add_list_filter(midcom_core_query $query) { $qf = new org_openpsa_core_queryfilter('org_openpsa_expenses_list'); $person_filter = new org_openpsa_core_filter('person'); $person_filter->set('option_callback', array($this, 'get_person_options')); $person_filter->set('mode', 'multiselect'); $person_filter->set('helptext', $this->_l10n->get("choose user")); $qf->add_filter($person_filter); if ($this->_request_data['handler_id'] != 'index_timestamp' && $this->_request_data['handler_id'] != 'index') { $date_filter = new org_openpsa_core_filter('date'); $date_filter->set('mode', 'timeframe'); $date_filter->set('helptext', $this->_l10n->get("timeframe")); $qf->add_filter($date_filter); } $qf->apply_filters($query); $this->_request_data["qf"] = $qf; }
/** * List all tasks, optionally filtered by status */ private function _handler_list_all($args) { // Default to open tasks list if none specified if (!isset($args[1]) || empty($args[1])) { $this->_request_data['view_identifier'] = 'open'; $args[1] = 'open'; } switch ($args[1]) { case 'agreement': if (!$args[2]) { throw new midcom_error('Invalid arguments for agreement filter'); } $agreement_id = (int) $args[2]; $this->_request_data['agreement'] = $agreement_id; $deliverable = org_openpsa_sales_salesproject_deliverable_dba::get_cached($agreement_id); $title = sprintf($this->_l10n->get('tasks for agreement %s'), $deliverable->title); midcom::get('head')->set_pagetitle($title); $this->add_breadcrumb("", $title); $this->_qb->add_constraint('agreement', '=', $deliverable->id); $this->_provider->add_order('end', 'DESC'); break; case 'all': case 'both': $args[1] = 'all'; $this->_provider->add_order('end', 'DESC'); break; case 'open': $this->set_active_leaf($this->_topic->id . ':tasks_open'); $this->_qb->add_constraint('status', '<', org_openpsa_projects_task_status_dba::CLOSED); $this->_provider->add_order('end'); break; case 'closed': $this->set_active_leaf($this->_topic->id . ':tasks_closed'); $this->_qb->add_constraint('status', '=', org_openpsa_projects_task_status_dba::CLOSED); $this->_provider->add_order('end', 'DESC'); break; case 'current': $this->_qb->add_constraint('status', 'IN', array(org_openpsa_projects_task_status_dba::ACCEPTED, org_openpsa_projects_task_status_dba::STARTED, org_openpsa_projects_task_status_dba::REJECTED, org_openpsa_projects_task_status_dba::REOPENED)); $this->_provider->add_order('end'); break; case 'invoiceable': $this->set_active_leaf($this->_topic->id . ':tasks_invoiceable'); $this->_qb->add_constraint('invoiceableHours', '>', 0); $this->_provider->add_order('end'); break; case 'invoiced': $this->set_active_leaf($this->_topic->id . ':tasks_invoiced'); $this->_qb->add_constraint('invoicedHours', '>', 0); $this->_provider->add_order('end', 'DESC'); break; default: throw new midcom_error("Filter {$args[1]} not recognized"); } $qf = new org_openpsa_core_queryfilter('org_openpsa_task_list_' . $args[1]); $qf->add_filter(new org_openpsa_core_filter('priority', '<=', $this->_request_data['priority_array'])); $date_filter = new org_openpsa_core_filter('timeframe'); $date_filter->set('mode', 'timeframe'); $date_filter->set('helptext', $this->_l10n->get("timeframe")); $date_filter->set('fieldname', array('start' => 'start', 'end' => 'end')); $qf->add_filter($date_filter); $qf->apply_filters($this->_qb); $this->_request_data["qf"] = $qf; $this->_request_data['table-heading'] = $args[1] . ' tasks'; $this->_request_data['view'] = 'grid'; }