Merged in bugfix/HOR-3807 (pull request #6027)

HOR-3807

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2017-08-31 15:11:21 +00:00
committed by Julio Cesar Laura Avendaño
4 changed files with 105 additions and 83 deletions

View File

@@ -22,6 +22,7 @@ class Applications
* @param string $category uid for the process
* @param date $dateFrom
* @param date $dateTo
* @param string $columnSearch name of column for a specific search
* @return array $result result of the query
*/
public function searchAll(
@@ -35,7 +36,8 @@ class Applications
$sort = null,
$category = null,
$dateFrom = null,
$dateTo = null
$dateTo = null,
$columnSearch = 'APP_TITLE'
) {
//Exclude the Task Dummies in the delegations
$arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT");
@@ -127,8 +129,42 @@ class Applications
}
if (!empty($search)) {
//In the filter search we check in the following columns: APP_NUMBER APP_TAS_TITLE APP_TITLE
$sqlData .= " AND (APPLICATION.APP_TITLE LIKE '%{$search}%' OR APP_DELEGATION.APP_NUMBER LIKE '%{$search}%' OR TASK.TAS_TITLE LIKE '%{$search}%')";
//If the filter is related to the APPLICATION table: APP_NUMBER or APP_TITLE
if ($columnSearch === 'APP_NUMBER' || $columnSearch === 'APP_TITLE') {
$sqlSearch = "SELECT APPLICATION.APP_NUMBER FROM APPLICATION";
$sqlSearch .= " WHERE APPLICATION.{$columnSearch} LIKE '%{$search}%'";
switch ($columnSearch) {
case 'APP_TITLE':
break;
case 'APP_NUMBER':
//Cast the search criteria to string
if (!is_string($search)) {
$search = (string)$search;
}
//Only if is integer we will to add to greater equal in the query
if (substr($search, 0, 1) != '0' && ctype_digit($search)) {
$sqlSearch .= " AND APPLICATION.{$columnSearch} >= {$search}";
}
break;
}
if (!empty($start)) {
$sqlSearch .= " LIMIT $start, " . $limit;
} else {
$sqlSearch .= " LIMIT " . $limit;
}
$dataset = $stmt->executeQuery($sqlSearch);
$appNumbers = array(-1);
while ($dataset->next()) {
$newRow = $dataset->getRow();
array_push($appNumbers, $newRow['APP_NUMBER']);
}
$sqlData .= " AND APP_DELEGATION.APP_NUMBER IN (" . implode(",", $appNumbers) . ")";
}
//If the filter is related to the TASK table: TAS_TITLE
if ($columnSearch === 'TAS_TITLE') {
$sqlData .= " AND TASK.TAS_TITLE LIKE '%{$search}%' ";
}
}
if (!empty($dateFrom)) {
@@ -141,7 +177,7 @@ class Applications
}
//Add the additional filters
if (!empty($sort)) {
if (!empty($sort) && empty($search)) {
switch ($sort) {
case 'APP_NUMBER':
//The order by APP_DELEGATION.APP_NUMBER is must be fast than APPLICATION.APP_NUMBER
@@ -156,7 +192,7 @@ class Applications
}
//Sorts the records in descending order by default
if (!empty($dir)) {
if (!empty($dir) && empty($search)) {
$sqlData .= " " . $dir;
}
@@ -164,7 +200,7 @@ class Applications
if(empty($limit)) {
$limit = 25;
}
if (!empty($start)) {
if (!empty($start) && empty($search)) {
$sqlData .= " LIMIT $start, " . $limit;
} else {
$sqlData .= " LIMIT " . $limit;
@@ -633,23 +669,6 @@ class Applications
// this is the optimal way or query to render the cases search list
// fixing the bug related to the wrong data displayed in the list
/*
if ($action == 'search') {
$oDatasetIndex = AppCacheViewPeer::doSelectRS( $Criteria );
$oDatasetIndex->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDatasetIndex->next();
$maxDelIndexList = array ();
// a list of MAX_DEL_INDEXES is required in order to validate the right row
while ($aRow = $oDatasetIndex->getRow()) {
$maxDelIndexList[] = $aRow['MAX_DEL_INDEX'];
$oDatasetIndex->next();
}
// adding the validation condition in order to get the right row using the group by sentence
$Criteria->add( AppCacheViewPeer::DEL_INDEX, $maxDelIndexList, Criteria::IN );
//
//$params = array($maxDelIndexList);
}
*/
//here we count how many records exists for this criteria.
//BUT there are some special cases, and if we dont optimize them the server will crash.
@@ -657,16 +676,6 @@ class Applications
//case 1. when the SEARCH action is selected and none filter, search criteria is defined,
//we need to count using the table APPLICATION, because APP_CACHE_VIEW takes 3 seconds
/*
if ($action == 'search' && $filter == '' && $search == '' && $process == '' && $status == '' && $dateFrom == '' && $dateTo == '' && $category == '') {
$totalCount = $oAppCache->getSearchAllCount();
$doCountAlreadyExecuted = true;
}
if ($category != '') {
$totalCount = $oAppCache->getSearchCountCriteria();
$doCountAlreadyExecuted = true;
}
*/
$tableNameAux = '';
$totalCount = 0;
if ($doCountAlreadyExecuted == true) {
@@ -786,31 +795,6 @@ class Applications
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
//$aRow = $oAppCache->replaceRowUserData($aRow);
/*
* For participated cases, we want the last step in the case, not only the last step this user participated. To do that we get every case information again for the last step. (This could be solved by a subquery, but Propel might not support it and subqueries can be slower for larger
* datasets).
*/
/*if ($action == 'sent' || $action == 'search') {
$maxCriteria = new Criteria('workflow');
$maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL);
$maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX);
$maxCriteria->setLimit(1);
$maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria );
$maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$maxDataset->next();
$newData = $maxDataset->getRow();
foreach ($aRow as $col => $value) {
if (array_key_exists($col, $newData))
$aRow[$col] = $newData[$col];
}
$maxDataset->close();
}*/
//Current delegation (*)
if ($action == 'sent' || $action == 'simple_search' || $action == 'to_reassign') {
//Current task

View File

@@ -136,30 +136,31 @@ if ($action == "todo" || $action == "draft" || $action == "sent" || $action == "
}
//get values for the comboBoxes
$processes[] = array ('',G::LoadTranslation( 'ID_ALL_PROCESS' ));
$status = getStatusArray( $action, $userUid );
$processes[] = array('', G::LoadTranslation('ID_ALL_PROCESS'));
$status = getStatusArray($action, $userUid);
$category = getCategoryArray();
$oHeadPublisher->assign( 'reassignReaderFields', $reassignReaderFields ); //sending the fields to get from proxy
$oHeadPublisher->addExtJsScript( 'cases/reassignList', false );
$columnToSearch = getColumnsSearchArray();
$oHeadPublisher->assign('reassignReaderFields', $reassignReaderFields); //sending the fields to get from proxy
$oHeadPublisher->addExtJsScript('cases/reassignList', false);
$enableEnterprise = false;
if (class_exists( 'enterprisePlugin' )) {
if (class_exists('enterprisePlugin')) {
$enableEnterprise = true;
$oHeadPublisher->addExtJsScript(PATH_PLUGINS . "enterprise" . PATH_SEP . "advancedTools" . PATH_SEP , false, true);
$oHeadPublisher->addExtJsScript(PATH_PLUGINS . "enterprise" . PATH_SEP . "advancedTools" . PATH_SEP, false, true);
}
$oHeadPublisher->assign( 'pageSize', $pageSize ); //sending the page size
$oHeadPublisher->assign( 'columns', $columns ); //sending the columns to display in grid
$oHeadPublisher->assign( 'readerFields', $readerFields ); //sending the fields to get from proxy
$oHeadPublisher->assign( 'reassignColumns', $reassignColumns ); //sending the columns to display in grid
$oHeadPublisher->assign( 'action', $action ); //sending the action to make
$oHeadPublisher->assign( 'urlProxy', $urlProxy ); //sending the urlProxy to make
$oHeadPublisher->assign( 'PMDateFormat', $dateFormat ); //sending the fields to get from proxy
$oHeadPublisher->assign( 'statusValues', $status ); //Sending the listing of status
$oHeadPublisher->assign( 'processValues', $processes ); //Sending the listing of processes
$oHeadPublisher->assign( 'categoryValues', $category ); //Sending the listing of categories
$oHeadPublisher->assign( 'solrEnabled', $solrEnabled ); //Sending the status of solar
$oHeadPublisher->assign( 'enableEnterprise', $enableEnterprise ); //sending the page size
$oHeadPublisher->assign('pageSize', $pageSize); //sending the page size
$oHeadPublisher->assign('columns', $columns); //sending the columns to display in grid
$oHeadPublisher->assign('readerFields', $readerFields); //sending the fields to get from proxy
$oHeadPublisher->assign('reassignColumns', $reassignColumns); //sending the columns to display in grid
$oHeadPublisher->assign('action', $action); //sending the action to make
$oHeadPublisher->assign('urlProxy', $urlProxy); //sending the urlProxy to make
$oHeadPublisher->assign('PMDateFormat', $dateFormat); //sending the fields to get from proxy
$oHeadPublisher->assign('statusValues', $status); //Sending the listing of status
$oHeadPublisher->assign('processValues', $processes); //Sending the listing of processes
$oHeadPublisher->assign('categoryValues', $category); //Sending the listing of categories
$oHeadPublisher->assign('solrEnabled', $solrEnabled); //Sending the status of solar
$oHeadPublisher->assign('enableEnterprise', $enableEnterprise); //sending the page size
$oHeadPublisher->assign('columnSearchValues', $columnToSearch); //Sending the list of column for search: caseTitle, caseNumber, tasTitle
/*----------------------------------********---------------------------------*/
@@ -214,7 +215,6 @@ if(sizeof($fromPlugin)) {
}
}
$oHeadPublisher->assign( 'openReassignCallback', $jsFunction );
G::RenderPage( 'publish', 'extJs' );
function getCategoryArray ()
@@ -255,8 +255,6 @@ function getStatusArray($action, $userUid)
return $status;
}
//these getXX function gets the default fields in casesListSetup
/**
* get the list configuration headers of the cases checked for reassign, for the
* reassign cases list.
@@ -388,6 +386,18 @@ function getAdditionalFields($action, $confCasesList = array())
return $arrayConfig;
}
/**
* This function define the possibles columns for apply the specific search
* @return array $filters values of the dropdown
*/
function getColumnsSearchArray ()
{
$filters = [];
$filters[] = ['APP_TITLE', G::LoadTranslation('ID_CASE_TITLE')];
$filters[] = ['APP_NUMBER', G::LoadTranslation('ID_CASE_NUMBER')];
$filters[] = ['TAS_TITLE', G::LoadTranslation('ID_TASK')];
return $filters;
}
/*----------------------------------********---------------------------------*/
function getClientCredentials($clientId)

View File

@@ -36,8 +36,8 @@ $dateTo = isset($_REQUEST["dateTo"]) ? substr($_REQUEST["dateTo"], 0, 10) : "";
$first = isset($_REQUEST["first"]) ? true : false;
$openApplicationUid = (isset($_REQUEST['openApplicationUid']) && $_REQUEST['openApplicationUid'] != '') ?
$_REQUEST['openApplicationUid'] : null;
$search = (!is_null($openApplicationUid)) ? $openApplicationUid : $search;
$columnSearch = isset($_REQUEST["columnSearch"]) ? strtoupper($_REQUEST["columnSearch"]) : "";
if ($sort == 'CASE_SUMMARY' || $sort == 'CASE_NOTES_COUNT') {
$sort = 'APP_NUMBER';//DEFAULT VALUE
@@ -81,7 +81,8 @@ try {
$sort,
$category,
$dateFrom,
$dateTo
$dateTo,
$columnSearch
);
} else {
$data = $apps->getAll(

View File

@@ -1230,6 +1230,29 @@ Ext.onReady ( function() {
iconCls: 'no-icon' //use iconCls if placing within menu to shift to right side of menu
});
// ComboBox creation for the columnSearch: caseTitle, appNumber, tasTitle
var comboColumnSearch = new Ext.form.ComboBox({
width : 80,
boxMaxWidth : 90,
editable : false,
mode : 'local',
store : new Ext.data.ArrayStore({
fields: ['id', 'value'],
data : columnSearchValues
}),
valueField : 'id',
displayField : 'value',
triggerAction : 'all',
listeners:{
scope: this,
'select': function() {
var filter = comboColumnSearch.value;
storeCases.setBaseParam('columnSearch', filter);
}
},
iconCls: 'no-icon' //use iconCls if placing within menu to shift to right side of menu
});
// ComboBox creation processValues
var userStore = new Ext.data.Store( {
proxy : new Ext.data.HttpProxy( {
@@ -2081,6 +2104,9 @@ Ext.onReady ( function() {
clearDateTo,
"->",
'-',
_('ID_FILTER_BY'),
comboColumnSearch,
'-',
textSearch,
resetSearchButton,
btnSearch ,
@@ -2357,7 +2383,7 @@ Ext.onReady ( function() {
storeCases.setBaseParam("category", "");
storeCases.setBaseParam("process", "");
storeCases.setBaseParam("status", comboStatus.store.getAt(0).get(comboStatus.valueField));
//storeCases.setBaseParam("user", comboUser.store.getAt(0).get(comboUser.valueField));
storeCases.setBaseParam("columnSearch", comboColumnSearch.store.getAt(0).get(comboColumnSearch.valueField));
storeCases.setBaseParam("search", textSearch.getValue());
storeCases.setBaseParam("dateFrom", dateFrom.getValue());
storeCases.setBaseParam("dateTo", dateTo.getValue());
@@ -2504,6 +2530,7 @@ Ext.onReady ( function() {
comboCategory.setValue("");
suggestProcess.setValue("");
comboStatus.setValue("");
comboColumnSearch.setValue("APP_TITLE");
/*----------------------------------********---------------------------------*/
if (typeof valueFilterStatus != 'undefined') {
comboFilterStatus.setValue(valueFilterStatus);