PMCORE-2381

This commit is contained in:
Paula Quispe
2020-11-25 18:11:22 -04:00
parent a00593696d
commit 6bdadfd59c
21 changed files with 1925 additions and 731 deletions

View File

@@ -21,7 +21,8 @@ class Inbox extends AbstractCases
'APP_DELEGATION.DEL_DELEGATE_DATE', // Delegate Date
'APP_DELEGATION.DEL_PRIORITY', // Priority
// Additional column for other functionalities
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
'APP_DELEGATION.APP_UID', // Case Uid for Open case
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
];
/**
@@ -33,6 +34,39 @@ class Inbox extends AbstractCases
return $this->columnsView;
}
/**
* Scope filters
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function filters($query)
{
// Specific case
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD
}
// Specific process
if ($this->getProcessId()) {
$query->processId($this->getProcessId());
}
// Specific task
if ($this->getTaskId()) {
$query->task($this->getTaskId());
}
// Specific case uid PMFCaseLink
if (!empty($this->getCaseUid())) {
$query->appUid($this->getCaseUid());
}
return $query;
}
/**
* Get the data corresponding to List Inbox
*
@@ -48,30 +82,16 @@ class Inbox extends AbstractCases
$query->joinUser();
// Join with application for add the initial scope for TO_DO cases
$query->inbox($this->getUserId());
// Define a specific risk
switch ($this->getRiskStatus()) {
case 'ON_TIME':
// Scope that search for the ON_TIME cases
$query->onTime();
break;
case 'AT_RISK':
// Scope that search for the AT_RISK cases
$query->atRisk();
break;
case 'OVERDUE':
// Scope that search for the OVERDUE cases
$query->overdue();
break;
/** Apply filters */
$this->filters($query);
/** Apply order and pagination */
// Add any sort if needed
if ($this->getOrderByColumn()) {
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
}
// Scope to search for an specific process
if (!empty($this->getProcessId())) {
$query->processId($this->getProcessId());
}
// The order by clause
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
// The limit by clause
$query->offset($this->getOffset())->limit($this->getLimit());
//Execute the query
// Execute the query
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) {