PMC-604
This commit is contained in:
@@ -39,6 +39,7 @@ use ProcessMaker\BusinessModel\Task as BmTask;
|
||||
use ProcessMaker\BusinessModel\User as BmUser;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Exception\UploadException;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Services\OAuth2\Server;
|
||||
use ProcessMaker\Util\DateTime as UtilDateTime;
|
||||
@@ -2438,6 +2439,14 @@ class Cases
|
||||
*
|
||||
* @return array Return an array with status info Case, array empty otherwise
|
||||
* @throws Exception
|
||||
*
|
||||
* @see workflow/engine/methods/cases/main_init.php
|
||||
* @see workflow/engine/methods/cases/opencase.php
|
||||
* @see ProcessMaker\BusinessModel\Cases->setCaseVariables()
|
||||
* @see ProcessMaker\BusinessModel\Cases\InputDocument->getCasesInputDocuments()
|
||||
* @see ProcessMaker\BusinessModel\Cases\InputDocument->throwExceptionIfHaventPermissionToDelete()
|
||||
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfCaseNotIsInInbox()
|
||||
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfHaventPermissionToDelete()
|
||||
*/
|
||||
public function getStatusInfo($applicationUid, $delIndex = 0, $userUid = "")
|
||||
{
|
||||
@@ -2598,19 +2607,7 @@ class Cases
|
||||
}
|
||||
|
||||
//Status is PARTICIPATED
|
||||
$criteria2 = clone $criteria;
|
||||
|
||||
$criteria2->setDistinct();
|
||||
$criteria2->clearSelectColumns();
|
||||
$criteria2->addSelectColumn($delimiter . 'PARTICIPATED' . $delimiter . ' AS APP_STATUS');
|
||||
$criteria2->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$criteria2->addSelectColumn(ApplicationPeer::APP_UID);
|
||||
$criteria2->addSelectColumn(ApplicationPeer::PRO_UID);
|
||||
|
||||
$rsCriteria2 = ApplicationPeer::doSelectRS($criteria2);
|
||||
$rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->__getStatusInfoDataByRsCriteria($rsCriteria2);
|
||||
$arrayData = Delegation::getParticipatedInfo($applicationUid);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
|
||||
@@ -45,6 +45,19 @@ class Delegation extends Model
|
||||
return $this->belongsTo(Process::class, 'PRO_ID', 'PRO_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the delegations from a case by APP_UID
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeAppUid($query, $appUid)
|
||||
{
|
||||
return $query->where('APP_UID', '=', $appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for delegations which match certain criteria
|
||||
*
|
||||
@@ -330,4 +343,50 @@ class Delegation extends Model
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participation information for a case
|
||||
*
|
||||
* @param string $appUid
|
||||
* @return array
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\Cases:getStatusInfo()
|
||||
*/
|
||||
public static function getParticipatedInfo($appUid)
|
||||
{
|
||||
// Build the query
|
||||
$query = Delegation::query()->select([
|
||||
'APP_UID',
|
||||
'DEL_INDEX',
|
||||
'PRO_UID'
|
||||
]);
|
||||
$query->appUid($appUid);
|
||||
$query->orderBy('DEL_INDEX', 'ASC');
|
||||
|
||||
// Fetch results
|
||||
$results = $query->get();
|
||||
|
||||
// Initialize the array to return
|
||||
$arrayData = [];
|
||||
|
||||
// If the collection have at least one item, build the main array to return
|
||||
if ($results->count() > 0) {
|
||||
// Get the first item
|
||||
$first = $results->first();
|
||||
|
||||
// Build the main array to return
|
||||
$arrayData = [
|
||||
'APP_STATUS' => 'PARTICIPATED', // Value hardcoded because we need to return the same structure previously sent
|
||||
'DEL_INDEX' => [], // Initialize this item like an array
|
||||
'PRO_UID' => $first->PRO_UID
|
||||
];
|
||||
|
||||
// Populate the DEL_INDEX key with the values of the items collected
|
||||
$results->each(function ($item) use (&$arrayData) {
|
||||
$arrayData['DEL_INDEX'][] = $item->DEL_INDEX;
|
||||
});
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user