2015-04-21 12:16:22 -04:00
|
|
|
<?php
|
2018-01-02 12:07:43 +00:00
|
|
|
|
2015-04-21 12:16:22 -04:00
|
|
|
if (!isset($_SESSION['USER_LOGGED'])) {
|
|
|
|
|
$responseObject = new stdclass();
|
|
|
|
|
$responseObject->error = G::LoadTranslation('ID_LOGIN_AGAIN');
|
|
|
|
|
$responseObject->success = true;
|
|
|
|
|
$responseObject->lostSession = true;
|
2018-01-02 12:07:43 +00:00
|
|
|
print G::json_encode($responseObject);
|
2015-04-21 12:16:22 -04:00
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $_SESSION['USER_LOGGED'];
|
2017-07-25 16:20:30 -04:00
|
|
|
|
2017-06-28 13:52:17 -04:00
|
|
|
$filters['paged'] = isset($_REQUEST["paged"]) ? $_REQUEST["paged"] : true;
|
|
|
|
|
$filters['count'] = isset($_REQUEST['count']) ? $_REQUEST["count"] : true;
|
|
|
|
|
$filters['category'] = isset($_REQUEST["category"]) ? $_REQUEST["category"] : "";
|
|
|
|
|
$filters['process'] = isset($_REQUEST["process"]) ? $_REQUEST["process"] : "";
|
|
|
|
|
$filters['search'] = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
|
|
|
|
|
$filters['filter'] = isset($_REQUEST["filter"]) ? $_REQUEST["filter"] : "";
|
|
|
|
|
$filters['dateFrom'] = (!empty($_REQUEST["dateFrom"])) ? substr($_REQUEST["dateFrom"], 0, 10) : "";
|
|
|
|
|
$filters['dateTo'] = (!empty($_REQUEST["dateTo"])) ? substr($_REQUEST["dateTo"], 0, 10) : "";
|
|
|
|
|
$filters['start'] = isset($_REQUEST["start"]) ? $_REQUEST["start"] : "0";
|
|
|
|
|
$filters['limit'] = isset($_REQUEST["limit"]) ? $_REQUEST["limit"] : "25";
|
|
|
|
|
$filters['sort'] = (isset($_REQUEST['sort'])) ? (($_REQUEST['sort'] == 'APP_STATUS_LABEL') ? 'APP_STATUS' : $_REQUEST["sort"]) : '';
|
|
|
|
|
$filters['dir'] = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "DESC";
|
|
|
|
|
$filters['action'] = isset($_REQUEST["action"]) ? $_REQUEST["action"] : "";
|
|
|
|
|
$filters['user'] = isset($_REQUEST["user"]) ? $_REQUEST["user"] : "";
|
|
|
|
|
$listName = isset($_REQUEST["list"]) ? $_REQUEST["list"] : "inbox";
|
|
|
|
|
$filters['filterStatus'] = isset($_REQUEST["filterStatus"]) ? $_REQUEST["filterStatus"] : "";
|
2017-07-13 14:58:43 -04:00
|
|
|
$filters['sort'] = G::toUpper($filters['sort']);
|
2017-02-10 13:47:49 -04:00
|
|
|
$openApplicationUid = (isset($_REQUEST['openApplicationUid']) && $_REQUEST['openApplicationUid'] != '') ? $_REQUEST['openApplicationUid'] : null;
|
2015-04-21 12:16:22 -04:00
|
|
|
|
2017-12-12 15:11:16 -04:00
|
|
|
global $RBAC;
|
|
|
|
|
$RBAC->allows(basename(__FILE__), $filters['action']);
|
|
|
|
|
|
2017-01-06 11:58:24 -04:00
|
|
|
//Define user when is reassign
|
2017-02-13 14:50:48 -04:00
|
|
|
if ($filters['action'] == 'to_reassign') {
|
2018-01-02 12:07:43 +00:00
|
|
|
if ($filters['user'] == '') {
|
2017-01-06 11:58:24 -04:00
|
|
|
$userUid = '';
|
|
|
|
|
}
|
2017-02-13 14:50:48 -04:00
|
|
|
if ($filters['user'] !== '' && $filters['user'] !== 'CURRENT_USER') {
|
2017-01-06 11:58:24 -04:00
|
|
|
$userUid = $filters['user'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-21 12:16:22 -04:00
|
|
|
// Select list
|
|
|
|
|
switch ($listName) {
|
|
|
|
|
case 'inbox':
|
|
|
|
|
$list = new ListInbox();
|
|
|
|
|
break;
|
|
|
|
|
case 'participated_history':
|
|
|
|
|
$list = new ListParticipatedHistory();
|
|
|
|
|
break;
|
|
|
|
|
case 'participated':
|
|
|
|
|
case 'participated_last':
|
|
|
|
|
$list = new ListParticipatedLast();
|
|
|
|
|
break;
|
|
|
|
|
case 'completed':
|
|
|
|
|
$list = new ListCompleted();
|
|
|
|
|
break;
|
|
|
|
|
case 'paused':
|
|
|
|
|
$list = new ListPaused();
|
|
|
|
|
break;
|
|
|
|
|
case 'canceled':
|
|
|
|
|
$list = new ListCanceled();
|
|
|
|
|
break;
|
|
|
|
|
case 'my_inbox':
|
|
|
|
|
$list = new ListMyInbox();
|
|
|
|
|
break;
|
|
|
|
|
case 'unassigned':
|
|
|
|
|
$list = new ListUnassigned();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate filters
|
2018-01-02 12:07:43 +00:00
|
|
|
$filters['search'] = (!is_null($openApplicationUid)) ? $openApplicationUid : $filters['search'];
|
2017-06-13 14:31:05 -04:00
|
|
|
//Set a flag for review in the list by APP_UID when is used the case Link with parallel task
|
2018-01-02 12:07:43 +00:00
|
|
|
$filters['caseLink'] = (!is_null($openApplicationUid)) ? $openApplicationUid : '';
|
2016-06-07 16:52:49 -04:00
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
$filters['start'] = (int) $filters['start'];
|
2015-05-04 15:37:35 -04:00
|
|
|
$filters['start'] = abs($filters['start']);
|
|
|
|
|
if ($filters['start'] != 0) {
|
2018-01-02 12:07:43 +00:00
|
|
|
$filters['start'] + 1;
|
2015-04-21 12:16:22 -04:00
|
|
|
}
|
|
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
$filters['limit'] = (int) $filters['limit'];
|
2015-05-04 15:37:35 -04:00
|
|
|
$filters['limit'] = abs($filters['limit']);
|
2017-10-13 15:02:14 -04:00
|
|
|
$conf = new Configurations();
|
|
|
|
|
$formats = $conf->getFormats();
|
|
|
|
|
$list->setUserDisplayFormat($formats['format']);
|
|
|
|
|
|
2015-05-04 15:37:35 -04:00
|
|
|
if ($filters['limit'] == 0) {
|
2015-04-21 12:16:22 -04:00
|
|
|
$generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
|
|
|
|
|
if (isset($generalConfCasesList['casesListRowNumber'])) {
|
2018-01-02 12:07:43 +00:00
|
|
|
$filters['limit'] = (int) $generalConfCasesList['casesListRowNumber'];
|
2015-04-21 12:16:22 -04:00
|
|
|
} else {
|
2015-05-04 15:37:35 -04:00
|
|
|
$filters['limit'] = 25;
|
2015-04-21 12:16:22 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2018-01-02 12:07:43 +00:00
|
|
|
$filters['limit'] = (int) $filters['limit'];
|
2015-04-21 12:16:22 -04:00
|
|
|
}
|
2017-10-13 15:02:14 -04:00
|
|
|
|
2017-07-13 14:58:43 -04:00
|
|
|
switch ($filters['sort']) {
|
|
|
|
|
case 'APP_CURRENT_USER':
|
2017-10-13 15:02:14 -04:00
|
|
|
//This value is format according to the userDisplayFormat, for this reason we will sent the UID
|
|
|
|
|
$filters['sort'] = 'USR_UID';
|
2017-07-13 14:58:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'DEL_TASK_DUE_DATE':
|
|
|
|
|
$filters['sort'] = 'DEL_DUE_DATE';
|
|
|
|
|
break;
|
|
|
|
|
case 'APP_UPDATE_DATE':
|
|
|
|
|
$filters['sort'] = 'DEL_DELEGATE_DATE';
|
|
|
|
|
break;
|
|
|
|
|
case 'APP_DEL_PREVIOUS_USER':
|
2017-10-13 15:02:14 -04:00
|
|
|
//This value is format according to the userDisplayFormat, for this reason we will sent the UID
|
|
|
|
|
$filters['sort'] = 'DEL_PREVIOUS_USR_UID';
|
2017-07-13 14:58:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'DEL_CURRENT_TAS_TITLE':
|
|
|
|
|
$filters['sort'] = 'APP_TAS_TITLE';
|
|
|
|
|
break;
|
|
|
|
|
case 'APP_STATUS_LABEL':
|
|
|
|
|
$filters['sort'] = 'APP_STATUS';
|
|
|
|
|
break;
|
2015-04-21 12:16:22 -04:00
|
|
|
}
|
|
|
|
|
|
2015-05-04 15:37:35 -04:00
|
|
|
$filters['dir'] = G::toUpper($filters['dir']);
|
|
|
|
|
if (!($filters['dir'] == 'DESC' || $filters['dir'] == 'ASC')) {
|
|
|
|
|
$filters['dir'] = 'DESC';
|
2015-04-21 12:16:22 -04:00
|
|
|
}
|
|
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
$result = $list->loadList($userUid, $filters, function (array $record) {
|
|
|
|
|
try {
|
|
|
|
|
if (isset($record["DEL_PREVIOUS_USR_UID"])) {
|
|
|
|
|
if ($record["DEL_PREVIOUS_USR_UID"] == "") {
|
|
|
|
|
$appDelegation = AppDelegationPeer::retrieveByPK($record["APP_UID"], $record["DEL_INDEX"]);
|
|
|
|
|
|
|
|
|
|
if (!is_null($appDelegation)) {
|
|
|
|
|
$appDelegationPrevious = AppDelegationPeer::retrieveByPK($record["APP_UID"], $appDelegation->getDelPrevious());
|
|
|
|
|
|
|
|
|
|
if (!is_null($appDelegationPrevious)) {
|
|
|
|
|
$taskPrevious = TaskPeer::retrieveByPK($appDelegationPrevious->getTasUid());
|
|
|
|
|
|
|
|
|
|
if (!is_null($taskPrevious)) {
|
|
|
|
|
switch ($taskPrevious->getTasType()) {
|
|
|
|
|
case "SCRIPT-TASK":
|
|
|
|
|
$record["DEL_PREVIOUS_USR_UID"] = $taskPrevious->getTasType();
|
|
|
|
|
break;
|
2015-10-21 15:06:11 -04:00
|
|
|
}
|
|
|
|
|
}
|
2015-10-19 14:01:31 -04:00
|
|
|
}
|
|
|
|
|
}
|
2015-05-05 16:51:53 -04:00
|
|
|
}
|
|
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
$record["PREVIOUS_USR_UID"] = $record["DEL_PREVIOUS_USR_UID"];
|
|
|
|
|
$record["PREVIOUS_USR_USERNAME"] = $record["DEL_PREVIOUS_USR_USERNAME"];
|
|
|
|
|
$record["PREVIOUS_USR_FIRSTNAME"] = $record["DEL_PREVIOUS_USR_FIRSTNAME"];
|
|
|
|
|
$record["PREVIOUS_USR_LASTNAME"] = $record["DEL_PREVIOUS_USR_LASTNAME"];
|
|
|
|
|
}
|
2015-05-05 16:51:53 -04:00
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
if (isset($record["DEL_DUE_DATE"])) {
|
|
|
|
|
$record["DEL_TASK_DUE_DATE"] = $record["DEL_DUE_DATE"];
|
|
|
|
|
}
|
2015-05-05 16:51:53 -04:00
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
if (isset($record["APP_PAUSED_DATE"])) {
|
|
|
|
|
$record["APP_UPDATE_DATE"] = $record["APP_PAUSED_DATE"];
|
|
|
|
|
}
|
2015-04-21 12:16:22 -04:00
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
if (isset($record["DEL_CURRENT_USR_USERNAME"])) {
|
|
|
|
|
$record["USR_USERNAME"] = $record["DEL_CURRENT_USR_USERNAME"];
|
|
|
|
|
$record["USR_FIRSTNAME"] = $record["DEL_CURRENT_USR_FIRSTNAME"];
|
|
|
|
|
$record["USR_LASTNAME"] = $record["DEL_CURRENT_USR_LASTNAME"];
|
|
|
|
|
$record["APP_UPDATE_DATE"] = $record["DEL_DELEGATE_DATE"];
|
|
|
|
|
}
|
2016-02-29 14:45:07 -04:00
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
if (isset($record['DEL_CURRENT_TAS_TITLE']) && $record['DEL_CURRENT_TAS_TITLE'] != '') {
|
|
|
|
|
$record['APP_TAS_TITLE'] = $record['DEL_CURRENT_TAS_TITLE'];
|
|
|
|
|
}
|
2015-05-05 16:51:53 -04:00
|
|
|
|
2018-01-02 12:07:43 +00:00
|
|
|
if (isset($record["APP_STATUS"])) {
|
|
|
|
|
$record["APP_STATUS_LABEL"] = G::LoadTranslation("ID_" . $record["APP_STATUS"]);
|
2015-05-05 16:51:53 -04:00
|
|
|
}
|
2018-01-02 12:07:43 +00:00
|
|
|
|
|
|
|
|
return $record;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
2015-04-21 12:16:22 -04:00
|
|
|
}
|
2018-01-02 12:07:43 +00:00
|
|
|
});
|
2015-04-21 12:16:22 -04:00
|
|
|
|
2015-05-05 16:51:53 -04:00
|
|
|
$response = array();
|
2018-01-02 12:07:43 +00:00
|
|
|
$response['filters'] = $filters;
|
|
|
|
|
$response['totalCount'] = $list->getCountList($userUid, $filters);
|
2015-11-26 20:11:58 -04:00
|
|
|
$response['data'] = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($result);
|
2015-04-21 12:16:22 -04:00
|
|
|
echo G::json_encode($response);
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$msg = array("error" => $e->getMessage());
|
|
|
|
|
echo G::json_encode($msg);
|
|
|
|
|
}
|