Merged in bugfix/PMCORE-2727 (pull request #7755)
PMCORE-2727 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -550,15 +550,5 @@ class SupervisingTest extends TestCase
|
||||
|
||||
$res = $supervising->getPagingCounters();
|
||||
$this->assertEquals(3, $res);
|
||||
|
||||
$delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
|
||||
|
||||
$supervising->setCaseNumber($delegation->APP_NUMBER);
|
||||
$supervising->setProcessId($delegation->PRO_ID);
|
||||
$supervising->setTaskId($delegation->TAS_ID);
|
||||
$supervising->setCaseUid($delegation->APP_UID);
|
||||
|
||||
$res = $supervising->getPagingCounters();
|
||||
$this->assertEquals(1, $res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1064,10 +1064,11 @@ class AbstractCases implements CasesInterface
|
||||
* Get task color according the due date
|
||||
*
|
||||
* @param string $dueDate
|
||||
* @param string $statusThread
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTaskColor(string $dueDate)
|
||||
public function getTaskColor(string $dueDate, string $statusThread = '')
|
||||
{
|
||||
$currentDate = new DateTime('now');
|
||||
$dueDate = new DateTime($dueDate);
|
||||
@@ -1077,13 +1078,13 @@ class AbstractCases implements CasesInterface
|
||||
} else {
|
||||
// OnTime
|
||||
$taskColor = self::COLOR_ON_TIME;
|
||||
if (get_class($this) === Draft::class) {
|
||||
if (get_class($this) === Draft::class || $statusThread === self::TASK_STATUS[3]) {
|
||||
$taskColor = self::COLOR_DRAFT;
|
||||
}
|
||||
if (get_class($this) === Paused::class) {
|
||||
if (get_class($this) === Paused::class || $statusThread === self::TASK_STATUS[4]) {
|
||||
$taskColor = self::COLOR_PAUSED;
|
||||
}
|
||||
if (get_class($this) === Unassigned::class) {
|
||||
if (get_class($this) === Unassigned::class || $statusThread === self::TASK_STATUS[5]) {
|
||||
$taskColor = self::COLOR_UNASSIGNED;
|
||||
}
|
||||
}
|
||||
@@ -1157,6 +1158,39 @@ class AbstractCases implements CasesInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thread information
|
||||
*
|
||||
* @param array $thread
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function threadInformation(array $thread)
|
||||
{
|
||||
$result = [];
|
||||
$status = '';
|
||||
// Define the task status
|
||||
if ($thread['TAS_ASSIGN_TYPE'] === 'SELF_SERVICE') {
|
||||
$status = 'UNASSIGNED';
|
||||
}
|
||||
if ($thread['APP_STATUS'] === 'DRAFT') {
|
||||
$status = 'DRAFT';
|
||||
}
|
||||
// Define the thread information
|
||||
$result['tas_title'] = $thread['TAS_TITLE'];
|
||||
$result['user_id'] = $thread['USR_ID'];
|
||||
$result['due_date'] = $thread['DEL_TASK_DUE_DATE'];
|
||||
$result['delay'] = getDiffBetweenDates($thread['DEL_TASK_DUE_DATE'], date("Y-m-d H:i:s"));
|
||||
$result['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE'], $status) : '';
|
||||
$result['tas_color_label'] = (!empty($result['tas_color'])) ? self::TASK_COLORS[$result['tas_color']] : '';
|
||||
$result['tas_status'] = self::TASK_STATUS[$result['tas_color']];
|
||||
$result['unassigned'] = ($status === 'UNASSIGNED' ? true : false);
|
||||
// Get the user tooltip information
|
||||
$result['user_tooltip'] = User::getInformation($thread['USR_ID']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all properties
|
||||
*
|
||||
|
||||
@@ -17,6 +17,7 @@ class Participated extends AbstractCases
|
||||
'APP_DELEGATION.DEL_TITLE', // Case Title
|
||||
'PROCESS.PRO_TITLE', // Process Name
|
||||
'TASK.TAS_TITLE', // Pending Task
|
||||
'TASK.TAS_ASSIGN_TYPE', // Task assign rule
|
||||
'APPLICATION.APP_STATUS', // Status
|
||||
'APPLICATION.APP_CREATE_DATE', // Start Date
|
||||
'APPLICATION.APP_FINISH_DATE', // Finish Date
|
||||
@@ -118,24 +119,6 @@ class Participated extends AbstractCases
|
||||
$query->caseStarted();
|
||||
break;
|
||||
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'
|
||||
);
|
||||
// Only cases in progress: TO_DO without DRAFT
|
||||
$query->caseTodo();
|
||||
// Group by AppNumber
|
||||
@@ -168,59 +151,36 @@ class Participated extends AbstractCases
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
// Get total case notes
|
||||
$item['CASE_NOTES_COUNT'] = AppNotes::total($item['APP_NUMBER']);
|
||||
// Define the thread information
|
||||
$thread = [];
|
||||
$thread['TAS_TITLE'] = $item['TAS_TITLE'];
|
||||
$thread['USR_ID'] = $item['USR_ID'];
|
||||
$thread['DEL_TASK_DUE_DATE'] = $item['DEL_TASK_DUE_DATE'];
|
||||
$thread['TAS_ASSIGN_TYPE'] = $item['TAS_ASSIGN_TYPE'];
|
||||
$thread['APP_STATUS'] = $item['APP_STATUS'];
|
||||
// Define data according to the filters
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
case 'IN_PROGRESS':
|
||||
$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]['delay'] = getDiffBetweenDates($thread['DEL_TASK_DUE_DATE'], date("Y-m-d H:i:s"));
|
||||
$result[$i]['tas_color'] = (!empty($thread['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($thread['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($result[$i]['tas_color'])) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$result[$i]['tas_status'] = self::TASK_STATUS[$result[$i]['tas_color']];
|
||||
// Get the user tooltip information
|
||||
$result[$i]['user_tooltip'] = User::getInformation($thread['USR_ID']);
|
||||
$thread['APP_STATUS'] = $item['APP_STATUS'];
|
||||
$result[$i] = $this->threadInformation($thread);
|
||||
$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]['delay'] = getDiffBetweenDates($item['DEL_TASK_DUE_DATE'], date("Y-m-d H:i:s"));
|
||||
$result[$i]['tas_color'] = (!empty($item['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($result[$i]['tas_color'])) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$result[$i]['tas_status'] = self::TASK_STATUS[$result[$i]['tas_color']];
|
||||
// Get the user tooltip information
|
||||
$result[$i]['user_tooltip'] = User::getInformation($item['USR_ID']);
|
||||
$result[$i] = $this->threadInformation($thread);
|
||||
$item['PENDING'] = $result;
|
||||
}
|
||||
break;
|
||||
case 'IN_PROGRESS':
|
||||
// Get the detail related to the open thread
|
||||
if (!empty($item['PENDING'])) {
|
||||
$result = $this->prepareTaskPending($item['PENDING']);
|
||||
$item['PENDING'] = !empty($result['THREAD_TASKS']) ? $result['THREAD_TASKS'] : [];
|
||||
}
|
||||
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]['delay'] = getDiffBetweenDates($item['DEL_TASK_DUE_DATE'], date("Y-m-d H:i:s"));
|
||||
$result[$i]['tas_color'] = (!empty($item['DEL_TASK_DUE_DATE'])) ? $this->getTaskColor($item['DEL_TASK_DUE_DATE']) : '';
|
||||
$result[$i]['tas_color_label'] = (!empty($result[$i]['tas_color'])) ? self::TASK_COLORS[$result[$i]['tas_color']] : '';
|
||||
$result[$i]['tas_status'] = self::TASK_STATUS[$result[$i]['tas_color']];
|
||||
// Get the user tooltip information
|
||||
$result[$i]['user_tooltip'] = User::getInformation($item['USR_ID']);
|
||||
$result[$i] = $this->threadInformation($thread);
|
||||
$item['PENDING'] = $result;
|
||||
break;
|
||||
}
|
||||
@@ -236,6 +196,7 @@ class Participated extends AbstractCases
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
||||
public function getCounter()
|
||||
{
|
||||
// Get base query
|
||||
|
||||
@@ -1805,6 +1805,7 @@ class Delegation extends Model
|
||||
{
|
||||
$query = Delegation::query()->select([
|
||||
'TASK.TAS_TITLE',
|
||||
'TASK.TAS_ASSIGN_TYPE',
|
||||
'APP_DELEGATION.USR_ID',
|
||||
'APP_DELEGATION.DEL_TASK_DUE_DATE'
|
||||
]);
|
||||
@@ -1887,6 +1888,7 @@ class Delegation extends Model
|
||||
{
|
||||
$query = Delegation::query()->select([
|
||||
'TASK.TAS_TITLE', // Task
|
||||
'TASK.TAS_ASSIGN_TYPE', // Task assign rule
|
||||
'APP_DELEGATION.DEL_TITLE', // Thread title
|
||||
'APP_DELEGATION.DEL_THREAD_STATUS', // Thread status
|
||||
'APP_DELEGATION.USR_ID', // Current UserId
|
||||
@@ -1914,6 +1916,7 @@ class Delegation extends Model
|
||||
$abs = new AbstractCases();
|
||||
$item['TAS_COLOR'] = $abs->getTaskColor($item['DEL_TASK_DUE_DATE']);
|
||||
$item['TAS_COLOR_LABEL'] = AbstractCases::TASK_COLORS[$item['TAS_COLOR']];
|
||||
$item['UNASSIGNED'] = ($item['TAS_ASSIGN_TYPE'] === 'SELF_SERVICE' ? true : false);
|
||||
return $item;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user