PMCORE-1215
PMCORE-1215
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\ProcessUser;
|
||||
|
||||
class Supervising extends AbstractCases
|
||||
{
|
||||
/**
|
||||
* Gets the data for the Cases list Review
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
//Get the list of processes of the supervisor
|
||||
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
|
||||
|
||||
// Start tthe query for get the cases related to the user
|
||||
$query = Delegation::query()->select();
|
||||
|
||||
$query->inbox($this->getUserId());
|
||||
|
||||
$query->categoryProcess($this->getCategoryUid());
|
||||
|
||||
$query->processInList($processes);
|
||||
|
||||
$query->joinPreviousIndex();
|
||||
|
||||
$query->joinPreviousUser();
|
||||
|
||||
if (!empty($this->getCaseNumber())) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
|
||||
if (!empty($this->getProcessId())) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
|
||||
//The order by clause
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
|
||||
//The limit clause
|
||||
$query->offset($this->getOffset())->limit($this->getLimit());
|
||||
|
||||
return $query->get()->values()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total of Review cases
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
$quantity = $this->getData();
|
||||
return count($quantity);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class Delegation extends Model
|
||||
*/
|
||||
public function scopeThreadOpen($query)
|
||||
{
|
||||
return $query->where('DEL_THREAD_STATUS', '=', 'OPEN');
|
||||
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,6 +523,53 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope delegation table
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinPreviousIndex($query)
|
||||
{
|
||||
$query->leftJoin('APP_DELEGATION AS AD', function( $leftJoin) {
|
||||
$leftJoin->on('APP_DELEGATION.APP_NUMBER', '=', 'AD.APP_NUMBER')
|
||||
->on('APP_DELEGATION.DEL_PREVIOUS', '=', 'AD.DEL_INDEX');
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope users table as previous
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinPreviousUser($query)
|
||||
{
|
||||
$query->leftJoin('USERS AS PREVIOUS', function ($leftJoin) {
|
||||
$leftJoin->on('AD.USR_UID', '=', 'PREVIOUS.USR_UID');
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Process is in list
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $processes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcessInList($query, $processes)
|
||||
{
|
||||
$query->whereIn('PROCESS.PRO_ID', $processes);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific cases unassigned that the user can view
|
||||
*
|
||||
|
||||
105
workflow/engine/src/ProcessMaker/Model/ProcessUser.php
Normal file
105
workflow/engine/src/ProcessMaker/Model/ProcessUser.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProcessUser extends Model
|
||||
{
|
||||
protected $table = 'PROCESS_USER';
|
||||
protected $primaryKey = 'PU_UID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Scope process supervisor
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $userUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcessSupervisor($query, $userUid)
|
||||
{
|
||||
$query->where('USR_UID', $userUid);
|
||||
$query->where('PU_TYPE', 'SUPERVISOR');
|
||||
$query->joinProcess();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope process group supervisor
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $userUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcessGroupSupervisor($query, $userUid)
|
||||
{
|
||||
$query->where('PU_TYPE', 'GROUP_SUPERVISOR');
|
||||
$query->leftJoin('GROUP_USER', function ($leftJoin) use ($userUid) {
|
||||
$leftJoin->on('PROCESS_USER.USR_UID', '=', 'GROUP_USER.GRP_UID')
|
||||
->where('GROUP_USER.USR_UID', $userUid);
|
||||
});
|
||||
$query->joinProcess();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope join with process table
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinProcess($query)
|
||||
{
|
||||
$query->leftJoin('PROCESS', function ($leftJoin) {
|
||||
$leftJoin->on('PROCESS.PRO_UID', '=', 'PROCESS_USER.PRO_UID');
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* It returns a list of processes ids as an array
|
||||
*
|
||||
* @param array $processes
|
||||
* @return array
|
||||
*/
|
||||
public static function getListOfProcessUid($processes)
|
||||
{
|
||||
$res = (array_map(function ($x) {
|
||||
if (array_key_exists('PRO_ID', $x)) {
|
||||
return $x['PRO_ID'];
|
||||
}
|
||||
}, $processes));
|
||||
|
||||
return array_filter($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It returns a list of processes of the supervisor
|
||||
*
|
||||
* @param string $userUid
|
||||
* @return array
|
||||
*/
|
||||
public static function getProcessesOfSupervisor($userUid)
|
||||
{
|
||||
$query1 = ProcessUser::query()->select(['PRO_ID']);
|
||||
$query1->processSupervisor($userUid);
|
||||
$processes = $query1->get()->values()->toArray();
|
||||
|
||||
$query2 = ProcessUser::query()->select(['PRO_ID']);
|
||||
$query2->processGroupSupervisor($userUid);
|
||||
|
||||
array_push($processes, $query2->get()->values()->toArray());
|
||||
|
||||
$processes = ProcessUser::getListOfProcessUid($processes);
|
||||
|
||||
return $processes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user