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

138 lines
4.7 KiB
PHP
Raw Normal View History

<?php
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();
}
G::LoadSystem('inputfilter');
$filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET);
$_REQUEST = $filter->xssFilterHard($_REQUEST);
$_SESSION['USER_LOGGED'] = $filter->xssFilterHard($_SESSION['USER_LOGGED']);
//Getting the extJs parameters
$callback = isset( $_REQUEST["callback"] ) ? $_REQUEST["callback"] : "stcCallback1001";
2017-02-16 15:00:57 -04:00
//This default value was defined in casesList.js
$dir = isset( $_REQUEST["dir"] ) ? $_REQUEST["dir"] : "DESC";
2017-02-16 15:00:57 -04:00
//This default value was defined in casesList.js
$sort = isset( $_REQUEST["sort"] ) ? $_REQUEST["sort"] : "APP_NUMBER";
$start = isset( $_REQUEST["start"] ) ? $_REQUEST["start"] : "0";
$limit = isset( $_REQUEST["limit"] ) ? $_REQUEST["limit"] : "25";
$filter = isset( $_REQUEST["filter"] ) ? $_REQUEST["filter"] : "";
$process = isset( $_REQUEST["process"] ) ? $_REQUEST["process"] : "";
$category = isset( $_REQUEST["category"] ) ? $_REQUEST["category"] : "";
$status = isset( $_REQUEST["status"] ) ? strtoupper( $_REQUEST["status"] ) : "";
2015-12-04 12:03:55 -04:00
$filterStatus = isset( $_REQUEST["filterStatus"] ) ? strtoupper( $_REQUEST["filterStatus"] ) : "";
$user = isset( $_REQUEST["user"] ) ? $_REQUEST["user"] : "";
$search = isset( $_REQUEST["search"] ) ? $_REQUEST["search"] : "";
$action = isset( $_GET["action"] ) ? $_GET["action"] : (isset( $_REQUEST["action"] ) ? $_REQUEST["action"] : "todo");
$type = isset( $_GET["type"] ) ? $_GET["type"] : (isset( $_REQUEST["type"] ) ? $_REQUEST["type"] : "extjs");
$dateFrom = isset( $_REQUEST["dateFrom"] ) ? substr( $_REQUEST["dateFrom"], 0, 10 ) : "";
$dateTo = isset( $_REQUEST["dateTo"] ) ? substr( $_REQUEST["dateTo"], 0, 10 ) : "";
2017-02-16 15:00:57 -04:00
$first = isset( $_REQUEST["first"] ) ? true : false;
$openApplicationUid = (isset($_REQUEST['openApplicationUid']) && $_REQUEST['openApplicationUid'] != '')?
$_REQUEST['openApplicationUid'] : null;
$search = (!is_null($openApplicationUid))? $openApplicationUid : $search;
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;
$result = "";
$solrEnabled = false;
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 ;
}
$user = ($user == "CURRENT_USER")? $userUid : $user;
$userUid = $user;
break;
default:
break;
}
if ((
$action == "todo" || $action == "draft" || $action == "paused" || $action == "sent" ||
$action == "selfservice" || $action == "unassigned" || $action == "search"
) &&
(($solrConf = System::solrEnv()) !== false)
) {
G::LoadClass("AppSolr");
$ApplicationSolrIndex = new AppSolr(
$solrConf["solr_enabled"],
$solrConf["solr_host"],
$solrConf["solr_instance"]
);
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
//Check if there are missing records to reindex and reindex them
$ApplicationSolrIndex->synchronizePendingApplications();
$solrEnabled = true;
} else{
$solrEnabled = false;
}
}
if ($solrEnabled) {
$data = $ApplicationSolrIndex->getAppGridData(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
$status,
$type,
$dateFrom,
$dateTo,
$callback,
$dir,
$sort,
$category
);
} else {
G::LoadClass("applications");
$apps = new Applications();
2017-01-10 13:41:43 -04:00
$data = $apps->searchAll(
$userUid,
$start,
$limit,
$search,
$process,
2015-12-04 12:03:55 -04:00
$filterStatus,
$dir,
2017-02-16 15:00:57 -04:00
$sort,
2017-01-13 19:11:14 -04:00
$category,
$dateFrom,
$dateTo
);
}
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);
}