/** * @param int $from * @param int $to * @throws Task_Not_Found */ private function showGoals($from, $to) { $this->load->library("session"); $goals = new Goal(); $goals->where("user_id", $this->session->getStudentId()); $goals->where("start >=", $from); $goals->where("end <=", $to); $goals->get(); $goalsView = array(); /** @var Goal $goal */ foreach ($goals as $goal) { $goalsView[] = array("id" => $goal->getId(), "value" => $goal->getValue(), "done" => $goal->getDoneTime(), "task_name" => $goal->task->getName()); } $this->load->view("goal/get", array("goals" => $goalsView)); }
/** * Show the form for editing the specified resource. * * @param Project $project * @return Response */ public function edit($project) { $goals = Goal::where('project_id', '=', $project->id)->get(); $tags_all = Tag::orderby('tag')->lists('tag', 'id'); $tags = $project->tags()->lists('tag_id'); $users = $project->users; $creator = User::find($project->user_id); /** format enum for expected time */ switch ($project->expected_time) { case 'lessMonth': $project->expected_time = 1; break; case 'aMonth': $project->expected_time = 2; break; case 'fourMonths': $project->expected_time = 3; break; case 'eightMonths': $project->expected_time = 4; break; case 'ayear': $project->expected_time = 5; break; case 'moreYear': $project->expected_time = 6; break; } /** format enum for state */ switch ($project->state) { case 'Application': $project->state = 1; break; case 'Available': $project->state = 2; break; case 'InProgress': $project->state = 3; break; case 'Complete': $project->state = 4; break; case 'Canceled': $project->state = 5; break; case 'NA': $project->state = 6; break; } return View::make('admin/projects/edit', compact('project', 'goals', 'tags_all', 'tags', 'users', 'creator')); }
public function checkOverlap($task = null) { if ($task == null && $this->task == null) { throw new Task_Not_Found(); } if ($task == null) { $task = $this->task; } $goal = new Goal(); $goal->where(array("start <=" => $this->start, "end >=" => $this->end))->get_by_related($task); if ($goal->exists()) { throw new Goal_Overlap(); } }
/** * Show the form for editing the specified resource. * * @param Project $project * @return Response */ public function edit($project) { if (Auth::check() && Auth::user()->id == $project->user_id) { $goals = Goal::where('project_id', '=', $project->id)->get(); $tags_all = Tag::orderby('tag')->lists('tag', 'id'); $tags = $project->tags()->lists('tag_id'); /** format enum for expected time */ switch ($project->expected_time) { case 'lessMonth': $project->expected_time = 1; break; case 'aMonth': $project->expected_time = 2; break; case 'fourMonths': $project->expected_time = 3; break; case 'eightMonths': $project->expected_time = 4; break; case 'ayear': $project->expected_time = 5; break; case 'moreYear': $project->expected_time = 6; break; } return View::make('site/project/edit', compact('project', 'goals', 'tags_all', 'tags')); } else { return Redirect::to('/'); } }