PMCORE-3515
This commit is contained in:
@@ -1552,16 +1552,16 @@ class AbstractCases implements CasesInterface
|
||||
$list = end($listArray);
|
||||
switch ($list) {
|
||||
case 'Inbox':
|
||||
$query->inbox($this->getUserId());
|
||||
$query->inboxMetrics();
|
||||
break;
|
||||
case 'Draft':
|
||||
$query->draft($this->getUserId());
|
||||
$query->draftMetrics();
|
||||
break;
|
||||
case 'Paused':
|
||||
$query->paused($this->getUserId());
|
||||
$query->pausedMetrics();
|
||||
break;
|
||||
case 'Unassigned':
|
||||
$query->selfService($this->getUserUid());
|
||||
$query->selfServiceMetrics();
|
||||
break;
|
||||
}
|
||||
$query->joinProcess();
|
||||
@@ -1604,16 +1604,16 @@ class AbstractCases implements CasesInterface
|
||||
$list = end($listArray);
|
||||
switch ($list) {
|
||||
case 'Inbox':
|
||||
$query->inbox($this->getUserId());
|
||||
$query->inboxMetrics();
|
||||
break;
|
||||
case 'Draft':
|
||||
$query->draft($this->getUserId());
|
||||
$query->draftMetrics();
|
||||
break;
|
||||
case 'Paused':
|
||||
$query->paused($this->getUserId());
|
||||
$query->pausedMetrics();
|
||||
break;
|
||||
case 'Unassigned':
|
||||
$query->selfService($this->getUserUid());
|
||||
$query->selfServiceMetrics();
|
||||
break;
|
||||
}
|
||||
$query->joinProcess();
|
||||
@@ -1657,16 +1657,16 @@ class AbstractCases implements CasesInterface
|
||||
$list = end($listArray);
|
||||
switch ($list) {
|
||||
case 'Inbox':
|
||||
$query->inbox($this->getUserId());
|
||||
$query->inboxMetrics();
|
||||
break;
|
||||
case 'Draft':
|
||||
$query->draft($this->getUserId());
|
||||
$query->draftMetrics();
|
||||
break;
|
||||
case 'Paused':
|
||||
$query->paused($this->getUserId());
|
||||
$query->pausedMetrics();
|
||||
break;
|
||||
case 'Unassigned':
|
||||
$query->selfService($this->getUserUid());
|
||||
$query->selfServiceMetrics();
|
||||
break;
|
||||
}
|
||||
$query->joinProcess();
|
||||
|
||||
@@ -244,4 +244,16 @@ class Draft extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in DRAFT
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->draftMetrics();
|
||||
return $query->count(['APPLICATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,4 +260,16 @@ class Inbox extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in TO_DO
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->inboxMetrics();
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,4 +254,16 @@ class Paused extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in PAUSED
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->pausedMetrics();
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,4 +263,16 @@ class Unassigned extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in SELF_SERVICE
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->selfServiceMetrics();
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1069,6 +1069,64 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Inbox cases no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeInboxMetrics($query)
|
||||
{
|
||||
$query->joinApplication();
|
||||
$query->status(Application::STATUS_TODO);
|
||||
$query->threadOpen();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a draft cases no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeDraftMetrics($query)
|
||||
{
|
||||
$query->joinApplication();
|
||||
$query->status(Application::STATUS_DRAFT);
|
||||
$query->threadOpen();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope paused cases list no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePausedMetrics($query)
|
||||
{
|
||||
$query->joinAppDelay('PAUSE');
|
||||
$query->joinApplication();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a self service cases no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeSelfServiceMetrics($query)
|
||||
{
|
||||
$query->taskAssignType('SELF_SERVICE');
|
||||
$query->threadOpen()->withoutUserId();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific cases unassigned that the user can view
|
||||
*
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||
use ProcessMaker\BusinessModel\Cases\Inbox;
|
||||
use ProcessMaker\BusinessModel\Cases\Paused;
|
||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||
use ProcessMaker\Model\User;
|
||||
use ProcessMaker\Services\Api;
|
||||
use RBAC;
|
||||
|
||||
@@ -46,8 +46,6 @@ class Metrics extends Api
|
||||
*/
|
||||
public function getProcessTotalCases($caseList, $category = null, $topTen = false, $processes = [])
|
||||
{
|
||||
$usrUid = $this->getUserId();
|
||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
try {
|
||||
switch ($caseList) {
|
||||
case 'inbox':
|
||||
@@ -61,10 +59,8 @@ class Metrics extends Api
|
||||
break;
|
||||
case 'unassigned':
|
||||
$list = new Unassigned();
|
||||
$list->setUserUid($usrUid);
|
||||
break;
|
||||
}
|
||||
$list->setUserId($usrId);
|
||||
$result = $list->getCountersByProcesses($category, $topTen, $processes);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
@@ -91,8 +87,6 @@ class Metrics extends Api
|
||||
*/
|
||||
public function getTotalCasesByRange($caseList, $processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day')
|
||||
{
|
||||
$usrUid = $this->getUserId();
|
||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
try {
|
||||
switch ($caseList) {
|
||||
case 'inbox':
|
||||
@@ -106,10 +100,8 @@ class Metrics extends Api
|
||||
break;
|
||||
case 'unassigned':
|
||||
$list = new Unassigned();
|
||||
$list->setUserUid($usrUid);
|
||||
break;
|
||||
}
|
||||
$list->setUserId($usrId);
|
||||
$result = $list->getCountersByRange($processId, $dateFrom, $dateTo, $groupBy);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
@@ -125,31 +117,21 @@ class Metrics extends Api
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @class AccessControl {@permission TASK_METRICS_VIEW}
|
||||
*/
|
||||
public function getCountersList()
|
||||
{
|
||||
try {
|
||||
$usrUid = $this->getUserId();
|
||||
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
|
||||
$listInbox = new Inbox();
|
||||
$listInbox->setProperties($properties);
|
||||
|
||||
$listDraft = new Draft();
|
||||
$listDraft->setUserUid($usrUid);
|
||||
$listDraft->setProperties($properties);
|
||||
|
||||
$listPaused = new Paused();
|
||||
$listPaused->setProperties($properties);
|
||||
|
||||
$listUnassigned = new Unassigned();
|
||||
$listUnassigned->setUserUid($usrUid);
|
||||
$listUnassigned->setProperties($properties);
|
||||
|
||||
$casesInbox = $listInbox->getCounter();
|
||||
$casesDraft = $listDraft->getCounter();
|
||||
$casesPaused = $listPaused->getCounter();
|
||||
$casesUnassigned = $listUnassigned->getCounter();
|
||||
$casesInbox = $listInbox->getCounterMetrics();
|
||||
$casesDraft = $listDraft->getCounterMetrics();
|
||||
$casesPaused = $listPaused->getCounterMetrics();
|
||||
$casesUnassigned = $listUnassigned->getCounterMetrics();
|
||||
|
||||
$result = [
|
||||
['List Name' => 'Inbox', 'Total' => $casesInbox, 'Color' => 'green'],
|
||||
@@ -179,12 +161,12 @@ class Metrics extends Api
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @class AccessControl {@permission TASK_METRICS_VIEW}
|
||||
*/
|
||||
public function getCasesRiskByProcess($caseList = 'inbox', $process, $dateFrom = null, $dateTo = null, $riskStatus = 'ON_TIME', $topCases = null)
|
||||
{
|
||||
try {
|
||||
$usrUid = $this->getUserId();
|
||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
switch ($caseList) {
|
||||
case 'inbox':
|
||||
$list = new Inbox();
|
||||
@@ -197,10 +179,8 @@ class Metrics extends Api
|
||||
break;
|
||||
case 'unassigned':
|
||||
$list = new Unassigned();
|
||||
$list->setUserUid($usrUid);
|
||||
break;
|
||||
}
|
||||
$list->setUserId($usrId);
|
||||
$result = $list->getCasesRisk($process, $dateFrom, $dateTo, $riskStatus, $topCases);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user