Remove commented line in proxyCasesList. Add filtering support for task title and application only when requested.

This commit is contained in:
Taylor Dondich
2019-04-25 15:58:26 -07:00
committed by Paula Quispe
parent e79503f590
commit 141e358b6b
2 changed files with 26 additions and 3 deletions

View File

@@ -100,8 +100,6 @@ try {
break; break;
} }
//$apps = new Applications();
if ($action == 'search') { if ($action == 'search') {
$data = Delegation::search( $data = Delegation::search(
$userUid, $userUid,

View File

@@ -88,6 +88,31 @@ class Delegation extends Model
// Start the query builder // Start the query builder
$query = self::query(); $query = self::query();
// Add join for task, filtering for task title if needed
// It doesn't make sense for us to search for any delegations that match tasks that are events or web entry
$query->join('TASK', function($join) use($filterBy, $search) {
$join->on('APP_DELEGATION.TAS_ID', '=', 'TASK.TAS_ID')
->whereNotIn('TASK.TAS_TYPE', [
'WEBENTRYEVENT',
'END-MESSAGE-EVENT',
'START-MESSAGE-EVENT',
'INTERMEDIATE-THROW'
]);
if($filterBy == 'TAS_TITLE') {
$join->where('TASK.TAS_TITLE', 'LIKE', "%${search}%");
}
});
// Add join for application, but only for certain scenarios of app title search or sorting by app title
if($filterBy == 'APP_TITLE' || $sort == 'APP_TITLE') {
$query->join('APPLICATION', function($join) use($filterBy, $search) {
$join->on('APP_DELEGATION.APP_UID', '=', 'APPLICATION.APP_UID');
if($filterBy == 'APP_TITLE') {
$join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%");
}
});
}
// Add pagination to the query // Add pagination to the query
$query = $query->offset($start) $query = $query->offset($start)
->limit($limit); ->limit($limit);
@@ -99,7 +124,7 @@ class Delegation extends Model
$priorities = ['1' => 'VL','2' => 'L','3' => 'N','4' => 'H','5' => 'VH']; $priorities = ['1' => 'VL','2' => 'L','3' => 'N','4' => 'H','5' => 'VH'];
$results->transform(function($item, $key) use($priorities) { $results->transform(function($item, $key) use($priorities) {
// Grab related records // Grab related records
$application = Application::where('APP_UID', $item['APP_UID'])->first(); $application = Application::where('APP_NUMBER', $item['APP_NUMBER'])->first();
if(!$application) { if(!$application) {
// Application wasn't found, return null // Application wasn't found, return null
return null; return null;