This commit is contained in:
Paula Quispe
2017-10-05 14:54:41 -04:00
parent 99db5a9d90
commit 7c724070dd
4 changed files with 1062 additions and 870 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,20 @@
<?php
namespace ProcessMaker\Services\Api;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
use \ProcessMaker\Util\DateTime;
use \ProcessMaker\BusinessModel\Validator;
use AppDocument;
use AppDelegation;
use AppDelegationPeer;
use Criteria;
use Exception;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Cases as BmCases;
use ProcessMaker\BusinessModel\User as BmUser;
use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor;
use ProcessMaker\Util\DateTime;
use ProcessMaker\BusinessModel\Validator;
use ProcessMaker\Services\Api;
/**
* Cases Api Controller
@@ -42,7 +51,7 @@ class Cases extends Api
$delIndex = $this->parameters[$arrayArgs['app_index']];
$userUid = $this->getUserId();
//Check if the user has the case
$appDelegation = new \AppDelegation();
$appDelegation = new AppDelegation();
$aCurUser = $appDelegation->getCurrentUsers($applicationUid, $delIndex);
if (!empty($aCurUser)) {
foreach ($aCurUser as $key => $value) {
@@ -52,16 +61,37 @@ class Cases extends Api
}
}
//Check if the user has Permissions
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
return $oCases->checkUserHasPermissionsOrSupervisor($userUid, $applicationUid, $dynaformUid);
break;
case 'doPutCaseVariables':
$applicationUid = $this->parameters[$arrayArgs['app_uid']];
$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
$case = new \ProcessMaker\BusinessModel\Cases();
$user = new \ProcessMaker\BusinessModel\User();
$case = new BmCases();
$user = new BmUser();
$count = 0;
@@ -71,7 +101,7 @@ class Cases extends Api
if (!empty($arrayApplicationData)) {
if (!$user->checkPermission($usrUid, 'PM_REASSIGNCASE')) {
if ($user->checkPermission($usrUid, 'PM_REASSIGNCASE_SUPERVISOR')) {
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
$supervisor = new BmProcessSupervisor();
$flagps = $supervisor->isUserProcessSupervisor($arrayApplicationData['PRO_UID'], $usrUid);
if (!$flagps) {
$count = $count + 1;
@@ -90,20 +120,20 @@ class Cases extends Api
$appUid = $this->parameters[$arrayArgs['app_uid']];
$usrUid = $this->getUserId();
//Check if the user is supervisor process
$case = new \ProcessMaker\BusinessModel\Cases();
$user = new \ProcessMaker\BusinessModel\User();
$case = new BmCases();
$user = new BmUser();
$arrayApplicationData = $case->getApplicationRecordByPk($appUid, [], false);
if (!empty($arrayApplicationData)) {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\AppDelegationPeer::APP_UID);
$criteria->add(\AppDelegationPeer::APP_UID, $appUid);
$criteria->add(\AppDelegationPeer::USR_UID, $usrUid);
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(AppDelegationPeer::APP_UID);
$criteria->add(AppDelegationPeer::APP_UID, $appUid);
$criteria->add(AppDelegationPeer::USR_UID, $usrUid);
$criteria->setLimit(1);
$rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
$rsCriteria = AppDelegationPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
return true;
} else {
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
$supervisor = new BmProcessSupervisor();
$flagps = $supervisor->isUserProcessSupervisor($arrayApplicationData['PRO_UID'], $usrUid);
return $flagps;
}
@@ -131,7 +161,7 @@ class Cases extends Api
}
return false;
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -147,9 +177,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET
*/
@@ -174,11 +202,11 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -194,9 +222,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /paged
*/
@@ -221,10 +247,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -240,9 +266,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /draft
*/
@@ -267,10 +291,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -286,9 +310,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /draft/paged
*/
@@ -313,10 +335,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -332,9 +354,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /participated
*/
@@ -359,10 +379,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -378,9 +398,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /participated/paged
*/
@@ -405,10 +423,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -424,9 +442,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /unassigned
*/
@@ -451,10 +467,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -470,9 +486,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /unassigned/paged
*/
@@ -497,10 +511,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -516,9 +530,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /paused
*/
@@ -543,10 +555,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -562,9 +574,7 @@ class Cases extends Api
* @param string $pro_uid {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /paused/paged
*/
@@ -589,10 +599,10 @@ class Cases extends Api
$dataList['category'] = $cat_uid;
$dataList['process'] = $pro_uid;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -612,9 +622,7 @@ class Cases extends Api
* @param string $date_to {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /advanced-search
*/
@@ -647,10 +655,10 @@ class Cases extends Api
$dataList['dateFrom'] = $date_from;
$dataList['dateTo'] = $date_to;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -670,9 +678,7 @@ class Cases extends Api
* @param string $date_to {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /advanced-search/paged
*/
@@ -705,10 +711,10 @@ class Cases extends Api
$dataList['dateFrom'] = $date_from;
$dataList['dateTo'] = $date_to;
$dataList['search'] = $search;
$oCases = new \ProcessMaker\BusinessModel\Cases();
$oCases = new BmCases();
$response = $oCases->getList($dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -719,17 +725,19 @@ class Cases extends Api
* @url GET /:app_uid
*
* @param string $app_uid {@min 32}{@max 32}
* @return array
* @throws Exception
*/
public function doGetCaseInfo($app_uid)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
$caseInfo = $case->getCaseInfo($app_uid, $this->getUserId());
$caseInfo = DateTime::convertUtcToIso8601($caseInfo, $this->arrayFieldIso8601);
return $caseInfo;
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -742,7 +750,7 @@ class Cases extends Api
public function doGetTaskCase($app_uid)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
$arrayData = $case->getTaskCase($app_uid, $this->getUserId());
@@ -750,7 +758,7 @@ class Cases extends Api
$response = $arrayData;
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -767,10 +775,10 @@ class Cases extends Api
{
try {
$userUid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$oData = $cases->addCase($pro_uid, $tas_uid, $userUid, $variables);
return $oData;
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -787,10 +795,10 @@ class Cases extends Api
public function doPostCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables = null)
{
try {
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$oData = $cases->addCaseImpersonate($pro_uid, $usr_uid, $tas_uid, $variables);
return $oData;
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -807,9 +815,9 @@ class Cases extends Api
{
try {
$userUid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$cases->updateReassignCase($app_uid, $userUid, $del_index, $usr_uid_source, $usr_uid_target);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -825,9 +833,9 @@ class Cases extends Api
{
try {
$userUid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$cases->updateRouteCase($app_uid, $userUid, $del_index);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -846,9 +854,9 @@ class Cases extends Api
{
try {
$userUid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$cases->putCancelCase($cas_uid, $userUid);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -858,9 +866,7 @@ class Cases extends Api
*
* @param string $cas_uid {@min 1}{@max 32}
* @param string $unpaused_date {@from body}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url PUT /:cas_uid/pause
*/
@@ -868,13 +874,13 @@ class Cases extends Api
{
try {
$userUid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
if ($unpaused_date == null) {
$cases->putPauseCase($cas_uid, $userUid);
} else {
$cases->putPauseCase($cas_uid, $userUid, false, $unpaused_date);
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -883,9 +889,7 @@ class Cases extends Api
* Unpause Case
*
* @param string $cas_uid {@min 1}{@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url PUT /:cas_uid/unpause
*/
@@ -893,9 +897,9 @@ class Cases extends Api
{
try {
$userUid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$cases->putUnpauseCase($cas_uid, $userUid);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -905,9 +909,7 @@ class Cases extends Api
*
* @param string $cas_uid {@min 1}{@max 32}
* @param string $tri_uid {@min 1}{@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url PUT /:cas_uid/execute-trigger/:tri_uid
*/
@@ -915,9 +917,9 @@ class Cases extends Api
{
try {
$userUid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$cases->putExecuteTriggerCase($cas_uid, $tri_uid, $userUid);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -926,9 +928,7 @@ class Cases extends Api
* Delete Case
*
* @param string $cas_uid {@min 1}{@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url DELETE /:cas_uid
*/
@@ -936,9 +936,9 @@ class Cases extends Api
{
try {
$usr_uid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$cases->deleteCase($cas_uid, $usr_uid);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -962,10 +962,10 @@ class Cases extends Api
{
try {
$usr_uid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$response = $cases->getCaseVariables($app_uid, $usr_uid, $dyn_uid, $pro_uid, $act_uid, $app_index);
return DateTime::convertUtcToIso8601($response);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -977,9 +977,7 @@ class Cases extends Api
* @param array $request_data
* @param string $dyn_uid {@from path}
* @param int $del_index {@from path}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url PUT /:app_uid/variable
*/
@@ -987,10 +985,10 @@ class Cases extends Api
{
try {
$usr_uid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$request_data = \ProcessMaker\Util\DateTime::convertDataToUtc($request_data);
$cases->setCaseVariables($app_uid, $request_data, $dyn_uid, $usr_uid, $del_index);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -1008,9 +1006,7 @@ class Cases extends Api
* @param string $date_to {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /:app_uid/notes
*/
@@ -1038,10 +1034,10 @@ class Cases extends Api
$dataList['search'] = $search;
$usr_uid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$response = $cases->getCaseNotes($app_uid, $usr_uid, $dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -1058,9 +1054,7 @@ class Cases extends Api
* @param string $date_to {@from path}
* @param string $search {@from path}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url GET /:app_uid/notes/paged
*/
@@ -1086,10 +1080,10 @@ class Cases extends Api
$dataList['search'] = $search;
$usr_uid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$response = $cases->getCaseNotes($app_uid, $usr_uid, $dataList);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -1100,9 +1094,7 @@ class Cases extends Api
* @param string $app_uid {@min 1}{@max 32}
* @param string $note_content {@min 1}{@max 500}
* @param int $send_mail {@choice 1,0}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url POST /:app_uid/note
*/
@@ -1110,10 +1102,10 @@ class Cases extends Api
{
try {
$usr_uid = $this->getUserId();
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$send_mail = ($send_mail == 0) ? false : true;
$cases->saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -1126,13 +1118,13 @@ class Cases extends Api
public function doGetTasks($app_uid)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
$response = $case->getTasks($app_uid);
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -1144,17 +1136,16 @@ class Cases extends Api
* @param int $del_index {@from body}
* @param string $obj_type {@from body}
* @param string $obj_uid {@from body}
*
* @copyright Colosa - Bolivia
* @throws Exception
*
* @url PUT /:app_uid/execute-triggers
*/
public function doPutExecuteTriggers($app_uid, $del_index, $obj_type, $obj_uid)
{
try {
$cases = new \ProcessMaker\BusinessModel\Cases();
$cases = new BmCases();
$cases->putExecuteTriggers($app_uid, $del_index, $obj_type, $obj_uid);
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -1169,13 +1160,13 @@ class Cases extends Api
public function doGetSteps($app_uid, $del_index)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
$response = $case->getSteps($app_uid, $del_index);
return $response;
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -1187,6 +1178,7 @@ class Cases extends Api
*
* @param string $type_view {@from path}
* @return array
* @throws Exception
*
*/
public function doGetCasesListStarCase(
@@ -1194,12 +1186,12 @@ class Cases extends Api
) {
try {
$usr_uid = $this->getUserId();
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BmCases();
$response = $case->getCasesListStarCase($usr_uid, $type_view);
return $response;
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -1211,6 +1203,7 @@ class Cases extends Api
*
* @param string $type_view {@from path}
* @return array
* @throws Exception
*
*/
public function doGetCasesListBookmarkStarCase(
@@ -1218,12 +1211,12 @@ class Cases extends Api
) {
try {
$usr_uid = $this->getUserId();
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BmCases();
$response = $case->getCasesListBookmarkStarCase($usr_uid, $type_view);
return $response;
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -1234,15 +1227,16 @@ class Cases extends Api
* @url POST /bookmark/:tas_uid
*
* @param string $tas_uid {@min 32}{@max 32}
* @throws Exception
*
*/
public function doPostBookmarkStartCase($tas_uid)
{
try {
$userLoggedUid = $this->getUserId();
$user = new \ProcessMaker\BusinessModel\User();
$user = new BmUser();
$user->updateBookmark($userLoggedUid, $tas_uid, 'INSERT');
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -1252,15 +1246,16 @@ class Cases extends Api
* @url DELETE /bookmark/:tas_uid
*
* @param string $tas_uid {@min 32}{@max 32}
* @throws Exception
*
*/
public function doDeleteBookmarkStartCase($tas_uid)
{
try {
$userLoggedUid = $this->getUserId();
$user = new \ProcessMaker\BusinessModel\User();
$user = new BmUser();
$user->updateBookmark($userLoggedUid, $tas_uid, 'DELETE');
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
@@ -1273,15 +1268,16 @@ class Cases extends Api
* @class AccessControl {@className \ProcessMaker\Services\Api\Cases}
*
* @param array $request_data
* @throws Exception
*
*/
public function doPostReassign($request_data)
{
try {
$case = new \ProcessMaker\BusinessModel\Cases();
$case = new BmCases();
$response = $case->doPostReassign($request_data);
return $response;
} catch (\Exception $e) {
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}

View File

@@ -1715,24 +1715,26 @@ class Light extends Api
/**
* Put Case Variables
* @access protected
* @class AccessControl {@className \ProcessMaker\Services\Api\Cases}
* @url PUT /:app_uid/variable
*
* @param string $app_uid {@min 1}{@max 32}
* @param array $request_data
* @param string $dyn_uid {@from path}
* @param int $del_index {@from path}
*
* @url PUT /:app_uid/variable
* @return void
* @throws RestException
*/
public function doPutCaseVariables($app_uid, $request_data, $dyn_uid = '', $del_index = 0)
{
try {
//Check if the user is a supervisor or have permissions
$usr_uid = $this->getUserId();
$cases = new BusinessModelCases();
$hasAccess = $cases->checkUserHasPermissionsOrSupervisor($usr_uid, $app_uid, $dyn_uid);
//When the user is a supervisor del_index is 0
if ($del_index <= 0 && !$hasAccess) {
if ($del_index < 0) {
throw (new Exception(G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER',
array('del_index')), Api::STAT_APP_EXCEPTION));
}
@@ -1740,6 +1742,7 @@ class Light extends Api
throw (new Exception(G::LoadTranslation('ID_CAN_NOT_BE_NULL', array('del_index')),
Api::STAT_APP_EXCEPTION));
}
$cases = new BusinessModelCases();
if ($del_index > 0) {
if ($cases->caseAlreadyRouted($app_uid, $del_index, $usr_uid)) {
throw (new Exception(G::LoadTranslation('ID_CASE_ALREADY_DERIVATED'), Api::STAT_APP_EXCEPTION));