2014-03-14 15:33:35 -04:00
|
|
|
<?php
|
|
|
|
|
namespace Services\Api\ProcessMaker;
|
|
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cases Api Controller
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class Cases extends Api
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases To Do
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url GET
|
|
|
|
|
*/
|
|
|
|
|
public function doGetCasesListToDo($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'todo';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Draft
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url GET /draft
|
|
|
|
|
*/
|
|
|
|
|
public function doGetCasesListDraft($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'draft';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Participated
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /participated
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListParticipated($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'sent';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Unassigned
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /unassigned
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListUnassigned($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'unassigned';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Paused
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /paused
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListPaused($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'paused';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list Cases Advanced Search
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $request_data , Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-03-14 15:38:03 -04:00
|
|
|
* @url GET /advanced-search
|
2014-03-14 15:33:35 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetCasesListAdvancedSearch($request_data = array())
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$request_data['action'] = 'search';
|
|
|
|
|
$request_data['userId'] = $this->getUserId();
|
|
|
|
|
$oCases = new \BusinessModel\Cases();
|
|
|
|
|
$response = $oCases->getList($request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-17 09:09:29 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:cas_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $cas_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetCaseInfo($cas_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-18 11:59:28 -04:00
|
|
|
$oData = $cases->getCaseInfo($cas_uid, $userUid);
|
|
|
|
|
return $oData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:cas_uid/current-task
|
|
|
|
|
*
|
|
|
|
|
* @param string $cas_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
2014-03-17 17:06:59 -04:00
|
|
|
public function doGetTaskCase($cas_uid)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-18 11:59:28 -04:00
|
|
|
$oData = $cases->getTaskCase($cas_uid);
|
|
|
|
|
return $oData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param string $act_uid {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param array $variables {@from body}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function doPostCase($prj_uid, $act_uid, $variables=null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
$arrayData = $cases->addCase($prj_uid, $act_uid, $userUid, $variables);
|
2014-03-17 17:06:59 -04:00
|
|
|
return $arrayData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST /impersonate
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param string $usr_uid {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param string $act_uid {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param array $variables {@from body}
|
|
|
|
|
*/
|
2014-03-17 17:06:59 -04:00
|
|
|
public function doPostCaseImpersonate($prj_uid, $usr_uid, $act_uid, $variables=null)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
$arrayData = $cases->addCaseImpersonate($prj_uid, $usr_uid, $act_uid, $variables);
|
2014-03-17 17:06:59 -04:00
|
|
|
return $arrayData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url PUT /:cas_uid/reassign-case
|
|
|
|
|
*
|
|
|
|
|
* @param string $del_index {@from body}
|
|
|
|
|
* @param string $usr_uid_source {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param string $usr_uid_target {@from body} {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doPutReassignCase($cas_uid, $del_index, $usr_uid_source, $usr_uid_target)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
|
|
|
|
$arrayData = $cases->updateReassignCase($cas_uid, $userUid, $del_index, $usr_uid_source, $usr_uid_target);
|
2014-03-17 17:06:59 -04:00
|
|
|
return $arrayData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url PUT /:cas_uid/route-case
|
|
|
|
|
*
|
|
|
|
|
* @param string $del_index {@from body}
|
|
|
|
|
* @param string $usr_uid_source {@from body} {@min 32}{@max 32}
|
|
|
|
|
* @param string $usr_uid_target {@from body} {@min 32}{@max 32}
|
|
|
|
|
*/
|
2014-03-17 17:06:59 -04:00
|
|
|
public function doPutRouteCase($cas_uid, $del_index)
|
2014-03-17 09:09:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$cases = new \BusinessModel\Cases();
|
2014-03-17 17:06:59 -04:00
|
|
|
$arrayData = $cases->updateRouteCase($cas_uid, $userUid, $del_index);
|
|
|
|
|
return $arrayData;
|
2014-03-17 09:09:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-14 15:33:35 -04:00
|
|
|
}
|
|
|
|
|
|