diff --git a/workflow/engine/src/ProcessMaker/Model/CaseList.php b/workflow/engine/src/ProcessMaker/Model/CaseList.php index 443a61ecf..1e1f30f50 100644 --- a/workflow/engine/src/ProcessMaker/Model/CaseList.php +++ b/workflow/engine/src/ProcessMaker/Model/CaseList.php @@ -62,7 +62,8 @@ class CaseList extends Model 'USR_FIRSTNAME' => 'userFirstname', 'USR_LASTNAME' => 'userLastname', 'USR_EMAIL' => 'userEmail', - 'ADD_TAB_NAME' => 'tableName' + 'ADD_TAB_NAME' => 'tableName', + 'PRO_TITLE' => 'process' ]; /** @@ -180,19 +181,18 @@ class CaseList extends Model $model = CaseList::where('CAL_TYPE', '=', $type) ->leftJoin('USERS', 'USERS.USR_ID', '=', 'CASE_LIST.USR_ID') ->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID') + ->leftJoin('PROCESS', 'PROCESS.PRO_UID', '=', 'ADDITIONAL_TABLES.PRO_UID') ->select([ 'CASE_LIST.*', - 'USERS.USR_UID', 'USERS.USR_USERNAME', 'USERS.USR_FIRSTNAME', 'USERS.USR_LASTNAME', 'USERS.USR_EMAIL', - 'ADDITIONAL_TABLES.ADD_TAB_NAME' + 'PROCESS.PRO_TITLE', + 'ADDITIONAL_TABLES.ADD_TAB_NAME', + 'USERS.USR_UID', 'USERS.USR_USERNAME', 'USERS.USR_FIRSTNAME', 'USERS.USR_LASTNAME', 'USERS.USR_EMAIL' ]) ->where(function ($query) use ($search) { $query ->orWhere('CASE_LIST.CAL_NAME', 'like', '%' . $search . '%') - ->orWhere('CASE_LIST.CAL_DESCRIPTION', 'like', '%' . $search . '%') - ->orWhere('USERS.USR_USERNAME', 'like', '%' . $search . '%') - ->orWhere('USERS.USR_FIRSTNAME', 'like', '%' . $search . '%') - ->orWhere('USERS.USR_LASTNAME', 'like', '%' . $search . '%') - ->orWhere('USERS.USR_EMAIL', 'like', '%' . $search . '%'); + ->orWhere('PROCESS.PRO_TITLE', 'like', '%' . $search . '%') + ->orWhere('ADDITIONAL_TABLES.ADD_TAB_NAME', 'like', '%' . $search . '%'); }) ->orderBy('CASE_LIST.CAL_NAME', $order); diff --git a/workflow/engine/src/ProcessMaker/Services/Api/CaseList.php b/workflow/engine/src/ProcessMaker/Services/Api/CaseList.php index d6f18f2f7..b780665cf 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/CaseList.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/CaseList.php @@ -92,8 +92,8 @@ class CaseList extends Api * Get inbox Case List settings. * @url GET /inbox * @param string $search - * @param string $offset - * @param string $limit + * @param int $offset + * @param int $limit * @access protected * @class AccessControl {@permission PM_CASES} * @return array @@ -107,8 +107,8 @@ class CaseList extends Api * Get draft Case List settings. * @url GET /draft * @param string $search - * @param string $offset - * @param string $limit + * @param int $offset + * @param int $limit * @access protected * @class AccessControl {@permission PM_CASES} * @return array @@ -122,8 +122,8 @@ class CaseList extends Api * Get paused Case List settings. * @url GET /paused * @param string $search - * @param string $offset - * @param string $limit + * @param int $offset + * @param int $limit * @access protected * @class AccessControl {@permission PM_CASES} * @return array @@ -137,13 +137,13 @@ class CaseList extends Api * Get unassigned Case List settings. * @url GET /unassigned * @param string $search - * @param string $offset - * @param string $limit + * @param int $offset + * @param int $limit * @access protected * @class AccessControl {@permission PM_CASES} * @return array */ - public function doGetUnassigned(string $search, int $offset, int $limit) + public function doGetUnassigned(string $search = '', int $offset = 0, int $limit = 10) { return CaseListBusinessModel::getSetting('unassigned', $search, $offset, $limit); } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Home.php b/workflow/engine/src/ProcessMaker/Services/Api/Home.php index 5f40121af..43b40ddc6 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Home.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Home.php @@ -50,9 +50,10 @@ class Home extends Api * @param int $caseNumber * @param int $process * @param int $task + * @param int $limit + * @param int $offset * @param string $caseTitle * @param string $filterCases - * @param string $paged * @param string $sort * * @return array @@ -66,9 +67,10 @@ class Home extends Api int $caseNumber = 0, int $process = 0, int $task = 0, + int $limit = 15, + int $offset = 0, string $caseTitle = '', string $filterCases = '', - string $paged = '0,15', string $sort = 'APP_NUMBER,DESC' ) { try { @@ -83,11 +85,10 @@ class Home extends Api // Get the user that access to the API $usrUid = $this->getUserId(); $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; - // Set the pagination parameters - $paged = explode(',', $paged); + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters $sort = explode(',', $sort); - $properties['start'] = (int)$paged[0]; - $properties['limit'] = (int)$paged[1]; $properties['sort'] = $sort[0]; $properties['dir'] = $sort[1]; $list->setProperties($properties); @@ -108,11 +109,12 @@ class Home extends Api * @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 $paged * @param string $sort * * @return array @@ -126,11 +128,12 @@ class Home extends Api int $caseNumber = 0, int $process = 0, int $task = 0, + int $limit = 15, + int $offset = 0, string $caseTitle = '', string $delegateFrom = '', string $delegateTo = '', string $filterCases = '', - string $paged = '0,15', string $sort = 'APP_NUMBER,DESC' ) { try { @@ -147,11 +150,10 @@ class Home extends Api // 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 - $paged = explode(',', $paged); $sort = explode(',', $sort); - $properties['start'] = (int)$paged[0]; - $properties['limit'] = (int)$paged[1]; $properties['sort'] = $sort[0]; $properties['dir'] = $sort[1]; $list->setProperties($properties); @@ -172,11 +174,12 @@ class Home extends Api * @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 $paged * @param string $sort * * @return array @@ -190,11 +193,12 @@ class Home extends Api int $caseNumber = 0, int $process = 0, int $task = 0, + int $limit = 15, + int $offset = 0, string $caseTitle = '', string $delegateFrom = '', string $delegateTo = '', string $filterCases = '', - string $paged = '0,15', string $sort = 'APP_NUMBER,DESC' ) { try { @@ -211,11 +215,10 @@ class Home extends Api // Get the user that access to the API $usrUid = $this->getUserId(); $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; - // Set the pagination parameters - $paged = explode(',', $paged); + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters $sort = explode(',', $sort); - $properties['start'] = (int)$paged[0]; - $properties['limit'] = (int)$paged[1]; $properties['sort'] = $sort[0]; $properties['dir'] = $sort[1]; // todo: some queries related to the unassigned are using the USR_UID @@ -238,11 +241,12 @@ class Home extends Api * @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 $paged * @param string $sort * * @return array @@ -256,11 +260,12 @@ class Home extends Api int $caseNumber = 0, int $process = 0, int $task = 0, + int $limit = 15, + int $offset = 0, string $caseTitle = '', string $delegateFrom = '', string $delegateTo = '', string $filterCases = '', - string $paged = '0,15', string $sort = 'APP_NUMBER,DESC' ) { try { @@ -277,11 +282,10 @@ class Home extends Api // Get the user that access to the API $usrUid = $this->getUserId(); $properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0; - // Set the pagination parameters - $paged = explode(',', $paged); + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters $sort = explode(',', $sort); - $properties['start'] = (int)$paged[0]; - $properties['limit'] = (int)$paged[1]; $properties['sort'] = $sort[0]; $properties['dir'] = $sort[1]; $list->setProperties($properties); @@ -302,6 +306,8 @@ class Home extends Api * @param int $caseNumber * @param int $process * @param int $task + * @param int $limit + * @param int $offset * @param string $caseTitle * @param string $filterCases * @param string $filter @@ -310,7 +316,6 @@ class Home extends Api * @param string $startCaseTo * @param string $finishCaseFrom * @param string $finishCaseTo - * @param string $paged * @param string $sort * * @return array @@ -324,6 +329,8 @@ class Home extends Api int $caseNumber = 0, int $process = 0, int $task = 0, + int $limit = 15, + int $offset = 0, string $caseTitle = '', string $filterCases = '', string $filter = 'IN_PROGRESS', @@ -332,7 +339,6 @@ class Home extends Api string $startCaseTo = '', string $finishCaseFrom = '', string $finishCaseTo = '', - string $paged = '0,15', string $sort = 'APP_NUMBER,DESC' ) { // Define the filters to apply @@ -351,11 +357,10 @@ class Home extends Api $properties['startCaseTo'] = $startCaseTo; $properties['finishCaseFrom'] = $finishCaseFrom; $properties['finishCaseTo'] = $finishCaseTo; - // Set the pagination parameters - $paged = explode(',', $paged); + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters $sort = explode(',', $sort); - $properties['start'] = (int)$paged[0]; - $properties['limit'] = (int)$paged[1]; $properties['sort'] = $sort[0]; $properties['dir'] = $sort[1]; $result = []; @@ -395,6 +400,7 @@ class Home extends Api * Get counters * * @url GET /counters + * @url GET /mycases/counters * * @return array * @@ -466,6 +472,8 @@ class Home extends Api * @param int $user * @param int $userCompleted * @param int $userStarted + * @param int $limit + * @param int $offset * @param string $caseTitle * @param string $caseStatuses * @param string $filterCases @@ -473,7 +481,6 @@ class Home extends Api * @param string $startCaseTo * @param string $finishCaseFrom * @param string $finishCaseTo - * @param string $paged * @param string $sort * * @return array @@ -491,6 +498,8 @@ class Home extends Api int $user = 0, int $userCompleted = 0, int $userStarted = 0, + int $limit = 15, + int $offset = 0, string $caseTitle = '', string $caseStatuses = '', string $filterCases = '', @@ -498,7 +507,6 @@ class Home extends Api string $startCaseTo = '', string $finishCaseFrom = '', string $finishCaseTo = '', - string $paged = '0,15', string $sort = 'APP_NUMBER,DESC' ) { try { @@ -519,11 +527,10 @@ class Home extends Api $properties['startCaseTo'] = $startCaseTo; $properties['finishCaseFrom'] = $finishCaseFrom; $properties['finishCaseTo'] = $finishCaseTo; - // Set the pagination parameters - $paged = explode(',', $paged); + $properties['start'] = $offset; + $properties['limit'] = $limit; + // Set the sort parameters $sort = explode(',', $sort); - $properties['start'] = (int)$paged[0]; - $properties['limit'] = (int)$paged[1]; $properties['sort'] = $sort[0]; $properties['dir'] = $sort[1]; $list->setProperties($properties); @@ -625,9 +632,7 @@ class Home extends Api public function getPendingTasks(int $appNumber) { // Get the pending task - $result = Delegation::getPendingTask($appNumber); - - return $result; + return Delegation::getPendingTask($appNumber); } /** @@ -647,11 +652,10 @@ class Home extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function getProcesses($text = null, $category = null, $offset = null, $limit = null) + public function getProcesses($text = null, $category = null, int $offset = 0, int $limit = 15) { try { - $processes = Process::getProcessesForHome($text, $category, $offset, $limit); - return $processes; + return Process::getProcessesForHome($text, $category, $offset, $limit); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -673,11 +677,10 @@ class Home extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function getUsers($text = null, $offset = null, $limit = null) + public function getUsers($text = null, int $offset = 0, int $limit = 15) { try { - $users = User::getUsersForHome($text, $offset, $limit); - return $users; + return User::getUsersForHome($text, $offset, $limit); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -732,7 +735,9 @@ class Home extends Api * Get the tasks counters for todo, draft, paused and unassigned * * @url GET /tasks/counter + * * @return array + * * @access protected * @class AccessControl {@permission PM_CASES} */ @@ -782,11 +787,10 @@ class Home extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function getTasks($text = null, $proId = null, $offset = null, $limit = null) + public function getTasks(string $text = null, string $proId = null, int $offset = 0, int $limit = 15) { try { - $tasks = Task::getTasksForHome($text, $proId, $offset, $limit); - return $tasks; + return Task::getTasksForHome($text, $proId, $offset, $limit); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } @@ -806,7 +810,7 @@ class Home extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function getProcessDebugStatus($processUid) + public function getProcessDebugStatus(string $processUid) { try { // Get the process requested @@ -891,8 +895,8 @@ class Home extends Api * @url GET /categories * * @param string $name - * @param int $start * @param int $limit + * @param int $offset * * @return array * @@ -901,11 +905,10 @@ class Home extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function getCategories($name = null, $start = null, $limit = null) + public function getCategories($name = null, int $limit = 0, int $offset = 15) { try { - $categories = ProcessCategory::getProcessCategories($name, $start, $limit); - return $categories; + return ProcessCategory::getProcessCategories($name, $offset, $limit); } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); }