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:
Paula Quispe
2021-01-20 15:41:20 +00:00
committed by Julio Cesar Laura Avendaño
4 changed files with 55 additions and 67 deletions

View File

@@ -550,15 +550,5 @@ class SupervisingTest extends TestCase
$res = $supervising->getPagingCounters(); $res = $supervising->getPagingCounters();
$this->assertEquals(3, $res); $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);
} }
} }

View File

@@ -1064,10 +1064,11 @@ class AbstractCases implements CasesInterface
* Get task color according the due date * Get task color according the due date
* *
* @param string $dueDate * @param string $dueDate
* @param string $statusThread
* *
* @return int * @return int
*/ */
public function getTaskColor(string $dueDate) public function getTaskColor(string $dueDate, string $statusThread = '')
{ {
$currentDate = new DateTime('now'); $currentDate = new DateTime('now');
$dueDate = new DateTime($dueDate); $dueDate = new DateTime($dueDate);
@@ -1077,13 +1078,13 @@ class AbstractCases implements CasesInterface
} else { } else {
// OnTime // OnTime
$taskColor = self::COLOR_ON_TIME; $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; $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; $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; $taskColor = self::COLOR_UNASSIGNED;
} }
} }
@@ -1157,6 +1158,39 @@ class AbstractCases implements CasesInterface
return $result; 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 * Set all properties
* *

View File

@@ -17,6 +17,7 @@ class Participated extends AbstractCases
'APP_DELEGATION.DEL_TITLE', // Case Title 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process Name 'PROCESS.PRO_TITLE', // Process Name
'TASK.TAS_TITLE', // Pending Task 'TASK.TAS_TITLE', // Pending Task
'TASK.TAS_ASSIGN_TYPE', // Task assign rule
'APPLICATION.APP_STATUS', // Status 'APPLICATION.APP_STATUS', // Status
'APPLICATION.APP_CREATE_DATE', // Start Date 'APPLICATION.APP_CREATE_DATE', // Start Date
'APPLICATION.APP_FINISH_DATE', // Finish Date 'APPLICATION.APP_FINISH_DATE', // Finish Date
@@ -118,24 +119,6 @@ class Participated extends AbstractCases
$query->caseStarted(); $query->caseStarted();
break; 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'
);
// Only cases in progress: TO_DO without DRAFT // Only cases in progress: TO_DO without DRAFT
$query->caseTodo(); $query->caseTodo();
// Group by AppNumber // Group by AppNumber
@@ -168,59 +151,36 @@ class Participated extends AbstractCases
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate); $item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
// Get total case notes // Get total case notes
$item['CASE_NOTES_COUNT'] = AppNotes::total($item['APP_NUMBER']); $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 // Define data according to the filters
switch ($filter) { switch ($filter) {
case 'STARTED': case 'STARTED':
case 'IN_PROGRESS':
$result = []; $result = [];
$i = 0; $i = 0;
if ($item['APP_STATUS'] === 'TO_DO') { if ($item['APP_STATUS'] === 'TO_DO') {
$taskPending = Delegation::getPendingThreads($item['APP_NUMBER']); $taskPending = Delegation::getPendingThreads($item['APP_NUMBER']);
foreach ($taskPending as $thread) { foreach ($taskPending as $thread) {
// todo this need to review $thread['APP_STATUS'] = $item['APP_STATUS'];
$result[$i]['tas_title'] = $thread['TAS_TITLE']; $result[$i] = $this->threadInformation($thread);
$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']);
$i++; $i++;
} }
$item['PENDING'] = $result; $item['PENDING'] = $result;
} else { } else {
$result[$i]['tas_title'] = $item['TAS_TITLE']; $result[$i] = $this->threadInformation($thread);
$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']);
$item['PENDING'] = $result; $item['PENDING'] = $result;
} }
break; 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': case 'COMPLETED':
$result = []; $result = [];
$i = 0; $i = 0;
$result[$i]['tas_title'] = $item['TAS_TITLE']; $result[$i] = $this->threadInformation($thread);
$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']);
$item['PENDING'] = $result; $item['PENDING'] = $result;
break; break;
} }
@@ -236,6 +196,7 @@ class Participated extends AbstractCases
* *
* @return int * @return int
*/ */
public function getCounter() public function getCounter()
{ {
// Get base query // Get base query

View File

@@ -1805,6 +1805,7 @@ class Delegation extends Model
{ {
$query = Delegation::query()->select([ $query = Delegation::query()->select([
'TASK.TAS_TITLE', 'TASK.TAS_TITLE',
'TASK.TAS_ASSIGN_TYPE',
'APP_DELEGATION.USR_ID', 'APP_DELEGATION.USR_ID',
'APP_DELEGATION.DEL_TASK_DUE_DATE' 'APP_DELEGATION.DEL_TASK_DUE_DATE'
]); ]);
@@ -1887,6 +1888,7 @@ class Delegation extends Model
{ {
$query = Delegation::query()->select([ $query = Delegation::query()->select([
'TASK.TAS_TITLE', // Task 'TASK.TAS_TITLE', // Task
'TASK.TAS_ASSIGN_TYPE', // Task assign rule
'APP_DELEGATION.DEL_TITLE', // Thread title 'APP_DELEGATION.DEL_TITLE', // Thread title
'APP_DELEGATION.DEL_THREAD_STATUS', // Thread status 'APP_DELEGATION.DEL_THREAD_STATUS', // Thread status
'APP_DELEGATION.USR_ID', // Current UserId 'APP_DELEGATION.USR_ID', // Current UserId
@@ -1914,6 +1916,7 @@ class Delegation extends Model
$abs = new AbstractCases(); $abs = new AbstractCases();
$item['TAS_COLOR'] = $abs->getTaskColor($item['DEL_TASK_DUE_DATE']); $item['TAS_COLOR'] = $abs->getTaskColor($item['DEL_TASK_DUE_DATE']);
$item['TAS_COLOR_LABEL'] = AbstractCases::TASK_COLORS[$item['TAS_COLOR']]; $item['TAS_COLOR_LABEL'] = AbstractCases::TASK_COLORS[$item['TAS_COLOR']];
$item['UNASSIGNED'] = ($item['TAS_ASSIGN_TYPE'] === 'SELF_SERVICE' ? true : false);
return $item; return $item;
}); });