summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/ColumnModel.php18
-rw-r--r--app/Model/TaskFinderModel.php11
2 files changed, 24 insertions, 5 deletions
diff --git a/app/Model/ColumnModel.php b/app/Model/ColumnModel.php
index 5498ef54..535a31e5 100644
--- a/app/Model/ColumnModel.php
+++ b/app/Model/ColumnModel.php
@@ -121,6 +121,24 @@ class ColumnModel extends Base
}
/**
+ * Get all columns with tasks count
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @return array
+ */
+ public function getAllWithTasksCount($project_id)
+ {
+ return $this->db->table(self::TABLE)
+ ->columns('id', 'title', 'position', 'task_limit', 'description', 'hide_in_dashboard', 'project_id')
+ ->subquery('SELECT COUNT(*) FROM '.TaskModel::TABLE.' WHERE column_id='.self::TABLE.'.id AND is_active=1', 'nb_open_tasks')
+ ->subquery('SELECT COUNT(*) FROM '.TaskModel::TABLE.' WHERE column_id='.self::TABLE.'.id AND is_active=0', 'nb_closed_tasks')
+ ->eq('project_id', $project_id)
+ ->asc('position')
+ ->findAll();
+ }
+
+ /**
* Get the list of columns sorted by position [ column_id => title ]
*
* @access public
diff --git a/app/Model/TaskFinderModel.php b/app/Model/TaskFinderModel.php
index 3185afb7..e54a613b 100644
--- a/app/Model/TaskFinderModel.php
+++ b/app/Model/TaskFinderModel.php
@@ -367,17 +367,18 @@ class TaskFinderModel extends Base
* Count the number of tasks for a given column and status
*
* @access public
- * @param integer $project_id Project id
- * @param integer $column_id Column id
- * @return integer
+ * @param integer $project_id Project id
+ * @param integer $column_id Column id
+ * @param array $status
+ * @return int
*/
- public function countByColumnId($project_id, $column_id)
+ public function countByColumnId($project_id, $column_id, array $status = array(TaskModel::STATUS_OPEN))
{
return $this->db
->table(TaskModel::TABLE)
->eq('project_id', $project_id)
->eq('column_id', $column_id)
- ->eq('is_active', 1)
+ ->in('is_active', $status)
->count();
}