blob: 4ddddf124418cf8b6e4c0fcb6a804c0660039e41 (
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
|
<?php
namespace Model;
/**
* Time tracking model
*
* @package model
* @author Frederic Guillot
*/
class TimeTracking extends Base
{
/**
* Calculate time metrics for a task
*
* Use subtasks time metrics if not empty otherwise return task time metrics
*
* @access public
* @param array $task Task properties
* @param array $subtasks Subtasks list
* @return array
*/
public function getTaskTimesheet(array $task, array $subtasks)
{
$timesheet = array(
'time_spent' => 0,
'time_estimated' => 0,
'time_remaining' => 0,
);
foreach ($subtasks as &$subtask) {
$timesheet['time_estimated'] += $subtask['time_estimated'];
$timesheet['time_spent'] += $subtask['time_spent'];
}
if ($timesheet['time_estimated'] == 0 && $timesheet['time_spent'] == 0) {
$timesheet['time_estimated'] = $task['time_estimated'];
$timesheet['time_spent'] = $task['time_spent'];
}
$timesheet['time_remaining'] = $timesheet['time_estimated'] - $timesheet['time_spent'];
return $timesheet;
}
}
|