Merged in bugfix/HOR-2873 (pull request #5567)
HOR-2873 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
5ecd36cfe6
@@ -156,6 +156,9 @@ class Applications
|
||||
}
|
||||
|
||||
//Define the number of records by return
|
||||
if(empty($limit)) {
|
||||
$limit = 25;
|
||||
}
|
||||
if (!empty($start)) {
|
||||
$sqlData .= " LIMIT $start, " . $limit;
|
||||
} else {
|
||||
|
||||
@@ -1027,4 +1027,16 @@ class Process extends BaseProcess
|
||||
$users->update($newData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a process object by PRO_ID
|
||||
*
|
||||
* @param type $id
|
||||
* @return Process
|
||||
*/
|
||||
public static function loadById($id) {
|
||||
$criteria = new Criteria(ProcessPeer::DATABASE_NAME);
|
||||
$criteria->add(ProcessPeer::PRO_ID, $id);
|
||||
return ProcessPeer::doSelect($criteria)[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,5 +484,16 @@ class Users extends BaseUsers
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a process object by USR_ID
|
||||
*
|
||||
* @param type $id
|
||||
* @return Users
|
||||
*/
|
||||
public static function loadById($id) {
|
||||
$criteria = new Criteria(UsersPeer::DATABASE_NAME);
|
||||
$criteria->add(UsersPeer::USR_ID, $id);
|
||||
return UsersPeer::doSelect($criteria)[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +286,17 @@ class Home extends Controller
|
||||
$user = (isset($httpData->user)) ? $httpData->user : null;
|
||||
$dateFrom = (isset($httpData->dateFrom)) ? $httpData->dateFrom : null;
|
||||
$dateTo = (isset($httpData->dateTo)) ? $httpData->dateTo : null;
|
||||
if (!empty($process)) {
|
||||
$processTitle = Process::loadById($process)->getProTitle();
|
||||
} else {
|
||||
$processTitle = '';
|
||||
}
|
||||
if (!empty($user)) {
|
||||
$userObject = Users::loadById($user);
|
||||
$userName = $userObject->getUsrLastname()." ".$userObject->getUsrFirstname();
|
||||
} else {
|
||||
$userName = '';
|
||||
}
|
||||
|
||||
$cases = $this->getAppsData( $httpData->t, null, null, $user, null, $search, $process, $status, $dateFrom, $dateTo, null, null, 'APP_CACHE_VIEW.APP_NUMBER', $category);
|
||||
$arraySearch = array($process, $status, $search, $category, $user, $dateFrom, $dateTo );
|
||||
@@ -294,9 +305,7 @@ class Home extends Controller
|
||||
$processes = array();
|
||||
$processes = $this->getProcessArray($httpData->t, $this->userID );
|
||||
$this->setVar( 'statusValues', $this->getStatusArray( $httpData->t, $this->userID ) );
|
||||
$this->setVar( 'processValues', $processes );
|
||||
$this->setVar( 'categoryValues', $this->getCategoryArray() );
|
||||
$this->setVar( 'userValues', $this->getUserArray( $httpData->t, $this->userID ) );
|
||||
$this->setVar( 'allUsersValues', $this->getAllUsersArray( 'search' ) );
|
||||
$this->setVar( 'categoryTitle', G::LoadTranslation("ID_CATEGORY") );
|
||||
$this->setVar( 'processTitle', G::LoadTranslation("ID_PROCESS") );
|
||||
@@ -316,6 +325,11 @@ class Home extends Controller
|
||||
$this->setVar( 'appListLimit', 10 );
|
||||
$this->setVar( 'listType', $httpData->t );
|
||||
|
||||
$this->setVar( 'processCurrentTitle', $processTitle );
|
||||
$this->setVar( 'userCurrentName', $userName );
|
||||
$this->setVar( 'currentUserLabel', G::LoadTranslation( "ID_ALL_USERS" ) );
|
||||
$this->setVar( 'allProcessLabel', G::LoadTranslation("ID_ALL_PROCESS") );
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
@@ -545,7 +559,7 @@ class Home extends Controller
|
||||
$this->render();
|
||||
}
|
||||
|
||||
function getUserArray ($action, $userUid)
|
||||
function getUserArray ($action, $userUid, $search = null)
|
||||
{
|
||||
global $oAppCache;
|
||||
$status = array ();
|
||||
@@ -561,6 +575,10 @@ class Home extends Controller
|
||||
$cUsers->addSelectColumn( UsersPeer::USR_UID );
|
||||
$cUsers->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$cUsers->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
if (!empty($search)) {
|
||||
$cUsers->addOr(UsersPeer::USR_FIRSTNAME, "%$search%", Criteria::LIKE);
|
||||
$cUsers->addOr(UsersPeer::USR_LASTNAME, "%$search%", Criteria::LIKE);
|
||||
}
|
||||
$oDataset = UsersPeer::doSelectRS( $cUsers );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->next();
|
||||
@@ -693,60 +711,75 @@ class Home extends Controller
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
function getProcessArray($action, $userUid)
|
||||
|
||||
/**
|
||||
* Get the list of active processes
|
||||
*
|
||||
* @global type $oAppCache
|
||||
* @param type $action
|
||||
* @param type $userUid
|
||||
* @return array
|
||||
*/
|
||||
private function getProcessArray($action, $userUid, $search=null)
|
||||
{
|
||||
global $oAppCache;
|
||||
|
||||
$processes = array();
|
||||
$processes[] = array("", G::LoadTranslation("ID_ALL_PROCESS"));
|
||||
|
||||
switch ($action) {
|
||||
case "simple_search":
|
||||
case "search":
|
||||
//In search action, the query to obtain all process is too slow, so we need to query directly to
|
||||
//process and content tables, and for that reason we need the current language in AppCacheView.
|
||||
G::loadClass("configuration");
|
||||
$oConf = new Configurations;
|
||||
$oConf->loadConfig($x, "APP_CACHE_VIEW_ENGINE", "", "", "", "");
|
||||
$appCacheViewEngine = $oConf->aConfig;
|
||||
$lang = isset($appCacheViewEngine["LANG"])? $appCacheViewEngine["LANG"] : "en";
|
||||
|
||||
$cProcess = new Criteria("workflow");
|
||||
$cProcess->clearSelectColumns();
|
||||
$cProcess->addSelectColumn(ProcessPeer::PRO_UID);
|
||||
$cProcess->addSelectColumn(ProcessPeer::PRO_ID);
|
||||
$cProcess->addSelectColumn(ProcessPeer::PRO_TITLE);
|
||||
$cProcess->add(ProcessPeer::PRO_STATUS, "ACTIVE");
|
||||
if (!empty($search)) {
|
||||
$cProcess->add(ProcessPeer::PRO_TITLE, "%$search%", Criteria::LIKE);
|
||||
}
|
||||
$oDataset = ProcessPeer::doSelectRS($cProcess);
|
||||
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$processes[] = array($aRow["PRO_UID"], $aRow["PRO_TITLE"]);
|
||||
$processes[] = array($aRow["PRO_ID"], $aRow["PRO_TITLE"]);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
return ($processes);
|
||||
break;
|
||||
case "consolidated":
|
||||
default:
|
||||
$cProcess = $oAppCache->getToDoListCriteria($userUid); //fast enough
|
||||
break;
|
||||
}
|
||||
|
||||
$cProcess->clearSelectColumns();
|
||||
$cProcess->setDistinct();
|
||||
$cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID);
|
||||
$cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE);
|
||||
$oDataset = AppCacheViewPeer::doSelectRS($cProcess);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$processes[] = array($aRow["PRO_UID"], $aRow["APP_PRO_TITLE"]);
|
||||
$oDataset->next();
|
||||
/**
|
||||
* Get the list of processes
|
||||
* @param type $httpData
|
||||
*/
|
||||
public function getProcesses($httpData)
|
||||
{
|
||||
$processes = [];
|
||||
foreach ($this->getProcessArray($httpData->t, null, $httpData->term) as $row) {
|
||||
$processes[] = [
|
||||
'id' => $row[0],
|
||||
'label' => $row[1],
|
||||
'value' => $row[1],
|
||||
];
|
||||
}
|
||||
return ($processes);
|
||||
print G::json_encode($processes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of users
|
||||
* @param type $httpData
|
||||
*/
|
||||
public function getUsers($httpData)
|
||||
{
|
||||
$users = [];
|
||||
foreach ($this->getUserArray($httpData->t, null, $httpData->term) as $row) {
|
||||
$users[] = [
|
||||
'id' => $row[0],
|
||||
'label' => $row[1],
|
||||
'value' => $row[1],
|
||||
];
|
||||
}
|
||||
print G::json_encode($users);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,11 +232,14 @@ class Cases
|
||||
Validator::usrUid($dataList["userId"], "userId");
|
||||
}
|
||||
|
||||
G::LoadClass("applications");
|
||||
$solrEnabled = false;
|
||||
$userUid = $dataList["userId"];
|
||||
$callback = isset( $dataList["callback"] ) ? $dataList["callback"] : "stcCallback1001";
|
||||
$dir = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC";
|
||||
$sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APP_CACHE_VIEW.APP_NUMBER";
|
||||
$sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APPLICATION.APP_NUMBER";
|
||||
if ($sort === 'APP_CACHE_VIEW.APP_NUMBER') {
|
||||
$sort = "APPLICATION.APP_NUMBER";
|
||||
}
|
||||
$start = isset( $dataList["start"] ) ? $dataList["start"] : "0";
|
||||
$limit = isset( $dataList["limit"] ) ? $dataList["limit"] : "";
|
||||
$filter = isset( $dataList["filter"] ) ? $dataList["filter"] : "";
|
||||
@@ -253,112 +256,24 @@ class Cases
|
||||
$newerThan = (!empty($dataList['newerThan']))? $dataList['newerThan'] : '';
|
||||
$oldestThan = (!empty($dataList['oldestthan']))? $dataList['oldestthan'] : '';
|
||||
$first = isset( $dataList["first"] ) ? true :false;
|
||||
$filterStatus = isset( $dataList["filterStatus"] ) ? strtoupper( $dataList["filterStatus"] ) : "";
|
||||
|
||||
$u = new \ProcessMaker\BusinessModel\User();
|
||||
|
||||
if ($action == "search" && !$u->checkPermission($dataList["userId"], "PM_ALLCASES")) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CASE_USER_NOT_HAVE_PERMISSION", array($dataList["userId"])));
|
||||
}
|
||||
|
||||
$valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search');
|
||||
if (!in_array($action, $valuesCorrect)) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INCORRECT_VALUE_ACTION")));
|
||||
}
|
||||
|
||||
$start = (int)$start;
|
||||
$start = abs($start);
|
||||
if ($start != 0) {
|
||||
$start--;
|
||||
}
|
||||
$limit = (int)$limit;
|
||||
$limit = abs($limit);
|
||||
if ($limit == 0) {
|
||||
G::LoadClass("configuration");
|
||||
$conf = new \Configurations();
|
||||
$generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
|
||||
if (isset($generalConfCasesList['casesListRowNumber'])) {
|
||||
$limit = (int)$generalConfCasesList['casesListRowNumber'];
|
||||
} else {
|
||||
$limit = 25;
|
||||
}
|
||||
} else {
|
||||
$limit = (int)$limit;
|
||||
}
|
||||
if ($sort != 'APP_CACHE_VIEW.APP_NUMBER') {
|
||||
$sort = G::toUpper($sort);
|
||||
$columnsAppCacheView = \AppCacheViewPeer::getFieldNames(\BasePeer::TYPE_FIELDNAME);
|
||||
if (!(in_array($sort, $columnsAppCacheView))) {
|
||||
$sort = 'APP_CACHE_VIEW.APP_NUMBER';
|
||||
}
|
||||
}
|
||||
$dir = G::toUpper($dir);
|
||||
if (!($dir == 'DESC' || $dir == 'ASC')) {
|
||||
$dir = 'ASC';
|
||||
}
|
||||
if ($process != '') {
|
||||
Validator::proUid($process, '$pro_uid');
|
||||
}
|
||||
if ($category != '') {
|
||||
Validator::catUid($category, '$cat_uid');
|
||||
}
|
||||
$status = G::toUpper($status);
|
||||
$listStatus = array('TO_DO', 'DRAFT', 'COMPLETED', 'CANCELLED', 'OPEN', 'CLOSE');
|
||||
if (!(in_array($status, $listStatus))) {
|
||||
$status = '';
|
||||
}
|
||||
if ($user != '') {
|
||||
Validator::usrUid($user, '$usr_uid');
|
||||
}
|
||||
if ($dateFrom != '') {
|
||||
Validator::isDate($dateFrom, 'Y-m-d', '$date_from');
|
||||
}
|
||||
if ($dateTo != '') {
|
||||
Validator::isDate($dateTo, 'Y-m-d', '$date_to');
|
||||
}
|
||||
|
||||
if ($action == 'search' || $action == 'to_reassign') {
|
||||
$userUid = ($user == "CURRENT_USER") ? $userUid : $user;
|
||||
if ($first) {
|
||||
$result = array();
|
||||
$result['totalCount'] = 0;
|
||||
$result['data'] = array();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
G::LoadClass("applications");
|
||||
$apps = new \Applications();
|
||||
$result = $apps->getAll(
|
||||
$response = $apps->searchAll(
|
||||
$userUid,
|
||||
$start,
|
||||
$limit,
|
||||
$action,
|
||||
$filter,
|
||||
$search,
|
||||
$process,
|
||||
$status,
|
||||
$type,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$callback,
|
||||
$filterStatus,
|
||||
$dir,
|
||||
(strpos($sort, ".") !== false) ? $sort : "APP_CACHE_VIEW." . $sort,
|
||||
$sort,
|
||||
$category,
|
||||
true,
|
||||
$paged,
|
||||
$newerThan,
|
||||
$oldestThan
|
||||
$dateFrom,
|
||||
$dateTo
|
||||
);
|
||||
|
||||
if (!empty($result['data'])) {
|
||||
foreach ($result['data'] as &$value) {
|
||||
$value = array_change_key_case($value, CASE_LOWER);
|
||||
}
|
||||
}
|
||||
if ($paged == false) {
|
||||
$response = $result['data'];
|
||||
} else {
|
||||
$response['total'] = $result['totalCount'];
|
||||
$response['total'] = 0;
|
||||
$response['start'] = $start + 1;
|
||||
$response['limit'] = $limit;
|
||||
$response['sort'] = G::toLower($sort);
|
||||
@@ -372,8 +287,6 @@ class Cases
|
||||
$response['date_from'] = $dateFrom;
|
||||
$response['date_to'] = $dateTo;
|
||||
}
|
||||
$response['data'] = $result['data'];
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,11 @@
|
||||
src = src.split("?");
|
||||
|
||||
var params = '?';
|
||||
params += 'process='+$("#comboProcess option:selected").val();
|
||||
params += 'process='+$("#comboProcess").val();
|
||||
params += '&status='+$("#comboStatus option:selected").val();
|
||||
params += '&search='+$("#searchText").val();
|
||||
params += '&category='+$("#comboCategory option:selected").val();
|
||||
params += '&user='+$("#comboUsers option:selected").val();
|
||||
params += '&user='+$("#comboUsers").val();
|
||||
params += '&dateFrom='+$("#dateFrom").val();
|
||||
params += '&dateTo='+$("#dateTo").val();
|
||||
|
||||
@@ -261,7 +261,22 @@
|
||||
$("#comboUsers").val(user);
|
||||
$("#dateFrom").val(dateFrom);
|
||||
$("#dateTo").val(dateTo);
|
||||
|
||||
$("#comboProcessAuto" ).autocomplete({
|
||||
source: "getProcesses?t="+listType,
|
||||
minLength: 1,
|
||||
select: function( event, ui ) {
|
||||
$("#comboProcess").val(ui.item.id);
|
||||
$("#comboProcess").trigger("change");
|
||||
}
|
||||
});
|
||||
$("#comboUsersAuto" ).autocomplete({
|
||||
source: "getUsers?t="+listType,
|
||||
minLength: 1,
|
||||
select: function( event, ui ) {
|
||||
$("#comboUsers").val(ui.item.id);
|
||||
$("#comboUsers").trigger("change");
|
||||
}
|
||||
});
|
||||
});
|
||||
{/literal}
|
||||
|
||||
@@ -294,11 +309,8 @@
|
||||
</select>
|
||||
</div>
|
||||
<div style = "float: right;"> <b>{$processTitle}:</b>
|
||||
<select id="comboProcess" onchange="redirect();" style="width: 220px">
|
||||
{foreach from=$processValues key=k item=VALUE}
|
||||
<option value="{$VALUE[0]}">{$VALUE[1]}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input id="comboProcessAuto" style="width: 220px" placeholder="{$allProcessLabel}" value="{$processCurrentTitle|htmlentities:2:"UTF-8"}">
|
||||
<input id="comboProcess" onchange="redirect();" type="hidden">
|
||||
</div>
|
||||
<div style = "float: left;"> <b>{$statusTitle}: </b>
|
||||
<select id="comboStatus" onchange="redirect();" style="width: 200px">
|
||||
@@ -319,11 +331,8 @@
|
||||
|
||||
<div id='panelDown' style = "display: none; width: 95%;">
|
||||
<div style = "float: left;"> <b>{$userTitle}: </b>
|
||||
<select id="comboUsers" onchange="redirect();" style="width: 400px">
|
||||
{foreach from=$userValues key=k item=VALUE}
|
||||
<option value="{$VALUE[0]}">{$VALUE[1]}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input id="comboUsersAuto" style="width: 400px" placeholder="{$currentUserLabel|htmlentities:2:'UTF-8'}" value="{$userCurrentName|htmlentities:2:'UTF-8'}">
|
||||
<input id="comboUsers" onchange="redirect();" type="hidden">
|
||||
</div>
|
||||
<div style = "float: left;"><b>{$fromTitle} </b>
|
||||
<input id="dateFrom" type="text" size="10">
|
||||
|
||||
Reference in New Issue
Block a user