summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-10-11 21:11:10 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-10-11 21:11:10 -0400
commitacba6839a6082e3e3800a733f8baea7c843fc02e (patch)
treee2847dcd13d9ccc3d8f0f6f936a5776df852e11b /app/Controller
parenta8418afdebe92dde495bc5010645779c73939b7b (diff)
Add 3 new fields for tasks: start date, time estimated and time spent
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Base.php1
-rw-r--r--app/Controller/Subtask.php3
-rw-r--r--app/Controller/Task.php51
3 files changed, 43 insertions, 12 deletions
diff --git a/app/Controller/Base.php b/app/Controller/Base.php
index aabb1775..abe702a2 100644
--- a/app/Controller/Base.php
+++ b/app/Controller/Base.php
@@ -34,6 +34,7 @@ use Model\LastLogin;
* @property \Model\TaskValidator $taskValidator
* @property \Model\CommentHistory $commentHistory
* @property \Model\SubtaskHistory $subtaskHistory
+ * @property \Model\TimeTracking $timeTracking
* @property \Model\User $user
* @property \Model\Webhook $webhook
*/
diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php
index da9acbab..48f0d6e2 100644
--- a/app/Controller/Subtask.php
+++ b/app/Controller/Subtask.php
@@ -197,7 +197,8 @@ class Subtask extends Base
$value = array(
'id' => $subtask['id'],
- 'status' => ($subtask['status'] + 1) % 3
+ 'status' => ($subtask['status'] + 1) % 3,
+ 'task_id' => $task['id'],
);
if (! $this->subTask->update($value)) {
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 163929d2..695e29ec 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -54,15 +54,29 @@ class Task extends Base
public function show()
{
$task = $this->getTask();
+ $subtasks = $this->subTask->getAll($task['id']);
+
+ $values = array(
+ 'id' => $task['id'],
+ 'date_started' => $task['date_started'],
+ 'time_estimated' => $task['time_estimated'] ?: '',
+ 'time_spent' => $task['time_spent'] ?: '',
+ );
+
+ $this->dateParser->format($values, array('date_started'));
$this->response->html($this->taskLayout('task_show', array(
'project' => $this->project->getById($task['project_id']),
'files' => $this->file->getAll($task['id']),
'comments' => $this->comment->getAll($task['id']),
- 'subtasks' => $this->subTask->getAll($task['id']),
+ 'subtasks' => $subtasks,
'task' => $task,
+ 'values' => $values,
+ 'timesheet' => $this->timeTracking->getTaskTimesheet($task, $subtasks),
'columns_list' => $this->board->getColumnsList($task['project_id']),
'colors_list' => $this->color->getList(),
+ 'date_format' => $this->config->get('application_date_format'),
+ 'date_formats' => $this->dateParser->getAvailableFormats(),
'menu' => 'tasks',
'title' => $task['title'],
)));
@@ -155,17 +169,10 @@ class Task extends Base
public function edit()
{
$task = $this->getTask();
-
- if (! empty($task['date_due'])) {
- $task['date_due'] = date($this->config->get('application_date_format'), $task['date_due']);
- }
- else {
- $task['date_due'] = '';
- }
-
- $task['score'] = $task['score'] ?: '';
$ajax = $this->request->isAjax();
+ $this->dateParser->format($task, array('date_due'));
+
$params = array(
'values' => $task,
'errors' => array(),
@@ -209,7 +216,7 @@ class Task extends Base
$this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
}
else {
- $this->response->redirect('?controller=task&action=show&task_id='.$values['id']);
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
}
}
else {
@@ -234,6 +241,28 @@ class Task extends Base
}
/**
+ * Update time tracking information
+ *
+ * @access public
+ */
+ public function time()
+ {
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+
+ list($valid, $errors) = $this->taskValidator->validateTimeModification($values);
+
+ if ($valid && $this->task->update($values)) {
+ $this->session->flash(t('Task updated successfully.'));
+ }
+ else {
+ $this->session->flashError(t('Unable to update your task.'));
+ }
+
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
+ }
+
+ /**
* Hide a task
*
* @access public