2019-06-10 11:36:01 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace ProcessMaker\BusinessModel\Cases;
|
|
|
|
|
|
2020-10-21 16:56:11 -04:00
|
|
|
use ProcessMaker\Model\Application;
|
|
|
|
|
use ProcessMaker\Model\Delegation;
|
|
|
|
|
|
2019-06-10 11:36:01 -04:00
|
|
|
class Participated extends AbstractCases
|
|
|
|
|
{
|
2020-10-21 16:56:11 -04:00
|
|
|
/**
|
|
|
|
|
* Get the data corresponding to Participated
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getData()
|
|
|
|
|
{
|
|
|
|
|
// Start the query for get the cases related to the user
|
|
|
|
|
$query = Delegation::query()->select();
|
|
|
|
|
// Scope to Participated
|
|
|
|
|
$query->participated($this->getUserId());
|
|
|
|
|
|
|
|
|
|
// Scope to search for an specific process
|
|
|
|
|
if (!empty($this->getProcessId())) {
|
|
|
|
|
$query->processId($this->getProcessId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scope the specific category
|
|
|
|
|
$category = $this->getCategoryUid();
|
|
|
|
|
if (!empty($category)) {
|
|
|
|
|
$query->categoryProcess($category);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scope the specific case status
|
|
|
|
|
$status = $this->getCaseStatus();
|
|
|
|
|
if (array_key_exists($status, Application::$app_status_values)) {
|
|
|
|
|
$statusId = Application::$app_status_values[$status];
|
|
|
|
|
$query->appStatusId($statusId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add filter
|
|
|
|
|
$filter = $this->getParticipatedStatus();
|
|
|
|
|
if (!empty($filter)) {
|
|
|
|
|
switch ($filter) {
|
|
|
|
|
case 'STARTED':
|
|
|
|
|
// Scope that search for the STARTED cases by specific user
|
|
|
|
|
$query->caseStarted();
|
|
|
|
|
break;
|
|
|
|
|
case 'COMPLETED':
|
|
|
|
|
// Scope that search for the COMPLETED cases by specific user
|
|
|
|
|
$query->caseCompleted();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The order by clause
|
|
|
|
|
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
|
|
|
|
|
|
|
|
|
// The limit by clause
|
|
|
|
|
$query->offset($this->getOffset())->limit($this->getLimit());
|
|
|
|
|
|
|
|
|
|
//Execute the query
|
|
|
|
|
$result = $query->get();
|
2019-06-10 11:36:01 -04:00
|
|
|
|
2020-10-21 16:56:11 -04:00
|
|
|
//Return the values as an array format
|
|
|
|
|
return $result->values()->toArray();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of rows corresponding to the Participate
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getCounter()
|
|
|
|
|
{
|
|
|
|
|
$query = Delegation::query()->select();
|
|
|
|
|
// Scope that sets the queries for Participated
|
|
|
|
|
$query->participated($this->getUserId());
|
|
|
|
|
// Return the number of rows
|
|
|
|
|
return $query->count();
|
|
|
|
|
}
|
2019-06-10 11:36:01 -04:00
|
|
|
}
|