diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php index c0229587f..05e652dec 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php @@ -1065,12 +1065,13 @@ class AbstractCases implements CasesInterface * * @param string $dueDate * @param string $statusThread + * @param string $dateToCompare * * @return int */ - public function getTaskColor(string $dueDate, string $statusThread = '') + public function getTaskColor(string $dueDate, string $statusThread = '', $dateToCompare = 'now') { - $currentDate = new DateTime('now'); + $currentDate = new DateTime($dateToCompare); $dueDate = new DateTime($dueDate); if ($currentDate > $dueDate) { // Overdue: When the current date is mayor to the due date of the case @@ -1170,6 +1171,8 @@ class AbstractCases implements CasesInterface { $result = []; $status = ''; + $finishDate = 'now'; + $dateToCompare = date("Y-m-d H:i:s"); // Define the task status if ($thread['TAS_ASSIGN_TYPE'] === 'SELF_SERVICE') { $status = 'UNASSIGNED'; @@ -1177,12 +1180,16 @@ class AbstractCases implements CasesInterface if ($thread['APP_STATUS'] === 'DRAFT') { $status = 'DRAFT'; } + if ($thread['APP_STATUS'] === 'COMPLETED') { + $finishDate = $thread['APP_FINISH_DATE']; + $dateToCompare = $finishDate; + } // Define the thread information $result['tas_title'] = $thread['TAS_TITLE']; $result['user_id'] = $thread['USR_ID']; $result['due_date'] = $thread['DEL_TASK_DUE_DATE']; - $result['delay'] = getDiffBetweenDates($thread['DEL_TASK_DUE_DATE'], date("Y-m-d H:i:s")); - $result['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE'], $status) : ''; + $result['delay'] = getDiffBetweenDates($thread['DEL_TASK_DUE_DATE'], $dateToCompare); + $result['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE'], $status, $finishDate) : ''; $result['tas_color_label'] = (!empty($result['tas_color'])) ? self::TASK_COLORS[$result['tas_color']] : ''; $result['tas_status'] = self::TASK_STATUS[$result['tas_color']]; $result['unassigned'] = ($status === 'UNASSIGNED' ? true : false); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php index 93c57347e..1445d7716 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php @@ -156,6 +156,7 @@ class Participated extends AbstractCases $thread['TAS_TITLE'] = $item['TAS_TITLE']; $thread['USR_ID'] = $item['USR_ID']; $thread['DEL_TASK_DUE_DATE'] = $item['DEL_TASK_DUE_DATE']; + $thread['APP_FINISH_DATE'] = $item['APP_FINISH_DATE']; $thread['TAS_ASSIGN_TYPE'] = $item['TAS_ASSIGN_TYPE']; $thread['APP_STATUS'] = $item['APP_STATUS']; // Define data according to the filters