PMCORE-3092
This commit is contained in:
@@ -881,7 +881,7 @@ class Cases
|
||||
public function participation($usrUid, $caseNumber, $index)
|
||||
{
|
||||
$userId = User::getId($usrUid);
|
||||
$query = Delegation::query()->select(['APP_NUMBER'])->case($caseNumber)->index($index)->isThreadOpen();
|
||||
$query = Delegation::query()->select(['APP_NUMBER'])->case($caseNumber)->index($index)->threadOpen();
|
||||
$query1 = clone $query;
|
||||
$result = $query->userId($userId)->limit(1)->get()->values()->toArray();
|
||||
$permission = empty($result) ? false : true;
|
||||
@@ -1048,6 +1048,11 @@ class Cases
|
||||
Validator::isDate($date, 'Y-m-d', '$unpaused_date');
|
||||
}
|
||||
|
||||
// Check if the case is unassigned
|
||||
if ($this->isUnassignedPauseCase($appUid, $index)) {
|
||||
throw new Exception(G::LoadTranslation("ID_CASE_NOT_PAUSED", [G::LoadTranslation("ID_UNASSIGNED_STATUS")]));
|
||||
}
|
||||
|
||||
/** Pause case */
|
||||
$case->pauseCase($appUid, $index, $usrUid, $date . ' ' . $time);
|
||||
|
||||
|
||||
@@ -1262,6 +1262,9 @@ class AbstractCases implements CasesInterface
|
||||
if ($thread['APP_STATUS'] === 'DRAFT') {
|
||||
$status = 'DRAFT';
|
||||
}
|
||||
if (isset($thread['DEL_THREAD_STATUS']) && $thread['DEL_THREAD_STATUS'] === 'PAUSED') {
|
||||
$status = 'PAUSED';
|
||||
}
|
||||
if ($thread['APP_STATUS'] === 'COMPLETED') {
|
||||
$finishDate = !empty($thread['APP_FINISH_DATE']) ? $thread['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$dateToCompare = $finishDate;
|
||||
|
||||
@@ -181,7 +181,7 @@ class Participated extends AbstractCases
|
||||
switch ($item['APP_STATUS']) {
|
||||
case 'TO_DO':
|
||||
// Get the pending task
|
||||
$taskPending = Delegation::getPendingThreads($item['APP_NUMBER']);
|
||||
$taskPending = Delegation::getPendingThreads($item['APP_NUMBER'], false);
|
||||
foreach ($taskPending as $thread) {
|
||||
$thread['APP_STATUS'] = $item['APP_STATUS'];
|
||||
// Get the thread information
|
||||
|
||||
@@ -192,7 +192,7 @@ class Supervising extends AbstractCases
|
||||
// Only cases in to_do
|
||||
$query->caseTodo();
|
||||
// Only open threads
|
||||
$query->isThreadOpen();
|
||||
$query->threadOpen();
|
||||
// For parallel threads the distinct by APP_NUMBER is important
|
||||
$query->distinct();
|
||||
// Get the list of processes of the supervisor
|
||||
@@ -217,7 +217,7 @@ class Supervising extends AbstractCases
|
||||
// Only cases in to_do
|
||||
$query->caseTodo();
|
||||
// Only open threads
|
||||
$query->isThreadOpen();
|
||||
$query->threadOpen();
|
||||
// For parallel threads the distinct by APP_NUMBER is important
|
||||
$query->distinct();
|
||||
// Get the list of processes of the supervisor
|
||||
|
||||
@@ -8,4 +8,26 @@ class AppDelay extends Model
|
||||
{
|
||||
protected $table = 'APP_DELAY';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'APP_DELAY_UID',
|
||||
'PRO_UID',
|
||||
'PRO_ID',
|
||||
'APP_UID',
|
||||
'APP_NUMBER',
|
||||
'APP_THREAD_INDEX',
|
||||
'APP_DEL_INDEX',
|
||||
'APP_TYPE',
|
||||
'APP_STATUS',
|
||||
'APP_DELEGATION_USER',
|
||||
'APP_DELEGATION_USER_ID'.
|
||||
'APP_ENABLE_ACTION_USER',
|
||||
'APP_ENABLE_ACTION_DATE',
|
||||
'APP_DISABLE_ACTION_DATE',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -9,4 +9,46 @@ class AppThread extends Model
|
||||
protected $table = 'APP_THREAD';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Scope a query to filter a specific case
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $appUid
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeAppUid($query, string $appUid)
|
||||
{
|
||||
return $query->where('APP_UID', $appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter a specific index
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $index
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIndex($query, int $index)
|
||||
{
|
||||
return $query->where('DEL_INDEX', $index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get thread related to the specific case and index
|
||||
*
|
||||
* @param string $appUid
|
||||
* @param int $index
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getThread(string $appUid, int $index)
|
||||
{
|
||||
$query = AppThread::query()->select(['APP_THREAD_INDEX']);
|
||||
$query->appUid($appUid);
|
||||
$query->index($index);
|
||||
$results = $query->get()->toArray();
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ class Application extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information related to the created case
|
||||
* Get information related to the case, avoiding to load the APP_DATA
|
||||
*
|
||||
* @param string $appUid
|
||||
*
|
||||
@@ -382,7 +382,13 @@ class Application extends Model
|
||||
*/
|
||||
public static function getCase($appUid)
|
||||
{
|
||||
$query = Application::query()->select(['APP_STATUS', 'APP_INIT_USER']);
|
||||
$query = Application::query()->select([
|
||||
'APP_NUMBER',
|
||||
'APP_STATUS',
|
||||
'PRO_UID',
|
||||
'PRO_ID',
|
||||
'APP_INIT_USER'
|
||||
]);
|
||||
$query->appUid($appUid);
|
||||
$result = $query->get()->toArray();
|
||||
$firstElement = head($result);
|
||||
|
||||
@@ -24,6 +24,8 @@ class Delegation extends Model
|
||||
// Static properties to preserve values
|
||||
public static $usrUid = '';
|
||||
public static $groups = [];
|
||||
// Status name and status id
|
||||
public static $thread_status = ['CLOSED' => 0, 'OPEN' => 1, 'PAUSED' => 3];
|
||||
|
||||
/**
|
||||
* Returns the application this delegation belongs to
|
||||
@@ -92,6 +94,34 @@ class Delegation extends Model
|
||||
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include pause threads
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeThreadPause($query)
|
||||
{
|
||||
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS_ID', '=', 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include open and pause threads
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeOpenAndPause($query)
|
||||
{
|
||||
$query->where(function ($query) {
|
||||
$query->threadOpen();
|
||||
$query->orWhere(function ($query) {
|
||||
$query->threadPause();
|
||||
});
|
||||
});
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to use when the case is IN_PROGRESS like DRAFT or TO_DO
|
||||
*
|
||||
@@ -101,7 +131,7 @@ class Delegation extends Model
|
||||
*/
|
||||
public function scopeCasesInProgress($query, array $ids)
|
||||
{
|
||||
$query->isThreadOpen()->statusIds($ids);
|
||||
$query->threadOpen()->statusIds($ids);
|
||||
|
||||
return $query;
|
||||
}
|
||||
@@ -546,17 +576,6 @@ class Delegation extends Model
|
||||
return $query->where('APP_DELEGATION.APP_UID', '=', $appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include open threads
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIsThreadOpen($query)
|
||||
{
|
||||
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the last thread
|
||||
*
|
||||
@@ -755,6 +774,19 @@ class Delegation extends Model
|
||||
return $query->whereIn('APP_DELEGATION.PRO_ID', $processes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope where in processes
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $processes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeInProcesses($query, array $processes)
|
||||
{
|
||||
return $query->whereIn('PROCESS.PRO_ID', $processes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Inbox cases
|
||||
*
|
||||
@@ -853,6 +885,33 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope process category id
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $category
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCategoryId($query, int $category)
|
||||
{
|
||||
return $query->where('PROCESS.CATEGORY_ID', $category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope top ten
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $column
|
||||
* @param string $order
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTopTen($query, $column, $order)
|
||||
{
|
||||
return $query->orderBy($column, $order)->limit(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope join with delegation for get the previous index
|
||||
*
|
||||
@@ -1015,49 +1074,6 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope process category id
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $category
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCategoryId($query, $category)
|
||||
{
|
||||
$query->where('PROCESS.CATEGORY_ID', $category);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope top ten
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $column
|
||||
* @param string $order
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTopTen($query, $column, $order)
|
||||
{
|
||||
$query->orderBy($column, $order)->limit(10);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope where in processes
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $processes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeInProcesses($query, $processes)
|
||||
{
|
||||
$query->whereIn('PROCESS.PRO_ID', $processes);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific cases unassigned that the user can view
|
||||
*
|
||||
@@ -1562,7 +1578,7 @@ class Delegation extends Model
|
||||
// Start the second query
|
||||
$query2 = Delegation::query()->select($selectedColumns);
|
||||
$query2->tasksIn($selfServiceTasks);
|
||||
$query2->isThreadOpen();
|
||||
$query2->threadOpen();
|
||||
$query2->noUserInThread();
|
||||
|
||||
// Add join clause with the previous APP_DELEGATION record if required
|
||||
@@ -1856,10 +1872,11 @@ class Delegation extends Model
|
||||
* Return the open thread related to the task
|
||||
*
|
||||
* @param int $appNumber
|
||||
* @param bool $onlyOpen
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPendingThreads(int $appNumber)
|
||||
public static function getPendingThreads(int $appNumber, $onlyOpen = true)
|
||||
{
|
||||
$query = Delegation::query()->select([
|
||||
'TASK.TAS_UID',
|
||||
@@ -1869,6 +1886,7 @@ class Delegation extends Model
|
||||
'APP_DELEGATION.DEL_INDEX',
|
||||
'APP_DELEGATION.DEL_TITLE',
|
||||
'APP_DELEGATION.USR_ID',
|
||||
'APP_DELEGATION.DEL_THREAD_STATUS',
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE',
|
||||
'APP_DELEGATION.DEL_FINISH_DATE',
|
||||
'APP_DELEGATION.DEL_INIT_DATE',
|
||||
@@ -1877,7 +1895,11 @@ class Delegation extends Model
|
||||
// Join with task
|
||||
$query->joinTask();
|
||||
// Get the open threads
|
||||
$query->threadOpen();
|
||||
if ($onlyOpen) {
|
||||
$query->threadOpen();
|
||||
} else {
|
||||
$query->openAndPause();
|
||||
}
|
||||
// Related to the specific case number
|
||||
$query->case($appNumber);
|
||||
// Get the results
|
||||
|
||||
Reference in New Issue
Block a user