Files
luos/workflow/engine/methods/cases/proxyCasesList.php

145 lines
4.3 KiB
PHP
Raw Normal View History

<?php
use ProcessMaker\Model\Delegation;
/**
* Authentication check for session. If not logged in, return json error
*/
if (!isset($_SESSION['USER_LOGGED'])) {
$responseObject = new stdclass();
$responseObject->error = G::LoadTranslation('ID_LOGIN_AGAIN');
$responseObject->success = true;
$responseObject->lostSession = true;
print G::json_encode($responseObject);
die();
}
/**
* Do input filtering, although filtering should be done on the frontend rendering, not here
*/
$filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET);
$_REQUEST = $filter->xssFilterHard($_REQUEST);
$_SESSION['USER_LOGGED'] = $filter->xssFilterHard($_SESSION['USER_LOGGED']);
// Callback in the UI to utilize
$callback = isset($_REQUEST["callback"]) ? $_REQUEST["callback"] : "stcCallback1001";
// Sort column
$sort = isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : "APP_NUMBER";
// Sort direction
$dir = isset($_REQUEST["dir"]) ? $_REQUEST["dir"] : "DESC";
// Pagination control
2018-07-09 14:15:42 -04:00
$start = !empty($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
$limit = !empty($_REQUEST["limit"]) ? $_REQUEST["limit"] : 25;
// Our search filter
$filter = isset($_REQUEST["filter"]) ? $_REQUEST["filter"] : "";
// What process
$process = isset($_REQUEST["process"]) ? $_REQUEST["process"] : "";
// What category
$category = isset($_REQUEST["category"]) ? $_REQUEST["category"] : "";
// What status
$status = isset($_REQUEST["status"]) ? strtoupper($_REQUEST["status"]) : "";
$filterStatus = isset($_REQUEST["filterStatus"]) ? strtoupper($_REQUEST["filterStatus"]) : "";
// What user
$user = isset($_REQUEST["user"]) ? $_REQUEST["user"] : "";
// What keywords to search
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
// What kind of action
$action = isset($_GET["action"]) ? $_GET["action"] : (isset($_REQUEST["action"]) ? $_REQUEST["action"] : "todo");
// What kind of search
$type = isset($_GET["type"]) ? $_GET["type"] : (isset($_REQUEST["type"]) ? $_REQUEST["type"] : "extjs");
// Date ranges
$dateFrom = isset($_REQUEST["dateFrom"]) ? substr($_REQUEST["dateFrom"], 0, 10) : "";
$dateTo = isset($_REQUEST["dateTo"]) ? substr($_REQUEST["dateTo"], 0, 10) : "";
// First? No idea
$first = isset($_REQUEST["first"]) ? true : false;
$openApplicationUid = (isset($_REQUEST['openApplicationUid']) && $_REQUEST['openApplicationUid'] != '') ?
$_REQUEST['openApplicationUid'] : null;
$search = (!is_null($openApplicationUid)) ? $openApplicationUid : $search;
2017-08-29 16:09:57 -04:00
$columnSearch = isset($_REQUEST["columnSearch"]) ? strtoupper($_REQUEST["columnSearch"]) : "";
if ($sort == 'CASE_SUMMARY' || $sort == 'CASE_NOTES_COUNT') {
$sort = 'APP_NUMBER';//DEFAULT VALUE
}
2014-03-27 16:04:34 -04:00
if ($sort == 'APP_STATUS_LABEL') {
$sort = 'APP_STATUS';
}
try {
$userUid = (isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "") ? $_SESSION["USER_LOGGED"] : null;
2017-12-04 13:25:35 +00:00
$result = [];
switch ($action) {
case "search":
case "to_reassign":
2013-01-29 15:18:55 -04:00
if ($first) {
$result['totalCount'] = 0;
$result['data'] = array();
$result = G::json_encode($result);
echo $result;
return;
2013-01-29 15:18:55 -04:00
}
$user = ($user == "CURRENT_USER") ? $userUid : $user;
$userUid = $user;
break;
default:
break;
}
if ($action == 'search') {
$data = Delegation::search(
$userUid,
$start,
$limit,
$search,
$process,
$filterStatus,
$dir,
$sort,
$category,
$dateFrom,
2017-08-29 16:09:57 -04:00
$dateTo,
$columnSearch
);
} else {
$data = Delegation::search(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
2015-12-04 12:03:55 -04:00
$filterStatus,
$type,
2017-01-13 19:11:14 -04:00
$dateFrom,
$dateTo,
$callback,
$dir,
(strpos($sort, ".") !== false) ? $sort : "APP_CACHE_VIEW." . $sort,
$category
);
}
2017-02-16 15:00:57 -04:00
$data['data'] = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($data['data']);
$result = G::json_encode($data);
echo $result;
} catch (Exception $e) {
$msg = array("error" => $e->getMessage());
echo G::json_encode($msg);
}