blob: 868368e11c3ab93378e1cb6125fab229ea918809 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?php
namespace Kanboard\Controller;
use Kanboard\Filter\TaskProjectFilter;
use Kanboard\Formatter\TaskGanttFormatter;
use Kanboard\Model\TaskModel;
/**
* Tasks Gantt Controller
*
* @package Kanboard\Controller
* @author Frederic Guillot
*/
class TaskGanttController extends BaseController
{
/**
* Show Gantt chart for one project
*/
public function show()
{
$project = $this->getProject();
$search = $this->helper->projectHeader->getSearchQuery($project);
$sorting = $this->request->getStringParam('sorting', 'board');
$filter = $this->taskLexer->build($search)->withFilter(new TaskProjectFilter($project['id']));
if ($sorting === 'date') {
$filter->getQuery()->asc(TaskModel::TABLE.'.date_started')->asc(TaskModel::TABLE.'.date_creation');
} else {
$filter->getQuery()->asc('column_position')->asc(TaskModel::TABLE.'.position');
}
$this->response->html($this->helper->layout->app('task_gantt/show', array(
'project' => $project,
'title' => $project['name'],
'description' => $this->helper->projectHeader->getDescription($project),
'sorting' => $sorting,
'tasks' => $filter->format(new TaskGanttFormatter($this->container)),
)));
}
/**
* Save new task start date and due date
*/
public function save()
{
$this->getProject();
$values = $this->request->getJson();
$result = $this->taskModificationModel->update(array(
'id' => $values['id'],
'date_started' => strtotime($values['start']),
'date_due' => strtotime($values['end']),
));
if (! $result) {
$this->response->json(array('message' => 'Unable to save task'), 400);
} else {
$this->response->json(array('message' => 'OK'), 201);
}
}
}
|