From 4124e59ac233aa13fb43361b2b8628a344eb071c Mon Sep 17 00:00:00 2001 From: Roly Gutierrez Date: Wed, 25 Aug 2021 15:41:05 -0400 Subject: [PATCH] PMCORE-3222 Service - Get custom case list schema and data --- .../BusinessModel/Cases/HomeTest.php | 534 ++++++++++++++++++ .../BusinessModel/Cases/Draft.php | 7 +- .../ProcessMaker/BusinessModel/Cases/Home.php | 461 +++++++++++++++ .../BusinessModel/Cases/Inbox.php | 7 +- .../BusinessModel/Cases/Paused.php | 7 +- .../BusinessModel/Cases/Unassigned.php | 7 +- .../src/ProcessMaker/Services/Api/Home.php | 286 ++++++---- 7 files changed, 1196 insertions(+), 113 deletions(-) create mode 100644 tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php create mode 100644 workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php new file mode 100644 index 000000000..5e7922ee6 --- /dev/null +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php @@ -0,0 +1,534 @@ +states('draft')->create(); + factory(Delegation::class)->states('foreign_keys')->create([ + 'DEL_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => 1, + 'USR_UID' => $application->APP_INIT_USER, + 'APP_UID' => $application->APP_UID, + 'APP_NUMBER' => $application->APP_NUMBER, + ]); + + $home = new Home($application->APP_INIT_USER); + $result = $home->getDraft(); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + } + + /** + * This test the getInbox method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::getInbox() + */ + public function it_should_test_getInbox() + { + $application = factory(Application::class)->states('todo')->create(); + factory(Delegation::class)->states('foreign_keys')->create([ + 'DEL_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => 2 + ]); + + $home = new Home($application->APP_INIT_USER); + $result = $home->getInbox(); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + } + + /** + * This test the getUnassigned method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::getUnassigned() + */ + public function it_should_test_getUnassigned() + { + $user = factory(User::class)->create(); + $group = factory(Groupwf::class)->create(); + factory(GroupUser::class)->create([ + 'GRP_UID' => $group->GRP_UID, + 'GRP_ID' => $group->GRP_ID, + 'USR_UID' => $user->USR_UID, + ]); + $process = factory(Process::class)->create(); + $application = factory(Application::class)->create([ + 'APP_STATUS_ID' => 2 + ]); + $task = factory(Task::class)->create([ + 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', + 'TAS_GROUP_VARIABLE' => '', + 'PRO_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ]); + factory(TaskUser::class)->create([ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'TU_RELATION' => 1, + 'TU_TYPE' => 1 + ]); + factory(Delegation::class)->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'TAS_ID' => $task->TAS_ID, + 'PRO_ID' => $process->PRO_ID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'USR_ID' => 0, + 'DEL_DELEGATE_DATE' => date('Y-m-d H:m:s', strtotime("-1 year")) + ]); + + $home = new Home($user->USR_UID); + $result = $home->getUnassigned(); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + } + + /** + * This test the getPaused method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::getPaused() + */ + public function it_should_test_getPaused() + { + $user = factory(User::class)->create(); + $process1 = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'TAS_ASSIGN_TYPE' => '', + 'TAS_GROUP_VARIABLE' => '', + 'PRO_UID' => $process1->PRO_UID, + 'TAS_TYPE' => 'NORMAL' + ]); + + $application1 = factory(Application::class)->create(); + $delegation1 = factory(Delegation::class)->create([ + 'APP_NUMBER' => $application1->APP_NUMBER, + 'TAS_ID' => $task->TAS_ID, + 'DEL_THREAD_STATUS' => 'CLOSED', + 'USR_UID' => $user->USR_UID, + 'USR_ID' => $user->USR_ID, + 'PRO_ID' => $process1->PRO_ID, + 'PRO_UID' => $process1->PRO_UID, + 'DEL_PREVIOUS' => 1, + 'DEL_INDEX' => 2 + ]); + + $process2 = factory(Process::class)->create(); + $application2 = factory(Application::class)->create(); + $delegation2 = factory(Delegation::class)->create([ + 'APP_NUMBER' => $application2->APP_NUMBER, + 'TAS_ID' => $task->TAS_ID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'USR_UID' => $user->USR_UID, + 'USR_ID' => $user->USR_ID, + 'PRO_ID' => $process2->PRO_ID, + 'PRO_UID' => $process2->PRO_UID, + 'DEL_PREVIOUS' => 1, + 'DEL_INDEX' => 2 + ]); + factory(AppDelay::class, 5)->create([ + 'APP_DELEGATION_USER' => $user->USR_UID, + 'PRO_UID' => $process2->PRO_UID, + 'APP_NUMBER' => $delegation1->APP_NUMBER, + 'APP_DEL_INDEX' => $delegation1->DEL_INDEX, + 'APP_DISABLE_ACTION_USER' => 0, + 'APP_TYPE' => 'PAUSE' + ]); + factory(AppDelay::class, 5)->create([ + 'APP_DELEGATION_USER' => $user->USR_UID, + 'PRO_UID' => $process2->PRO_UID, + 'APP_NUMBER' => $delegation2->APP_NUMBER, + 'APP_DEL_INDEX' => $delegation2->DEL_INDEX, + 'APP_DISABLE_ACTION_USER' => 0, + 'APP_TYPE' => 'PAUSE' + ]); + + $home = new Home($user->USR_UID); + $result = $home->getPaused(); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + } + + /** + * This test the buildCustomCaseList method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::buildCustomCaseList() + */ + public function it_should_test_buildCustomCaseList() + { + $user = factory(User::class)->create(); + $additionalTables = factory(AdditionalTables::class)->create(); + $query = "" + . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" + . "`APP_UID` varchar(32) NOT NULL," + . "`APP_NUMBER` int(11) NOT NULL," + . "`APP_STATUS` varchar(10) NOT NULL," + . "`VAR1` varchar(255) DEFAULT NULL," + . "`VAR2` varchar(255) DEFAULT NULL," + . "`VAR3` varchar(255) DEFAULT NULL," + . "PRIMARY KEY (`APP_UID`)," + . "KEY `indexTable` (`APP_UID`))"; + DB::statement($query); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR1' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR2' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR3' + ]); + + //for inbox + $type = 'inbox'; + $caseList = factory(CaseList::class)->create([ + 'CAL_TYPE' => $type, + '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, + 'USR_ID' => $user->USR_ID + ]); + $arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC']; + $defaultColumns = CaseList::formattingColumns($type, '', []); + + $home = new Home($user->USR_UID); + $home->buildCustomCaseList($type, $caseList->CAL_ID, $arguments, $defaultColumns); + + $this->assertTrue(is_callable(array_pop($arguments))); + } + + /** + * This test the getCustomDraft method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomDraft() + */ + public function it_should_test_getCustomDraft() + { + $additionalTables = factory(AdditionalTables::class)->create(); + $query = "" + . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" + . "`APP_UID` varchar(32) NOT NULL," + . "`APP_NUMBER` int(11) NOT NULL," + . "`APP_STATUS` varchar(10) NOT NULL," + . "`VAR1` varchar(255) DEFAULT NULL," + . "`VAR2` varchar(255) DEFAULT NULL," + . "`VAR3` varchar(255) DEFAULT NULL," + . "PRIMARY KEY (`APP_UID`)," + . "KEY `indexTable` (`APP_UID`))"; + DB::statement($query); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR1' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR2' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR3' + ]); + + $application = factory(Application::class)->states('draft')->create(); + factory(Delegation::class)->states('foreign_keys')->create([ + 'DEL_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => 1, + 'USR_UID' => $application->APP_INIT_USER, + 'APP_UID' => $application->APP_UID, + 'APP_NUMBER' => $application->APP_NUMBER, + ]); + + $caseList = factory(CaseList::class)->create([ + 'CAL_TYPE' => 'draft', + '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']; + + $home = new Home($application->APP_INIT_USER); + $result = $home->getCustomDraft(...$arguments); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + $this->assertArrayHasKey('columns', $result); + } + + /** + * This test the getCustomInbox method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomInbox() + */ + public function it_should_test_getCustomInbox() + { + $additionalTables = factory(AdditionalTables::class)->create(); + $query = "" + . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" + . "`APP_UID` varchar(32) NOT NULL," + . "`APP_NUMBER` int(11) NOT NULL," + . "`APP_STATUS` varchar(10) NOT NULL," + . "`VAR1` varchar(255) DEFAULT NULL," + . "`VAR2` varchar(255) DEFAULT NULL," + . "`VAR3` varchar(255) DEFAULT NULL," + . "PRIMARY KEY (`APP_UID`)," + . "KEY `indexTable` (`APP_UID`))"; + DB::statement($query); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR1' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR2' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR3' + ]); + + $application = factory(Application::class)->states('todo')->create(); + factory(Delegation::class)->states('foreign_keys')->create([ + 'DEL_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => 2 + ]); + + $caseList = factory(CaseList::class)->create([ + 'CAL_TYPE' => 'inbox', + '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']; + + $home = new Home($application->APP_INIT_USER); + $result = $home->getCustomDraft(...$arguments); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + $this->assertArrayHasKey('columns', $result); + } + + /** + * This test the getCustomUnassigned method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomUnassigned() + */ + public function it_should_test_getCustomUnassignedt() + { + $additionalTables = factory(AdditionalTables::class)->create(); + $query = "" + . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" + . "`APP_UID` varchar(32) NOT NULL," + . "`APP_NUMBER` int(11) NOT NULL," + . "`APP_STATUS` varchar(10) NOT NULL," + . "`VAR1` varchar(255) DEFAULT NULL," + . "`VAR2` varchar(255) DEFAULT NULL," + . "`VAR3` varchar(255) DEFAULT NULL," + . "PRIMARY KEY (`APP_UID`)," + . "KEY `indexTable` (`APP_UID`))"; + DB::statement($query); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR1' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR2' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR3' + ]); + + $user = factory(User::class)->create(); + $group = factory(Groupwf::class)->create(); + factory(GroupUser::class)->create([ + 'GRP_UID' => $group->GRP_UID, + 'GRP_ID' => $group->GRP_ID, + 'USR_UID' => $user->USR_UID, + ]); + $process = factory(Process::class)->create(); + $application = factory(Application::class)->create([ + 'APP_STATUS_ID' => 2 + ]); + $task = factory(Task::class)->create([ + 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', + 'TAS_GROUP_VARIABLE' => '', + 'PRO_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + ]); + factory(TaskUser::class)->create([ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'TU_RELATION' => 1, + 'TU_TYPE' => 1 + ]); + factory(Delegation::class)->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'TAS_ID' => $task->TAS_ID, + 'PRO_ID' => $process->PRO_ID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'USR_ID' => 0, + 'DEL_DELEGATE_DATE' => date('Y-m-d H:m:s', strtotime("-1 year")) + ]); + + $caseList = factory(CaseList::class)->create([ + 'CAL_TYPE' => 'unassigned', + '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']; + + $home = new Home($application->APP_INIT_USER); + $result = $home->getCustomDraft(...$arguments); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + $this->assertArrayHasKey('columns', $result); + } + + /** + * This test the getCustomPaused method. + * @test + * @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomPaused() + */ + public function it_should_test_getCustomPaused() + { + $additionalTables = factory(AdditionalTables::class)->create(); + $query = "" + . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" + . "`APP_UID` varchar(32) NOT NULL," + . "`APP_NUMBER` int(11) NOT NULL," + . "`APP_STATUS` varchar(10) NOT NULL," + . "`VAR1` varchar(255) DEFAULT NULL," + . "`VAR2` varchar(255) DEFAULT NULL," + . "`VAR3` varchar(255) DEFAULT NULL," + . "PRIMARY KEY (`APP_UID`)," + . "KEY `indexTable` (`APP_UID`))"; + DB::statement($query); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR1' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR2' + ]); + factory(Fields::class)->create([ + 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, + 'FLD_NAME' => 'VAR3' + ]); + + $user = factory(User::class)->create(); + $process1 = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'TAS_ASSIGN_TYPE' => '', + 'TAS_GROUP_VARIABLE' => '', + 'PRO_UID' => $process1->PRO_UID, + 'TAS_TYPE' => 'NORMAL' + ]); + + $application1 = factory(Application::class)->create(); + $delegation1 = factory(Delegation::class)->create([ + 'APP_NUMBER' => $application1->APP_NUMBER, + 'TAS_ID' => $task->TAS_ID, + 'DEL_THREAD_STATUS' => 'CLOSED', + 'USR_UID' => $user->USR_UID, + 'USR_ID' => $user->USR_ID, + 'PRO_ID' => $process1->PRO_ID, + 'PRO_UID' => $process1->PRO_UID, + 'DEL_PREVIOUS' => 1, + 'DEL_INDEX' => 2 + ]); + + $process2 = factory(Process::class)->create(); + $application2 = factory(Application::class)->create(); + $delegation2 = factory(Delegation::class)->create([ + 'APP_NUMBER' => $application2->APP_NUMBER, + 'TAS_ID' => $task->TAS_ID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'USR_UID' => $user->USR_UID, + 'USR_ID' => $user->USR_ID, + 'PRO_ID' => $process2->PRO_ID, + 'PRO_UID' => $process2->PRO_UID, + 'DEL_PREVIOUS' => 1, + 'DEL_INDEX' => 2 + ]); + factory(AppDelay::class, 5)->create([ + 'APP_DELEGATION_USER' => $user->USR_UID, + 'PRO_UID' => $process2->PRO_UID, + 'APP_NUMBER' => $delegation1->APP_NUMBER, + 'APP_DEL_INDEX' => $delegation1->DEL_INDEX, + 'APP_DISABLE_ACTION_USER' => 0, + 'APP_TYPE' => 'PAUSE' + ]); + factory(AppDelay::class, 5)->create([ + 'APP_DELEGATION_USER' => $user->USR_UID, + 'PRO_UID' => $process2->PRO_UID, + 'APP_NUMBER' => $delegation2->APP_NUMBER, + 'APP_DEL_INDEX' => $delegation2->DEL_INDEX, + 'APP_DISABLE_ACTION_USER' => 0, + 'APP_TYPE' => 'PAUSE' + ]); + + $caseList = factory(CaseList::class)->create([ + 'CAL_TYPE' => 'paused', + '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']; + + $home = new Home($application1->APP_INIT_USER); + $result = $home->getCustomDraft(...$arguments); + + $this->assertArrayHasKey('data', $result); + $this->assertArrayHasKey('total', $result); + $this->assertArrayHasKey('columns', $result); + } +} diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php index 3238ec292..3af923c24 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php @@ -84,10 +84,10 @@ class Draft extends AbstractCases /** * Get data self-services cases by user - * + * @param callable $callback * @return array */ - public function getData() + public function getData(callable $callback = null) { $query = Delegation::query()->select($this->getColumnsView()); // Join with process @@ -105,6 +105,9 @@ class Draft extends AbstractCases } // Add pagination to the query $query->offset($this->getOffset())->limit($this->getLimit()); + if (is_callable($callback)) { + $callback($query); + } // Get the data $results = $query->get(); // Prepare the result diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php new file mode 100644 index 000000000..34b786327 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Home.php @@ -0,0 +1,461 @@ +userId = $userId; + } + + /** + * Get the userId field. + * @return string + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Get the draft cases. + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $filterCases + * @param string $sort + * @param callable $callback + * @return array + */ + public function getDraft( + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC', + callable $callback = null + ) + { + $list = new Draft(); + // Define the filters to apply + $properties = []; + $properties['caseNumber'] = $caseNumber; + $properties['caseTitle'] = $caseTitle; + $properties['filterCases'] = $filterCases; + $properties['process'] = $process; + $properties['task'] = $task; + // Get the user that access to the API + $usrUid = $this->getUserId(); + $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters + $sort = explode(',', $sort); + $properties['sort'] = $sort[0]; + $properties['dir'] = $sort[1]; + $list->setProperties($properties); + $result = []; + $result['data'] = DateTime::convertUtcToTimeZone($list->getData($callback)); + $result['total'] = $list->getPagingCounters(); + return $result; + } + + /** + * Get the inbox cases. + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @param callable $callback + * @return array + */ + public function getInbox( + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC', + callable $callback = null + ) + { + $list = new Inbox(); + // Define the filters to apply + $properties = []; + $properties['caseNumber'] = $caseNumber; + $properties['caseTitle'] = $caseTitle; + $properties['delegateFrom'] = $delegateFrom; + $properties['delegateTo'] = $delegateTo; + $properties['filterCases'] = $filterCases; + $properties['process'] = $process; + $properties['task'] = $task; + // Get the user that access to the API + $usrUid = $this->getUserId(); + $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the pagination parameters + $sort = explode(',', $sort); + $properties['sort'] = $sort[0]; + $properties['dir'] = $sort[1]; + $list->setProperties($properties); + $result = []; + $result['data'] = DateTime::convertUtcToTimeZone($list->getData($callback)); + $result['total'] = $list->getPagingCounters(); + return $result; + } + + /** + * Get the unassigned cases. + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @param callable $callback + * @return array + */ + public function getUnassigned( + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC', + callable $callback = null + ) + { + $list = new Unassigned(); + // Define the filters to apply + $properties = []; + $properties['caseNumber'] = $caseNumber; + $properties['caseTitle'] = $caseTitle; + $properties['delegateFrom'] = $delegateFrom; + $properties['delegateTo'] = $delegateTo; + $properties['filterCases'] = $filterCases; + $properties['process'] = $process; + $properties['task'] = $task; + // Get the user that access to the API + $usrUid = $this->getUserId(); + $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters + $sort = explode(',', $sort); + $properties['sort'] = $sort[0]; + $properties['dir'] = $sort[1]; + // todo: some queries related to the unassigned are using the USR_UID + $list->setUserUid($usrUid); + $list->setProperties($properties); + $result = []; + $result['data'] = DateTime::convertUtcToTimeZone($list->getData($callback)); + $result['total'] = $list->getPagingCounters(); + return $result; + } + + /** + * Get the paused cases. + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @param callable $callback + * @return array + */ + public function getPaused( + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC', + callable $callback = null + ) + { + $list = new Paused(); + // Define the filters to apply + $properties = []; + $properties['caseNumber'] = $caseNumber; + $properties['caseTitle'] = $caseTitle; + $properties['delegateFrom'] = $delegateFrom; + $properties['delegateTo'] = $delegateTo; + $properties['filterCases'] = $filterCases; + $properties['process'] = $process; + $properties['task'] = $task; + // Get the user that access to the API + $usrUid = $this->getUserId(); + $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters + $sort = explode(',', $sort); + $properties['sort'] = $sort[0]; + $properties['dir'] = $sort[1]; + $list->setProperties($properties); + $result = []; + $result['data'] = DateTime::convertUtcToTimeZone($list->getData($callback)); + $result['total'] = $list->getPagingCounters(); + return $result; + } + + /** + * Build the columns and data from the custom list. + * @param string $type + * @param int $id + * @param array $arguments + * @param array $defaultColumns + */ + public function buildCustomCaseList(string $type, int $id, array &$arguments, array &$defaultColumns) + { + $caseList = CaseList::where('CAL_TYPE', '=', $type) + ->where('CAL_ID', '=', $id) + ->join('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID') + ->get() + ->first(); + if (!empty($caseList)) { + $tableName = $caseList->ADD_TAB_NAME; + + //this gets the configured columns + $columns = json_decode($caseList->CAL_COLUMNS); + $columns = CaseList::formattingColumns($type, $caseList->ADD_TAB_UID, $columns); + + //this gets the visible columns from the custom List and the fields from the table + if (!empty($columns)) { + $defaultColumns = []; + } + $fields = []; + foreach ($columns as $value) { + if ($value['set'] === true) { + $defaultColumns[] = $value; + if ($value['source'] === $tableName) { + $fields[] = $value['field']; + } + } + } + + //this modifies the query + if (!empty($tableName) && !empty($fields)) { + $arguments[] = function ($query) use ($tableName, $fields) { + $query->leftJoin($tableName, "{$tableName}.APP_UID", "=", "APP_DELEGATION.APP_UID"); + foreach ($fields as $value) { + $query->addSelect($value); + } + }; + } + } + } + + /** + * Get the custom draft cases. + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $filterCases + * @param string $sort + * @return array + */ + public function getCustomDraft( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + $arguments = func_get_args(); + array_shift($arguments); + + $type = 'draft'; + $defaultColumns = CaseList::formattingColumns($type, '', []); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + + $result = $this->getDraft(...$arguments); + $result['columns'] = $defaultColumns; + return $result; + } + + /** + * Get the custom inbox cases. + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @return array + */ + public function getCustomInbox( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + $arguments = func_get_args(); + array_shift($arguments); + + $type = 'inbox'; + $defaultColumns = CaseList::formattingColumns($type, '', []); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + + $result = $this->getInbox(...$arguments); + $result['columns'] = $defaultColumns; + return $result; + } + + /** + * Get the custom unassigned cases. + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @return array + */ + public function getCustomUnassigned( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + $arguments = func_get_args(); + array_shift($arguments); + + $type = 'unassigned'; + $defaultColumns = CaseList::formattingColumns($type, '', []); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + + $result = $this->getUnassigned(...$arguments); + $result['columns'] = $defaultColumns; + return $result; + } + + /** + * Get the custom paused cases. + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @return array + */ + public function getCustomPaused( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + $arguments = func_get_args(); + array_shift($arguments); + + $type = 'paused'; + $defaultColumns = CaseList::formattingColumns($type, '', []); + $this->buildCustomCaseList($type, $id, $arguments, $defaultColumns); + + $result = $this->getPaused(...$arguments); + $result['columns'] = $defaultColumns; + return $result; + } +} diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php index 82de3e43f..b1bfb1f05 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php @@ -96,10 +96,10 @@ class Inbox extends AbstractCases /** * Get the data corresponding to List Inbox - * + * @param callable $callback * @return array */ - public function getData() + public function getData(callable $callback = null) { // Start the query for get the cases related to the user $query = Delegation::query()->select($this->getColumnsView()); @@ -120,6 +120,9 @@ class Inbox extends AbstractCases } // The limit by clause $query->offset($this->getOffset())->limit($this->getLimit()); + if (is_callable($callback)) { + $callback($query); + } // Execute the query $results = $query->get(); // Prepare the result diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php index 6edcdd483..371ef1997 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php @@ -95,10 +95,10 @@ class Paused extends AbstractCases /** * Gets the data for the paused cases list - * + * @param callable $callback * @return array */ - public function getData() + public function getData(callable $callback = null) { $query = Delegation::query()->select($this->getColumnsView()); // Join with process @@ -114,6 +114,9 @@ class Paused extends AbstractCases $query->orderBy($this->getOrderByColumn(), $this->getOrderDirection()); // Add pagination to the query $query->offset($this->getOffset())->limit($this->getLimit()); + if (is_callable($callback)) { + $callback($query); + } //Execute the query $results = $query->get(); // Prepare the result diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php index 706849d00..957e22501 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php @@ -96,10 +96,10 @@ class Unassigned extends AbstractCases /** * Get data self-services cases by user - * + * @param callable $callback * @return array */ - public function getData() + public function getData(callable $callback = null) { $query = Delegation::query()->select($this->getColumnsView()); // Join with process @@ -122,6 +122,9 @@ class Unassigned extends AbstractCases } // Add pagination to the query $query->offset($this->getOffset())->limit($this->getLimit()); + if (is_callable($callback)) { + $callback($query); + } // Get the data $results = $query->get(); // Prepare the result diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Home.php b/workflow/engine/src/ProcessMaker/Services/Api/Home.php index 7b3aa24e4..138d58336 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Home.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Home.php @@ -6,9 +6,9 @@ use Exception; use G; use Luracast\Restler\RestException; use Menu; -use ProcessMaker\BusinessModel\Cases\CasesList; use ProcessMaker\BusinessModel\Cases\Draft; use ProcessMaker\BusinessModel\Cases\Filter; +use ProcessMaker\BusinessModel\Cases\Home as BMHome; use ProcessMaker\BusinessModel\Cases\Inbox; use ProcessMaker\BusinessModel\Cases\Participated; use ProcessMaker\BusinessModel\Cases\Paused; @@ -60,7 +60,7 @@ class Home extends Api * * @return array * - * @throws Exception + * @throws RestException * * @access protected * @class AccessControl {@permission PM_CASES} @@ -74,30 +74,11 @@ class Home extends Api string $caseTitle = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC' - ) { + ) + { try { - $list = new Draft(); - // Define the filters to apply - $properties = []; - $properties['caseNumber'] = $caseNumber; - $properties['caseTitle'] = $caseTitle; - $properties['filterCases'] = $filterCases; - $properties['process'] = $process; - $properties['task'] = $task; - // Get the user that access to the API - $usrUid = $this->getUserId(); - $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; - $properties['start'] = $offset; - $properties['limit'] = $limit; - // Set the sort parameters - $sort = explode(',', $sort); - $properties['sort'] = $sort[0]; - $properties['dir'] = $sort[1]; - $list->setProperties($properties); - $result = []; - $result['data'] = DateTime::convertUtcToTimeZone($list->getData()); - $result['total'] = $list->getPagingCounters(); - return $result; + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getDraft(...func_get_args()); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -121,7 +102,7 @@ class Home extends Api * * @return array * - * @throws Exception + * @throws RestException * * @access protected * @class AccessControl {@permission PM_CASES} @@ -137,32 +118,11 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC' - ) { + ) + { try { - $list = new Inbox(); - // Define the filters to apply - $properties = []; - $properties['caseNumber'] = $caseNumber; - $properties['caseTitle'] = $caseTitle; - $properties['delegateFrom'] = $delegateFrom; - $properties['delegateTo'] = $delegateTo; - $properties['filterCases'] = $filterCases; - $properties['process'] = $process; - $properties['task'] = $task; - // Get the user that access to the API - $usrUid = $this->getUserId(); - $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; - $properties['start'] = $offset; - $properties['limit'] = $limit; - // Set the pagination parameters - $sort = explode(',', $sort); - $properties['sort'] = $sort[0]; - $properties['dir'] = $sort[1]; - $list->setProperties($properties); - $result = []; - $result['data'] = DateTime::convertUtcToTimeZone($list->getData()); - $result['total'] = $list->getPagingCounters(); - return $result; + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getInbox(...func_get_args()); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -186,7 +146,7 @@ class Home extends Api * * @return array * - * @throws Exception + * @throws RestException * * @access protected * @class AccessControl {@permission PM_CASES} @@ -202,34 +162,11 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC' - ) { + ) + { try { - $list = new Unassigned(); - // Define the filters to apply - $properties = []; - $properties['caseNumber'] = $caseNumber; - $properties['caseTitle'] = $caseTitle; - $properties['delegateFrom'] = $delegateFrom; - $properties['delegateTo'] = $delegateTo; - $properties['filterCases'] = $filterCases; - $properties['process'] = $process; - $properties['task'] = $task; - // Get the user that access to the API - $usrUid = $this->getUserId(); - $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; - $properties['start'] = $offset; - $properties['limit'] = $limit; - // Set the sort parameters - $sort = explode(',', $sort); - $properties['sort'] = $sort[0]; - $properties['dir'] = $sort[1]; - // todo: some queries related to the unassigned are using the USR_UID - $list->setUserUid($usrUid); - $list->setProperties($properties); - $result = []; - $result['data'] = DateTime::convertUtcToTimeZone($list->getData()); - $result['total'] = $list->getPagingCounters(); - return $result; + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getUnassigned(...func_get_args()); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -253,7 +190,7 @@ class Home extends Api * * @return array * - * @throws Exception + * @throws RestException * * @access protected * @class AccessControl {@permission PM_CASES} @@ -269,32 +206,171 @@ class Home extends Api string $delegateTo = '', string $filterCases = '', string $sort = 'APP_NUMBER,DESC' - ) { + ) + { try { - $list = new Paused(); - // Define the filters to apply - $properties = []; - $properties['caseNumber'] = $caseNumber; - $properties['caseTitle'] = $caseTitle; - $properties['delegateFrom'] = $delegateFrom; - $properties['delegateTo'] = $delegateTo; - $properties['filterCases'] = $filterCases; - $properties['process'] = $process; - $properties['task'] = $task; - // Get the user that access to the API - $usrUid = $this->getUserId(); - $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; - $properties['start'] = $offset; - $properties['limit'] = $limit; - // Set the sort parameters - $sort = explode(',', $sort); - $properties['sort'] = $sort[0]; - $properties['dir'] = $sort[1]; - $list->setProperties($properties); - $result = []; - $result['data'] = DateTime::convertUtcToTimeZone($list->getData()); - $result['total'] = $list->getPagingCounters(); - return $result; + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getPaused(...func_get_args()); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * Get the custom draft cases. + * @url GET /draft/:id + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $filterCases + * @param string $sort + * @return array + * @throws RestException + * @access protected + * @class AccessControl {@permission PM_CASES} + */ + public function doGetCustomDraftCases( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + try { + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getCustomDraft(...func_get_args()); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * Get the custom inbox cases. + * @url GET /inbox/:id + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @return array + * @throws RestException + * @access protected + * @class AccessControl {@permission PM_CASES} + */ + public function doGetCustomTodoCases( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + try { + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getCustomInbox(...func_get_args()); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * Get the custom unassigned cases. + * @url GET /unassigned/:id + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @return array + * @throws RestException + * @access protected + * @class AccessControl {@permission PM_CASES} + */ + public function doGetCustomUnassignedCases( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + try { + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getCustomUnassigned(...func_get_args()); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * Get the custom paused cases. + * @url GET /paused/:id + * @param int $id + * @param int $caseNumber + * @param int $process + * @param int $task + * @param int $limit + * @param int $offset + * @param string $caseTitle + * @param string $delegateFrom + * @param string $delegateTo + * @param string $filterCases + * @param string $sort + * @return array + * @throws RestException + * @access protected + * @class AccessControl {@permission PM_CASES} + */ + public function doGetCustomPausedCases( + int $id, + int $caseNumber = 0, + int $process = 0, + int $task = 0, + int $limit = 15, + int $offset = 0, + string $caseTitle = '', + string $delegateFrom = '', + string $delegateTo = '', + string $filterCases = '', + string $sort = 'APP_NUMBER,DESC' + ) + { + try { + $bmHome = new BMHome($this->getUserId()); + return $bmHome->getCustomPaused(...func_get_args()); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); }