From acba6839a6082e3e3800a733f8baea7c843fc02e Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 11 Oct 2014 21:11:10 -0400 Subject: Add 3 new fields for tasks: start date, time estimated and time spent --- app/Controller/Task.php | 51 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'app/Controller/Task.php') 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 { @@ -233,6 +240,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 * -- cgit v1.2.3