diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-02-08 18:36:13 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-02-08 18:36:13 -0500 |
commit | 73dce1279760434e1d1b7a903a0a7500462d6f9c (patch) | |
tree | 59a4fa8b6aa0215c658d339e6a31a0ba32b10036 /app/Model/ColumnModel.php | |
parent | d3650eaa2582f6224eb5f5549829b7a84cda1ea4 (diff) |
Prevent people to remove columns that contains tasks
Diffstat (limited to 'app/Model/ColumnModel.php')
-rw-r--r-- | app/Model/ColumnModel.php | 18 |
1 files changed, 18 insertions, 0 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 |