diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index 2c9d43145..180f1901a 100755 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -4262,8 +4262,14 @@ msgstr "The Case {APP_NUMBER} was unpaused successfully!" # TRANSLATION # LABEL/ID_CASE_USER_INVALID_CANCEL_CASE #: LABEL/ID_CASE_USER_INVALID_CANCEL_CASE -msgid "The user with \"{0}\" is invalid to cancel the Case." -msgstr "The user with \"{0}\" is invalid to cancel the Case." +msgid "The user with \"{0}\" is invalid to cancel the case." +msgstr "The user with \"{0}\" is invalid to cancel the case." + +# TRANSLATION +# LABEL/ID_CASE_USER_INVALID_CLAIM_CASE +#: LABEL/ID_CASE_USER_INVALID_CLAIM_CASE +msgid "The user with \"{0}\" is invalid to claim the case." +msgstr "The user with \"{0}\" is invalid to claim the case." # TRANSLATION # LABEL/ID_CASE_USER_INVALID_PAUSED_CASE @@ -4274,8 +4280,8 @@ msgstr "The user with \"{0}\" is invalid to pause the case." # TRANSLATION # LABEL/ID_CASE_USER_INVALID_UNPAUSE_CASE #: LABEL/ID_CASE_USER_INVALID_UNPAUSE_CASE -msgid "The user with \"{0}\" is invalid to Unpause the Case." -msgstr "The user with \"{0}\" is invalid to Unpause the Case." +msgid "The user with \"{0}\" is invalid to Unpause the case." +msgstr "The user with \"{0}\" is invalid to Unpause the case." # TRANSLATION # LABEL/ID_CASE_USER_NOT_HAVE_PERMISSION diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 93452c51a..60be34a13 100755 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -57521,9 +57521,10 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_CASE_TRACKER_OBJECT_DOES_NOT_EXIST','en','The case tracker object with {0}: {1} does not exist.','2014-05-20') , ( 'LABEL','ID_CASE_UNARHIVE','en','Case Unarhive','2015-09-15') , ( 'LABEL','ID_CASE_UNPAUSED_SUCCESSFULLY','en','The Case {APP_NUMBER} was unpaused successfully!','2014-01-15') , -( 'LABEL','ID_CASE_USER_INVALID_CANCEL_CASE','en','The user with "{0}" is invalid to cancel the Case.','2015-08-24') , +( 'LABEL','ID_CASE_USER_INVALID_CANCEL_CASE','en','The user with "{0}" is invalid to cancel the case.','2015-08-24') , +( 'LABEL','ID_CASE_USER_INVALID_CLAIM_CASE','en','The user with "{0}" is invalid to claim the case.','2021-05-212') , ( 'LABEL','ID_CASE_USER_INVALID_PAUSED_CASE','en','The user with "{0}" is invalid to pause the case.','2015-08-14') , -( 'LABEL','ID_CASE_USER_INVALID_UNPAUSE_CASE','en','The user with "{0}" is invalid to Unpause the Case.','2015-08-14') , +( 'LABEL','ID_CASE_USER_INVALID_UNPAUSE_CASE','en','The user with "{0}" is invalid to Unpause the case.','2015-08-14') , ( 'LABEL','ID_CASE_USER_NOT_HAVE_PERMISSION','en','The user with "{0}" did not have permission to perform this action.','2015-09-01') , ( 'LABEL','ID_CASE_VARIABLE_ALREADY_EXISTS','en','The Variable with {0}: "{1}" already exists in Case','2016-02-23') , ( 'LABEL','ID_CASE_VARIABLE_DOES_NOT_EXIST','en','The Variable with {0}: "{1}" does not exist in Case','2016-02-23') , diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 7390dab78..a438568b8 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -39,6 +39,7 @@ use InputDocument; use InvalidIndexSearchTextException; use PmDynaform; use PmTable; +use ProcessMaker\BusinessModel\Cases as BmCases; use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor; use ProcessMaker\BusinessModel\Task as BmTask; use ProcessMaker\BusinessModel\User as BmUser; @@ -912,12 +913,12 @@ class Cases * @access public * @param string $appUid, Uid for case * @param string $usrUid, Uid for user - * @param bool|string $delIndex + * @param interger $delIndex * * @return void * @throws Exception */ - public function putCancelCase($appUid, $usrUid, $delIndex = false) + public function putCancelCase($appUid, $usrUid, $delIndex = null, $reason = '', $sendMail = false) { Validator::isString($appUid, '$app_uid'); Validator::appUid($appUid, '$app_uid'); @@ -929,7 +930,7 @@ class Cases $supervisor = new BmProcessSupervisor(); $isSupervisor = $supervisor->isUserProcessSupervisor($fields['PRO_UID'], $usrUid); - if ($delIndex === false) { + if (is_null($delIndex)) { $u = new ModelUsers(); $usrId = $u->load($usrUid)['USR_ID']; @@ -956,6 +957,13 @@ class Cases if ($result->status_code !== 0) { throw new Exception($result->message); } + /** Add the note */ + if (!empty($reason)) { + $noteContent = $reason; + // Define the Case for register a case note + $cases = new BmCases(); + $response = $cases->addNote($appUid, $usrUid, $noteContent, $sendMail); + } } /** @@ -1076,6 +1084,39 @@ class Cases $case->unpauseCase($app_uid, $del_index, $usr_uid); } + /** + * Put claim case + * + * @param string $appUid + * @param integer $index + * @param string $userUid + * + * @return void + * @throws Exception + * + * @access public + */ + public function putClaimCase($appUid, $index, $userUid) + { + // Validate the parameters + Validator::isString($appUid, '$appUid'); + Validator::isString($userUid, '$userUid'); + Validator::isInteger($index, '$index'); + Validator::appUid($appUid, '$appUid'); + Validator::usrUid($userUid, '$userUid'); + + // Review if the user can claim the case + $appDelegation = new AppDelegation(); + $delegation = $appDelegation->load($appUid, $index); + if (empty($delegation['USR_UID'])) { + $case = new ClassesCases(); + $case->loadCase($appUid); + $case->setCatchUser($appUid, $index, $userUid); + } else { + throw new Exception(G::LoadTranslation("ID_CASE_USER_INVALID_CLAIM_CASE", [$userUid])); + } + } + /** * Put execute trigger case * @@ -1977,98 +2018,89 @@ class Cases /** * Get Case Notes * - * @access public - * @param string $app_uid , Uid for case + * @param string $appUid + * @param string $usrUid + * @param array $parameters * * @return array - * @throws Exception + * @throws \PropelException + * @access public */ - public function getCaseNotes($app_uid, $usr_uid, $data_get) + public function getCaseNotes($appUid, $usrUid, $parameters = []) { - Validator::isString($app_uid, '$app_uid'); - Validator::appUid($app_uid, '$app_uid'); - Validator::isString($usr_uid, '$usr_uid'); - Validator::usrUid($usr_uid, '$usr_uid'); - Validator::isArray($data_get, '$data_get'); - - Validator::isArray($data_get, '$data_get'); - $start = isset($data_get["start"]) ? $data_get["start"] : "0"; - $limit = isset($data_get["limit"]) ? $data_get["limit"] : ""; - $sort = isset($data_get["sort"]) ? $data_get["sort"] : "APP_NOTES.NOTE_DATE"; - $dir = isset($data_get["dir"]) ? $data_get["dir"] : "DESC"; - $user = isset($data_get["user"]) ? $data_get["user"] : ""; - $dateFrom = (!empty($data_get["dateFrom"])) ? substr($data_get["dateFrom"], 0, 10) : ""; - $dateTo = (!empty($data_get["dateTo"])) ? substr($data_get["dateTo"], 0, 10) : ""; - $search = isset($data_get["search"]) ? $data_get["search"] : ""; - $paged = isset($data_get["paged"]) ? $data_get["paged"] : true; - - $case = new ClassesCases(); - $caseLoad = $case->loadCase($app_uid); - $pro_uid = $caseLoad['PRO_UID']; - $tas_uid = AppDelegation::getCurrentTask($app_uid); - $respView = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW'); - $respBlock = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK'); - if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { - throw (new Exception(G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS"))); - } - - if ($sort != 'APP_NOTE.NOTE_DATE') { - $sort = G::toUpper($sort); - $columnsAppCacheView = AppNotesPeer::getFieldNames(BasePeer::TYPE_FIELDNAME); - if (!(in_array($sort, $columnsAppCacheView))) { - $sort = 'APP_NOTES.NOTE_DATE'; - } else { - $sort = 'APP_NOTES.' . $sort; - } - } - if ((int)$start == 1 || (int)$start == 0) { - $start = 0; - } - $dir = G::toUpper($dir); - if (!($dir == 'DESC' || $dir == 'ASC')) { - $dir = 'DESC'; - } - if ($user != '') { + // Validate parameters + Validator::isString($appUid, '$app_uid'); + Validator::appUid($appUid, '$app_uid'); + Validator::isString($usrUid, '$usr_uid'); + Validator::usrUid($usrUid, '$usr_uid'); + Validator::isArray($parameters, '$parameters'); + Validator::isArray($parameters, '$parameters'); + $start = isset($parameters["start"]) ? $parameters["start"] : "0"; + $limit = isset($parameters["limit"]) ? $parameters["limit"] : ""; + $sort = isset($parameters["sort"]) ? $parameters["sort"] : "NOTE_DATE"; + $dir = isset($parameters["dir"]) ? $parameters["dir"] : "DESC"; + $user = isset($parameters["user"]) ? $parameters["user"] : ""; + $dateFrom = (!empty($parameters["dateFrom"])) ? substr($parameters["dateFrom"], 0, 10) : ""; + $dateTo = (!empty($parameters["dateTo"])) ? substr($parameters["dateTo"], 0, 10) : ""; + $search = isset($parameters["search"]) ? $parameters["search"] : ""; + $paged = isset($parameters["paged"]) ? $parameters["paged"] : true; + $files = isset($parameters["files"]) ? $parameters["files"] : false; + if (!empty($user)) { Validator::usrUid($user, '$usr_uid'); } - if ($dateFrom != '') { + if (!empty($dateFrom)) { Validator::isDate($dateFrom, 'Y-m-d', '$date_from'); } - if ($dateTo != '') { + if (!empty($dateTo)) { Validator::isDate($dateTo, 'Y-m-d', '$date_to'); } - - $appNote = new \AppNotes(); - $note_data = $appNote->getNotesList($app_uid, $user, $start, $limit, $sort, $dir, $dateFrom, $dateTo, $search); - $response = array(); - if ($paged === true) { - $response['total'] = $note_data['array']['totalCount']; - $response['start'] = $start; - $response['limit'] = $limit; - $response['sort'] = $sort; - $response['dir'] = $dir; - $response['usr_uid'] = $user; - $response['date_to'] = $dateTo; - $response['date_from'] = $dateFrom; - $response['search'] = $search; - $response['data'] = array(); - $con = 0; - foreach ($note_data['array']['notes'] as $value) { - $response['data'][$con]['app_uid'] = $value['APP_UID']; - $response['data'][$con]['usr_uid'] = $value['USR_UID']; - $response['data'][$con]['note_date'] = $value['NOTE_DATE']; - $response['data'][$con]['note_content'] = $value['NOTE_CONTENT']; - $con++; + // Review the process permissions + $case = new ClassesCases(); + $caseLoad = $case->loadCase($appUid); + $proUid = $caseLoad['PRO_UID']; + $tasUid = AppDelegation::getCurrentTask($appUid); + $respView = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'VIEW'); + $respBlock = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'BLOCK'); + if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { + throw new Exception(G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")); + } + // Get the notes + $appNote = new Notes(); + $notes = $appNote->getNotes($appUid, $start, $limit, $dir); + $notes = AppNotes::applyHtmlentitiesInNotes($notes); + // Add a the notes the files related + $documents = new Documents(); + $iterator = 0; + $data = []; + foreach ($notes['notes'] as $value) { + $data[$iterator] = array_change_key_case($value, CASE_LOWER); + $data[$iterator]['note_date'] = UtilDateTime::convertUtcToTimeZone($value['NOTE_DATE']); + if ($files) { + $data[$iterator]['attachments'] = $documents->getFiles($value['NOTE_ID']); } + $iterator++; + } + // If is paged will add the filters used + $filters = []; + if ($paged) { + $total = $appNote->getTotal($appUid); + $filters['total'] = $total; + $filters['start'] = $start; + $filters['limit'] = $limit; + $filters['sort'] = $sort; + $filters['dir'] = $dir; + $filters['usr_uid'] = $user; + $filters['date_to'] = $dateTo; + $filters['date_from'] = $dateFrom; + $filters['search'] = $search; + } + // Prepare the response + $response = []; + if ($paged) { + $response = $filters; + $response['data'] = $data; } else { - $con = 0; - foreach ($note_data['array']['notes'] as $value) { - $response[$con]['app_uid'] = $value['APP_UID']; - $response[$con]['usr_uid'] = $value['USR_UID']; - $response[$con]['note_date'] = $value['NOTE_DATE']; - $response[$con]['note_content'] = $value['NOTE_CONTENT']; - $con++; - } + $response = $data; } return $response; @@ -2078,40 +2110,37 @@ class Cases * Save new case note * * @access public - * @param string $app_uid , Uid for case - * @param array $app_data , Data for case variables + * @param string $appUid, Uid for case + * @param string $usrUid, Uid for user + * @param string $noteContent + * @param boolean $sendMail * * @return void * @throws Exception */ - public function saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail = false) + public function saveCaseNote($appUid, $usrUid, $noteContent, $sendMail = false) { - Validator::isString($app_uid, '$app_uid'); - Validator::appUid($app_uid, '$app_uid'); - - Validator::isString($usr_uid, '$usr_uid'); - Validator::usrUid($usr_uid, '$usr_uid'); - - Validator::isString($note_content, '$note_content'); - if (strlen($note_content) > 500) { - throw (new Exception(G::LoadTranslation("ID_INVALID_MAX_PERMITTED", array($note_content, '500')))); + Validator::isString($appUid, '$app_uid'); + Validator::appUid($appUid, '$app_uid'); + Validator::isString($usrUid, '$usr_uid'); + Validator::usrUid($usrUid, '$usr_uid'); + Validator::isString($noteContent, '$note_content'); + if (strlen($noteContent) > 500) { + throw (new Exception(G::LoadTranslation("ID_INVALID_MAX_PERMITTED", [$noteContent, '500']))); } - - Validator::isBoolean($send_mail, '$send_mail'); - + Validator::isBoolean($sendMail, '$send_mail'); + // Review the process permissions $case = new ClassesCases(); - $caseLoad = $case->loadCase($app_uid); - $pro_uid = $caseLoad['PRO_UID']; - $tas_uid = AppDelegation::getCurrentTask($app_uid); - $respView = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW'); - $respBlock = $case->getAllObjectsFrom($pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK'); + $caseLoad = $case->loadCase($appUid); + $proUid = $caseLoad['PRO_UID']; + $tasUid = AppDelegation::getCurrentTask($appUid); + $respView = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'VIEW'); + $respBlock = $case->getAllObjectsFrom($proUid, $appUid, $tasUid, $usrUid, 'BLOCK'); if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { throw (new Exception(G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS"))); } - - $note_content = addslashes($note_content); - // Define the Case for register a case note - $response = $this->addNote($app_uid, $usr_uid, $note_content, intval($send_mail)); + // Save the notes + $response = $this->addNote($appUid, $usrUid, $noteContent, intval($sendMail)); } /** @@ -3988,7 +4017,7 @@ class Cases } } - //rules validation + // Rules validation foreach ($files as $key => $value) { $entry = [ "filename" => $value['name'], diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php index 32f84b545..425e73238 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php @@ -1,6 +1,6 @@ - * @copyright Colosa - Bolivia - * * @protected */ class Cases extends Api @@ -79,17 +76,17 @@ class Cases extends Api } //Check if the user has the case $appDelegation = new AppDelegation(); - $aCurUser = $appDelegation->getCurrentUsers($applicationUid, $delIndex); - if (!empty($aCurUser)) { - foreach ($aCurUser as $key => $value) { + $curUser = $appDelegation->getCurrentUsers($applicationUid, $delIndex); + if (!empty($curUser)) { + foreach ($curUser as $key => $value) { if ($value === $userUid) { return true; } } } //Check if the user has Permissions - $oCases = new BmCases(); - return $oCases->checkUserHasPermissionsOrSupervisor($userUid, $applicationUid, $dynaformUid); + $cases = new BmCases(); + return $cases->checkUserHasPermissionsOrSupervisor($userUid, $applicationUid, $dynaformUid); break; case 'doPutCaseVariables': $applicationUid = $this->parameters[$arrayArgs['app_uid']]; @@ -153,8 +150,8 @@ class Cases extends Api $arrayApplicationData = $case->getApplicationRecordByPk($appUid, [], false); if (!empty($arrayApplicationData)) { $criteria = new Criteria('workflow'); - $criteria->addSelectColumn(AppDelegationPeer::APP_UID); - $criteria->add(AppDelegationPeer::APP_UID, $appUid); + $criteria->addSelectColumn(AppDelegationPeer::appUid); + $criteria->add(AppDelegationPeer::appUid, $appUid); $criteria->add(AppDelegationPeer::USR_UID, $usrUid); $criteria->setLimit(1); $rsCriteria = AppDelegationPeer::doSelectRS($criteria); @@ -187,14 +184,14 @@ class Cases extends Api $appDocUid = $this->parameters[$arrayArgs['app_doc_uid']]; $version = $this->parameters[$arrayArgs['v']]; $usrUid = $this->getUserId(); - $oAppDocument = new AppDocument(); + $appDocument = new AppDocument(); if ($version == 0) { - $docVersion = $oAppDocument->getLastAppDocVersion($appDocUid); + $docVersion = $appDocument->getLastAppDocVersion($appDocUid); } else { $docVersion = $version; } if (defined('DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION') && DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION == 0) { - if ($oAppDocument->canDownloadInput($usrUid, $appDocUid, $docVersion)) { + if ($appDocument->canDownloadInput($usrUid, $appDocUid, $docVersion)) { return true; } } else { @@ -212,6 +209,8 @@ class Cases extends Api /** * Get list Cases To Do * + * @url GET + * * @param int $start {@from path} * @param int $limit {@from path} * @param string $sort {@from path} @@ -219,10 +218,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET */ public function doGetCasesListToDo( $start = 0, @@ -237,7 +235,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'todo'; $dataList['paged'] = false; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -245,8 +242,8 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { @@ -256,6 +253,7 @@ class Cases extends Api /** * Get list Cases To Do with paged + * @url GET /paged * * @param int $start {@from path} * @param int $limit {@from path} @@ -264,10 +262,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /paged */ public function doGetCasesListToDoPaged( $start = 0, @@ -282,7 +279,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'todo'; $dataList['paged'] = true; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -290,8 +286,9 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -300,6 +297,7 @@ class Cases extends Api /** * Get list Cases Draft + * @url GET /draft * * @param int $start {@from path} * @param int $limit {@from path} @@ -308,10 +306,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /draft */ public function doGetCasesListDraft( $start = 0, @@ -326,7 +323,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'draft'; $dataList['paged'] = false; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -334,8 +330,9 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -344,6 +341,7 @@ class Cases extends Api /** * Get list Cases Draft with paged + * @url GET /draft/paged * * @param int $start {@from path} * @param int $limit {@from path} @@ -352,10 +350,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /draft/paged */ public function doGetCasesListDraftPaged( $start = 0, @@ -370,7 +367,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'draft'; $dataList['paged'] = true; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -378,8 +374,9 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -388,6 +385,7 @@ class Cases extends Api /** * Get list Cases Participated + * @url GET /participated * * @param int $start {@from path} * @param int $limit {@from path} @@ -396,10 +394,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /participated */ public function doGetCasesListParticipated( $start = 0, @@ -414,7 +411,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'sent'; $dataList['paged'] = false; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -422,8 +418,9 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -432,6 +429,7 @@ class Cases extends Api /** * Get list Cases Participated with paged + * @url GET /participated/paged * * @param int $start {@from path} * @param int $limit {@from path} @@ -440,10 +438,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /participated/paged */ public function doGetCasesListParticipatedPaged( $start = 0, @@ -458,7 +455,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'sent'; $dataList['paged'] = true; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -466,8 +462,9 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -476,6 +473,7 @@ class Cases extends Api /** * Get list Cases Unassigned + * @url GET /unassigned * * @param int $start {@from path} * @param int $limit {@from path} @@ -484,10 +482,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /unassigned */ public function doGetCasesListUnassigned( $start = 0, @@ -502,7 +499,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'unassigned'; $dataList['paged'] = false; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -510,16 +506,18 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Get list Cases Unassigned with paged + * @url GET /unassigned/paged * * @param int $start {@from path} * @param int $limit {@from path} @@ -528,10 +526,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /unassigned/paged */ public function doGetCasesListUnassignedPaged( $start = 0, @@ -546,7 +543,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'unassigned'; $dataList['paged'] = true; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -554,16 +550,18 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Get list Cases Paused + * @url GET /paused * * @param int $start {@from path} * @param int $limit {@from path} @@ -572,10 +570,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /paused */ public function doGetCasesListPaused( $start = 0, @@ -590,7 +587,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'paused'; $dataList['paged'] = false; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -598,16 +594,18 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Get list Cases Paused with paged + * @url GET /paused/paged * * @param int $start {@from path} * @param int $limit {@from path} @@ -616,10 +614,9 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /paused/paged */ public function doGetCasesListPausedPaged( $start = 0, @@ -634,7 +631,6 @@ class Cases extends Api $dataList['userId'] = $this->getUserId(); $dataList['action'] = 'paused'; $dataList["paged"] = true; - $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -642,16 +638,18 @@ class Cases extends Api $dataList['category'] = $cat_uid; $dataList['process'] = $pro_uid; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Get list Cases Advanced Search + * @url GET /advanced-search * * @param int $start {@from path} * @param int $limit {@from path} @@ -660,14 +658,13 @@ class Cases extends Api * @param string $cat_uid {@from path} * @param string $pro_uid {@from path} * @param string $app_status {@from path} - * @param string $user {@from path} + * @param string $usr_uid {@from path} * @param string $date_from {@from path} * @param string $date_to {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /advanced-search */ public function doGetCasesListAdvancedSearch( $start = 0, @@ -699,16 +696,18 @@ class Cases extends Api $dataList['dateFrom'] = $date_from; $dataList['dateTo'] = $date_to; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Get list Cases Advanced Search with Paged + * @url GET /advanced-search/paged * * @param int $start {@from path} * @param int $limit {@from path} @@ -721,10 +720,9 @@ class Cases extends Api * @param string $date_from {@from path} * @param string $date_to {@from path} * @param string $search {@from path} + * * @return array * @throws Exception - * - * @url GET /advanced-search/paged */ public function doGetCasesListAdvancedSearchPaged( $start = 0, @@ -756,31 +754,33 @@ class Cases extends Api $dataList['dateFrom'] = $date_from; $dataList['dateTo'] = $date_to; $dataList['search'] = $search; - $oCases = new BmCases(); - $response = $oCases->getList($dataList); + $cases = new BmCases(); + $response = $cases->getList($dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * @access protected * @class AccessControl {@className \ProcessMaker\Services\Api\Cases} - * @url GET /:app_uid + * @url GET /:appUid + * + * @param string $appUid {@min 32}{@max 32} * - * @param string $app_uid {@min 32}{@max 32} * @return array * @throws Exception */ - public function doGetCaseInfo($app_uid) + public function doGetCaseInfo($appUid) { try { $case = new BmCases(); $case->setFormatFieldNameInUppercase(false); - - $caseInfo = $case->getCaseInfo($app_uid, $this->getUserId()); + $caseInfo = $case->getCaseInfo($appUid, $this->getUserId()); $caseInfo = DateTime::convertUtcToIso8601($caseInfo, $this->arrayFieldIso8601); + return $caseInfo; } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); @@ -788,23 +788,21 @@ class Cases extends Api } /** - * @url GET /:app_uid/current-task + * @url GET /:appUid/current-task * - * @param string $app_uid {@min 32}{@max 32} + * @param string $appUid {@min 32}{@max 32} */ - public function doGetTaskCase($app_uid) + public function doGetTaskCase($appUid) { try { $case = new BmCases(); $case->setFormatFieldNameInUppercase(false); - - $arrayData = $case->getTaskCase($app_uid, $this->getUserId()); - + $arrayData = $case->getTaskCase($appUid, $this->getUserId()); $response = $arrayData; return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -830,10 +828,11 @@ class Cases extends Api try { $userUid = $this->getUserId(); $cases = new BmCases(); - $oData = $cases->addCase($pro_uid, $tas_uid, $userUid, $variables); - return $oData; + $data = $cases->addCase($pro_uid, $tas_uid, $userUid, $variables); + + return $data; } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -863,19 +862,19 @@ class Cases extends Api { try { $cases = new BmCases(); - $oData = $cases->addCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables); - return $oData; + $data = $cases->addCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables); + return $data; } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Update case reassignment. * - * @url PUT /:app_uid/reassign-case + * @url PUT /:appUid/reassign-case * - * @param string $app_uid {@min 32}{@max 32} + * @param string $appUid {@min 32}{@max 32} * @param string $usr_uid_source {@from body} {@min 32}{@max 32} * @param string $usr_uid_target {@from body} {@min 32}{@max 32} * @param string $del_index {@from body} @@ -885,23 +884,23 @@ class Cases extends Api * @access protected * @class AccessControl {@className \ProcessMaker\Services\Api\Cases} */ - public function doPutReassignCase($app_uid, $usr_uid_source, $usr_uid_target, $del_index = null) + public function doPutReassignCase($appUid, $usr_uid_source, $usr_uid_target, $del_index = null) { try { $userUid = $this->getUserId(); $cases = new BmCases(); - $cases->updateReassignCase($app_uid, $userUid, $del_index, $usr_uid_source, $usr_uid_target); + $cases->updateReassignCase($appUid, $userUid, $del_index, $usr_uid_source, $usr_uid_target); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Route Case. * - * @url PUT /:app_uid/route-case + * @url PUT /:appUid/route-case * - * @param string $app_uid {@min 32}{@max 32} + * @param string $appUid {@min 32}{@max 32} * @param string $del_index {@from body} * @param boolean $executeTriggersBeforeAssignment {@from body} * @@ -910,46 +909,49 @@ class Cases extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doPutRouteCase($app_uid, $del_index = null, $executeTriggersBeforeAssignment = false) + public function doPutRouteCase($appUid, $del_index = null, $executeTriggersBeforeAssignment = false) { try { $userUid = $this->getUserId(); $cases = new BmCases(); - $cases->updateRouteCase($app_uid, $userUid, $del_index, $executeTriggersBeforeAssignment); + $cases->updateRouteCase($appUid, $userUid, $del_index, $executeTriggersBeforeAssignment); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Cancel Case * - * @url PUT /:cas_uid/cancel + * @url PUT /:appUid/cancel * - * @param string $cas_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} + * @param integer $index {@from body} + * @param string $reason {@from body} + * @param boolean $sendMail {@from body} * * @throws RestException * * @access protected * @class AccessControl {@permission PM_CANCELCASE} */ - public function doPutCancelCase($cas_uid) + public function doPutCancelCase($appUid, $index = null, $reason = '', $sendMail = false) { try { $userUid = $this->getUserId(); $cases = new BmCases(); - $cases->putCancelCase($cas_uid, $userUid); + $cases->putCancelCase($appUid, $userUid, $index, $reason, $sendMail); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Pause Case * - * @url PUT /:cas_uid/pause + * @url PUT /:appUid/pause * - * @param string $cas_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * @param string $unpaused_date {@from body} * * @throws RestException @@ -957,50 +959,74 @@ class Cases extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doPutPauseCase($cas_uid, $unpaused_date = null) + public function doPutPauseCase($appUid, $unpaused_date = null) { try { $userUid = $this->getUserId(); $cases = new BmCases(); if ($unpaused_date == null) { - $cases->putPauseCase($cas_uid, $userUid); + $cases->putPauseCase($appUid, $userUid); } else { - $cases->putPauseCase($cas_uid, $userUid, false, $unpaused_date); + $cases->putPauseCase($appUid, $userUid, false, $unpaused_date); } } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Unpause Case * - * @url PUT /:cas_uid/unpause + * @url PUT /:appUid/unpause * - * @param string $cas_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * * @throws RestException * * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doPutUnpauseCase($cas_uid) + public function doPutUnpauseCase($appUid) { try { $userUid = $this->getUserId(); $cases = new BmCases(); - $cases->putUnpauseCase($cas_uid, $userUid); + $cases->putUnpauseCase($appUid, $userUid); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * Claim Case + * + * @url PUT /:appUid/claim + * + * @param string $appUid {@min 1}{@max 32} + * @param integer $index {@from body} + * + * @throws RestException + * + * @access protected + * @class AccessControl {@permission PM_CASES} + */ + public function doPutClaimCase($appUid, $index) + { + try { + $userUid = $this->getUserId(); + $cases = new BmCases(); + $cases->putClaimCase($appUid, $index, $userUid); + } catch (Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Execute trigger in a case. * - * @url PUT /:cas_uid/execute-trigger/:tri_uid + * @url PUT /:appUid/execute-trigger/:tri_uid * - * @param string $cas_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * @param string $tri_uid {@min 1}{@max 32} * * @throws RestException @@ -1008,34 +1034,34 @@ class Cases extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doPutExecuteTriggerCase($cas_uid, $tri_uid) + public function doPutExecuteTriggerCase($appUid, $tri_uid) { try { $userUid = $this->getUserId(); $cases = new BmCases(); - $cases->putExecuteTriggerCase($cas_uid, $tri_uid, $userUid); + $cases->putExecuteTriggerCase($appUid, $tri_uid, $userUid); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Delete Case - * @url DELETE /:cas_uid + * @url DELETE /:appUid * * @access protected * @class AccessControl {@permission PM_CASES} - * @param string $cas_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * @throws Exception */ - public function doDeleteCase($cas_uid) + public function doDeleteCase($appUid) { try { $usr_uid = $this->getUserId(); $cases = new BmCases(); - $cases->deleteCase($cas_uid, $usr_uid); + $cases->deleteCase($appUid, $usr_uid); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -1044,9 +1070,9 @@ class Cases extends Api * * @access protected * @class AccessControl {@className \ProcessMaker\Services\Api\Cases} - * @url GET /:app_uid/variables + * @url GET /:appUid/variables * - * @param string $app_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * @param string $dyn_uid * @param string $pro_uid * @param string $act_uid @@ -1054,24 +1080,24 @@ class Cases extends Api * @return mixed * @throws RestException */ - public function doGetCaseVariables($app_uid, $dyn_uid = null, $pro_uid = null, $act_uid = null, $app_index = null) + public function doGetCaseVariables($appUid, $dyn_uid = null, $pro_uid = null, $act_uid = null, $app_index = null) { try { $usr_uid = $this->getUserId(); $cases = new BmCases(); - $response = $cases->getCaseVariables($app_uid, $usr_uid, $dyn_uid, $pro_uid, $act_uid, $app_index); + $response = $cases->getCaseVariables($appUid, $usr_uid, $dyn_uid, $pro_uid, $act_uid, $app_index); return DateTime::convertUtcToIso8601($response); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Put Case Variables * - * @url PUT /:app_uid/variable + * @url PUT /:appUid/variable * - * @param string $app_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * @param array $request_data * @param string $dyn_uid {@from path} * @param int $del_index {@from path} @@ -1081,22 +1107,25 @@ class Cases extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doPutCaseVariables($app_uid, $request_data, $dyn_uid = '', $del_index = 0) + public function doPutCaseVariables($appUid, $request_data, $dyn_uid = '', $del_index = 0) { try { $usr_uid = $this->getUserId(); $cases = new BmCases(); $request_data = \ProcessMaker\Util\DateTime::convertDataToUtc($request_data); - $cases->setCaseVariables($app_uid, $request_data, $dyn_uid, $usr_uid, $del_index); + $cases->setCaseVariables($appUid, $request_data, $dyn_uid, $usr_uid, $del_index); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** * Get Case Notes + * @url GET /:appUid/notes + * @url GET /:appUid/notes/:paged * - * @param string $app_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} + * @param string $paged * @param int $start {@from path} * @param int $limit {@from path} * @param string $sort {@from path} @@ -1105,25 +1134,26 @@ class Cases extends Api * @param string $date_from {@from path} * @param string $date_to {@from path} * @param string $search {@from path} + * @param boolean $files {@from path} + * * @return array * @throws Exception - * - * @url GET /:app_uid/notes */ public function doGetCaseNotes( - $app_uid, + $appUid, + $paged = '', $start = 0, $limit = 25, - $sort = 'APP_CACHE_VIEW.APP_NUMBER', + $sort = 'NOTE_DATE', $dir = 'DESC', $usr_uid = '', $date_from = '', $date_to = '', - $search = '' + $search = '', + $files = false ) { try { - $dataList['paged'] = false; - + $dataList['paged'] = ($paged === 'paged') ? true : false; $dataList['start'] = $start; $dataList['limit'] = $limit; $dataList['sort'] = $sort; @@ -1132,59 +1162,14 @@ class Cases extends Api $dataList['dateFrom'] = $date_from; $dataList['dateTo'] = $date_to; $dataList['search'] = $search; - + $dataList['files'] = $files; $usr_uid = $this->getUserId(); $cases = new BmCases(); - $response = $cases->getCaseNotes($app_uid, $usr_uid, $dataList); + $response = $cases->getCaseNotes($appUid, $usr_uid, $dataList); + return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); - } - } - - /** - * Get Case Notes with Paged - * - * @param int $start {@from path} - * @param int $limit {@from path} - * @param string $sort {@from path} - * @param string $dir {@from path} - * @param string $usr_uid {@from path} - * @param string $date_from {@from path} - * @param string $date_to {@from path} - * @param string $search {@from path} - * @return array - * @throws Exception - * - * @url GET /:app_uid/notes/paged - */ - public function doGetCaseNotesPaged( - $app_uid, - $start = 0, - $limit = 25, - $sort = 'APP_CACHE_VIEW.APP_NUMBER', - $dir = 'DESC', - $usr_uid = '', - $date_from = '', - $date_to = '', - $search = '' - ) { - try { - $dataList['start'] = $start; - $dataList['limit'] = $limit; - $dataList['sort'] = $sort; - $dataList['dir'] = $dir; - $dataList['user'] = $usr_uid; - $dataList['dateFrom'] = $date_from; - $dataList['dateTo'] = $date_to; - $dataList['search'] = $search; - - $usr_uid = $this->getUserId(); - $cases = new BmCases(); - $response = $cases->getCaseNotes($app_uid, $usr_uid, $dataList); - return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); - } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } @@ -1193,9 +1178,9 @@ class Cases extends Api * currently assigned to work on the case or have Process Permissions to * access case notes may create a case note. * - * @url POST /:app_uid/note + * @url POST /:appUid/note * - * @param string $app_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * @param string $note_content {@min 1}{@max 500} * @param int $send_mail {@choice 1,0} * @@ -1205,30 +1190,29 @@ class Cases extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doPostCaseNote($app_uid, $note_content, $send_mail = 0) + public function doPostCaseNote($appUid, $note_content, $send_mail = 0) { try { $usr_uid = $this->getUserId(); $cases = new BmCases(); $send_mail = ($send_mail == 0) ? false : true; - $cases->saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail); + $cases->saveCaseNote($appUid, $usr_uid, $note_content, $send_mail); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** - * @url GET /:app_uid/tasks + * @url GET /:appUid/tasks * - * @param string $app_uid {@min 32}{@max 32} + * @param string $appUid {@min 32}{@max 32} */ - public function doGetTasks($app_uid) + public function doGetTasks($appUid) { try { $case = new BmCases(); $case->setFormatFieldNameInUppercase(false); - - $response = $case->getTasks($app_uid); + $response = $case->getTasks($appUid); return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601); } catch (Exception $e) { @@ -1239,9 +1223,9 @@ class Cases extends Api /** * Execute triggers * - * @url PUT /:app_uid/execute-triggers + * @url PUT /:appUid/execute-triggers * - * @param string $app_uid {@min 1}{@max 32} + * @param string $appUid {@min 1}{@max 32} * @param int $del_index {@from body} * @param string $obj_type {@from body} * @param string $obj_uid {@from body} @@ -1251,30 +1235,28 @@ class Cases extends Api * @class AccessControl {@permission PM_CASES} * @access protected */ - public function doPutExecuteTriggers($app_uid, $del_index, $obj_type, $obj_uid) + public function doPutExecuteTriggers($appUid, $del_index, $obj_type, $obj_uid) { try { $cases = new BmCases(); - $cases->putExecuteTriggers($app_uid, $del_index, $obj_type, $obj_uid); + $cases->putExecuteTriggers($appUid, $del_index, $obj_type, $obj_uid); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } /** - * @url GET /:app_uid/:del_index/steps + * @url GET /:appUid/:del_index/steps * - * @param string $app_uid {@min 32}{@max 32} + * @param string $appUid {@min 32}{@max 32} * @param int $del_index - * */ - public function doGetSteps($app_uid, $del_index) + public function doGetSteps($appUid, $del_index) { try { $case = new BmCases(); $case->setFormatFieldNameInUppercase(false); - - $response = $case->getSteps($app_uid, $del_index); + $response = $case->getSteps($appUid, $del_index); return $response; } catch (Exception $e) { @@ -1290,16 +1272,14 @@ class Cases extends Api * @param string $type_view {@from path} * @return array * @throws Exception - * */ public function doGetCasesListStarCase( $type_view = '' ) { try { - $usr_uid = $this->getUserId(); + $usrUid = $this->getUserId(); $case = new BmCases(); - - $response = $case->getCasesListStarCase($usr_uid, $type_view); + $response = $case->getCasesListStarCase($usrUid, $type_view); return $response; } catch (Exception $e) { @@ -1315,16 +1295,14 @@ class Cases extends Api * @param string $type_view {@from path} * @return array * @throws Exception - * */ public function doGetCasesListBookmarkStarCase( $type_view = '' ) { try { - $usr_uid = $this->getUserId(); + $usrUid = $this->getUserId(); $case = new BmCases(); - - $response = $case->getCasesListBookmarkStarCase($usr_uid, $type_view); + $response = $case->getCasesListBookmarkStarCase($usrUid, $type_view); return $response; } catch (Exception $e) { @@ -1392,6 +1370,7 @@ class Cases extends Api try { $case = new BmCases(); $response = $case->doPostReassign($request_data); + return $response; } catch (Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); @@ -1402,11 +1381,11 @@ class Cases extends Api * Upload attachment related to the case, it does not need docUid * Upload document related to the case, it does need docUid * - * @url POST /:app_uid/upload/:var_name - * @url POST /:app_uid/upload/:var_name/:doc_uid - * @url POST /:app_uid/upload/:var_name/:doc_uid/:app_doc_uid + * @url POST /:appUid/upload/:var_name + * @url POST /:appUid/upload/:var_name/:doc_uid + * @url POST /:appUid/upload/:var_name/:doc_uid/:app_doc_uid * - * @param string $app_uid + * @param string $appUid * @param string $var_name * @param string $doc_uid * @param string $app_doc_uid @@ -1418,20 +1397,20 @@ class Cases extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function uploadDocumentToCase($app_uid, $var_name, $doc_uid = '-1', $app_doc_uid = null, $delIndex = null) + public function uploadDocumentToCase($appUid, $var_name, $doc_uid = '-1', $app_doc_uid = null, $delIndex = null) { try { $userUid = $this->getUserId(); $case = new BmCases(); if (isset($delIndex)) { - $response = $case->uploadFiles($userUid, $app_uid, $var_name, $doc_uid, $app_doc_uid, $delIndex); + $response = $case->uploadFiles($userUid, $appUid, $var_name, $doc_uid, $app_doc_uid, $delIndex); } else { - $response = $case->uploadFiles($userUid, $app_uid, $var_name, $doc_uid, $app_doc_uid); + $response = $case->uploadFiles($userUid, $appUid, $var_name, $doc_uid, $app_doc_uid); } } catch (ExceptionRestApi $e) { throw new RestException($e->getCode(), $e->getMessage()); } catch (Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } return $response; @@ -1440,9 +1419,9 @@ class Cases extends Api /** * Return information for sub process cases * - * @url GET /:app_uid/sub-process-cases + * @url GET /:appUid/sub-process-cases * - * @param string $app_uid {@min 32}{@max 32} + * @param string $appUid {@min 32}{@max 32} * * @return array * @throws Exception @@ -1450,13 +1429,12 @@ class Cases extends Api * @access protected * @class AccessControl {@permission PM_CASES} */ - public function doGetCaseSubProcess($app_uid) + public function doGetCaseSubProcess($appUid) { try { $case = new BmCases(); $case->setFormatFieldNameInUppercase(false); - - $caseInfo = $case->getCaseInfoSubProcess($app_uid, $this->getUserId()); + $caseInfo = $case->getCaseInfoSubProcess($appUid, $this->getUserId()); $caseInfo = DateTime::convertUtcToIso8601($caseInfo, $this->arrayFieldIso8601); return $caseInfo; @@ -1526,10 +1504,8 @@ class Cases extends Api try { // Create JSON object if is a serialized string $filters = is_string($filters) ? json_decode($filters) : $filters; - // Create new filter $filter = Filter::create($this->getUserId(), $name, $filters); - // Return the new filter return $filter; } catch (Exception $e) { @@ -1553,10 +1529,8 @@ class Cases extends Api try { // Create JSON object if is a serialized string $filters = is_string($filters) ? json_decode($filters) : $filters; - // Get requested filter $filter = Filter::getByUid($this->getUserId(), $filterUid); - // Update the requested filter if exists if (!is_null($filter)) { Filter::update($this->getUserId(), $filterUid, $name, $filters);