From 471e46e70294684efc6d7edfc814d5b9ca04738b Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 1 Jul 2015 19:32:51 -0400 Subject: Add project and column attributes for advanced search --- app/Model/TaskFilter.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'app/Model/TaskFilter.php') diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php index 4a086078..31080cb5 100644 --- a/app/Model/TaskFilter.php +++ b/app/Model/TaskFilter.php @@ -62,6 +62,12 @@ class TaskFilter extends Base case 'T_CATEGORY': $this->filterByCategoryName($value); break; + case 'T_PROJECT': + $this->filterByProjectName($value); + break; + case 'T_COLUMN': + $this->filterByColumnName($value); + break; } } @@ -189,6 +195,29 @@ class TaskFilter extends Base return $this; } + /** + * Filter by project name + * + * @access public + * @param array $values List of project name + * @return TaskFilter + */ + public function filterByProjectName(array $values) + { + $this->query->beginOr(); + + foreach ($values as $project) { + if (ctype_digit($project)) { + $this->query->eq(Task::TABLE.'.project_id', $project); + } + else { + $this->query->ilike(Project::TABLE.'.name', $project); + } + } + + $this->query->closeOr(); + } + /** * Filter by category id * @@ -325,6 +354,24 @@ class TaskFilter extends Base return $this; } + /** + * Filter by column name + * + * @access public + * @param array $values List of column name + * @return TaskFilter + */ + public function filterByColumnName(array $values) + { + $this->query->beginOr(); + + foreach ($values as $project) { + $this->query->ilike(Board::TABLE.'.title', $project); + } + + $this->query->closeOr(); + } + /** * Filter by swimlane * @@ -382,7 +429,6 @@ class TaskFilter extends Base */ public function filterByDueDate($date) { - $this->query->neq(Task::TABLE.'.date_due', ''); $this->query->neq(Task::TABLE.'.date_due', 0); $this->query->notNull(Task::TABLE.'.date_due'); return $this->filterWithOperator(Task::TABLE.'.date_due', $date, true); @@ -452,7 +498,7 @@ class TaskFilter extends Base */ public function findAll() { - return $this->query->findAll(); + return $this->query->asc(Task::TABLE.'.id')->findAll(); } /** -- cgit v1.2.3