From 648f6957e8fda5e6016ae7f15e0d292b14f099aa Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 19 Dec 2017 21:08:27 +0200 Subject: [PATCH] Working on task kanban --- app/Constants.php | 8 ++++---- app/Models/Task.php | 12 +++++++++++- app/Ninja/Repositories/TaskRepository.php | 5 +++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/Constants.php b/app/Constants.php index 661935285f..8cc4909b33 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -205,10 +205,10 @@ if (! defined('APP_NAME')) { define('PAYMENT_STATUS_PARTIALLY_REFUNDED', 5); define('PAYMENT_STATUS_REFUNDED', 6); - define('TASK_STATUS_LOGGED', 1); - define('TASK_STATUS_RUNNING', 2); - define('TASK_STATUS_INVOICED', 3); - define('TASK_STATUS_PAID', 4); + define('TASK_STATUS_LOGGED', -1); + define('TASK_STATUS_RUNNING', -2); + define('TASK_STATUS_INVOICED', -3); + define('TASK_STATUS_PAID', -4); define('EXPENSE_STATUS_LOGGED', 1); define('EXPENSE_STATUS_PENDING', 2); diff --git a/app/Models/Task.php b/app/Models/Task.php index 4715382383..d2668290e7 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -239,7 +239,17 @@ class Task extends EntityModel public static function getStatuses($entityType = false) { $statuses = []; - $statuses[TASK_STATUS_LOGGED] = trans('texts.logged'); + + $taskStatues = TaskStatus::scope()->orderBy('sort_order')->get(); + + foreach ($taskStatues as $status) { + $statuses[$status->id] = $status->name; + } + + if (! $taskStatues->count()) { + $statuses[TASK_STATUS_LOGGED] = trans('texts.logged'); + } + $statuses[TASK_STATUS_RUNNING] = trans('texts.running'); $statuses[TASK_STATUS_INVOICED] = trans('texts.invoiced'); $statuses[TASK_STATUS_PAID] = trans('texts.paid'); diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index e749944f76..a7571cc446 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -88,6 +88,11 @@ class TaskRepository extends BaseRepository if (in_array(TASK_STATUS_PAID, $statuses)) { $query->orWhere('invoices.balance', '=', 0); } + $query->orWhere(function ($query) use ($statuses) { + $query->whereIn('tasks.task_status_id', $statuses) + ->whereNull('tasks.invoice_id'); + }); + }); }