From b330c3c0b92cebc9fbc89b82b7650df5b9e894d4 Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Thu, 11 Nov 2021 16:33:48 -0400 Subject: [PATCH] COnflicts --- .../BusinessModel/Cases/AbstractCasesTest.php | 63 +++++++++++++++++++ .../BusinessModel/Cases/DraftTest.php | 4 +- .../BusinessModel/Cases/HomeTest.php | 8 +-- .../BusinessModel/Cases/AbstractCases.php | 4 ++ .../BusinessModel/Cases/Draft.php | 14 +++++ .../ProcessMaker/BusinessModel/Cases/Home.php | 49 +++++++++++++-- .../BusinessModel/Cases/Inbox.php | 14 +++++ .../BusinessModel/Cases/Participated.php | 15 +++++ .../BusinessModel/Cases/Paused.php | 10 +++ .../BusinessModel/Cases/Supervising.php | 15 +++++ .../BusinessModel/Cases/Unassigned.php | 14 +++++ .../ProcessMaker/Model/ProcessCategory.php | 30 +++++++++ .../src/ProcessMaker/Services/Api/Home.php | 27 ++++++++ 13 files changed, 257 insertions(+), 10 deletions(-) diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php index 49fa8ac94..239caaeaf 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php @@ -6,6 +6,9 @@ use Exception; use G; use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\BusinessModel\Cases\AbstractCases; +use ProcessMaker\BusinessModel\Cases\Draft; +use ProcessMaker\BusinessModel\Cases\Paused; +use ProcessMaker\BusinessModel\Cases\Unassigned; use ProcessMaker\Model\Application; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Process; @@ -738,6 +741,8 @@ class AbstractCasesTest extends TestCase $absCases = new AbstractCases(); $properties = []; $absCases->setProperties($properties); + $actual = $absCases->getCategoryId(); + $this->assertEquals(0, $actual); $actual = $absCases->getProcessId(); $this->assertEquals(0, $actual); $actual = $absCases->getTaskId(); @@ -784,6 +789,7 @@ class AbstractCasesTest extends TestCase * This check the setter related all the properties * * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties() + * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCategoryId() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProcessId() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setTaskId() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId() @@ -799,6 +805,7 @@ class AbstractCasesTest extends TestCase * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit() * + * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCategoryId() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessId() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskId() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserId() @@ -820,6 +827,7 @@ class AbstractCasesTest extends TestCase $absCases = new AbstractCases(); $properties = [ // Filters that works for all list + 'category' => rand(), 'process' => rand(), 'task' => rand(), 'user' => rand(), @@ -836,6 +844,8 @@ class AbstractCasesTest extends TestCase ]; $absCases->setProperties($properties); // Tasks - Cases + $actual = $absCases->getCategoryId(); + $this->assertEquals($properties['category'], $actual); $actual = $absCases->getProcessId(); $this->assertEquals($properties['process'], $actual); $actual = $absCases->getTaskId(); @@ -887,6 +897,33 @@ class AbstractCasesTest extends TestCase $this->assertNotEmpty($result); } + /** + * This check the get task color + * + * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskColor() + * @test + */ + public function it_return_task_color_class() + { + $absCases = new Draft(); + $dueDate = date('Y-m-d'); + // Review on-time + $result = $absCases->getTaskColor($dueDate,'DRAFT' ,'2000-01-01'); + $this->assertNotEmpty($result); + + $absCases = new Paused(); + $dueDate = date('Y-m-d'); + // Review on-time + $result = $absCases->getTaskColor($dueDate,'PAUSED' ,'2000-01-01'); + $this->assertNotEmpty($result); + + $absCases = new Unassigned(); + $dueDate = date('Y-m-d'); + // Review on-time + $result = $absCases->getTaskColor($dueDate,'UNASSIGNED' ,'2000-01-01'); + $this->assertNotEmpty($result); + } + /** * This check task color according the due date * @@ -925,5 +962,31 @@ class AbstractCasesTest extends TestCase $result = $absCases->threadInformation($thread, true, true); $this->assertNotEmpty($result); } + // APP_STATUS = DRAFT + foreach ($taskPending as $thread) { + $thread['APP_STATUS'] = 'DRAFT'; + $result = $absCases->threadInformation($thread, true, true); + $this->assertNotEmpty($result); + } + // APP_STATUS = COMPLETED + foreach ($taskPending as $thread) { + $thread['APP_STATUS'] = 'COMPLETED'; + $result = $absCases->threadInformation($thread, true, true); + $this->assertNotEmpty($result); + } + // DEL_THREAD_STATUS = PAUSED + foreach ($taskPending as $thread) { + $thread['APP_STATUS'] = 'TO_DO'; + $thread['DEL_THREAD_STATUS'] = 'PAUSED'; + $result = $absCases->threadInformation($thread, true, true); + $this->assertNotEmpty($result); + } + // TAS_ASSIGN_TYPE = SELF_SERVICE + foreach ($taskPending as $thread) { + $thread['APP_STATUS'] = 'TO_DO'; + $thread['TAS_ASSIGN_TYPE'] = 'SELF_SERVICE'; + $result = $absCases->threadInformation($thread, true, true); + $this->assertNotEmpty($result); + } } } \ No newline at end of file diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php index 427fce0ed..d11d2b14f 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php @@ -788,7 +788,7 @@ class DraftTest extends TestCase 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + $del = factory(Delegation::class)->states('foreign_keys')->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, @@ -804,7 +804,7 @@ class DraftTest extends TestCase $draft = new Draft(); $draft->setUserId($user->USR_ID); $draft->setUserUid($user->USR_ID); - $res = $draft->getCasesRisk($process->PRO_ID); + $res = $draft->getCasesRisk($process->PRO_ID, $currentDate, $currentDate, 'ON_TIME', 10); $this->assertCount(1, $res); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php index 36879d5d3..212198cf1 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php @@ -291,7 +291,7 @@ class HomeTest extends TestCase 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - $arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; + $arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; $home = new Home($application->APP_INIT_USER); $result = $home->getCustomDraft(...$arguments); @@ -344,7 +344,7 @@ class HomeTest extends TestCase 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - $arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; + $arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; $home = new Home($application->APP_INIT_USER); $result = $home->getCustomDraft(...$arguments); @@ -423,7 +423,7 @@ class HomeTest extends TestCase 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - $arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; + $arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; $home = new Home($application->APP_INIT_USER); $result = $home->getCustomDraft(...$arguments); @@ -522,7 +522,7 @@ class HomeTest extends TestCase 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - $arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; + $arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; $home = new Home($application1->APP_INIT_USER); $result = $home->getCustomDraft(...$arguments); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php index d3d4d8d30..ee8ffc1ba 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php @@ -1343,6 +1343,10 @@ class AbstractCases implements CasesInterface */ public function setProperties(array $properties) { + // Filter by category + if (!empty($properties['category'])) { + $this->setCategoryId($properties['category']); + } // Filter by process if (!empty($properties['process'])) { $this->setProcessId($properties['process']); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php index 42e9e6720..ed903539c 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php @@ -7,6 +7,7 @@ use ProcessMaker\Model\Application; use ProcessMaker\Model\CaseList; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Task; +use ProcessMaker\Model\ProcessCategory; use ProcessMaker\Model\User; class Draft extends AbstractCases @@ -16,6 +17,7 @@ class Draft extends AbstractCases // Columns view in the cases list 'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.DEL_TITLE', // Case Title + 'PROCESS.CATEGORY_ID', // Category 'PROCESS.PRO_TITLE', // Process 'TASK.TAS_TITLE', // Task 'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date @@ -67,6 +69,10 @@ class Draft extends AbstractCases if (!empty($this->getCaseTitle())) { $query->title($this->getCaseTitle()); } + // Specific category + if ($this->getCategoryId()) { + $query->categoryId($this->getCategoryId()); + } // Specific process if ($this->getProcessId()) { $query->processId($this->getProcessId()); @@ -113,6 +119,9 @@ class Draft extends AbstractCases $results = $query->get(); // Prepare the result $results->transform(function ($item, $key) { + // Get the category + $category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : ''; + $item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY'); // Get priority label $priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']]; $item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}"); @@ -199,6 +208,11 @@ class Draft extends AbstractCases $query = Delegation::query()->select(); // Add the initial scope for draft cases $query->draft($this->getUserId()); + // Check if the category was defined + if ($this->getCategoryId()) { + // Join with process if the filter with category exist + $query->joinProcess(); + } // Apply filters $this->filters($query); // Return the number of rows diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php index 94853ef7f..0a32a3e04 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php @@ -38,7 +38,9 @@ class Home /** * Get the draft cases. + * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -47,10 +49,12 @@ class Home * @param string $filterCases * @param string $sort * @param callable $callback + * * @return array */ public function getDraft( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -67,6 +71,7 @@ class Home $properties['caseNumber'] = $caseNumber; $properties['caseTitle'] = $caseTitle; $properties['filterCases'] = $filterCases; + $properties['category'] = $category; $properties['process'] = $process; $properties['task'] = $task; // Get the user that access to the API @@ -87,7 +92,9 @@ class Home /** * Get the inbox cases. + * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -99,10 +106,12 @@ class Home * @param string $sort * @param string $sendBy * @param callable $callback + * * @return array */ public function getInbox( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -124,6 +133,7 @@ class Home $properties['delegateFrom'] = $delegateFrom; $properties['delegateTo'] = $delegateTo; $properties['filterCases'] = $filterCases; + $properties['category'] = $category; $properties['process'] = $process; $properties['task'] = $task; // Get the user that access to the API @@ -145,7 +155,9 @@ class Home /** * Get the unassigned cases. + * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -157,10 +169,12 @@ class Home * @param string $sort * @param string $sendBy * @param callable $callback + * * @return array */ public function getUnassigned( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -182,6 +196,7 @@ class Home $properties['delegateFrom'] = $delegateFrom; $properties['delegateTo'] = $delegateTo; $properties['filterCases'] = $filterCases; + $properties['category'] = $category; $properties['process'] = $process; $properties['task'] = $task; // Get the user that access to the API @@ -205,7 +220,9 @@ class Home /** * Get the paused cases. + * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -217,10 +234,12 @@ class Home * @param string $sort * @param string $sendBy * @param callable $callback + * * @return array */ public function getPaused( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -242,6 +261,7 @@ class Home $properties['delegateFrom'] = $delegateFrom; $properties['delegateTo'] = $delegateTo; $properties['filterCases'] = $filterCases; + $properties['category'] = $category; $properties['process'] = $process; $properties['task'] = $task; // Get the user that access to the API @@ -263,6 +283,7 @@ class Home /** * Build the columns and data from the custom list. + * * @param string $type * @param int $id * @param array $arguments @@ -345,8 +366,10 @@ class Home /** * Get the custom draft cases. + * * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -355,11 +378,13 @@ class Home * @param string $filterCases * @param string $sort * @param array $customFilters + * * @return array */ public function getCustomDraft( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -372,6 +397,7 @@ class Home { $arguments = [ $caseNumber, + $category, $process, $task, $limit, @@ -382,7 +408,7 @@ class Home ]; //clear duplicate indexes - $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'filterCases', 'sort']; + $keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'filterCases', 'sort']; foreach ($keys as $value) { unset($customFilters[$value]); } @@ -398,8 +424,10 @@ class Home /** * Get the custom inbox cases. + * * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -411,11 +439,13 @@ class Home * @param string $sort * @param string $sendBy * @param array $customFilters + * * @return array */ public function getCustomInbox( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -431,6 +461,7 @@ class Home { $arguments = [ $caseNumber, + $category, $process, $task, $limit, @@ -444,7 +475,7 @@ class Home ]; //clear duplicate indexes - $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; + $keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; foreach ($keys as $value) { unset($customFilters[$value]); } @@ -460,8 +491,10 @@ class Home /** * Get the custom unassigned cases. + * * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -473,11 +506,13 @@ class Home * @param string $sort * @param string $sendBy * @param array $customFilters + * * @return array */ public function getCustomUnassigned( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -493,6 +528,7 @@ class Home { $arguments = [ $caseNumber, + $category, $process, $task, $limit, @@ -506,7 +542,7 @@ class Home ]; //clear duplicate indexes - $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; + $keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; foreach ($keys as $value) { unset($customFilters[$value]); } @@ -522,8 +558,10 @@ class Home /** * Get the custom paused cases. + * * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -535,11 +573,13 @@ class Home * @param string $sort * @param string $sendBy * @param array $customFilters + * * @return array */ public function getCustomPaused( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -555,6 +595,7 @@ class Home { $arguments = [ $caseNumber, + $category, $process, $task, $limit, @@ -568,7 +609,7 @@ class Home ]; //clear duplicate indexes - $keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; + $keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy']; foreach ($keys as $value) { unset($customFilters[$value]); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php index fbdcf13cd..be00c2aad 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php @@ -7,6 +7,7 @@ use ProcessMaker\Model\Application; use ProcessMaker\Model\CaseList; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Task; +use ProcessMaker\Model\ProcessCategory; use ProcessMaker\Model\User; class Inbox extends AbstractCases @@ -16,6 +17,7 @@ class Inbox extends AbstractCases // Columns view in the cases list 'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.DEL_TITLE', // Case Title + 'PROCESS.CATEGORY_ID', // Category 'PROCESS.PRO_TITLE', // Process 'TASK.TAS_TITLE', // Task 'USERS.USR_USERNAME', // Current UserName @@ -70,6 +72,10 @@ class Inbox extends AbstractCases if (!empty($this->getCaseTitle())) { $query->title($this->getCaseTitle()); } + // Specific category + if ($this->getCategoryId()) { + $query->categoryId($this->getCategoryId()); + } // Specific process if ($this->getProcessId()) { $query->processId($this->getProcessId()); @@ -131,6 +137,9 @@ class Inbox extends AbstractCases $results = $query->get(); // Prepare the result $results->transform(function ($item, $key) { + // Get the category + $category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : ''; + $item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY'); // Get priority label $priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']]; $item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}"); @@ -216,6 +225,11 @@ class Inbox extends AbstractCases $query = Delegation::query()->select(); // Scope that sets the queries for List Inbox $query->inbox($this->getUserId()); + // Check if the category was defined + if ($this->getCategoryId()) { + // Join with process if the filter with category exist + $query->joinProcess(); + } // Apply filters $this->filters($query); // Return the number of rows diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php index 54cb1650a..70d162e41 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php @@ -2,10 +2,12 @@ namespace ProcessMaker\BusinessModel\Cases; +use G; use ProcessMaker\Model\Application; use ProcessMaker\Model\AppNotes; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Task; +use ProcessMaker\Model\ProcessCategory; use ProcessMaker\Model\User; class Participated extends AbstractCases @@ -15,6 +17,7 @@ class Participated extends AbstractCases // Columns view in the cases list 'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.DEL_TITLE', // Case Title + 'PROCESS.CATEGORY_ID', // Category 'PROCESS.PRO_TITLE', // Process Name 'TASK.TAS_TITLE', // Pending Task 'TASK.TAS_ASSIGN_TYPE', // Task assign rule @@ -72,6 +75,10 @@ class Participated extends AbstractCases // Add the filter $query->specificCases($result); } + // Specific category + if ($this->getCategoryId()) { + $query->categoryId($this->getCategoryId()); + } // Scope to search for an specific process if ($this->getProcessId()) { $query->processId($this->getProcessId()); @@ -168,6 +175,9 @@ class Participated extends AbstractCases $results = $query->get(); // Prepare the result $results->transform(function ($item, $key) use ($filter) { + // Get the category + $category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : ''; + $item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY'); // Apply the date format defined in environment $item['APP_CREATE_DATE_LABEL'] = !empty($item['APP_CREATE_DATE']) ? applyMaskDateEnvironment($item['APP_CREATE_DATE']): null; $item['APP_FINISH_DATE_LABEL'] = !empty($item['APP_FINISH_DATE']) ? applyMaskDateEnvironment($item['APP_FINISH_DATE']): null; @@ -367,6 +377,11 @@ class Participated extends AbstractCases $query->lastThread(); break; } + // Check if the category was defined + if ($this->getCategoryId()) { + // Join with process if the filter with category exist + $query->joinProcess(); + } // Apply filters $this->filters($query); // Return the number of rows diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php index a0049a744..9ee54e43f 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php @@ -6,6 +6,7 @@ use G; use ProcessMaker\Model\CaseList; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Task; +use ProcessMaker\Model\ProcessCategory; use ProcessMaker\Model\User; class Paused extends AbstractCases @@ -15,6 +16,7 @@ class Paused extends AbstractCases // Columns view in the cases list 'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.DEL_TITLE', // Case Title + 'PROCESS.CATEGORY_ID', // Category 'PROCESS.PRO_TITLE', // Process 'TASK.TAS_TITLE', // Task 'USERS.USR_USERNAME', // Current UserName @@ -125,6 +127,9 @@ class Paused extends AbstractCases $results = $query->get(); // Prepare the result $results->transform(function ($item, $key) { + // Get the category + $category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : ''; + $item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY'); // Get priority label $priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']]; $item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}"); @@ -210,6 +215,11 @@ class Paused extends AbstractCases $query = Delegation::query()->select(); // Scope that set the paused cases $query->paused($this->getUserId()); + // Check if the category was defined + if ($this->getCategoryId()) { + // Join with process if the filter with category exist + $query->joinProcess(); + } // Apply filters $this->filters($query); // Return the number of rows diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php index bb4c61d67..0e4bbf437 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php @@ -2,9 +2,11 @@ namespace ProcessMaker\BusinessModel\Cases; +use G; use ProcessMaker\Model\AppNotes; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\ProcessUser; +use ProcessMaker\Model\ProcessCategory; use ProcessMaker\Model\User; class Supervising extends AbstractCases @@ -14,6 +16,7 @@ class Supervising extends AbstractCases // Columns view in the cases list 'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.DEL_TITLE', // Case Title + 'PROCESS.CATEGORY_ID', // Category 'PROCESS.PRO_TITLE', // Process Name 'TASK.TAS_TITLE', // Pending Task 'APPLICATION.APP_STATUS', // Status @@ -70,6 +73,10 @@ class Supervising extends AbstractCases // Add the filter $query->specificCases($result); } + // Specific category + if ($this->getCategoryId()) { + $query->categoryId($this->getCategoryId()); + } // Scope to search for an specific process if ($this->getProcessId()) { $query->processId($this->getProcessId()); @@ -144,6 +151,9 @@ class Supervising extends AbstractCases $results = $query->get(); // Prepare the result $results->transform(function ($item, $key) { + // Get the category + $category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : ''; + $item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY'); // Get task color label $item['TAS_COLOR'] = $this->getTaskColor($item['DEL_TASK_DUE_DATE']); $item['TAS_COLOR_LABEL'] = self::TASK_COLORS[$item['TAS_COLOR']]; @@ -243,6 +253,11 @@ class Supervising extends AbstractCases $processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid()); // Scope the specific array of processes supervising $query->processInList($processes); + // Check if the category was defined + if ($this->getCategoryId()) { + // Join with process if the filter with category exist + $query->joinProcess(); + } // Apply filters $this->filters($query); // Return the number of rows diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php index 0596dd604..be314177a 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php @@ -7,6 +7,7 @@ use ProcessMaker\Model\Application; use ProcessMaker\Model\CaseList; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Task; +use ProcessMaker\Model\ProcessCategory; use ProcessMaker\Model\User; class Unassigned extends AbstractCases @@ -16,6 +17,7 @@ class Unassigned extends AbstractCases // Columns view in the cases list 'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.DEL_TITLE', // Case Title + 'PROCESS.CATEGORY_ID', // Category 'PROCESS.PRO_TITLE', // Process 'TASK.TAS_TITLE', // Task 'USERS.USR_USERNAME', // Current UserName @@ -70,6 +72,10 @@ class Unassigned extends AbstractCases if ($this->getCaseTitle()) { $query->title($this->getCaseTitle()); } + // Specific category + if ($this->getCategoryId()) { + $query->categoryId($this->getCategoryId()); + } // Specific process if ($this->getProcessId()) { $query->processId($this->getProcessId()); @@ -134,6 +140,9 @@ class Unassigned extends AbstractCases $results = $query->get(); // Prepare the result $results->transform(function ($item, $key) { + // Get the category + $category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : ''; + $item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY'); // Get priority label $priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']]; $item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}"); @@ -219,6 +228,11 @@ class Unassigned extends AbstractCases $query = Delegation::query()->select(); // Add the initial scope for self-service cases $query->selfService($this->getUserUid()); + // Check if the category was defined + if ($this->getCategoryId()) { + // Join with process if the filter with category exist + $query->joinProcess(); + } // Apply filters $this->filters($query); // Return the number of rows diff --git a/workflow/engine/src/ProcessMaker/Model/ProcessCategory.php b/workflow/engine/src/ProcessMaker/Model/ProcessCategory.php index 3e96081c2..f22c7bca4 100644 --- a/workflow/engine/src/ProcessMaker/Model/ProcessCategory.php +++ b/workflow/engine/src/ProcessMaker/Model/ProcessCategory.php @@ -17,6 +17,18 @@ class ProcessCategory extends Model public $timestamps = false; + /** + * Scope a query to specific category id + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param int $category + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeCategory($query, $category) + { + return $query->where('CATEGORY_ID', $category); + } + /** * Scope a query to specific category name * @@ -92,4 +104,22 @@ class ProcessCategory extends Model return $query->first()->CATEGORY_ID; } } + + /** + * Get category name + * + * @param int $category + * + * @return string + */ + public static function getCategory(int $category) + { + $query = ProcessCategory::query()->select(['CATEGORY_NAME']); + $query->category($category); + if ($query->first()) { + return $query->first()->CATEGORY_NAME; + } else { + return ''; + } + } } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Home.php b/workflow/engine/src/ProcessMaker/Services/Api/Home.php index 6dc350d6a..9370c142b 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Home.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Home.php @@ -51,6 +51,7 @@ class Home extends Api * @url GET /draft * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -68,6 +69,7 @@ class Home extends Api */ public function doGetDraftCases( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -81,6 +83,7 @@ class Home extends Api $bmHome = new BMHome($this->getUserId()); return $bmHome->getDraft( $caseNumber, + $category, $process, $task, $limit, @@ -101,6 +104,7 @@ class Home extends Api * @url GET /todo [This is kept for compatibility should not be used 'todo', the reason is to only handle the same verb (inbox) for all 'normal case list' and 'custom case list'] * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -121,6 +125,7 @@ class Home extends Api */ public function doGetTodoCases( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -137,6 +142,7 @@ class Home extends Api $bmHome = new BMHome($this->getUserId()); return $bmHome->getInbox( $caseNumber, + $category, $process, $task, $limit, @@ -159,6 +165,7 @@ class Home extends Api * @url GET /unassigned * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -179,6 +186,7 @@ class Home extends Api */ public function doGetUnassignedCases( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -195,6 +203,7 @@ class Home extends Api $bmHome = new BMHome($this->getUserId()); return $bmHome->getUnassigned( $caseNumber, + $category, $process, $task, $limit, @@ -217,6 +226,7 @@ class Home extends Api * @url GET /paused * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -237,6 +247,7 @@ class Home extends Api */ public function doGetPausedCases( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -253,6 +264,7 @@ class Home extends Api $bmHome = new BMHome($this->getUserId()); return $bmHome->getPaused( $caseNumber, + $category, $process, $task, $limit, @@ -274,6 +286,7 @@ class Home extends Api * @url POST /draft/:id * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -290,6 +303,7 @@ class Home extends Api public function doGetCustomDraftCases( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -305,6 +319,7 @@ class Home extends Api return $bmHome->getCustomDraft( $id, $caseNumber, + $category, $process, $task, $limit, @@ -324,6 +339,7 @@ class Home extends Api * @url POST /inbox/:id * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -343,6 +359,7 @@ class Home extends Api public function doGetCustomInboxCases( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -361,6 +378,7 @@ class Home extends Api return $bmHome->getCustomInbox( $id, $caseNumber, + $category, $process, $task, $limit, @@ -383,6 +401,7 @@ class Home extends Api * @url POST /unassigned/:id * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -402,6 +421,7 @@ class Home extends Api public function doGetCustomUnassignedCases( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -420,6 +440,7 @@ class Home extends Api return $bmHome->getCustomUnassigned( $id, $caseNumber, + $category, $process, $task, $limit, @@ -442,6 +463,7 @@ class Home extends Api * @url POST /paused/:id * @param int $id * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -461,6 +483,7 @@ class Home extends Api public function doGetCustomPausedCases( int $id, int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -479,6 +502,7 @@ class Home extends Api return $bmHome->getCustomPaused( $id, $caseNumber, + $category, $process, $task, $limit, @@ -502,6 +526,7 @@ class Home extends Api * @url GET /mycases * * @param int $caseNumber + * @param int $category * @param int $process * @param int $task * @param int $limit @@ -525,6 +550,7 @@ class Home extends Api */ public function doGetMyCases( int $caseNumber = 0, + int $category = 0, int $process = 0, int $task = 0, int $limit = 15, @@ -544,6 +570,7 @@ class Home extends Api $properties['caseNumber'] = $caseNumber; $properties['caseTitle'] = $caseTitle; $properties['filterCases'] = $filterCases; + $properties['category'] = $category; $properties['process'] = $process; $properties['task'] = $task; // Get the user that access to the API