From 9e218032c485b7ab6ef8e00f45890151988b0f90 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 28 May 2016 14:29:07 -0400 Subject: Split Gantt controller --- app/Controller/ProjectGanttController.php | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/Controller/ProjectGanttController.php (limited to 'app/Controller/ProjectGanttController.php') diff --git a/app/Controller/ProjectGanttController.php b/app/Controller/ProjectGanttController.php new file mode 100644 index 00000000..1c6ace58 --- /dev/null +++ b/app/Controller/ProjectGanttController.php @@ -0,0 +1,57 @@ +projectPermission->getActiveProjectIds($this->userSession->getId()); + $filter = $this->projectQuery + ->withFilter(new ProjectTypeFilter(Project::TYPE_TEAM)) + ->withFilter(new ProjectStatusFilter(Project::ACTIVE)) + ->withFilter(new ProjectIdsFilter($project_ids)); + + $filter->getQuery()->asc(Project::TABLE.'.start_date'); + + $this->response->html($this->helper->layout->app('project_gantt/show', array( + 'projects' => $filter->format(new ProjectGanttFormatter($this->container)), + 'title' => t('Gantt chart for all projects'), + ))); + } + + /** + * Save new project start date and end date + */ + public function save() + { + $values = $this->request->getJson(); + + $result = $this->project->update(array( + 'id' => $values['id'], + 'start_date' => $this->dateParser->getIsoDate(strtotime($values['start'])), + 'end_date' => $this->dateParser->getIsoDate(strtotime($values['end'])), + )); + + if (! $result) { + $this->response->json(array('message' => 'Unable to save project'), 400); + } else { + $this->response->json(array('message' => 'OK'), 201); + } + } +} -- cgit v1.2.3