From 5ca9a12a0ac64dccded3f8ebae16c00f91a49455 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Tue, 11 Nov 2014 21:52:22 -0500 Subject: Add subtasks to the dashboard --- app/Model/SubTask.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'app/Model') diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php index 886ad1f3..f414da7f 100644 --- a/app/Model/SubTask.php +++ b/app/Model/SubTask.php @@ -92,6 +92,38 @@ class SubTask extends Base return $subtasks; } + /** + * Get all subtasks assigned to a user + * + * @access public + * @param integer $user_id User id + * @param array $status List of status + * @return array + */ + public function getAllByUser($user_id, array $status) + { + $status_list = $this->getStatusList(); + $subtasks = $this->db->table(self::TABLE) + ->columns( + self::TABLE.'.*', + Task::TABLE.'.project_id', + Task::TABLE.'.color_id', + Project::TABLE.'.name AS project_name' + ) + ->eq('user_id', $user_id) + ->in(self::TABLE.'.status', $status) + ->join(Task::TABLE, 'id', 'task_id') + ->join(Project::TABLE, 'id', 'project_id', Task::TABLE) + ->asc(Task::TABLE.'.id') + ->findAll(); + + foreach ($subtasks as &$subtask) { + $subtask['status_name'] = $status_list[$subtask['status']]; + } + + return $subtasks; + } + /** * Get a subtask by the id * -- cgit v1.2.3