summaryrefslogtreecommitdiff
path: root/app/Controller/Gantt.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-08-22 16:20:53 -0400
committerFrederic Guillot <fred@kanboard.net>2015-08-22 16:20:53 -0400
commitfd60964c239627d2d55c6eca0888be84a8f6653f (patch)
tree062836c4a49857625a25b2cfdd3bbb93732f915d /app/Controller/Gantt.php
parent18fd39e6d648a58be0782d514604877504833832 (diff)
Add global Gantt chart for all projects
Diffstat (limited to 'app/Controller/Gantt.php')
-rw-r--r--app/Controller/Gantt.php43
1 files changed, 41 insertions, 2 deletions
diff --git a/app/Controller/Gantt.php b/app/Controller/Gantt.php
index f450bca3..f73501c3 100644
--- a/app/Controller/Gantt.php
+++ b/app/Controller/Gantt.php
@@ -13,7 +13,46 @@ use Model\Task as TaskModel;
class Gantt extends Base
{
/**
- * Show Gantt chart for projects
+ * Show Gantt chart for all projects
+ */
+ public function projects()
+ {
+ if ($this->userSession->isAdmin()) {
+ $project_ids = $this->project->getAllIds();
+ }
+ else {
+ $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId());
+ }
+
+ $this->response->html($this->template->layout('gantt/projects', array(
+ 'projects' => $this->project->getGanttBars($project_ids),
+ 'title' => t('Gantt chart for all projects'),
+ 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
+ )));
+ }
+
+ /**
+ * Save new project start date and end date
+ */
+ public function saveProjectDate()
+ {
+ $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);
+ }
+
+ $this->response->json(array('message' => 'OK'), 201);
+ }
+
+ /**
+ * Show Gantt chart for one project
*/
public function project()
{
@@ -40,7 +79,7 @@ class Gantt extends Base
/**
* Save new task start date and due date
*/
- public function saveDate()
+ public function saveTaskDate()
{
$this->getProject();
$values = $this->request->getJson();