PMCORE-2513
This commit is contained in:
@@ -32,6 +32,7 @@ class ParticipatedTest extends TestCase
|
||||
'DEL_INDEX' => 1,
|
||||
]);
|
||||
$delegation2 = factory(Delegation::class)->states('last_thread')->create([
|
||||
'APP_NUMBER' => $delegation->APP_NUMBER,
|
||||
'TAS_ID' => $delegation->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $delegation->USR_UID,
|
||||
@@ -217,6 +218,9 @@ class ParticipatedTest extends TestCase
|
||||
$participated->setUserUid($cases->USR_UID);
|
||||
// Set the user ID
|
||||
$participated->setUserId($cases->USR_ID);
|
||||
// Set participated status
|
||||
$participated->setParticipatedStatus('IN_PROGRESS');
|
||||
// Get result
|
||||
$res = $participated->getCounter();
|
||||
// Assert the result of getCounter method
|
||||
$this->assertEquals(1, $res);
|
||||
|
||||
@@ -24959,6 +24959,12 @@ msgstr "You do not have permission to access to the summary form"
|
||||
msgid "Sun"
|
||||
msgstr "Sun"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_SUPERVISING
|
||||
#: LABEL/ID_SUPERVISING
|
||||
msgid "Supervising"
|
||||
msgstr "Supervising"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_SUPERVISOR
|
||||
#: LABEL/ID_SUPERVISOR
|
||||
|
||||
@@ -61077,6 +61077,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_SUMMARY_FORM','en','Summary form','2014-08-21') ,
|
||||
( 'LABEL','ID_SUMMARY_FORM_NO_PERMISSIONS','en','You do not have permission to access to the summary form','2014-10-21') ,
|
||||
( 'LABEL','ID_SUN','en','Sun','2014-01-15') ,
|
||||
( 'LABEL','ID_SUPERVISING','en','Supervising','2020-12-09') ,
|
||||
( 'LABEL','ID_SUPERVISOR','en','Supervisor','2014-01-15') ,
|
||||
( 'LABEL','ID_SUPERVISOR_ASSIGNED','en','Supervisor has been successfully assigned to a Process','2014-01-15') ,
|
||||
( 'LABEL','ID_SUPERVISOR_DOES_NOT_HAVE_DYNAFORMS','en','Supervisor does not have a permission for Dynaform(s).','2015-05-28') ,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Task;
|
||||
|
||||
@@ -214,16 +215,39 @@ class Participated extends AbstractCases
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of rows corresponding to the Participate
|
||||
* Get the number of rows corresponding to the Participated
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
// Get base query
|
||||
$query = Delegation::query()->select();
|
||||
// Join with application
|
||||
$query->joinApplication();
|
||||
// Scope that sets the queries for Participated
|
||||
$query->participated($this->getUserId());
|
||||
// Get filter
|
||||
$filter = $this->getParticipatedStatus();
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
// Scope that search for the STARTED by user
|
||||
$query->caseStarted();
|
||||
break;
|
||||
case 'IN_PROGRESS':
|
||||
// Only distinct APP_NUMBER
|
||||
$query->distinct();
|
||||
// Scope for in progress cases
|
||||
$query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]);
|
||||
break;
|
||||
case 'COMPLETED':
|
||||
// Scope that search for the COMPLETED
|
||||
$query->caseCompleted();
|
||||
// Scope to set the last thread
|
||||
$query->lastThread();
|
||||
break;
|
||||
}
|
||||
// Return the number of rows
|
||||
return $query->count();
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,12 +175,15 @@ class Supervising extends AbstractCases
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
// Get base query
|
||||
$query = Delegation::query()->select();
|
||||
// Only distinct APP_NUMBER
|
||||
$query->distinct();
|
||||
// Get the list of processes of the supervisor
|
||||
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
|
||||
// Scope the specific array of processes supervising
|
||||
$query->processInList($processes);
|
||||
|
||||
return $query->count();
|
||||
// Return the number of rows
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use G;
|
||||
use Luracast\Restler\RestException;
|
||||
use Menu;
|
||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||
@@ -359,30 +360,42 @@ class Home extends Api
|
||||
public function doGetCountMyCases()
|
||||
{
|
||||
try {
|
||||
$filters = ['STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
|
||||
$result = [];
|
||||
foreach ($filters as $row) {
|
||||
switch ($row) {
|
||||
// Initializing variables
|
||||
$participatedStatuses = ['STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
|
||||
$participatedLabels = array_combine($participatedStatuses, ['ID_OPT_STARTED', 'ID_IN_PROGRESS', 'ID_COMPLETED', 'ID_SUPERVISING']);
|
||||
$counters = [];
|
||||
|
||||
// Get counters
|
||||
foreach ($participatedStatuses as $participatedStatus) {
|
||||
// Initializing counter object
|
||||
$counter = new stdClass();
|
||||
$counter->id = $participatedStatus;
|
||||
$counter->title = G::LoadTranslation($participatedLabels[$participatedStatus]);
|
||||
|
||||
// Get counter value according to the participated status
|
||||
switch ($participatedStatus) {
|
||||
case 'STARTED':
|
||||
case 'IN_PROGRESS':
|
||||
case 'COMPLETED':
|
||||
$list = new Participated();
|
||||
$list->setParticipatedStatus($row);
|
||||
$list->setUserId($this->getUserId());
|
||||
$result[strtolower($row)] = $list->getCounter();
|
||||
$participated = new Participated();
|
||||
$participated->setParticipatedStatus($participatedStatus);
|
||||
$participated->setUserId($this->getUserId());
|
||||
$counter->counter = $participated->getCounter();
|
||||
break;
|
||||
case 'SUPERVISING':
|
||||
// Scope that search for the SUPERVISING cases by specific user
|
||||
$list = new Supervising();
|
||||
$list->setUserId($this->getUserId());
|
||||
$result[strtolower($row)] = $list->getCounter();
|
||||
$supervising = new Supervising();
|
||||
$supervising->setUserUid($this->getUserId());
|
||||
$counter->counter = $supervising->getCounter();
|
||||
break;
|
||||
default:
|
||||
$result[strtolower($row)] = 0;
|
||||
$counter->counter = 0;
|
||||
}
|
||||
// Add counter
|
||||
$counters[] = $counter;
|
||||
}
|
||||
|
||||
return $result;
|
||||
// Return counters in the expected format
|
||||
return $counters;
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user