PMCORE-2513
This commit is contained in:
@@ -32,6 +32,7 @@ class ParticipatedTest extends TestCase
|
|||||||
'DEL_INDEX' => 1,
|
'DEL_INDEX' => 1,
|
||||||
]);
|
]);
|
||||||
$delegation2 = factory(Delegation::class)->states('last_thread')->create([
|
$delegation2 = factory(Delegation::class)->states('last_thread')->create([
|
||||||
|
'APP_NUMBER' => $delegation->APP_NUMBER,
|
||||||
'TAS_ID' => $delegation->TAS_ID,
|
'TAS_ID' => $delegation->TAS_ID,
|
||||||
'DEL_THREAD_STATUS' => 'OPEN',
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
'USR_UID' => $delegation->USR_UID,
|
'USR_UID' => $delegation->USR_UID,
|
||||||
@@ -217,6 +218,9 @@ class ParticipatedTest extends TestCase
|
|||||||
$participated->setUserUid($cases->USR_UID);
|
$participated->setUserUid($cases->USR_UID);
|
||||||
// Set the user ID
|
// Set the user ID
|
||||||
$participated->setUserId($cases->USR_ID);
|
$participated->setUserId($cases->USR_ID);
|
||||||
|
// Set participated status
|
||||||
|
$participated->setParticipatedStatus('IN_PROGRESS');
|
||||||
|
// Get result
|
||||||
$res = $participated->getCounter();
|
$res = $participated->getCounter();
|
||||||
// Assert the result of getCounter method
|
// Assert the result of getCounter method
|
||||||
$this->assertEquals(1, $res);
|
$this->assertEquals(1, $res);
|
||||||
|
|||||||
@@ -24959,6 +24959,12 @@ msgstr "You do not have permission to access to the summary form"
|
|||||||
msgid "Sun"
|
msgid "Sun"
|
||||||
msgstr "Sun"
|
msgstr "Sun"
|
||||||
|
|
||||||
|
# TRANSLATION
|
||||||
|
# LABEL/ID_SUPERVISING
|
||||||
|
#: LABEL/ID_SUPERVISING
|
||||||
|
msgid "Supervising"
|
||||||
|
msgstr "Supervising"
|
||||||
|
|
||||||
# TRANSLATION
|
# TRANSLATION
|
||||||
# LABEL/ID_SUPERVISOR
|
# LABEL/ID_SUPERVISOR
|
||||||
#: 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','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_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_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','en','Supervisor','2014-01-15') ,
|
||||||
( 'LABEL','ID_SUPERVISOR_ASSIGNED','en','Supervisor has been successfully assigned to a Process','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') ,
|
( '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;
|
namespace ProcessMaker\BusinessModel\Cases;
|
||||||
|
|
||||||
|
use ProcessMaker\Model\Application;
|
||||||
use ProcessMaker\Model\Delegation;
|
use ProcessMaker\Model\Delegation;
|
||||||
use ProcessMaker\Model\Task;
|
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
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getCounter()
|
public function getCounter()
|
||||||
{
|
{
|
||||||
|
// Get base query
|
||||||
$query = Delegation::query()->select();
|
$query = Delegation::query()->select();
|
||||||
|
// Join with application
|
||||||
|
$query->joinApplication();
|
||||||
// Scope that sets the queries for Participated
|
// Scope that sets the queries for Participated
|
||||||
$query->participated($this->getUserId());
|
$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 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()
|
public function getCounter()
|
||||||
{
|
{
|
||||||
|
// Get base query
|
||||||
$query = Delegation::query()->select();
|
$query = Delegation::query()->select();
|
||||||
|
// Only distinct APP_NUMBER
|
||||||
|
$query->distinct();
|
||||||
// Get the list of processes of the supervisor
|
// Get the list of processes of the supervisor
|
||||||
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
|
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
|
||||||
// Scope the specific array of processes supervising
|
// Scope the specific array of processes supervising
|
||||||
$query->processInList($processes);
|
$query->processInList($processes);
|
||||||
|
// Return the number of rows
|
||||||
return $query->count();
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace ProcessMaker\Services\Api;
|
namespace ProcessMaker\Services\Api;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use G;
|
||||||
use Luracast\Restler\RestException;
|
use Luracast\Restler\RestException;
|
||||||
use Menu;
|
use Menu;
|
||||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||||
@@ -359,30 +360,42 @@ class Home extends Api
|
|||||||
public function doGetCountMyCases()
|
public function doGetCountMyCases()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$filters = ['STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
|
// Initializing variables
|
||||||
$result = [];
|
$participatedStatuses = ['STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
|
||||||
foreach ($filters as $row) {
|
$participatedLabels = array_combine($participatedStatuses, ['ID_OPT_STARTED', 'ID_IN_PROGRESS', 'ID_COMPLETED', 'ID_SUPERVISING']);
|
||||||
switch ($row) {
|
$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 'STARTED':
|
||||||
case 'IN_PROGRESS':
|
case 'IN_PROGRESS':
|
||||||
case 'COMPLETED':
|
case 'COMPLETED':
|
||||||
$list = new Participated();
|
$participated = new Participated();
|
||||||
$list->setParticipatedStatus($row);
|
$participated->setParticipatedStatus($participatedStatus);
|
||||||
$list->setUserId($this->getUserId());
|
$participated->setUserId($this->getUserId());
|
||||||
$result[strtolower($row)] = $list->getCounter();
|
$counter->counter = $participated->getCounter();
|
||||||
break;
|
break;
|
||||||
case 'SUPERVISING':
|
case 'SUPERVISING':
|
||||||
// Scope that search for the SUPERVISING cases by specific user
|
$supervising = new Supervising();
|
||||||
$list = new Supervising();
|
$supervising->setUserUid($this->getUserId());
|
||||||
$list->setUserId($this->getUserId());
|
$counter->counter = $supervising->getCounter();
|
||||||
$result[strtolower($row)] = $list->getCounter();
|
|
||||||
break;
|
break;
|
||||||
default:
|
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) {
|
} catch (Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user