Merged in bugfix/PMCORE-3066 (pull request #7994)

PMCORE-3066

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Paula Quispe
2021-07-21 20:09:57 +00:00
committed by Julio Cesar Laura Avendaño
3 changed files with 73 additions and 0 deletions

View File

@@ -683,6 +683,51 @@ class Home extends Api
}
}
/**
* Get the tasks counters for todo, draft, paused and unassigned
*
* @url GET /:task/counter
*
* @return array
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function getSpecificTaskCounter($task)
{
$result = [];
$usrUid = $this->getUserId();
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
switch ($task) {
case 'inbox':
$taskList = new Inbox();
$text = G::LoadTranslation('ID_NUMBER_OF_CASES_INBOX');
break;
case 'draft':
$taskList = new Draft();
$text = G::LoadTranslation('ID_NUMBER_OF_CASES_DRAFT');
break;
case 'paused':
$taskList = new Paused();
$text = G::LoadTranslation('ID_NUMBER_OF_CASES_PAUSED');
break;
case 'unassigned':
$taskList = new Unassigned();
$text = G::LoadTranslation('ID_NUMBER_OF_CASES_UNASSIGNED');
break;
default:
return [];
}
$taskList->setUserUid($usrUid);
$taskList->setUserId($usrId);
$count = $taskList->getCounter();
$result = [];
$result['label'] = $text . $count;
$result['total'] = $count;
return $result;
}
/**
* Get the tasks counters for todo, draft, paused and unassigned
*