PMC-426
This commit is contained in:
@@ -7,7 +7,7 @@ class Applications
|
|||||||
/**
|
/**
|
||||||
* This function return information by searching cases
|
* This function return information by searching cases
|
||||||
*
|
*
|
||||||
* The query is related to advanced search with diferents filters
|
* The query is related to advanced search with different filters
|
||||||
* We can search by process, status of case, category of process, users, delegate date from and to
|
* We can search by process, status of case, category of process, users, delegate date from and to
|
||||||
*
|
*
|
||||||
* @param string $userUid
|
* @param string $userUid
|
||||||
@@ -17,11 +17,12 @@ class Applications
|
|||||||
* @param integer $process the pro_id
|
* @param integer $process the pro_id
|
||||||
* @param integer $status of the case
|
* @param integer $status of the case
|
||||||
* @param string $dir if the order is DESC or ASC
|
* @param string $dir if the order is DESC or ASC
|
||||||
* @param string $sort name of column by sort
|
* @param string $sort name of column by sort, can be:
|
||||||
|
* [APP_NUMBER, APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE, APP_CURRENT_USER, APP_UPDATE_DATE, DEL_DELEGATE_DATE, DEL_TASK_DUE_DATE, APP_STATUS_LABEL]
|
||||||
* @param string $category uid for the process
|
* @param string $category uid for the process
|
||||||
* @param date $dateFrom
|
* @param date $dateFrom
|
||||||
* @param date $dateTo
|
* @param date $dateTo
|
||||||
* @param string $columnSearch name of column for a specific search
|
* @param string $filterBy name of column for a specific search, can be: [APP_NUMBER, APP_TITLE, TAS_TITLE]
|
||||||
* @return array $result result of the query
|
* @return array $result result of the query
|
||||||
*/
|
*/
|
||||||
public function searchAll(
|
public function searchAll(
|
||||||
@@ -36,11 +37,8 @@ class Applications
|
|||||||
$category = null,
|
$category = null,
|
||||||
$dateFrom = null,
|
$dateFrom = null,
|
||||||
$dateTo = null,
|
$dateTo = null,
|
||||||
$columnSearch = 'APP_TITLE'
|
$filterBy = '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");
|
|
||||||
|
|
||||||
//Start the connection to database
|
//Start the connection to database
|
||||||
$con = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
|
$con = Propel::getConnection(AppDelegationPeer::DATABASE_NAME);
|
||||||
|
|
||||||
@@ -58,7 +56,7 @@ class Applications
|
|||||||
$category = $inputFilter->escapeUsingConnection($category, $con);
|
$category = $inputFilter->escapeUsingConnection($category, $con);
|
||||||
$dateFrom = $inputFilter->escapeUsingConnection($dateFrom, $con);
|
$dateFrom = $inputFilter->escapeUsingConnection($dateFrom, $con);
|
||||||
$dateTo = $inputFilter->escapeUsingConnection($dateTo, $con);
|
$dateTo = $inputFilter->escapeUsingConnection($dateTo, $con);
|
||||||
$columnSearch = $inputFilter->escapeUsingConnection($columnSearch, $con);
|
$filterBy = $inputFilter->escapeUsingConnection($filterBy, $con);
|
||||||
|
|
||||||
//Start the transaction
|
//Start the transaction
|
||||||
$con->begin();
|
$con->begin();
|
||||||
@@ -101,18 +99,20 @@ class Applications
|
|||||||
FROM APP_DELEGATION
|
FROM APP_DELEGATION
|
||||||
";
|
";
|
||||||
$sqlData .= " LEFT JOIN APPLICATION ON (APP_DELEGATION.APP_NUMBER = APPLICATION.APP_NUMBER)";
|
$sqlData .= " LEFT JOIN APPLICATION ON (APP_DELEGATION.APP_NUMBER = APPLICATION.APP_NUMBER)";
|
||||||
$sqlData .= " LEFT JOIN TASK ON (APP_DELEGATION.TAS_ID = TASK.TAS_ID)";
|
$sqlData .= " LEFT JOIN TASK ON (APP_DELEGATION.TAS_ID = TASK.TAS_ID ";
|
||||||
|
//Exclude the Task Dummies in the delegations
|
||||||
|
$sqlData .= " AND TASK.TAS_TYPE <> 'WEBENTRYEVENT' AND TASK.TAS_TYPE <> 'END-MESSAGE-EVENT' AND TASK.TAS_TYPE <> 'START-MESSAGE-EVENT' AND TASK.TAS_TYPE <> 'INTERMEDIATE-THROW')";
|
||||||
$sqlData .= " LEFT JOIN USERS ON (APP_DELEGATION.USR_ID = USERS.USR_ID)";
|
$sqlData .= " LEFT JOIN USERS ON (APP_DELEGATION.USR_ID = USERS.USR_ID)";
|
||||||
$sqlData .= " LEFT JOIN PROCESS ON (APP_DELEGATION.PRO_ID = PROCESS.PRO_ID)";
|
$sqlData .= " LEFT JOIN PROCESS ON (APP_DELEGATION.PRO_ID = PROCESS.PRO_ID)";
|
||||||
|
|
||||||
$sqlData .= " WHERE TASK.TAS_TYPE NOT IN ('" . implode("','", $arrayTaskTypeToExclude) . "')";
|
$sqlData .= " WHERE 1";
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case 1: //DRAFT
|
case 1: //DRAFT
|
||||||
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS='OPEN'";
|
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS = 'OPEN'";
|
||||||
$sqlData .= " AND APPLICATION.APP_STATUS_ID = 1";
|
$sqlData .= " AND APPLICATION.APP_STATUS_ID = 1";
|
||||||
break;
|
break;
|
||||||
case 2: //TO_DO
|
case 2: //TO_DO
|
||||||
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS='OPEN'";
|
$sqlData .= " AND APP_DELEGATION.DEL_THREAD_STATUS = 'OPEN'";
|
||||||
$sqlData .= " AND APPLICATION.APP_STATUS_ID = 2";
|
$sqlData .= " AND APPLICATION.APP_STATUS_ID = 2";
|
||||||
break;
|
break;
|
||||||
case 3: //COMPLETED
|
case 3: //COMPLETED
|
||||||
@@ -148,17 +148,28 @@ class Applications
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
//If the filter is related to the APP_DELEGATION table: APP_NUMBER
|
//Search: we need to considerate the filterBy and the sortColumn
|
||||||
if ($columnSearch === 'APP_NUMBER') {
|
$appColumns = ['APP_NUMBER', 'APP_TITLE'];
|
||||||
$sqlData .= " AND APP_DELEGATION.APP_NUMBER LIKE '%{$search}%' ";
|
if (in_array($sort, $appColumns) && in_array($filterBy, $appColumns)) {
|
||||||
}
|
$sqlData .= " AND APP_DELEGATION.APP_NUMBER IN (";
|
||||||
//If the filter is related to the APPLICATION table: APP_TITLE
|
//Sub query: get the appNumber(s) that match with the search
|
||||||
if ($columnSearch === 'APP_TITLE') {
|
$sqlData .= " SELECT APPLICATION.APP_NUMBER FROM APPLICATION WHERE APPLICATION.{$filterBy} LIKE '%{$search}%'";
|
||||||
$sqlData .= " AND APPLICATION.APP_TITLE LIKE '%{$search}%' ";
|
$sqlData .= " ORDER BY APPLICATION.{$sort} " . $dir;
|
||||||
}
|
//End sub query
|
||||||
//If the filter is related to the TASK table: TAS_TITLE
|
$sqlData .= " )";
|
||||||
if ($columnSearch === 'TAS_TITLE') {
|
} else {
|
||||||
$sqlData .= " AND TASK.TAS_TITLE LIKE '%{$search}%' ";
|
//If the filter is related to the APP_DELEGATION table: APP_NUMBER
|
||||||
|
if ($filterBy === 'APP_NUMBER') {
|
||||||
|
$sqlData .= " AND APP_DELEGATION.APP_NUMBER LIKE '%{$search}%' ";
|
||||||
|
}
|
||||||
|
//If the filter is related to the APPLICATION table: APP_TITLE
|
||||||
|
if ($filterBy === 'APP_TITLE') {
|
||||||
|
$sqlData .= " AND APPLICATION.APP_TITLE LIKE '%{$search}%' ";
|
||||||
|
}
|
||||||
|
//If the filter is related to the TASK table: TAS_TITLE
|
||||||
|
if ($filterBy === 'TAS_TITLE') {
|
||||||
|
$sqlData .= " AND TASK.TAS_TITLE LIKE '%{$search}%' ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,6 +190,7 @@ class Applications
|
|||||||
$orderBy = 'APP_DELEGATION.APP_NUMBER ' . $dir;
|
$orderBy = 'APP_DELEGATION.APP_NUMBER ' . $dir;
|
||||||
break;
|
break;
|
||||||
case 'APP_CURRENT_USER':
|
case 'APP_CURRENT_USER':
|
||||||
|
//@todo: this section needs to use 'User Name Display Format', currently in the extJs is defined this
|
||||||
//The column APP_CURRENT_USER is result of concat those fields
|
//The column APP_CURRENT_USER is result of concat those fields
|
||||||
$orderBy = 'USR_LASTNAME ' . $dir . ' ,USR_FIRSTNAME ' . $dir;
|
$orderBy = 'USR_LASTNAME ' . $dir . ' ,USR_FIRSTNAME ' . $dir;
|
||||||
break;
|
break;
|
||||||
@@ -212,6 +224,7 @@ class Applications
|
|||||||
if (isset( $row['DEL_PRIORITY'] )) {
|
if (isset( $row['DEL_PRIORITY'] )) {
|
||||||
$row['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$priorities[$row['DEL_PRIORITY']]}" );
|
$row['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$priorities[$row['DEL_PRIORITY']]}" );
|
||||||
}
|
}
|
||||||
|
//@todo: this section needs to use 'User Name Display Format', currently in the extJs is defined this
|
||||||
$row["APP_CURRENT_USER"] = $row["USR_LASTNAME"].' '.$row["USR_FIRSTNAME"];
|
$row["APP_CURRENT_USER"] = $row["USR_LASTNAME"].' '.$row["USR_FIRSTNAME"];
|
||||||
$row["APPDELCR_APP_TAS_TITLE"] = '';
|
$row["APPDELCR_APP_TAS_TITLE"] = '';
|
||||||
$row["USRCR_USR_UID"] = $row["USR_UID"];
|
$row["USRCR_USR_UID"] = $row["USR_UID"];
|
||||||
|
|||||||
Reference in New Issue
Block a user