/** * Update existing report * * @param void * @return null */ function edit() { $this->wireframe->print_button = false; if ($this->active_report->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_report->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $active_project = null; $project_id = $this->request->getId('project_id'); if ($project_id) { $active_project = Projects::findById($project_id); } // if $report_data = $this->request->post('report'); if (empty($report_data)) { $report_data = array('name' => $this->active_report->getName(), 'group_name' => $this->active_report->getGroupName(), 'user_filter' => $this->active_report->getUserFilter(), 'user_filter_data' => $this->active_report->getUserFilterData(), 'billable_filter' => $this->active_report->getBillableFilter(), 'date_filter' => $this->active_report->getDateFilter(), 'date_from' => $this->active_report->getDateFrom(), 'date_to' => $this->active_report->getDateTo(), 'sum_by_user' => $this->active_report->getSumByUser()); } // if $this->smarty->assign(array('report_data' => $report_data, 'active_project' => $active_project)); if ($this->request->isSubmitted()) { $old_name = $this->active_report->getName(); $this->active_report->setAttributes($report_data); $this->active_report->setUserFilterData(array_var($report_data, 'user_filter_data')); $save = $this->active_report->save(); if ($save && !is_error($save)) { flash_success("Report ':name' has been updated", array('name' => $old_name)); $this->redirectToUrl($this->active_report->getUrl($active_project)); } else { $this->smarty->assign('errors', $save); } } // if }