2019-06-10 11:36:01 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace ProcessMaker\BusinessModel\Cases;
|
|
|
|
|
|
2019-06-11 07:51:19 -04:00
|
|
|
use ProcessMaker\Model\Delegation;
|
|
|
|
|
|
2019-06-10 11:36:01 -04:00
|
|
|
class Inbox extends AbstractCases
|
|
|
|
|
{
|
2019-06-11 07:51:19 -04:00
|
|
|
/**
|
|
|
|
|
* Get the data corresponding to List Inbox
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getData()
|
|
|
|
|
{
|
|
|
|
|
// Start the query for get the cases related to the user
|
|
|
|
|
$query = Delegation::query()->select();
|
|
|
|
|
|
|
|
|
|
// Scope that sets the queries for List Inbox
|
|
|
|
|
$query->inbox($this->getUserId());
|
|
|
|
|
|
|
|
|
|
// Scope that joins with the process and/or for an specific category in the process
|
|
|
|
|
$query->categoryProcess($this->getCategoryUid());
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-16 15:53:54 -04:00
|
|
|
if (!empty($this->getProcessId())) {
|
2019-06-11 07:51:19 -04:00
|
|
|
// Scope to search for an specific process
|
|
|
|
|
$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
|
|
|
|
|
$results = $query->get();
|
|
|
|
|
|
|
|
|
|
//Return the values as an array format
|
|
|
|
|
return $results->values()->toArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of rows corresponding to the List Inbox
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getCounter()
|
|
|
|
|
{
|
|
|
|
|
$query = Delegation::query()->select();
|
|
|
|
|
|
|
|
|
|
// Scope that sets the queries for List Inbox
|
|
|
|
|
$query->inbox($this->getUserId());
|
|
|
|
|
|
|
|
|
|
// Return the number of rows
|
|
|
|
|
return $query->count();
|
|
|
|
|
}
|
2019-06-10 11:36:01 -04:00
|
|
|
}
|