Update task time spent based on subtasks time spent

This commit is contained in:
Frederic Guillot 2015-02-17 20:37:14 -05:00
parent 4ec507724f
commit 10debb3f6c
2 changed files with 7 additions and 11 deletions

View File

@ -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'],
));
}
}

View File

@ -7,7 +7,7 @@
<table class="table-fixed">
<tr>
<th class="column-20"><?= $subtask_paginator->order(t('User'), 'username') ?></th>
<th class="column-40"><?= $subtask_paginator->order(t('Subtask'), 'subtask_title') ?></th>
<th class="column-30"><?= $subtask_paginator->order(t('Subtask'), 'subtask_title') ?></th>
<th><?= $subtask_paginator->order(t('Start'), 'start') ?></th>
<th><?= $subtask_paginator->order(t('End'), 'end') ?></th>
</tr>