Prevent people to remove columns that contains tasks

This commit is contained in:
Frederic Guillot
2017-02-08 18:36:13 -05:00
parent d3650eaa25
commit 73dce12797
33 changed files with 80 additions and 35 deletions

View File

@@ -120,6 +120,24 @@ class ColumnModel extends Base
return $this->db->table(self::TABLE)->eq('project_id', $project_id)->asc('position')->findAll();
}
/**
* 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 ]
*