Files
luos/workflow/engine/src/ProcessMaker/Services/Api/Cases.php

1582 lines
51 KiB
PHP
Raw Normal View History

2014-03-14 15:33:35 -04:00
<?php
2021-05-12 18:59:01 -04:00
namespace ProcessMaker\Services\Api;
2017-10-05 14:54:41 -04:00
use AppDelegation;
use AppDelegationPeer;
2018-10-25 09:43:44 -04:00
use AppDocument;
2017-10-05 14:54:41 -04:00
use Criteria;
use Exception;
use ListUnassigned;
2017-10-05 14:54:41 -04:00
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Cases as BmCases;
2020-12-03 20:27:03 +00:00
use ProcessMaker\BusinessModel\Cases\Filter;
2017-10-05 14:54:41 -04:00
use ProcessMaker\BusinessModel\User as BmUser;
use ProcessMaker\Services\Api;
2018-10-25 09:43:44 -04:00
use ProcessMaker\Util\DateTime;
use RBAC;
2017-10-05 14:54:41 -04:00
2014-03-14 15:33:35 -04:00
/**
* Cases Api Controller
*
* @protected
*/
class Cases extends Api
{
private $arrayFieldIso8601 = [
"del_init_date",
"del_finish_date",
"del_task_due_date",
"del_risk_date",
"del_delegate_date",
"app_create_date",
"app_update_date",
"app_finish_date",
"del_delegate_date",
"note_date"
];
2018-10-25 09:43:44 -04:00
/**
* Constructor of the class
* We will to define the $RBAC definition
*/
public function __construct()
{
global $RBAC;
if (!isset($RBAC)) {
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->sSystem = 'PROCESSMAKER';
$RBAC->initRBAC();
$RBAC->loadUserRolePermission($RBAC->sSystem, $this->getUserId());
}
}
/**
* This function adds customized validations for allow the access to functions
* If does not have access will be return 401
*
* @return boolean
* @throws Exception
*/
public function __isAllowed()
{
try {
$methodName = $this->restler->apiMethodInfo->methodName;
2016-08-13 13:13:59 -04:00
$arrayArgs = $this->restler->apiMethodInfo->arguments;
switch ($methodName) {
2016-08-13 13:13:59 -04:00
case 'doGetCaseVariables':
2022-03-31 09:35:02 -04:00
$applicationUid = $this->parameters[$arrayArgs['appUid']];
2016-08-13 13:13:59 -04:00
$dynaformUid = $this->parameters[$arrayArgs['dyn_uid']];
2016-09-19 13:38:34 -04:00
$delIndex = $this->parameters[$arrayArgs['app_index']];
2016-08-13 13:13:59 -04:00
$userUid = $this->getUserId();
//check the guest user
if ($userUid === RBAC::GUEST_USER_UID) {
return true;
}
2016-09-19 13:38:34 -04:00
//Check if the user has the case
2017-10-05 14:54:41 -04:00
$appDelegation = new AppDelegation();
2021-05-12 18:59:01 -04:00
$curUser = $appDelegation->getCurrentUsers($applicationUid, $delIndex);
if (!empty($curUser)) {
foreach ($curUser as $key => $value) {
2016-09-19 13:38:34 -04:00
if ($value === $userUid) {
return true;
}
}
}
//Check if the user has Permissions
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
return $cases->checkUserHasPermissionsOrSupervisor($userUid, $applicationUid, $dynaformUid);
2016-08-13 13:13:59 -04:00
break;
2017-10-05 14:54:41 -04:00
case 'doPutCaseVariables':
2022-03-31 09:35:02 -04:00
$applicationUid = $this->parameters[$arrayArgs['appUid']];
2017-10-05 14:54:41 -04:00
$dynaformUid = $this->parameters[$arrayArgs['dyn_uid']];
$delIndex = $this->parameters[$arrayArgs['del_index']];
$userUid = $this->getUserId();
//Check if the user has the case currently
$appDelegation = new AppDelegation();
$currentUser = $appDelegation->getCurrentUsers($applicationUid, $delIndex);
foreach ($currentUser as $key => $value) {
if ($value === $userUid) {
return true;
}
}
//Check if the user is a supervisor
//Unlike GET, it is not enough to have the processPermission for update the variables
$cases = new BmCases();
$isSupervisor = $cases->isSupervisorFromForm($userUid, $applicationUid, $dynaformUid);
return $isSupervisor;
break;
case 'doPostReassign':
$arrayParameters = $this->parameters[0]['cases'];
$usrUid = $this->getUserId();
//Check if the user is supervisor process
2017-10-05 14:54:41 -04:00
$case = new BmCases();
$user = new BmUser();
$count = 0;
foreach ($arrayParameters as $value) {
$arrayApplicationData = $case->getApplicationRecordByPk($value['APP_UID'], [], false);
if (!empty($arrayApplicationData)) {
2017-12-12 15:11:16 -04:00
$canReassign = $user->userCanReassign($usrUid, $arrayApplicationData['PRO_UID']);
if (!$canReassign) {
//We count when the user is not supervisor to the process
$count = $count + 1;
}
}
}
if ($count == 0) {
return true;
}
break;
2017-12-12 15:11:16 -04:00
case 'doPutReassignCase':
2021-07-19 13:19:55 -04:00
$appUid = $this->parameters[$arrayArgs['appUid']];
2017-12-12 15:11:16 -04:00
$usrUid = $this->getUserId();
$case = new BmCases();
$user = new BmUser();
$arrayApplicationData = $case->getApplicationRecordByPk($appUid, [], false);
return $user->userCanReassign($usrUid, $arrayApplicationData['PRO_UID']);
break;
case 'doGetCaseInfo':
2022-03-31 09:35:02 -04:00
$appUid = $this->parameters[$arrayArgs['appUid']];
$usrUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$case = new BmCases();
$arrayApplicationData = $case->getApplicationRecordByPk($appUid, [], false);
if (!empty($arrayApplicationData)) {
$criteria = new Criteria('workflow');
2022-03-31 09:30:47 -04:00
$criteria->addSelectColumn(AppDelegationPeer::APP_UID);
$criteria->add(AppDelegationPeer::APP_UID, $appUid);
2017-10-05 14:54:41 -04:00
$criteria->add(AppDelegationPeer::USR_UID, $usrUid);
2017-06-13 09:59:53 -04:00
$criteria->setLimit(1);
2017-10-05 14:54:41 -04:00
$rsCriteria = AppDelegationPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
return true;
}
//verify unassigned
$list = new ListUnassigned();
$data = $list->loadList($usrUid, ['search' => $appUid, 'caseLink' => true, 'limit' => 1]);
if ($data) {
return true;
}
//Check if the user is a process supervisor or has summary form view permission
$userCanAccess = $case->userAuthorization(
$usrUid,
$arrayApplicationData['PRO_UID'],
$appUid,
[],
['SUMMARY_FORM' => 'VIEW']
);
return $userCanAccess['supervisor'] || $userCanAccess['objectPermissions']['SUMMARY_FORM'];
}
break;
2017-08-15 16:37:58 -04:00
case 'doDownloadInputDocument':
//Verify if the user can be download the file
$appDocUid = $this->parameters[$arrayArgs['app_doc_uid']];
$version = $this->parameters[$arrayArgs['v']];
$usrUid = $this->getUserId();
2021-05-12 18:59:01 -04:00
$appDocument = new AppDocument();
2017-08-15 16:37:58 -04:00
if ($version == 0) {
2021-05-12 18:59:01 -04:00
$docVersion = $appDocument->getLastAppDocVersion($appDocUid);
2017-08-15 16:37:58 -04:00
} else {
$docVersion = $version;
}
if (defined('DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION') && DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION == 0) {
2021-05-12 18:59:01 -04:00
if ($appDocument->canDownloadInput($usrUid, $appDocUid, $docVersion)) {
2017-08-15 16:37:58 -04:00
return true;
}
} else {
return true;
}
break;
}
return false;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
2014-03-14 15:33:35 -04:00
/**
* Get list Cases To Do
*
2021-05-12 18:59:01 -04:00
* @url GET
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-14 15:33:35 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-14 15:33:35 -04:00
*/
2014-03-24 10:39:05 -04:00
public function doGetCasesListToDo(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-14 15:33:35 -04:00
try {
2014-03-24 10:39:05 -04:00
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'todo';
$dataList['paged'] = false;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2014-03-24 10:39:05 -04:00
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Cases To Do with paged
2021-05-12 18:59:01 -04:00
* @url GET /paged
2014-03-24 10:39:05 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-24 10:39:05 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-24 10:39:05 -04:00
*/
public function doGetCasesListToDoPaged(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-24 10:39:05 -04:00
try {
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'todo';
$dataList['paged'] = true;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2014-03-14 15:33:35 -04:00
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Cases Draft
2021-05-12 18:59:01 -04:00
* @url GET /draft
2014-03-14 15:33:35 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-14 15:33:35 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-14 15:33:35 -04:00
*/
2014-03-24 10:39:05 -04:00
public function doGetCasesListDraft(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-14 15:33:35 -04:00
try {
2014-03-24 10:39:05 -04:00
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'draft';
$dataList['paged'] = false;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2014-03-24 10:39:05 -04:00
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Cases Draft with paged
2021-05-12 18:59:01 -04:00
* @url GET /draft/paged
2014-03-24 10:39:05 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-24 10:39:05 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-24 10:39:05 -04:00
*/
public function doGetCasesListDraftPaged(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-24 10:39:05 -04:00
try {
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'draft';
$dataList['paged'] = true;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2014-03-14 15:33:35 -04:00
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Cases Participated
2021-05-12 18:59:01 -04:00
* @url GET /participated
2014-03-14 15:33:35 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-14 15:33:35 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-14 15:33:35 -04:00
*/
2014-03-24 10:39:05 -04:00
public function doGetCasesListParticipated(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-24 10:39:05 -04:00
try {
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'sent';
$dataList['paged'] = false;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2014-03-24 10:39:05 -04:00
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Cases Participated with paged
2021-05-12 18:59:01 -04:00
* @url GET /participated/paged
2014-03-24 10:39:05 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-24 10:39:05 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-24 10:39:05 -04:00
*/
public function doGetCasesListParticipatedPaged(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-14 15:33:35 -04:00
try {
2014-03-24 10:39:05 -04:00
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'sent';
$dataList['paged'] = true;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2014-03-14 15:33:35 -04:00
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Cases Unassigned
2021-05-12 18:59:01 -04:00
* @url GET /unassigned
2014-03-14 15:33:35 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-14 15:33:35 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-14 15:33:35 -04:00
*/
2014-03-24 10:39:05 -04:00
public function doGetCasesListUnassigned(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-14 15:33:35 -04:00
try {
2014-03-24 10:39:05 -04:00
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'unassigned';
$dataList['paged'] = false;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-24 10:39:05 -04:00
}
}
/**
* Get list Cases Unassigned with paged
2021-05-12 18:59:01 -04:00
* @url GET /unassigned/paged
2014-03-24 10:39:05 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-24 10:39:05 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-24 10:39:05 -04:00
*/
public function doGetCasesListUnassignedPaged(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-24 10:39:05 -04:00
try {
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'unassigned';
$dataList['paged'] = true;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-14 15:33:35 -04:00
}
}
/**
* Get list Cases Paused
2021-05-12 18:59:01 -04:00
* @url GET /paused
2014-03-14 15:33:35 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-14 15:33:35 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-14 15:33:35 -04:00
*/
2014-03-24 10:39:05 -04:00
public function doGetCasesListPaused(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-14 15:33:35 -04:00
try {
2014-03-24 10:39:05 -04:00
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'paused';
$dataList['paged'] = false;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-24 10:39:05 -04:00
}
}
/**
* Get list Cases Paused with paged
2021-05-12 18:59:01 -04:00
* @url GET /paused/paged
2014-03-24 10:39:05 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-24 10:39:05 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-24 10:39:05 -04:00
*/
public function doGetCasesListPausedPaged(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-24 10:39:05 -04:00
try {
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'paused';
$dataList["paged"] = true;
2014-03-24 10:39:05 -04:00
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-14 15:33:35 -04:00
}
}
/**
* Get list Cases Advanced Search
2021-05-12 18:59:01 -04:00
* @url GET /advanced-search
2014-03-14 15:33:35 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
* @param string $app_status {@from path}
2021-05-12 18:59:01 -04:00
* @param string $usr_uid {@from path}
2014-03-28 11:40:59 -04:00
* @param string $date_from {@from path}
* @param string $date_to {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-14 15:33:35 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-14 15:33:35 -04:00
*/
2014-03-24 10:39:05 -04:00
public function doGetCasesListAdvancedSearch(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
$app_status = '',
2014-04-24 08:36:24 -04:00
$usr_uid = '',
2014-03-28 11:40:59 -04:00
$date_from = '',
$date_to = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-24 10:39:05 -04:00
try {
2018-10-25 09:43:44 -04:00
global $RBAC;
//If the user does not have PM_ALLCASES we will be able to search for cases in which the user has participated
$dataList['userId'] = ($RBAC->userCanAccess('PM_ALLCASES') == 1)? '' : $this->getUserId();
2014-03-24 10:39:05 -04:00
$dataList['action'] = 'search';
$dataList['paged'] = false;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['status'] = $app_status;
2014-04-24 08:36:24 -04:00
$dataList['user'] = $usr_uid;
2014-03-28 11:40:59 -04:00
$dataList['dateFrom'] = $date_from;
$dataList['dateTo'] = $date_to;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-24 10:39:05 -04:00
}
}
/**
* Get list Cases Advanced Search with Paged
2021-05-12 18:59:01 -04:00
* @url GET /advanced-search/paged
2014-03-24 10:39:05 -04:00
*
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @param string $sort {@from path}
2014-03-24 10:39:05 -04:00
* @param string $dir {@from path}
2014-03-24 16:45:26 -04:00
* @param string $cat_uid {@from path}
* @param string $pro_uid {@from path}
* @param string $app_status {@from path}
* @param string $usr_uid {@from path}
2014-03-28 11:40:59 -04:00
* @param string $date_from {@from path}
* @param string $date_to {@from path}
2014-03-24 10:39:05 -04:00
* @param string $search {@from path}
2021-05-12 18:59:01 -04:00
*
2014-03-24 10:39:05 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2021-08-10 12:20:58 -04:00
* @deprecated Method deprecated in Release 3.6.x
2014-03-24 10:39:05 -04:00
*/
public function doGetCasesListAdvancedSearchPaged(
$start = 0,
$limit = 0,
2014-03-24 10:39:05 -04:00
$sort = 'APP_CACHE_VIEW.APP_NUMBER',
$dir = 'DESC',
2014-03-24 16:45:26 -04:00
$cat_uid = '',
$pro_uid = '',
$app_status = '',
$usr_uid = '',
$date_from = '',
$date_to = '',
2014-03-24 10:39:05 -04:00
$search = ''
) {
2014-03-14 15:33:35 -04:00
try {
2018-10-25 09:43:44 -04:00
global $RBAC;
//If the user does not have PM_ALLCASES we will be able to search for cases in which the user has participated
$dataList['userId'] = ($RBAC->userCanAccess('PM_ALLCASES') == 1)? '' : $this->getUserId();
2014-03-24 10:39:05 -04:00
$dataList['action'] = 'search';
$dataList['paged'] = true;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
$dataList['sort'] = $sort;
$dataList['dir'] = $dir;
2014-03-24 16:45:26 -04:00
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['status'] = $app_status;
$dataList['user'] = $usr_uid;
$dataList['dateFrom'] = $date_from;
$dataList['dateTo'] = $date_to;
2014-03-24 10:39:05 -04:00
$dataList['search'] = $search;
2021-05-12 18:59:01 -04:00
$cases = new BmCases();
$response = $cases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-14 15:33:35 -04:00
}
}
/**
* @access protected
2017-06-13 09:59:53 -04:00
* @class AccessControl {@className \ProcessMaker\Services\Api\Cases}
2021-05-12 18:59:01 -04:00
* @url GET /:appUid
*
* @param string $appUid {@min 32}{@max 32}
*
2017-10-05 14:54:41 -04:00
* @return array
* @throws Exception
*/
2021-05-12 18:59:01 -04:00
public function doGetCaseInfo($appUid)
{
try {
2017-10-05 14:54:41 -04:00
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
2021-05-12 18:59:01 -04:00
$caseInfo = $case->getCaseInfo($appUid, $this->getUserId());
$caseInfo = DateTime::convertUtcToIso8601($caseInfo, $this->arrayFieldIso8601);
2021-05-12 18:59:01 -04:00
return $caseInfo;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
2021-05-12 18:59:01 -04:00
* @url GET /:appUid/current-task
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 32}{@max 32}
*/
2021-05-12 18:59:01 -04:00
public function doGetTaskCase($appUid)
{
try {
2017-10-05 14:54:41 -04:00
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
2021-05-12 18:59:01 -04:00
$arrayData = $case->getTaskCase($appUid, $this->getUserId());
$response = $arrayData;
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
2017-10-18 10:47:40 -04:00
* Start a new case and assign the logged-in user to work on the initial task
* in the case. Note that the logged-in user must be in the pool of assigned
* users for the initial task.
*
* @url POST
2017-10-18 10:47:40 -04:00
*
* @param string $pro_uid {@from body} {@min 32}{@max 32}
* @param string $tas_uid {@from body} {@min 32}{@max 32}
* @param array $variables {@from body}
2017-10-18 10:47:40 -04:00
*
2017-10-18 14:53:15 -04:00
* @return array
* @throws RestException
*
2017-10-18 10:47:40 -04:00
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function doPostCase($pro_uid, $tas_uid, $variables = null)
{
try {
$userUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$data = $cases->addCase($pro_uid, $tas_uid, $userUid, $variables);
return $data;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
2017-10-18 10:47:40 -04:00
* Creates a new case. It is similar to POST /cases, but it impersonates the
* session variables, so it is more robust than POST /cases. Note that the
* specified user to work on the case must be assigned to the pool of users
* for the initial task. Also note that the new case's status will be set to
* "DRAFT", not "TO_DO". If wishing to change the new case's status to "TO_DO",
* then create the following trigger in the process and use
* PUT /cases/{app_uid}/execute-trigger/{tri_uid} to execute it.
*
* @url POST /impersonate
2022-01-24 17:36:01 -04:00
* @status 201
2017-10-18 10:47:40 -04:00
*
* @param string $pro_uid {@from body} {@min 32}{@max 32}
* @param string $usr_uid {@from body} {@min 32}{@max 32}
* @param string $tas_uid {@from body} {@min 32}{@max 32}
* @param array $variables {@from body}
2017-10-18 10:47:40 -04:00
*
2017-10-18 14:53:15 -04:00
* @return array
* @throws RestException
*
2017-10-18 10:47:40 -04:00
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function doPostCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables = null)
{
try {
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$data = $cases->addCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables);
return $data;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
2017-10-13 10:59:18 -04:00
* Update case reassignment.
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/reassign-case
*
2021-05-12 18:59:01 -04:00
* @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}
2021-07-19 13:19:55 -04:00
* @param int $del_index {@from body}
* @param string $reason {@from body}
* @param boolean $sendMail {@from body}
2017-10-13 10:59:18 -04:00
*
* @throws RestException
*
* @access protected
2017-12-12 15:11:16 -04:00
* @class AccessControl {@className \ProcessMaker\Services\Api\Cases}
*/
2021-07-19 13:19:55 -04:00
public function doPutReassignCase($appUid, $usr_uid_source, $usr_uid_target, $del_index = null, $reason = '', $sendMail = false)
{
try {
$userUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-07-19 13:19:55 -04:00
$cases->updateReassignCase($appUid, $userUid, $del_index, $usr_uid_source, $usr_uid_target, $reason, $sendMail);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
2017-10-13 10:59:18 -04:00
* Route Case.
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/route-case
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 32}{@max 32}
* @param string $del_index {@from body}
* @param boolean $executeTriggersBeforeAssignment {@from body}
2017-10-13 10:59:18 -04:00
*
* @throws RestException
*
* @access protected
2017-10-13 10:59:18 -04:00
* @class AccessControl {@permission PM_CASES}
*/
2021-05-12 18:59:01 -04:00
public function doPutRouteCase($appUid, $del_index = null, $executeTriggersBeforeAssignment = false)
{
try {
$userUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$cases->updateRouteCase($appUid, $userUid, $del_index, $executeTriggersBeforeAssignment);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
2014-03-18 14:37:47 -04:00
/**
* Cancel Case
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/cancel
2017-10-13 10:59:18 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
* @param integer $index {@from body}
* @param string $reason {@from body}
* @param boolean $sendMail {@from body}
2014-03-18 14:37:47 -04:00
*
2017-10-13 10:59:18 -04:00
* @throws RestException
2014-03-18 14:37:47 -04:00
*
* @access protected
2017-10-13 10:59:18 -04:00
* @class AccessControl {@permission PM_CANCELCASE}
2014-03-18 14:37:47 -04:00
*/
2021-05-12 18:59:01 -04:00
public function doPutCancelCase($appUid, $index = null, $reason = '', $sendMail = false)
2014-03-18 14:37:47 -04:00
{
try {
$userUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$cases->putCancelCase($appUid, $userUid, $index, $reason, $sendMail);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-18 14:37:47 -04:00
}
}
/**
* Pause Case
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/pause
2017-10-13 10:59:18 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
2014-03-18 14:37:47 -04:00
* @param string $unpaused_date {@from body}
2021-07-19 13:19:55 -04:00
* @param string $unpaused_time {@from body}
* @param int $index {@from body}
* @param string $reason {@from body}
* @param boolean $sendMail {@from body}
2014-03-18 14:37:47 -04:00
*
2017-10-13 10:59:18 -04:00
* @throws RestException
2014-03-18 14:37:47 -04:00
*
* @access protected
2017-10-13 10:59:18 -04:00
* @class AccessControl {@permission PM_CASES}
2014-03-18 14:37:47 -04:00
*/
2021-07-19 13:19:55 -04:00
public function doPutPauseCase($appUid, $unpaused_date = null, $unpaused_time = '00:00', $index = 0, $reason = '', $sendMail = false)
2014-03-18 14:37:47 -04:00
{
try {
$userUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-07-19 13:19:55 -04:00
$cases->putPauseCase($appUid, $userUid, $index, $unpaused_date, $unpaused_time, $reason, $sendMail);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-18 14:37:47 -04:00
}
}
/**
* Unpause Case
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/unpause
2017-10-13 10:59:18 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
2021-08-26 09:42:26 -04:00
* @param int $index {@from body}
2014-03-18 14:37:47 -04:00
*
2017-10-13 10:59:18 -04:00
* @throws RestException
2014-03-18 14:37:47 -04:00
*
* @access protected
2017-10-13 10:59:18 -04:00
* @class AccessControl {@permission PM_CASES}
2014-03-18 14:37:47 -04:00
*/
2021-08-26 09:42:26 -04:00
public function doPutUnpauseCase($appUid, $index = 0)
2014-03-18 14:37:47 -04:00
{
try {
$userUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-08-26 09:42:26 -04:00
$cases->putUnpauseCase($appUid, $userUid, $index);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
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());
2014-03-18 14:37:47 -04:00
}
}
/**
2017-10-13 10:59:18 -04:00
* Execute trigger in a case.
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/execute-trigger/:tri_uid
2014-03-18 14:37:47 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
2014-03-18 14:37:47 -04:00
* @param string $tri_uid {@min 1}{@max 32}
*
2017-10-13 10:59:18 -04:00
* @throws RestException
2014-03-18 14:37:47 -04:00
*
* @access protected
2017-10-13 10:59:18 -04:00
* @class AccessControl {@permission PM_CASES}
2014-03-18 14:37:47 -04:00
*/
2021-05-12 18:59:01 -04:00
public function doPutExecuteTriggerCase($appUid, $tri_uid)
2014-03-18 14:37:47 -04:00
{
try {
$userUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$cases->putExecuteTriggerCase($appUid, $tri_uid, $userUid);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-18 14:37:47 -04:00
}
}
/**
* Delete Case
2021-05-12 18:59:01 -04:00
* @url DELETE /:appUid
2014-03-18 14:37:47 -04:00
*
2017-10-10 16:29:36 -04:00
* @access protected
* @class AccessControl {@permission PM_CASES}
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
2017-10-05 14:54:41 -04:00
* @throws Exception
2014-03-18 14:37:47 -04:00
*/
2021-05-12 18:59:01 -04:00
public function doDeleteCase($appUid)
2014-03-18 14:37:47 -04:00
{
try {
$usr_uid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$cases->deleteCase($appUid, $usr_uid);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-18 14:37:47 -04:00
}
}
2014-03-26 09:50:06 -04:00
/**
* Get Case Variables
*
2016-08-13 13:13:59 -04:00
* @access protected
* @class AccessControl {@className \ProcessMaker\Services\Api\Cases}
2021-05-12 18:59:01 -04:00
* @url GET /:appUid/variables
2016-08-13 13:13:59 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
2016-08-13 13:13:59 -04:00
* @param string $dyn_uid
* @param string $pro_uid
* @param string $act_uid
* @param int $app_index
* @return mixed
* @throws RestException
2014-03-26 09:50:06 -04:00
*/
2021-05-12 18:59:01 -04:00
public function doGetCaseVariables($appUid, $dyn_uid = null, $pro_uid = null, $act_uid = null, $app_index = null)
2014-03-26 09:50:06 -04:00
{
try {
$usr_uid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$response = $cases->getCaseVariables($appUid, $usr_uid, $dyn_uid, $pro_uid, $act_uid, $app_index);
return DateTime::convertUtcToIso8601($response);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-26 09:50:06 -04:00
}
}
/**
* Put Case Variables
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/variable
2017-10-13 10:59:18 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
2014-03-26 09:50:06 -04:00
* @param array $request_data
* @param string $dyn_uid {@from path}
2016-08-04 12:11:23 -04:00
* @param int $del_index {@from path}
2014-03-26 09:50:06 -04:00
*
2017-10-13 10:59:18 -04:00
* @throws RestException
2014-03-26 09:50:06 -04:00
*
* @access protected
2017-10-13 10:59:18 -04:00
* @class AccessControl {@permission PM_CASES}
2014-03-26 09:50:06 -04:00
*/
2021-05-12 18:59:01 -04:00
public function doPutCaseVariables($appUid, $request_data, $dyn_uid = '', $del_index = 0)
2014-03-26 09:50:06 -04:00
{
try {
$usr_uid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
$request_data = \ProcessMaker\Util\DateTime::convertDataToUtc($request_data);
2021-05-12 18:59:01 -04:00
$cases->setCaseVariables($appUid, $request_data, $dyn_uid, $usr_uid, $del_index);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-26 12:20:20 -04:00
}
}
/**
* Get Case Notes
2021-05-12 18:59:01 -04:00
* @url GET /:appUid/notes
* @url GET /:appUid/notes/:paged
2014-03-26 12:20:20 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
* @param string $paged
2016-08-04 12:11:23 -04:00
* @param int $start {@from path}
* @param int $limit {@from path}
2014-03-28 11:40:59 -04:00
* @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}
2021-05-12 18:59:01 -04:00
* @param boolean $files {@from path}
*
2014-03-28 11:40:59 -04:00
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
2014-03-26 12:20:20 -04:00
*/
2014-03-28 11:40:59 -04:00
public function doGetCaseNotes(
2021-05-12 18:59:01 -04:00
$appUid,
$paged = '',
2014-03-28 11:40:59 -04:00
$start = 0,
$limit = 25,
2021-05-12 18:59:01 -04:00
$sort = 'NOTE_DATE',
2014-03-28 11:40:59 -04:00
$dir = 'DESC',
$usr_uid = '',
$date_from = '',
$date_to = '',
2021-05-12 18:59:01 -04:00
$search = '',
$files = false
) {
2014-03-28 11:40:59 -04:00
try {
2021-05-12 18:59:01 -04:00
$dataList['paged'] = ($paged === 'paged') ? true : false;
2014-03-28 11:40:59 -04:00
$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;
2021-05-12 18:59:01 -04:00
$dataList['files'] = $files;
2014-03-28 11:40:59 -04:00
$usr_uid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$response = $cases->getCaseNotes($appUid, $usr_uid, $dataList);
2014-03-28 11:40:59 -04:00
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(401, $e->getMessage());
2014-03-26 12:20:20 -04:00
}
}
/**
2017-10-23 11:37:41 -04:00
* Create a new case note for a given case. Note that only users who are
* currently assigned to work on the case or have Process Permissions to
2017-10-18 10:47:40 -04:00
* access case notes may create a case note.
2014-03-26 12:20:20 -04:00
*
2021-05-12 18:59:01 -04:00
* @url POST /:appUid/note
2022-01-24 17:36:01 -04:00
* @status 201
2014-03-26 12:20:20 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 1}{@max 32}
2014-03-26 12:20:20 -04:00
* @param string $note_content {@min 1}{@max 500}
* @param int $send_mail {@choice 1,0}
*
2017-10-18 14:53:15 -04:00
* @return void
2017-10-23 11:37:41 -04:00
* @throws RestException
*
2017-10-18 10:47:40 -04:00
* @access protected
* @class AccessControl {@permission PM_CASES}
2014-03-26 12:20:20 -04:00
*/
2021-05-12 18:59:01 -04:00
public function doPostCaseNote($appUid, $note_content, $send_mail = 0)
2014-03-26 12:20:20 -04:00
{
try {
$usr_uid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2014-03-26 12:20:20 -04:00
$send_mail = ($send_mail == 0) ? false : true;
2021-05-12 18:59:01 -04:00
$cases->saveCaseNote($appUid, $usr_uid, $note_content, $send_mail);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2014-03-26 09:50:06 -04:00
}
}
/**
2021-05-12 18:59:01 -04:00
* @url GET /:appUid/tasks
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 32}{@max 32}
*/
2021-05-12 18:59:01 -04:00
public function doGetTasks($appUid)
{
try {
2017-10-05 14:54:41 -04:00
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
2021-05-12 18:59:01 -04:00
$response = $case->getTasks($appUid);
2022-04-20 16:27:02 -04:00
return DateTime::convertUtcToTimeZone($response);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Execute triggers
*
2021-05-12 18:59:01 -04:00
* @url PUT /:appUid/execute-triggers
2017-10-13 10:59:18 -04:00
*
2021-05-12 18:59:01 -04:00
* @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}
*
2017-10-13 10:59:18 -04:00
* @throws RestException
*
* @class AccessControl {@permission PM_CASES}
* @access protected
*/
2021-05-12 18:59:01 -04:00
public function doPutExecuteTriggers($appUid, $del_index, $obj_type, $obj_uid)
{
try {
2017-10-05 14:54:41 -04:00
$cases = new BmCases();
2021-05-12 18:59:01 -04:00
$cases->putExecuteTriggers($appUid, $del_index, $obj_type, $obj_uid);
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
2021-05-12 18:59:01 -04:00
* @url GET /:appUid/:del_index/steps
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 32}{@max 32}
* @param int $del_index
*/
2021-05-12 18:59:01 -04:00
public function doGetSteps($appUid, $del_index)
{
try {
2017-10-05 14:54:41 -04:00
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
2021-05-12 18:59:01 -04:00
$response = $case->getSteps($appUid, $del_index);
return $response;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
2014-03-14 15:33:35 -04:00
/**
* Get process list for start case
*
* @url GET /start-cases
*
* @param string $type_view {@from path}
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
*/
public function doGetCasesListStarCase(
$type_view = ''
) {
try {
2021-05-12 18:59:01 -04:00
$usrUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$case = new BmCases();
2021-05-12 18:59:01 -04:00
$response = $case->getCasesListStarCase($usrUid, $type_view);
return $response;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Get process list bookmark for start case
*
* @url GET /bookmark-start-cases
*
* @param string $type_view {@from path}
* @return array
2017-10-05 14:54:41 -04:00
* @throws Exception
*/
public function doGetCasesListBookmarkStarCase(
$type_view = ''
) {
try {
2021-05-12 18:59:01 -04:00
$usrUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$case = new BmCases();
2021-05-12 18:59:01 -04:00
$response = $case->getCasesListBookmarkStarCase($usrUid, $type_view);
return $response;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Mark a task process as a bookmark
2017-10-23 11:37:41 -04:00
*
* @url POST /bookmark/:tas_uid
*
* @param string $tas_uid {@min 32}{@max 32}
*
2017-10-19 12:43:53 -04:00
* @return void
2017-10-23 11:37:41 -04:00
* @throws RestException
*
2017-10-11 13:47:24 -04:00
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function doPostBookmarkStartCase($tas_uid)
{
try {
$userLoggedUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$user = new BmUser();
$user->updateBookmark($userLoggedUid, $tas_uid, 'INSERT');
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Remove a task process from bookmarks
* @url DELETE /bookmark/:tas_uid
*
* @param string $tas_uid {@min 32}{@max 32}
2017-10-05 14:54:41 -04:00
* @throws Exception
*
*/
public function doDeleteBookmarkStartCase($tas_uid)
{
try {
$userLoggedUid = $this->getUserId();
2017-10-05 14:54:41 -04:00
$user = new BmUser();
$user->updateBookmark($userLoggedUid, $tas_uid, 'DELETE');
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Batch reassign
* @url POST /reassign
*
* @access protected
* @class AccessControl {@className \ProcessMaker\Services\Api\Cases}
*
* @param array $request_data
2017-10-05 14:54:41 -04:00
* @throws Exception
*
*/
public function doPostReassign($request_data)
{
try {
2017-10-05 14:54:41 -04:00
$case = new BmCases();
$response = $case->doPostReassign($request_data);
2021-05-12 18:59:01 -04:00
return $response;
2017-10-05 14:54:41 -04:00
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
2016-08-13 13:13:59 -04:00
2018-11-08 08:42:51 -04:00
/**
* Upload attachment related to the case, it does not need docUid
* Upload document related to the case, it does need docUid
*
2021-05-12 18:59:01 -04:00
* @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
2018-11-08 08:42:51 -04:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid
2018-11-08 08:42:51 -04:00
* @param string $var_name
* @param string $doc_uid
* @param string $app_doc_uid
2020-09-11 15:02:20 -04:00
* @param int $delIndex {@from body}
2018-11-08 08:42:51 -04:00
*
* @return array
* @throws RestException
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
2021-05-12 18:59:01 -04:00
public function uploadDocumentToCase($appUid, $var_name, $doc_uid = '-1', $app_doc_uid = null, $delIndex = null)
2018-11-08 08:42:51 -04:00
{
try {
$userUid = $this->getUserId();
$case = new BmCases();
2020-09-11 15:02:20 -04:00
if (isset($delIndex)) {
2021-05-12 18:59:01 -04:00
$response = $case->uploadFiles($userUid, $appUid, $var_name, $doc_uid, $app_doc_uid, $delIndex);
2020-09-11 15:02:20 -04:00
} else {
2021-05-12 18:59:01 -04:00
$response = $case->uploadFiles($userUid, $appUid, $var_name, $doc_uid, $app_doc_uid);
2020-09-11 15:02:20 -04:00
}
2018-11-08 08:42:51 -04:00
} catch (ExceptionRestApi $e) {
throw new RestException($e->getCode(), $e->getMessage());
} catch (Exception $e) {
2021-05-12 18:59:01 -04:00
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
2018-11-08 08:42:51 -04:00
}
return $response;
}
2017-12-08 18:28:16 +00:00
/**
* Return information for sub process cases
*
2021-05-12 18:59:01 -04:00
* @url GET /:appUid/sub-process-cases
2017-12-08 18:28:16 +00:00
*
2021-05-12 18:59:01 -04:00
* @param string $appUid {@min 32}{@max 32}
2017-12-08 18:28:16 +00:00
*
* @return array
* @throws Exception
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
2021-05-12 18:59:01 -04:00
public function doGetCaseSubProcess($appUid)
2017-12-08 18:28:16 +00:00
{
try {
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
2021-05-12 18:59:01 -04:00
$caseInfo = $case->getCaseInfoSubProcess($appUid, $this->getUserId());
2017-12-08 18:28:16 +00:00
$caseInfo = DateTime::convertUtcToIso8601($caseInfo, $this->arrayFieldIso8601);
return $caseInfo;
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
2020-12-03 20:27:03 +00:00
/**
* Get filters of the advanced search for the current user
*
* @url GET /advanced-search/filters
*
* @return array
*
* @throws RestException
*/
public function doGetAdvancedSearchFilters()
{
try {
return Filter::getByUser($this->getUserId());
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* Get a specific filter of the advanced search for the current user
*
* @url GET /advanced-search/filter/:filterUid
*
* @param string $filterUid {@min 32}{@max 32}
*
* @return object
*
* @throws RestException
*/
public function doGetAdvancedSearchFilter($filterUid)
{
try {
$filter = Filter::getByUid($this->getUserId(), $filterUid);
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
// If not exists the requested filter throw an 404 error
if (is_null($filter)) {
throw new RestException(404, "Filter with Uid '{$filterUid}'.");
}
return $filter;
}
/**
* Add a new filter of the advanced search for the current user
*
* @url POST /advanced-search/filter
*
* @param string $name
* @param string $filters
*
* @return object
*
* @throws RestException
*/
public function doPostAdvancedSearchFilter($name, $filters)
{
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) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
2020-12-08 19:24:41 +00:00
/**
* Update a filter of the advanced search for the current user
*
* @url PUT /advanced-search/filter/:filterUid
*
* @param string $filterUid {@min 32}{@max 32}
* @param string $name
* @param string $filters
*
* @throws RestException
*/
public function doPutAdvancedSearchFilter($filterUid, $name, $filters)
{
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);
}
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
// If not exists the requested filter throw an 404 error
if (is_null($filter)) {
throw new RestException(404, "Filter with Uid '{$filterUid}'.");
}
}
2020-12-03 20:27:03 +00:00
/**
* Delete a specific filter of the advanced search for the current user
*
* @url DELETE /advanced-search/filter/:filterUid
*
* @param string $filterUid {@min 32}{@max 32}
*
* @throws RestException
*/
public function doDeleteAdvancedSearchFilter($filterUid)
{
try {
Filter::delete($filterUid);
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}