PMCORE-2381
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,8 @@ class Draft extends AbstractCases
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE', // Delegate Date
|
||||
'APP_DELEGATION.DEL_PRIORITY', // Priority
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,39 @@ class Draft extends AbstractCases
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// Specific case
|
||||
if ($this->getCaseNumber()) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Specific case title
|
||||
if (!empty($this->getCaseTitle())) {
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
}
|
||||
// Specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Specific task
|
||||
if ($this->getTaskId()) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Specific case uid PMFCaseLink
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data self-services cases by user
|
||||
*
|
||||
@@ -44,18 +78,9 @@ class Draft extends AbstractCases
|
||||
$query->joinTask();
|
||||
// Join with application for add the initial scope for DRAFT cases
|
||||
$query->draft($this->getUserId());
|
||||
// Specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Specific case uid
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
// Specific cases
|
||||
if (!empty($this->getCasesUids())) {
|
||||
$query->specificCasesByUid($this->getCasesUids());
|
||||
}
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
// Add any sort if needed
|
||||
if ($this->getOrderByColumn()) {
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
@@ -92,6 +117,7 @@ class Draft extends AbstractCases
|
||||
$query = Delegation::query()->select();
|
||||
// Add the initial scope for draft cases
|
||||
$query->draft($this->getUserId());
|
||||
$this->filters($query);
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ class Inbox extends AbstractCases
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE', // Delegate Date
|
||||
'APP_DELEGATION.DEL_PRIORITY', // Priority
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,39 @@ class Inbox extends AbstractCases
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// Specific case
|
||||
if ($this->getCaseNumber()) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Specific case title
|
||||
if (!empty($this->getCaseTitle())) {
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
}
|
||||
// Specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Specific task
|
||||
if ($this->getTaskId()) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Specific case uid PMFCaseLink
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data corresponding to List Inbox
|
||||
*
|
||||
@@ -48,30 +82,16 @@ class Inbox extends AbstractCases
|
||||
$query->joinUser();
|
||||
// Join with application for add the initial scope for TO_DO cases
|
||||
$query->inbox($this->getUserId());
|
||||
// Define a specific risk
|
||||
switch ($this->getRiskStatus()) {
|
||||
case 'ON_TIME':
|
||||
// Scope that search for the ON_TIME cases
|
||||
$query->onTime();
|
||||
break;
|
||||
case 'AT_RISK':
|
||||
// Scope that search for the AT_RISK cases
|
||||
$query->atRisk();
|
||||
break;
|
||||
case 'OVERDUE':
|
||||
// Scope that search for the OVERDUE cases
|
||||
$query->overdue();
|
||||
break;
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
// Add any sort if needed
|
||||
if ($this->getOrderByColumn()) {
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
}
|
||||
// Scope to search for an specific process
|
||||
if (!empty($this->getProcessId())) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// The order by clause
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
// The limit by clause
|
||||
$query->offset($this->getOffset())->limit($this->getLimit());
|
||||
//Execute the query
|
||||
// Execute the query
|
||||
$results = $query->get();
|
||||
// Prepare the result
|
||||
$results->transform(function ($item, $key) {
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
class MyCases extends AbstractCases
|
||||
{
|
||||
/**
|
||||
* Gets the data for the Cases list My Cases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
$filter = $this->getParticipatedStatus();
|
||||
$result = [];
|
||||
if (!empty($filter)) {
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
case 'IN_PROGRESS':
|
||||
case 'COMPLETED':
|
||||
$list = new Participated();
|
||||
$result = $list->getData();
|
||||
break;
|
||||
case 'SUPERVISING':
|
||||
// Scope that search for the SUPERVISING cases by specific user
|
||||
$list = new Supervising();
|
||||
$result = $list->getData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total of My Cases
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
$filter = $this->getParticipatedStatus();
|
||||
$count = 0;
|
||||
if (!empty($filter)) {
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
case 'IN_PROGRESS':
|
||||
case 'COMPLETED':
|
||||
$list = new Participated();
|
||||
$count = $list->getCounter();
|
||||
break;
|
||||
case 'SUPERVISING':
|
||||
// Scope that search for the SUPERVISING cases by specific user
|
||||
$list = new Supervising();
|
||||
$count = $list->getCounter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Task;
|
||||
|
||||
class Participated extends AbstractCases
|
||||
{
|
||||
@@ -15,11 +15,13 @@ class Participated extends AbstractCases
|
||||
'PROCESS.PRO_TITLE', // Process Name
|
||||
'TASK.TAS_TITLE', // Pending Task
|
||||
'APPLICATION.APP_STATUS', // Status
|
||||
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE', // Start Date
|
||||
'APP_DELEGATION.DEL_FINISH_DATE', // Finish Date
|
||||
'APPLICATION.APP_CREATE_DATE', // Start Date
|
||||
'APPLICATION.APP_FINISH_DATE', // Finish Date
|
||||
'USERS.USR_ID', // Current UserId
|
||||
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date related to the colors
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -31,6 +33,59 @@ class Participated extends AbstractCases
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// Specific case
|
||||
if ($this->getCaseNumber()) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Specific case title
|
||||
if (!empty($this->getCaseTitle())) {
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
}
|
||||
// Scope to search for an specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Specific task
|
||||
if ($this->getTaskId()) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Specific status
|
||||
if ($this->getCaseStatus()) {
|
||||
$query->status($this->getCaseStatus());
|
||||
}
|
||||
// Specific start case date from
|
||||
if (!empty($this->getStartCaseFrom())) {
|
||||
$query->startDateFrom($this->getStartCaseFrom());
|
||||
}
|
||||
// Specific by start case date to
|
||||
if (!empty($this->getStartCaseTo())) {
|
||||
$query->startDateTo($this->getStartCaseTo());
|
||||
}
|
||||
// Specific finish case date from
|
||||
if (!empty($this->getFinishCaseFrom())) {
|
||||
$query->finishCaseFrom($this->getFinishCaseFrom());
|
||||
}
|
||||
// Filter by finish case date to
|
||||
if (!empty($this->getFinishCaseTo())) {
|
||||
$query->finishCaseTo($this->getFinishCaseTo());
|
||||
}
|
||||
// Specific case uid PMFCaseLink
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data corresponding to Participated
|
||||
*
|
||||
@@ -39,13 +94,15 @@ class Participated extends AbstractCases
|
||||
public function getData()
|
||||
{
|
||||
// Start the query for get the cases related to the user
|
||||
$query = Delegation::query()->select();
|
||||
$query = Delegation::query()->select($this->getColumnsView());
|
||||
// Join with process
|
||||
$query->joinProcess();
|
||||
// Join with task
|
||||
$query->joinTask();
|
||||
// Join with users
|
||||
$query->joinUser();
|
||||
// Join with application
|
||||
$query->joinApplication();
|
||||
// Scope to Participated
|
||||
$query->participated($this->getUserId());
|
||||
// Add filter
|
||||
@@ -53,29 +110,42 @@ class Participated extends AbstractCases
|
||||
if (!empty($filter)) {
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
// Scope that search for the STARTED
|
||||
// Scope that search for the STARTED by user
|
||||
$query->caseStarted();
|
||||
break;
|
||||
case 'IN-PROGRESS':
|
||||
case 'IN_PROGRESS':
|
||||
// Scope that search for the TO_DO
|
||||
$query->selectRaw(
|
||||
'CONCAT(
|
||||
\'[\',
|
||||
GROUP_CONCAT(
|
||||
CONCAT(
|
||||
\'{"tas_id":\',
|
||||
APP_DELEGATION.TAS_ID,
|
||||
\', "user_id":\',
|
||||
APP_DELEGATION.USR_ID,
|
||||
\', "due_date":"\',
|
||||
APP_DELEGATION.DEL_TASK_DUE_DATE,
|
||||
\'"}\'
|
||||
)
|
||||
),
|
||||
\']\'
|
||||
) AS PENDING'
|
||||
);
|
||||
$query->caseInProgress();
|
||||
$query->groupBy('APP_NUMBER');
|
||||
break;
|
||||
case 'COMPLETED':
|
||||
// Scope that search for the COMPLETED
|
||||
$query->caseCompleted();
|
||||
// Scope to set the last thread
|
||||
$query->lastThread();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Scope to search for an specific process
|
||||
if (!empty($this->getProcessId())) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
// The order by clause
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
// The limit by clause
|
||||
@@ -83,17 +153,57 @@ class Participated extends AbstractCases
|
||||
//Execute the query
|
||||
$results = $query->get();
|
||||
// Prepare the result
|
||||
$results->transform(function ($item, $key) {
|
||||
// Get task color label
|
||||
$item['TAS_COLOR'] = $this->getTaskColor($item['DEL_TASK_DUE_DATE']);
|
||||
$item['TAS_COLOR_LABEL'] = self::TASK_COLORS[$item['TAS_COLOR']];
|
||||
$results->transform(function ($item, $key) use ($filter) {
|
||||
// Apply the date format defined in environment
|
||||
$item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']);
|
||||
$item['DEL_FINISH_DATE_LABEL'] = !empty($item['DEL_FINISH_DATE']) ? applyMaskDateEnvironment($item['DEL_FINISH_DATE']): null;
|
||||
$item['APP_CREATE_DATE_LABEL'] = !empty($item['APP_CREATE_DATE']) ? applyMaskDateEnvironment($item['APP_CREATE_DATE']): null;
|
||||
$item['APP_FINISH_DATE_LABEL'] = !empty($item['APP_FINISH_DATE']) ? applyMaskDateEnvironment($item['APP_FINISH_DATE']): null;
|
||||
// Calculate duration
|
||||
$startDate = $item['DEL_DELEGATE_DATE'];
|
||||
$endDate = !empty($item['DEL_FINISH_DATE']) ? $item['DEL_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$startDate = (string)$item['APP_CREATE_DATE'];
|
||||
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
// Get the detail related to the open thread
|
||||
if (!empty($item['PENDING'])) {
|
||||
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
|
||||
}
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
$result = [];
|
||||
$i = 0;
|
||||
if ($item['APP_STATUS'] === 'TO_DO') {
|
||||
$taskPending = Delegation::getPendingThreads($item['APP_NUMBER']);
|
||||
foreach ($taskPending as $thread) {
|
||||
// todo this need to review
|
||||
$result[$i]['tas_title'] = $thread['TAS_TITLE'];
|
||||
$result[$i]['user_id'] = $thread['USR_ID'];
|
||||
$result[$i]['due_date'] = $thread['DEL_TASK_DUE_DATE'];
|
||||
$result[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$i++;
|
||||
}
|
||||
$item['PENDING'] = $result;
|
||||
} else {
|
||||
$result[$i]['tas_title'] = $item['TAS_TITLE'];
|
||||
$result[$i]['user_id'] = $item['USR_ID'];
|
||||
$result[$i]['due_date'] = $item['DEL_TASK_DUE_DATE'];
|
||||
$result[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$item['PENDING'] = $result;
|
||||
}
|
||||
break;
|
||||
case 'IN_PROGRESS':
|
||||
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
|
||||
break;
|
||||
case 'COMPLETED':
|
||||
$result = [];
|
||||
$i = 0;
|
||||
$result[$i]['tas_title'] = $item['TAS_TITLE'];
|
||||
$result[$i]['user_id'] = $item['USR_ID'];
|
||||
$result[$i]['due_date'] = $item['DEL_TASK_DUE_DATE'];
|
||||
$result[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$item['PENDING'] = $result;
|
||||
break;
|
||||
}
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
@@ -21,7 +21,8 @@ class Paused extends AbstractCases
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE', // Delegate Date
|
||||
'APP_DELEGATION.DEL_PRIORITY', // Priority
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,39 @@ class Paused extends AbstractCases
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// Specific case
|
||||
if ($this->getCaseNumber()) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Specific case title
|
||||
if (!empty($this->getCaseTitle())) {
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
}
|
||||
// Specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Specific task
|
||||
if ($this->getTaskId()) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Specific case uid PMFCaseLink
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data for the paused cases list
|
||||
*
|
||||
@@ -44,11 +78,10 @@ class Paused extends AbstractCases
|
||||
// Join with process
|
||||
$query->joinProcess();
|
||||
// Scope that set the paused cases
|
||||
$query->paused($this->getUserId(), $this->getTaskId(), $this->getCaseNumber());
|
||||
// Join with delegation for get the previous index
|
||||
$query->joinPreviousIndex();
|
||||
// Join with delegation for get the previous user
|
||||
$query->joinPreviousUser();
|
||||
$query->paused($this->getUserId(), $this->getTaskId());
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
// Add any sort if needed
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
// Add pagination to the query
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
|
||||
class Search extends AbstractCases
|
||||
@@ -14,6 +15,7 @@ class Search extends AbstractCases
|
||||
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
|
||||
'PROCESS.PRO_TITLE', // Process
|
||||
'TASK.TAS_TITLE', // Task
|
||||
'APPLICATION.APP_STATUS', // Status
|
||||
'USERS.USR_USERNAME', // Current UserName
|
||||
'USERS.USR_FIRSTNAME', // Current User FirstName
|
||||
'USERS.USR_LASTNAME', // Current User LastName
|
||||
@@ -21,7 +23,8 @@ class Search extends AbstractCases
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE', // Delegate Date
|
||||
'APP_DELEGATION.DEL_PRIORITY', // Priority
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -33,6 +36,101 @@ class Search extends AbstractCases
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// Filter case by case number
|
||||
if ($this->getCaseNumber()) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Filter cases by specific cases like [1,3,5]
|
||||
if (!empty($this->getCasesNumbers())) {
|
||||
$query->specificCases($this->getCasesNumbers());
|
||||
}
|
||||
// Filter cases by range of cases like ['1-5', '10-15']
|
||||
if (!empty($this->getRangeCasesFromTo())) {
|
||||
$query->rangeOfCases($this->getRangeCasesFromTo());
|
||||
}
|
||||
// Specific case title
|
||||
if (!empty($this->getCaseTitle())) {
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
}
|
||||
// Filter by process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Filter by user
|
||||
if ($this->getUserId()) {
|
||||
$query->userId($this->getUserId());
|
||||
}
|
||||
// Filter by task
|
||||
if ($this->getTaskId()) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Filter one or more priorities like ['VL', 'L', 'N']
|
||||
if (!empty($this->getPriorities())) {
|
||||
$query->priorities($this->getPriorities());
|
||||
}
|
||||
// Filter by delegate from
|
||||
if (!empty($this->getDelegateFrom())) {
|
||||
$query->delegateDateFrom($this->getDelegateFrom());
|
||||
}
|
||||
// Filter by delegate to
|
||||
if (!empty($this->getDelegateTo())) {
|
||||
$query->delegateDateTo($this->getDelegateTo());
|
||||
}
|
||||
// Filter by due from
|
||||
if (!empty($this->getDueFrom())) {
|
||||
$query->dueFrom($this->getDueFrom());
|
||||
}
|
||||
// Filter by due to
|
||||
if (!empty($this->getDueTo())) {
|
||||
$query->dueTo($this->getDueTo());
|
||||
}
|
||||
/** This filter define the UNION */
|
||||
|
||||
// Filter related to the case status like ['DRAFT', 'TO_DO']
|
||||
if (!empty($this->getCaseStatuses())) {
|
||||
$statuses = $this->getCaseStatuses();
|
||||
$casesOpen = [];
|
||||
$casesClosed = [];
|
||||
foreach ($statuses as $row) {
|
||||
if ($row === Application::STATUS_DRAFT or $row === Application::STATUS_TODO) {
|
||||
$casesOpen[] = $row;
|
||||
} else {
|
||||
$casesClosed[] = $row;
|
||||
}
|
||||
}
|
||||
if (!empty($casesOpen) && !empty($casesClosed)) {
|
||||
// Only in this case need to clone the same query for the union
|
||||
$cloneQuery = clone $query;
|
||||
// Get the open threads
|
||||
$query->casesInProgress($casesOpen);
|
||||
// Get the last thread
|
||||
$cloneQuery->casesDone($casesClosed);
|
||||
// Union
|
||||
$query->union($cloneQuery);
|
||||
} else {
|
||||
if (!empty($casesOpen)) {
|
||||
// Get the open thread
|
||||
$query->casesInProgress($casesOpen);
|
||||
}
|
||||
if (!empty($casesClosed)) {
|
||||
// Get the last thread
|
||||
$query->casesDone($casesClosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data corresponding to advanced search
|
||||
*
|
||||
@@ -47,33 +145,11 @@ class Search extends AbstractCases
|
||||
$query->joinTask();
|
||||
// Join with users
|
||||
$query->joinUser();
|
||||
// Filter by case number
|
||||
if ($this->getCaseNumber() > 0) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Filter by case number: from and to
|
||||
if ($this->getFromCaseNumber() > 0 && $this->getToCaseNumber() > 0) {
|
||||
$query->rangeOfCases($this->getFromCaseNumber(), $this->getToCaseNumber());
|
||||
}
|
||||
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
|
||||
// Filter by priority
|
||||
if ($this->getPriority() > 0) {
|
||||
$query->priority($this->getPriority());
|
||||
}
|
||||
// Filter by process
|
||||
if (!empty($this->getProcessId())) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Filter by user
|
||||
if (!empty($this->getUserId())) {
|
||||
$query->userId($this->getUserId());
|
||||
}
|
||||
// Filter by task
|
||||
if (!empty($this->getTaskId())) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Join with application
|
||||
$query->joinApplication();
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
// The order by clause
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
// The limit by clause
|
||||
|
||||
@@ -15,11 +15,12 @@ class Supervising extends AbstractCases
|
||||
'PROCESS.PRO_TITLE', // Process Name
|
||||
'TASK.TAS_TITLE', // Pending Task
|
||||
'APPLICATION.APP_STATUS', // Status
|
||||
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE', // Start Date
|
||||
'APP_DELEGATION.DEL_FINISH_DATE', // Finish Date
|
||||
'APPLICATION.APP_CREATE_DATE', // Start Date
|
||||
'APPLICATION.APP_FINISH_DATE', // Finish Date
|
||||
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date related to the colors
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,59 @@ class Supervising extends AbstractCases
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// Specific case
|
||||
if ($this->getCaseNumber()) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Specific case title
|
||||
if (!empty($this->getCaseTitle())) {
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
}
|
||||
// Scope to search for an specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Specific task
|
||||
if ($this->getTaskId()) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Specific status
|
||||
if ($this->getCaseStatus()) {
|
||||
$query->status($this->getCaseStatus());
|
||||
}
|
||||
// Specific start case date from
|
||||
if (!empty($this->getStartCaseFrom())) {
|
||||
$query->startDateFrom($this->getStartCaseFrom());
|
||||
}
|
||||
// Specific by start case date to
|
||||
if (!empty($this->getStartCaseTo())) {
|
||||
$query->startDateTo($this->getStartCaseTo());
|
||||
}
|
||||
// Specific finish case date from
|
||||
if (!empty($this->getFinishCaseFrom())) {
|
||||
$query->finishCaseFrom($this->getFinishCaseFrom());
|
||||
}
|
||||
// Filter by finish case date to
|
||||
if (!empty($this->getFinishCaseTo())) {
|
||||
$query->finishCaseTo($this->getFinishCaseTo());
|
||||
}
|
||||
// Specific case uid PMFCaseLink
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data for the Cases list Review
|
||||
*
|
||||
@@ -40,51 +94,53 @@ class Supervising extends AbstractCases
|
||||
{
|
||||
// Get the list of processes of the supervisor
|
||||
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
|
||||
// Start the query for get the cases related to the user
|
||||
$query = Delegation::query()->select($this->getColumnsView());
|
||||
// Join with process
|
||||
$query->joinProcess();
|
||||
// Join with users
|
||||
$query->joinUser();
|
||||
// Join with task and scope that sets the queries for List Inbox
|
||||
$query->inbox($this->getUserId());
|
||||
// Scope the specific array of processes supervising
|
||||
$query->processInList($processes);
|
||||
// Join with delegation for get the previous index
|
||||
$query->joinPreviousIndex();
|
||||
// Join with delegation for get the previous user
|
||||
$query->joinPreviousUser();
|
||||
// Scope to search for an specific case
|
||||
if (!empty($this->getCaseNumber())) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Scope to search for an specific process
|
||||
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());
|
||||
//Execute the query
|
||||
$results = $query->get();
|
||||
// Prepare the result
|
||||
$results->transform(function ($item, $key) {
|
||||
// Get task color label
|
||||
$item['TAS_COLOR'] = $this->getTaskColor($item['DEL_TASK_DUE_DATE']);
|
||||
$item['TAS_COLOR_LABEL'] = self::TASK_COLORS[$item['TAS_COLOR']];
|
||||
// Apply the date format defined in environment
|
||||
$item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']);
|
||||
$item['DEL_FINISH_DATE_LABEL'] = !empty($item['DEL_FINISH_DATE']) ? applyMaskDateEnvironment($item['DEL_FINISH_DATE']): null;
|
||||
// Calculate duration
|
||||
$startDate = $item['DEL_DELEGATE_DATE'];
|
||||
$endDate = !empty($item['DEL_FINISH_DATE']) ? $item['DEL_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
// We will prepare the queries if the user is supervisor
|
||||
if (!empty($processes)) {
|
||||
// Start the query for get the cases related to the user
|
||||
$query = Delegation::query()->select($this->getColumnsView());
|
||||
// Join with process
|
||||
$query->joinProcess();
|
||||
// Join with task
|
||||
$query->joinTask();
|
||||
// Join with users
|
||||
$query->joinUser();
|
||||
// Join with application
|
||||
$query->joinApplication();
|
||||
// Only cases in progress
|
||||
$query->caseInProgress();
|
||||
// Scope that return the results for an specific user
|
||||
$query->userId($this->getUserId());
|
||||
// Scope the specific array of processes supervising
|
||||
$query->processInList($processes);
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
//The order by clause
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
//The limit clause
|
||||
$query->offset($this->getOffset())->limit($this->getLimit());
|
||||
//Execute the query
|
||||
$results = $query->get();
|
||||
// Prepare the result
|
||||
$results->transform(function ($item, $key) {
|
||||
// Get task color label
|
||||
$item['TAS_COLOR'] = $this->getTaskColor($item['DEL_TASK_DUE_DATE']);
|
||||
$item['TAS_COLOR_LABEL'] = self::TASK_COLORS[$item['TAS_COLOR']];
|
||||
// Apply the date format defined in environment
|
||||
$item['APP_CREATE_DATE_LABEL'] = !empty($item['APP_CREATE_DATE']) ? applyMaskDateEnvironment($item['APP_CREATE_DATE']): null;
|
||||
$item['APP_FINISH_DATE_LABEL'] = !empty($item['APP_FINISH_DATE']) ? applyMaskDateEnvironment($item['APP_FINISH_DATE']): null;
|
||||
// Calculate duration
|
||||
$startDate = (string)$item['APP_CREATE_DATE'];
|
||||
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
|
||||
return $item;
|
||||
});
|
||||
return $item;
|
||||
});
|
||||
|
||||
return $results->values()->toArray();
|
||||
return $results->values()->toArray();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,8 @@ class Unassigned extends AbstractCases
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE', // Delegate Date
|
||||
'APP_DELEGATION.DEL_PRIORITY', // Priority
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for PMFCaseLink
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -34,6 +35,39 @@ class Unassigned extends AbstractCases
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// Specific case
|
||||
if ($this->getCaseNumber()) {
|
||||
$query->case($this->getCaseNumber());
|
||||
}
|
||||
// Specific case title
|
||||
if ($this->getCaseTitle()) {
|
||||
// @todo: Filter by case title, pending from other PRD
|
||||
}
|
||||
// Specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Specific task
|
||||
if ($this->getTaskId()) {
|
||||
$query->task($this->getTaskId());
|
||||
}
|
||||
// Specific case uid PMFCaseLink
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data self-services cases by user
|
||||
*
|
||||
@@ -47,28 +81,15 @@ class Unassigned extends AbstractCases
|
||||
// Join with users
|
||||
$query->joinUser();
|
||||
// Join with application for add the initial scope for unassigned cases
|
||||
$query->selfService($this->getUserUid());
|
||||
if (!empty($this->getUserUid())) {
|
||||
$query->selfService($this->getUserUid());
|
||||
}
|
||||
// Add join for application, for get the case title when the case status is TO_DO
|
||||
$query->appStatusId(Application::STATUS_TODO);
|
||||
// Specific process
|
||||
if ($this->getProcessId()) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
// Date range filter, this is used from mobile GET /light/unassigned
|
||||
if ($this->getNewestThan()) {
|
||||
$query->delegateDateFrom($this->getNewestThan());
|
||||
}
|
||||
if ($this->getOldestThan()) {
|
||||
$query->delegateDateTo($this->getOldestThan());
|
||||
}
|
||||
// Specific case uid
|
||||
if (!empty($this->getCaseUid())) {
|
||||
$query->appUid($this->getCaseUid());
|
||||
}
|
||||
// Specific cases
|
||||
if (!empty($this->getCasesUids())) {
|
||||
$query->specificCasesByUid($this->getCasesUids());
|
||||
}
|
||||
$query->joinApplication();
|
||||
$query->status(Application::STATUS_TODO);
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
// Add any sort if needed
|
||||
if ($this->getOrderByColumn()) {
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -64,41 +64,29 @@ class ProcessUser extends Model
|
||||
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)
|
||||
public static function getProcessesOfSupervisor(string $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);
|
||||
// Get the list of process when the user is supervisor
|
||||
$query = ProcessUser::query()->select(['PRO_ID']);
|
||||
$query->processSupervisor($userUid);
|
||||
$results = $query->get();
|
||||
$processes = [];
|
||||
$results->each(function ($item, $key) use (&$processes) {
|
||||
$processes[] = $item->PRO_ID;
|
||||
});
|
||||
// Get the list of process when the group related to the user is supervisor
|
||||
$query = ProcessUser::query()->select(['PRO_ID']);
|
||||
$query->processGroupSupervisor($userUid);
|
||||
$results = $query->get();
|
||||
$results->each(function ($item, $key) use (&$processes) {
|
||||
$processes[] = $item->PRO_ID;
|
||||
});
|
||||
|
||||
return $processes;
|
||||
}
|
||||
|
||||
463
workflow/engine/src/ProcessMaker/Services/Api/Home.php
Normal file
463
workflow/engine/src/ProcessMaker/Services/Api/Home.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user