/** * Contruct time report controller * * @param Request $request * @return ProjectTimeReportsController */ function __construct($request) { parent::__construct($request); if (!$this->logged_user->isAdministrator() && !$this->logged_user->getSystemPermission('use_time_reports')) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->wireframe->addBreadCrumb(lang('Reports'), timetracking_module_reports_url($this->active_project)); $report_id = $this->request->getId('report_id'); if ($report_id) { $this->active_report = TimeReports::findById($report_id); } // if if (instance_of($this->active_report, 'TimeReport')) { $this->wireframe->addBreadCrumb($this->active_report->getName(), $this->active_report->getUrl()); } else { $this->active_report = new TimeReport(); } // if $this->wireframe->page_actions = array(); if (TimeReport::canAdd($this->logged_user)) { $this->wireframe->addPageAction(lang('New Report'), assemble_url('global_time_report_add', array('project_id' => $this->active_project->getId()))); } // if $this->smarty->assign('active_report', $this->active_report); }
/** * Delete existing report * * @param void * @return null */ function delete() { if ($this->active_report->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_report->canDelete($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->request->isSubmitted()) { $delete = $this->active_report->delete(); if ($delete && !is_error($delete)) { flash_success("Report ':name' has been deleted", array('name' => $this->active_report->getName())); } else { flash_error("Failed to delete ':name' report", array('name' => $this->active_report->getName())); } // if $this->redirectTo('global_time'); } // if }