Merged in bugfix/PMC-112 (pull request #6870)
PMC-112 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -1006,4 +1006,24 @@ class PmTable
|
|||||||
}
|
}
|
||||||
return $oCriteria;
|
return $oCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of the column ex: string, int, double, boolean
|
||||||
|
*
|
||||||
|
* @param string $pmTablePeer
|
||||||
|
* @param string $tableName
|
||||||
|
* @param string $columnName
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getTypeOfColumn($pmTablePeer, $tableName, $columnName)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$type = $pmTablePeer::getMapBuilder()->getDatabaseMap()->getTable($tableName)->getColumn($columnName)->getCreoleType();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use BpmnEngineServicesSearchIndex;
|
|||||||
use Cases as ClassesCases;
|
use Cases as ClassesCases;
|
||||||
use CasesPeer;
|
use CasesPeer;
|
||||||
use Configurations;
|
use Configurations;
|
||||||
|
use CreoleTypes;
|
||||||
use Criteria;
|
use Criteria;
|
||||||
use DBAdapter;
|
use DBAdapter;
|
||||||
use EntitySolrRequestData;
|
use EntitySolrRequestData;
|
||||||
@@ -32,6 +33,7 @@ use InputDocument;
|
|||||||
use InvalidIndexSearchTextException;
|
use InvalidIndexSearchTextException;
|
||||||
use ListParticipatedLast;
|
use ListParticipatedLast;
|
||||||
use PmDynaform;
|
use PmDynaform;
|
||||||
|
use PmTable;
|
||||||
use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor;
|
use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor;
|
||||||
use ProcessMaker\BusinessModel\Task as BmTask;
|
use ProcessMaker\BusinessModel\Task as BmTask;
|
||||||
use ProcessMaker\BusinessModel\User as BmUser;
|
use ProcessMaker\BusinessModel\User as BmUser;
|
||||||
@@ -39,16 +41,16 @@ use ProcessMaker\Core\System;
|
|||||||
use ProcessMaker\Exception\UploadException;
|
use ProcessMaker\Exception\UploadException;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
use ProcessMaker\Services\OAuth2\Server;
|
use ProcessMaker\Services\OAuth2\Server;
|
||||||
|
use ProcessMaker\Util\DateTime as UtilDateTime;
|
||||||
use ProcessMaker\Validation\ExceptionRestApi;
|
use ProcessMaker\Validation\ExceptionRestApi;
|
||||||
use ProcessMaker\Validation\Validator as FileValidator;
|
use ProcessMaker\Validation\Validator as FileValidator;
|
||||||
|
|
||||||
use ProcessPeer;
|
use ProcessPeer;
|
||||||
use ProcessUser;
|
use ProcessUser;
|
||||||
use ProcessUserPeer;
|
use ProcessUserPeer;
|
||||||
use RBAC;
|
use RBAC;
|
||||||
use ResultSet;
|
use ResultSet;
|
||||||
use RoutePeer;
|
|
||||||
use SubApplication;
|
use SubApplication;
|
||||||
use SubProcessPeer;
|
|
||||||
use Task as ModelTask;
|
use Task as ModelTask;
|
||||||
use TaskPeer;
|
use TaskPeer;
|
||||||
use Tasks as ClassesTasks;
|
use Tasks as ClassesTasks;
|
||||||
@@ -3502,7 +3504,7 @@ class Cases
|
|||||||
* @param string $listPeer , name of the list class
|
* @param string $listPeer , name of the list class
|
||||||
* @param string $search , the parameter for search in the table
|
* @param string $search , the parameter for search in the table
|
||||||
* @param string $additionalClassName , name of the className of pmtable
|
* @param string $additionalClassName , name of the className of pmtable
|
||||||
* @param array $additionalColumns , columns related to the custom cases list
|
* @param array $additionalColumns , columns related to the custom cases list ex: TABLE_NAME.COLUMN_NAME
|
||||||
*
|
*
|
||||||
* @throws PropelException
|
* @throws PropelException
|
||||||
*/
|
*/
|
||||||
@@ -3511,31 +3513,35 @@ class Cases
|
|||||||
$listPeer,
|
$listPeer,
|
||||||
$search,
|
$search,
|
||||||
$additionalClassName = '',
|
$additionalClassName = '',
|
||||||
$additionalColumns = array()
|
$additionalColumns = []
|
||||||
) {
|
) {
|
||||||
$oTmpCriteria = '';
|
$tmpCriteria = '';
|
||||||
//If we have additional tables configured in the custom cases list, prepare the variables for search
|
//If we have additional tables configured in the custom cases list, prepare the variables for search
|
||||||
if (count($additionalColumns) > 0) {
|
if (count($additionalColumns) > 0) {
|
||||||
require_once(PATH_DATA_SITE . 'classes' . PATH_SEP . $additionalClassName . '.php');
|
require_once(PATH_DATA_SITE . 'classes' . PATH_SEP . $additionalClassName . '.php');
|
||||||
$oNewCriteria = new Criteria("workflow");
|
|
||||||
$oTmpCriteria = $oNewCriteria->getNewCriterion(current($additionalColumns), "%" . $search . "%",
|
$columnPivot = current($additionalColumns);
|
||||||
Criteria::LIKE);
|
$tableAndColumn = explode(".", $columnPivot);
|
||||||
|
$type = PmTable::getTypeOfColumn($listPeer, $tableAndColumn[0], $tableAndColumn[1]);
|
||||||
|
$tmpCriteria = $this->defineCriteriaByColumnType($type, $columnPivot, $search);
|
||||||
|
|
||||||
//We prepare the query related to the custom cases list
|
//We prepare the query related to the custom cases list
|
||||||
foreach (array_slice($additionalColumns, 1) as $value) {
|
foreach (array_slice($additionalColumns, 1) as $column) {
|
||||||
$oTmpCriteria = $oNewCriteria->getNewCriterion($value, "%" . $search . "%",
|
$tableAndColumn = explode(".", $column);
|
||||||
Criteria::LIKE)->addOr($oTmpCriteria);
|
$type = PmTable::getTypeOfColumn($listPeer, $tableAndColumn[0], $tableAndColumn[1]);
|
||||||
|
$tmpCriteria = $this->defineCriteriaByColumnType($type, $column, $search)->addOr($tmpCriteria);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($oTmpCriteria)) {
|
if (!empty($tmpCriteria)) {
|
||||||
$criteria->add(
|
$criteria->add(
|
||||||
$criteria->getNewCriterion($listPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr(
|
$criteria->getNewCriterion($listPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr(
|
||||||
$criteria->getNewCriterion($listPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr(
|
$criteria->getNewCriterion($listPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr(
|
||||||
$criteria->getNewCriterion($listPeer::APP_PRO_TITLE, '%' . $search . '%',
|
$criteria->getNewCriterion($listPeer::APP_PRO_TITLE, '%' . $search . '%',
|
||||||
Criteria::LIKE)->addOr(
|
Criteria::LIKE)->addOr(
|
||||||
$criteria->getNewCriterion($listPeer::APP_NUMBER, $search, Criteria::EQUAL)->addOr(
|
$criteria->getNewCriterion($listPeer::APP_NUMBER, $search, Criteria::EQUAL)->addOr(
|
||||||
$oTmpCriteria
|
$tmpCriteria
|
||||||
))))
|
))))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -3549,6 +3555,58 @@ class Cases
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the criteria according to the column type
|
||||||
|
*
|
||||||
|
* @param string $fieldType
|
||||||
|
* @param string $column
|
||||||
|
* @param string $search
|
||||||
|
*
|
||||||
|
* @return Criteria
|
||||||
|
*/
|
||||||
|
private function defineCriteriaByColumnType($fieldType, $column, $search)
|
||||||
|
{
|
||||||
|
$newCriteria = new Criteria("workflow");
|
||||||
|
|
||||||
|
switch ($fieldType) {
|
||||||
|
case CreoleTypes::BOOLEAN:
|
||||||
|
$criteria = $newCriteria->getNewCriterion($column, $search, Criteria::EQUAL);
|
||||||
|
break;
|
||||||
|
case CreoleTypes::BIGINT:
|
||||||
|
case CreoleTypes::INTEGER:
|
||||||
|
case CreoleTypes::SMALLINT:
|
||||||
|
case CreoleTypes::TINYINT:
|
||||||
|
$criteria = $newCriteria->getNewCriterion($column, $search, Criteria::EQUAL);
|
||||||
|
break;
|
||||||
|
case CreoleTypes::REAL:
|
||||||
|
case CreoleTypes::DECIMAL:
|
||||||
|
case CreoleTypes::DOUBLE:
|
||||||
|
case CreoleTypes::FLOAT:
|
||||||
|
$criteria = $newCriteria->getNewCriterion($column, $search, Criteria::LIKE);
|
||||||
|
break;
|
||||||
|
case CreoleTypes::CHAR:
|
||||||
|
case CreoleTypes::LONGVARCHAR:
|
||||||
|
case CreoleTypes::VARCHAR:
|
||||||
|
$criteria = $newCriteria->getNewCriterion($column, "%" . $search . "%", Criteria::LIKE);
|
||||||
|
break;
|
||||||
|
case CreoleTypes::DATE:
|
||||||
|
case CreoleTypes::TIME:
|
||||||
|
case CreoleTypes::TIMESTAMP://DATETIME
|
||||||
|
//@todo use the same constant in other places
|
||||||
|
if (preg_match(UtilDateTime::REGEX_IS_DATE,
|
||||||
|
$search, $arrayMatch)) {
|
||||||
|
$criteria = $newCriteria->getNewCriterion($column, $search, Criteria::GREATER_EQUAL);
|
||||||
|
} else {
|
||||||
|
$criteria = $newCriteria->getNewCriterion($column, $search, Criteria::EQUAL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$criteria = $newCriteria->getNewCriterion($column, $search, Criteria::EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $criteria;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function get the table.column by order by the result
|
* This function get the table.column by order by the result
|
||||||
* We can include the additional table related to the custom cases list
|
* We can include the additional table related to the custom cases list
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class DateTime
|
|||||||
|
|
||||||
const REGEXPDATE = '[1-9]\d{3}\-(?:0[1-9]|1[0-2])\-(?:0[1-9]|[12][0-9]|3[01])';
|
const REGEXPDATE = '[1-9]\d{3}\-(?:0[1-9]|1[0-2])\-(?:0[1-9]|[12][0-9]|3[01])';
|
||||||
const REGEXPTIME = '(?:[0-1]\d|2[0-3])\:[0-5]\d\:[0-5]\d';
|
const REGEXPTIME = '(?:[0-1]\d|2[0-3])\:[0-5]\d\:[0-5]\d';
|
||||||
|
const REGEX_IS_DATE = '/^([1-9]\d{3})\-(0[1-9]|1[0-2])\-(0[1-9]|[12][0-9]|3[01])(?:\s([0-1]\d|2[0-3])\:([0-5]\d)\:([0-5]\d))?$/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Time Zone Offset by Time Zone ID
|
* Get Time Zone Offset by Time Zone ID
|
||||||
|
|||||||
Reference in New Issue
Block a user