From 10debb3f6c442f12d77175d7b16d4e633f6e0bca Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 17 Feb 2015 20:37:14 -0500 Subject: Update task time spent based on subtasks time spent --- app/Model/SubtaskTimeTracking.php | 16 ++++++---------- app/Template/task/time_tracking.php | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/Model/SubtaskTimeTracking.php b/app/Model/SubtaskTimeTracking.php index 1e7e252e..8b197c46 100644 --- a/app/Model/SubtaskTimeTracking.php +++ b/app/Model/SubtaskTimeTracking.php @@ -307,17 +307,13 @@ class SubtaskTimeTracking extends Base ->eq('end', 0) ->findOneColumn('start'); - $time_spent = $this->db - ->table(Subtask::TABLE) - ->eq('id', $subtask_id) - ->findOneColumn('time_spent'); + $subtask = $this->subtask->getById($subtask_id); return $start_time && - $this->db - ->table(Subtask::TABLE) - ->eq('id', $subtask_id) - ->update(array( - 'time_spent' => $time_spent + round((time() - $start_time) / 3600, 1) - )); + $this->subtask->update(array( // Fire the event subtask.update + 'id' => $subtask['id'], + 'time_spent' => $subtask['time_spent'] + round((time() - $start_time) / 3600, 1), + 'task_id' => $subtask['task_id'], + )); } } diff --git a/app/Template/task/time_tracking.php b/app/Template/task/time_tracking.php index 6e86df91..1dea0f0b 100644 --- a/app/Template/task/time_tracking.php +++ b/app/Template/task/time_tracking.php @@ -7,7 +7,7 @@ - + -- cgit v1.2.3
order(t('User'), 'username') ?>order(t('Subtask'), 'subtask_title') ?>order(t('Subtask'), 'subtask_title') ?> order(t('Start'), 'start') ?> order(t('End'), 'end') ?>