diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php index b6117a34d..9c23d600f 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php @@ -1250,7 +1250,7 @@ class AbstractCases implements CasesInterface * * @return array */ - public function threadInformation(array $thread, $addUserInfo = false, $addThreadInfo = false) + public function threadInformation(array $thread, $addUserInfo = false, $addThreadInfo = true) { $status = ''; $finishDate = 'now'; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php index 6881e6680..d6acdfd65 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php @@ -176,19 +176,24 @@ class Participated extends AbstractCases switch ($filter) { case 'STARTED': case 'IN_PROGRESS': - $result = []; - $i = 0; switch ($item['APP_STATUS']) { case 'TO_DO': // Get the pending task $taskPending = Delegation::getPendingThreads($item['APP_NUMBER'], false); + $result = []; foreach ($taskPending as $thread) { $thread['APP_STATUS'] = $item['APP_STATUS']; // Get the thread information - $result[$i] = $this->threadInformation($thread); - $i++; + $information = $this->threadInformation($thread); + $result['THREAD_TASKS'] = []; + $result['THREAD_TITLES'] = []; + $result['THREAD_TASKS'][] = $information['THREAD_TASK']; + $result['THREAD_TITLES'][] = $information['THREAD_TITLE']; } - $item['PENDING'] = $result; + // Return THREAD_TASKS and THREAD_USERS in the same column + $item['PENDING'] = !empty($result['THREAD_TASKS']) ? $result['THREAD_TASKS'] : []; + // Return the THREAD_TITLES + $item['THREAD_TITLES'] = !empty($result['THREAD_TITLES']) ? $result['THREAD_TITLES'] : []; break; case 'COMPLETED': // Get the last thread @@ -199,22 +204,57 @@ class Participated extends AbstractCases $thread['APP_STATUS'] = $item['APP_STATUS']; $thread['APP_FINISH_DATE'] = $item['APP_FINISH_DATE']; // Get the thread information - $result[$i] = $this->threadInformation($thread); + $information = $this->threadInformation($thread); + $result = []; + $result[] = $information['THREAD_TASK']; + // Return THREAD_TASKS and THREAD_USERS in the same column $item['PENDING'] = $result; + // Return the THREAD_TITLES + $result = []; + $result[] = $information['THREAD_TITLE']; + $item['THREAD_TITLES'] = $result; break; - default: // Other status - $result[$i] = $this->threadInformation($thread); + default: // Other status like DRAFT + // Get the last thread + $taskPending = Delegation::getLastThread($item['APP_NUMBER']); + // Get the head of array + $thread = head($taskPending); + // Define some values required for define the color status + $thread['APP_STATUS'] = $item['APP_STATUS']; + $thread['APP_FINISH_DATE'] = $item['APP_FINISH_DATE']; + // Get the thread information + $information = $this->threadInformation($thread); + $result = []; + $result[] = $information['THREAD_TASK']; + // Return THREAD_TASKS and THREAD_USERS in the same column $item['PENDING'] = $result; + // Return the THREAD_TITLES + $result = []; + $result[] = $information['THREAD_TITLE']; + $item['THREAD_TITLES'] = $result; } break; case 'COMPLETED': + // Get the last thread + $taskPending = Delegation::getLastThread($item['APP_NUMBER']); + // Get the head of array + $thread = head($taskPending); + // Define some values required for define the color status + $thread['APP_STATUS'] = $item['APP_STATUS']; + $thread['APP_FINISH_DATE'] = $item['APP_FINISH_DATE']; + // Get the thread information + $information = $this->threadInformation($thread); $result = []; - $i = 0; - $result[$i] = $this->threadInformation($thread); + $result[] = $information['THREAD_TASK']; + // Return THREAD_TASKS and THREAD_USERS in the same column $item['PENDING'] = $result; + // Return the THREAD_TITLES + $result = []; + $result[] = $information['THREAD_TITLE']; + $item['THREAD_TITLES'] = $result; break; } - // Get the send by related to the previous index + // Get send by related to the previous index $previousThread = Delegation::getThreadInfo($item['APP_NUMBER'], $item['DEL_PREVIOUS']); $userInfo = !empty($previousThread) ? User::getInformation($previousThread['USR_ID']) : []; $result = []; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php index c49b89faa..633531569 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Search.php @@ -183,7 +183,7 @@ class Search extends AbstractCases $result = []; foreach ($taskPending as $thread) { $thread['APP_STATUS'] = $item['APP_STATUS']; - $information = $this->threadInformation($thread, true, true); + $information = $this->threadInformation($thread, true); $result['THREAD_TASKS'][$i] = $information['THREAD_TASK']; $result['THREAD_USERS'][$i] = $information['THREAD_USER']; $result['THREAD_TITLES'][$i] = $information['THREAD_TITLE']; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php index 08b500421..638b7486c 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php @@ -155,13 +155,18 @@ class Supervising extends AbstractCases $item['CASE_NOTES_COUNT'] = AppNotes::total($item['APP_NUMBER']); // Get the detail related to the open thread $taskPending = Delegation::getPendingThreads($item['APP_NUMBER']); - $information = []; + $result = []; foreach ($taskPending as $thread) { $thread['APP_STATUS'] = $item['APP_STATUS']; - $information[] = $this->threadInformation($thread); + $information = $this->threadInformation($thread); + $result['THREAD_TASKS'] = []; + $result['THREAD_TITLES'] = []; + $result['THREAD_TASKS'][] = $information['THREAD_TASK']; + $result['THREAD_TITLES'][] = $information['THREAD_TITLE']; } - $item['PENDING'] = $information; - // Get the send by related to the previous index + $item['PENDING'] = $result['THREAD_TASKS']; + $item['THREAD_TITLES'] = $result['THREAD_TITLES']; + // Get send by related to the previous index $previousThread = Delegation::getThreadInfo($item['APP_NUMBER'], $item['DEL_PREVIOUS']); $userInfo = !empty($previousThread) ? User::getInformation($previousThread['USR_ID']) : []; $result = [];