diff options
author | Busfreak <martin@middeke.de> | 2015-12-15 12:00:47 +0100 |
---|---|---|
committer | Busfreak <martin@middeke.de> | 2015-12-15 12:00:47 +0100 |
commit | 16e8241f0f29f0afb9c4ad4c6f68699d62d889ff (patch) | |
tree | aa0f03c5c1d7897246e513e52c6a1f823709dd3d /app/Model | |
parent | b834f5475c8eebb76548046558e7d1464cbd01d4 (diff) | |
parent | 9e1f4fa6c7eae1b46cf5431ab085b82e970e2d57 (diff) |
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/ProjectAnalytic.php | 45 | ||||
-rw-r--r-- | app/Model/ProjectPermission.php | 6 | ||||
-rw-r--r-- | app/Model/TaskFinder.php | 1 |
3 files changed, 49 insertions, 3 deletions
diff --git a/app/Model/ProjectAnalytic.php b/app/Model/ProjectAnalytic.php index e77a0368..d23695dc 100644 --- a/app/Model/ProjectAnalytic.php +++ b/app/Model/ProjectAnalytic.php @@ -179,4 +179,49 @@ class ProjectAnalytic extends Base return $stats; } + + /** + * Get the time spent and estimated into each status + * + * @access public + * @param integer $project_id + * @return array + */ + public function getHoursByStatus($project_id) + { + $stats = array(); + + // Get the times related to each task + $tasks = $this->db + ->table(Task::TABLE) + ->columns('id', 'time_estimated', 'time_spent', 'is_active') + ->eq('project_id', $project_id) + ->desc('id') + ->limit(1000) + ->findAll(); + + // Init values + $stats['closed'] = array( + 'time_spent' => 0, + 'time_estimated' => 0, + ); + + $stats['open'] = array( + 'time_spent' => 0, + 'time_estimated' => 0, + ); + + // Add times spent and estimated to each status + foreach ($tasks as &$task) { + if ($task['is_active']) { + $stats['open']['time_estimated'] += $task['time_estimated']; + $stats['open']['time_spent'] += $task['time_spent']; + } else { + $stats['closed']['time_estimated'] += $task['time_estimated']; + $stats['closed']['time_spent'] += $task['time_spent']; + } + } + + return $stats; + } } diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php index b311c10b..f74b8587 100644 --- a/app/Model/ProjectPermission.php +++ b/app/Model/ProjectPermission.php @@ -28,10 +28,10 @@ class ProjectPermission extends Base return $this ->db - ->table(self::TABLE) + ->table(ProjectUserRole::TABLE) ->join(User::TABLE, 'id', 'user_id') ->join(Project::TABLE, 'id', 'project_id') - ->eq(self::TABLE.'.role', $role) + ->eq(ProjectUserRole::TABLE.'.role', $role) ->eq(Project::TABLE.'.is_private', 0) ->in(Project::TABLE.'.id', $project_ids) ->columns( @@ -88,7 +88,7 @@ class ProjectPermission extends Base */ public function isMember($project_id, $user_id) { - return in_array($this->projectUserRole->getUSerRole($project_id, $user_id), array(Role::PROJECT_MEMBER, Role::PROJECT_MANAGER)); + return in_array($this->projectUserRole->getUserRole($project_id, $user_id), array(Role::PROJECT_MEMBER, Role::PROJECT_MANAGER)); } /** diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php index 9514fe4a..836fbe46 100644 --- a/app/Model/TaskFinder.php +++ b/app/Model/TaskFinder.php @@ -122,6 +122,7 @@ class TaskFinder extends Base 'tasks.recurrence_parent', 'tasks.recurrence_child', 'tasks.time_estimated', + 'tasks.time_spent', User::TABLE.'.username AS assignee_username', User::TABLE.'.name AS assignee_name', Category::TABLE.'.name AS category_name', |