summaryrefslogtreecommitdiff
path: root/app/Formatter
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-04-01 17:04:18 -0400
committerFrederic Guillot <fred@kanboard.net>2017-04-01 17:04:18 -0400
commit5cc488947305eea5b9762997222c84d6007761c8 (patch)
tree5f602bb06ade363aa40eda99b4fe9a61f592609f /app/Formatter
parent253d5a9331e4b4775066ec8cb9664da9a2aa6ac9 (diff)
Move Gantt charts to external plugin
Diffstat (limited to 'app/Formatter')
-rw-r--r--app/Formatter/ProjectGanttFormatter.php57
-rw-r--r--app/Formatter/TaskGanttFormatter.php78
2 files changed, 0 insertions, 135 deletions
diff --git a/app/Formatter/ProjectGanttFormatter.php b/app/Formatter/ProjectGanttFormatter.php
deleted file mode 100644
index af04f498..00000000
--- a/app/Formatter/ProjectGanttFormatter.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-namespace Kanboard\Formatter;
-
-use Kanboard\Core\Filter\FormatterInterface;
-
-/**
- * Gantt chart formatter for projects
- *
- * @package formatter
- * @author Frederic Guillot
- */
-class ProjectGanttFormatter extends BaseFormatter implements FormatterInterface
-{
- /**
- * Format projects to be displayed in the Gantt chart
- *
- * @access public
- * @return array
- */
- public function format()
- {
- $projects = $this->query->findAll();
- $colors = $this->colorModel->getDefaultColors();
- $bars = array();
-
- foreach ($projects as $project) {
- $start = empty($project['start_date']) ? time() : strtotime($project['start_date']);
- $end = empty($project['end_date']) ? $start : strtotime($project['end_date']);
- $color = next($colors) ?: reset($colors);
-
- $bars[] = array(
- 'type' => 'project',
- 'id' => $project['id'],
- 'title' => $project['name'],
- 'start' => array(
- (int) date('Y', $start),
- (int) date('n', $start),
- (int) date('j', $start),
- ),
- 'end' => array(
- (int) date('Y', $end),
- (int) date('n', $end),
- (int) date('j', $end),
- ),
- 'link' => $this->helper->url->href('ProjectViewController', 'show', array('project_id' => $project['id'])),
- 'board_link' => $this->helper->url->href('BoardViewController', 'show', array('project_id' => $project['id'])),
- 'gantt_link' => $this->helper->url->href('TaskGanttController', 'show', array('project_id' => $project['id'])),
- 'color' => $color,
- 'not_defined' => empty($project['start_date']) || empty($project['end_date']),
- 'users' => $this->projectUserRoleModel->getAllUsersGroupedByRole($project['id']),
- );
- }
-
- return $bars;
- }
-}
diff --git a/app/Formatter/TaskGanttFormatter.php b/app/Formatter/TaskGanttFormatter.php
deleted file mode 100644
index ddb3f93a..00000000
--- a/app/Formatter/TaskGanttFormatter.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-
-namespace Kanboard\Formatter;
-
-use Kanboard\Core\Filter\FormatterInterface;
-
-/**
- * Task Gantt Formatter
- *
- * @package formatter
- * @author Frederic Guillot
- */
-class TaskGanttFormatter extends BaseFormatter implements FormatterInterface
-{
- /**
- * Local cache for project columns
- *
- * @access private
- * @var array
- */
- private $columns = array();
-
- /**
- * Apply formatter
- *
- * @access public
- * @return array
- */
- public function format()
- {
- $bars = array();
-
- foreach ($this->query->findAll() as $task) {
- $bars[] = $this->formatTask($task);
- }
-
- return $bars;
- }
-
- /**
- * Format a single task
- *
- * @access private
- * @param array $task
- * @return array
- */
- private function formatTask(array $task)
- {
- if (! isset($this->columns[$task['project_id']])) {
- $this->columns[$task['project_id']] = $this->columnModel->getList($task['project_id']);
- }
-
- $start = $task['date_started'] ?: time();
- $end = $task['date_due'] ?: $start;
-
- return array(
- 'type' => 'task',
- 'id' => $task['id'],
- 'title' => $task['title'],
- 'start' => array(
- (int) date('Y', $start),
- (int) date('n', $start),
- (int) date('j', $start),
- ),
- 'end' => array(
- (int) date('Y', $end),
- (int) date('n', $end),
- (int) date('j', $end),
- ),
- 'column_title' => $task['column_name'],
- 'assignee' => $task['assignee_name'] ?: $task['assignee_username'],
- 'progress' => $this->taskModel->getProgress($task, $this->columns[$task['project_id']]).'%',
- 'link' => $this->helper->url->href('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])),
- 'color' => $this->colorModel->getColorProperties($task['color_id']),
- 'not_defined' => empty($task['date_due']) || empty($task['date_started']),
- );
- }
-}