public function action_addtask($project_id) { if (!($project = Model_Project::find($project_id))) { \Fuel\Core\Session::set_flash('error', "Cannot find the selected project # {$project_id}"); \Fuel\Core\Response::redirect_back('user/projects'); } $val = Model_Projecttask::validate('create'); if (\Fuel\Core\Input::method() == 'POST') { if ($val->run()) { $projecttask = Model_Projecttask::forge(array('project_id' => Input::post('project_id'), 'user_id' => Input::post('user_id'), 'project_task_name_id' => Input::post('project_task_name_id'), 'hourly_rate' => Input::post('hourly_rate'), 'task_status' => 0, 'task_due' => Input::post('task_due'), 'project_task_description' => Input::post('project_task_description'), 'comment' => Input::post('comment'), 'priority' => Input::post('priority'))); if ($projecttask and $projecttask->save()) { Session::set_flash('success', e('Added task #' . $projecttask->id . '.')); Response::redirect('user/projects/view/' . $project_id); } else { Session::set_flash('error', e('Could not save task.')); } } else { \Fuel\Core\Session::set_flash('error', $val->error()); } } $this->load_presenter($project, Model_Projecttask::forge(array('id' => 0, 'project_id' => $project->id, 'user_id' => $this->current_user->id, 'task_status' => 0, 'hourly_rate' => 456, 'task_due' => date('Y-m-d')))); $this->template->set_global('project_task_names', Model_Projecttaskname::find('all', array('order_by' => array(array('name', 'asc'))))); $this->template->set_global('users', array(Model_User::find($this->current_user->id))); $this->template->set_global('priorities', THelper::get_priorities()); $this->template->title = 'My Projects'; $this->template->content = Fuel\Core\View::forge('user/projects/addtask'); }
public function action_delete($id = null) { if ($projecttaskname = Model_Projecttaskname::find($id)) { $projecttaskname->delete(); Session::set_flash('success', e('Deleted projecttaskname #' . $id)); } else { Session::set_flash('error', e('Could not delete projecttaskname #' . $id)); } Response::redirect('admin/projecttasknames'); }
public function get_project_task_name() { return !is_null($this->project_task_name) ? $this->project_task_name : Model_Projecttaskname::forge(array('id' => 0)); }