Merged in bugfix/PMC-1003 (pull request #7001)

PMC-1003

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
Approved-by: Mauricio Veliz <mauricio@processmaker.com>
This commit is contained in:
Julio Cesar Laura Avendaño
2019-07-26 20:39:52 +00:00
8 changed files with 271 additions and 175 deletions

View File

@@ -225,7 +225,14 @@ class Delegation extends Model
$query->join('APPLICATION', function ($join) use ($filterBy, $search, $status, $query) {
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
if ($filterBy == 'APP_TITLE' && $search) {
$join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%");
// Cleaning "fulltext" operators in order to avoid unexpected results
$search = str_replace(['-', '+', '<', '>', '(', ')', '~', '*', '"'], ['', '', '', '', '', '', '', '', ''], $search);
// Build the "fulltext" expression
$search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"';
// Searching using "fulltext" index
$join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
}
// Based on the below, we can further limit the join so that we have a smaller data set based on join criteria
switch ($status) {