PMCORE-2536

This commit is contained in:
Paula Quispe
2020-12-15 11:37:58 -04:00
parent e77c4222e7
commit a08b087318
9 changed files with 163 additions and 120 deletions

View File

@@ -25,8 +25,9 @@ $factory->define(\ProcessMaker\Model\Application::class, function(Faker $faker)
'APP_CUR_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID,
'APP_PIN' => G::generateUniqueID(), 'APP_PIN' => G::generateUniqueID(),
'APP_CREATE_DATE' => $faker->dateTime(), 'APP_CREATE_DATE' => $faker->dateTime(),
'APP_UPDATE_DATE' => $faker->dateTime(),
'APP_INIT_DATE' => $faker->dateTime(), 'APP_INIT_DATE' => $faker->dateTime(),
'APP_UPDATE_DATE' => $faker->dateTime(),
'APP_FINISH_DATE' => $faker->dateTime(),
'APP_DATA' => serialize(['APP_NUMBER' => $appNumber]) 'APP_DATA' => serialize(['APP_NUMBER' => $appNumber])
]; ];
}); });
@@ -59,8 +60,9 @@ $factory->state(\ProcessMaker\Model\Application::class, 'foreign_keys', function
'APP_CUR_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID,
'APP_PIN' => G::generateUniqueID(), 'APP_PIN' => G::generateUniqueID(),
'APP_CREATE_DATE' => $faker->dateTime(), 'APP_CREATE_DATE' => $faker->dateTime(),
'APP_UPDATE_DATE' => $faker->dateTime(),
'APP_INIT_DATE' => $faker->dateTime(), 'APP_INIT_DATE' => $faker->dateTime(),
'APP_UPDATE_DATE' => $faker->dateTime(),
'APP_FINISH_DATE' => $faker->dateTime(),
'APP_DATA' => serialize(['APP_NUMBER' => $appNumber]) 'APP_DATA' => serialize(['APP_NUMBER' => $appNumber])
]; ];
}); });

View File

@@ -678,11 +678,8 @@ class AbstractCasesTest extends TestCase
'caseNumber' => rand(), 'caseNumber' => rand(),
'caseTitle' => G::generateUniqueID(), 'caseTitle' => G::generateUniqueID(),
// Home - Search // Home - Search
'priorities' => ['N'],
'caseStatuses' => ['TO_DO','DRAFT'], 'caseStatuses' => ['TO_DO','DRAFT'],
'filterCases'=> '1,3-5,8,10-15', 'filterCases'=> '1,3-5,8,10-15',
'delegationDateFrom' => date('Y-m-d'),
'delegationDateTo' => date('Y-m-d'),
// Home - My cases // Home - My cases
'filter'=> 'STARTED', 'filter'=> 'STARTED',
'caseStatus' => 'TO_DO', 'caseStatus' => 'TO_DO',
@@ -691,8 +688,6 @@ class AbstractCasesTest extends TestCase
'finishCaseFrom' => date('Y-m-d'), 'finishCaseFrom' => date('Y-m-d'),
'finishCaseTo' => date('Y-m-d'), 'finishCaseTo' => date('Y-m-d'),
// Other // Other
'search' => G::generateUniqueID(),
'category' => G::generateUniqueID(),
'caseLink' => G::generateUniqueID(), 'caseLink' => G::generateUniqueID(),
'appUidCheck' => [G::generateUniqueID()], 'appUidCheck' => [G::generateUniqueID()],
'sort' => 'APP_NUMBER', 'sort' => 'APP_NUMBER',
@@ -714,8 +709,6 @@ class AbstractCasesTest extends TestCase
$actual = $absCases->getCaseTitle(); $actual = $absCases->getCaseTitle();
$this->assertEquals($properties['caseTitle'], $actual); $this->assertEquals($properties['caseTitle'], $actual);
// Home - Search // Home - Search
$actual = $absCases->getPriorities();
$this->assertEmpty($actual);
$actual = $absCases->getCaseStatuses(); $actual = $absCases->getCaseStatuses();
$this->assertNotEmpty($actual); $this->assertNotEmpty($actual);
$actual = $absCases->getFilterCases(); $actual = $absCases->getFilterCases();
@@ -724,28 +717,28 @@ class AbstractCasesTest extends TestCase
$this->assertEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getRangeCasesFromTo(); $actual = $absCases->getRangeCasesFromTo();
$this->assertEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getDelegateFrom(); $actual = $absCases->getStartCaseFrom();
$this->assertEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getDelegateTo(); $actual = $absCases->getStartCaseTo();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseTo();
$this->assertEmpty($actual); $this->assertEmpty($actual);
// Home - My cases // Home - My cases
$actual = $absCases->getParticipatedStatus(); $actual = $absCases->getParticipatedStatus();
$this->assertEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getCaseStatus(); $actual = $absCases->getCaseStatus();
$this->assertEquals(2, $actual); $this->assertEmpty($actual);
$actual = $absCases->getStartCaseFrom(); $actual = $absCases->getStartCaseFrom();
$this->assertEquals($properties['startCaseFrom'], $actual); $this->assertEmpty($actual);
$actual = $absCases->getStartCaseTo(); $actual = $absCases->getStartCaseTo();
$this->assertEquals($properties['startCaseTo'], $actual); $this->assertEmpty($actual);
$actual = $absCases->getFinishCaseFrom(); $actual = $absCases->getFinishCaseFrom();
$this->assertEquals($properties['finishCaseFrom'], $actual); $this->assertEmpty($actual);
$actual = $absCases->getFinishCaseTo(); $actual = $absCases->getFinishCaseTo();
$this->assertEquals($properties['finishCaseTo'], $actual); $this->assertEmpty($actual);
// Other // Other
$actual = $absCases->getValueToSearch();
$this->assertEquals($properties['search'], $actual);
$actual = $absCases->getCategoryUid();
$this->assertEquals($properties['category'], $actual);
$actual = $absCases->getCaseUid(); $actual = $absCases->getCaseUid();
$this->assertEquals($properties['caseLink'], $actual); $this->assertEquals($properties['caseLink'], $actual);
$actual = $absCases->getCasesUids(); $actual = $absCases->getCasesUids();

View File

@@ -44,7 +44,7 @@ class SearchTest extends TestCase
* It tests the getData method without filters * It tests the getData method without filters
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @test * @test
*/ */
public function it_get_result_without_filters() public function it_get_result_without_filters()
@@ -62,7 +62,7 @@ class SearchTest extends TestCase
* It tests the getData with case number * It tests the getData with case number
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters() * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
@@ -84,7 +84,7 @@ class SearchTest extends TestCase
* It tests the getData with process * It tests the getData with process
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters() * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
@@ -106,7 +106,7 @@ class SearchTest extends TestCase
* It tests the getData with task * It tests the getData with task
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters() * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
@@ -128,7 +128,7 @@ class SearchTest extends TestCase
* It tests the getData method with case title filter * It tests the getData method with case title filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters() * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
@@ -153,7 +153,7 @@ class SearchTest extends TestCase
* It tests the getData with user * It tests the getData with user
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters() * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
@@ -175,17 +175,17 @@ class SearchTest extends TestCase
* It tests the getData with priority * It tests the getData with priority
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters() * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
public function it_filter_by_priority() public function it_filter_by_status()
{ {
// Create factories related to the delegation cases // Create factories related to the delegation cases
$cases = $this->createSearch(); $cases = $this->createSearch();
// Create new Search object // Create new Search object
$search = new Search(); $search = new Search();
$search->setPriority('N'); $search->setCaseStatuses(['TO_DO']);
// Set order by column value // Set order by column value
$search->setOrderByColumn('APP_NUMBER'); $search->setOrderByColumn('APP_NUMBER');
$result = $search->getData(); $result = $search->getData();

View File

@@ -929,9 +929,9 @@ class UnassignedTest extends TestCase
{ {
// Create factories related to the unassigned cases // Create factories related to the unassigned cases
$cases = $this->createSelfServiceUser(); $cases = $this->createSelfServiceUser();
$usrUid = $cases->last()->USR_UID; $usrUid = $cases['taskUser']->USR_UID;
$usrId = $cases->last()->USR_ID; $usrId = $cases['delegation']->USR_ID;
$title = $cases->last()->DEL_TITLE; $title = $cases['delegation']->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index // We need to commit the records inserted because is needed for the "fulltext" index
DB::commit(); DB::commit();
// Create new Unassigned object // Create new Unassigned object

View File

@@ -6,6 +6,7 @@ use Datetime;
use Exception; use Exception;
use ProcessMaker\BusinessModel\Interfaces\CasesInterface; use ProcessMaker\BusinessModel\Interfaces\CasesInterface;
use ProcessMaker\BusinessModel\Validator; use ProcessMaker\BusinessModel\Validator;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task; use ProcessMaker\Model\Task;
use ProcessMaker\Model\User; use ProcessMaker\Model\User;
@@ -1091,33 +1092,60 @@ class AbstractCases implements CasesInterface
/** /**
* Get task color according the due date * Get task color according the due date
* *
* @param string $pending * @param string $pendingJson
* @param bool $onlyTask
* *
* @return int * @return int
*/ */
public function prepareTaskPending($pending) public function prepareTaskPending($pendingJson, $onlyTask = true)
{ {
$taskPending = json_decode($pending, true); $taskPending = json_decode($pendingJson, true);
$result = []; $result = [];
$threadTasks = [];
$threadUsers = [];
$threadTitles = [];
$i = 0; $i = 0;
foreach ($taskPending as $thread) { foreach ($taskPending as $thread) {
foreach ($thread as $key => $row) { foreach ($thread as $key => $row) {
if($key === 'tas_id') { // Thread tasks
$result[$i][$key] = $row; if ($key === 'tas_id') {
$result[$i]['tas_title'] = (!empty($row)) ? Task::where('TAS_ID', $row)->first()->TAS_TITLE : ''; $threadTasks[$i][$key] = $row;
$threadTasks[$i]['tas_title'] = (!empty($row)) ? Task::where('TAS_ID', $row)->first()->TAS_TITLE : '';
} }
if($key === 'user_id') { if ($key === 'due_date') {
$result[$i][$key] = $row; $threadTasks[$i][$key] = $row;
}
if($key === 'due_date') {
$result[$i][$key] = $row;
// Get task color label // Get task color label
$result[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($row) : ''; $threadTasks[$i]['tas_color'] = (!empty($row)) ? $this->getTaskColor($row) : '';
$result[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$result[$i]['tas_color']] : ''; $threadTasks[$i]['tas_color_label'] = (!empty($row)) ? self::TASK_COLORS[$threadTasks[$i]['tas_color']] : '';
}
// Review if require other information
if ($onlyTask) {
// Thread tasks
if($key === 'user_id') {
$threadTasks[$i][$key] = $row;
}
} else {
// Thread users
if ($key === 'user_id') {
$threadUsers[$i][$key] = $row;
$user = (!empty($row)) ? User::where('USR_ID', $row)->first(): null;
$threadUsers[$i]['usr_username'] = $user ? $user->USR_USERNAME : '';
$threadUsers[$i]['usr_lastname'] = $user ? $user->USR_LASTNAME : '';
$threadUsers[$i]['usr_firstname'] = $user ? $user->USR_FIRSTNAME : '';
}
// Thread titles
if ($key === 'del_id') {
$threadTitles[$i][$key] = $row;
$threadTitles[$i]['thread_title'] = (!empty($row)) ? Delegation::where('DELEGATION_ID', $row)->first()->DEL_TITLE : '';
}
} }
} }
$i ++; $i ++;
} }
// Define the array responses
$result['THREAD_TASKS'] = $threadTasks;
$result['THREAD_USERS'] = $threadUsers;
$result['THREAD_TITLES'] = $threadTitles;
return $result; return $result;
} }
@@ -1187,25 +1215,21 @@ class AbstractCases implements CasesInterface
if (get_class($this) === Search::class && !empty($properties['caseStatuses'])) { if (get_class($this) === Search::class && !empty($properties['caseStatuses'])) {
$this->setCaseStatuses($properties['caseStatuses']); $this->setCaseStatuses($properties['caseStatuses']);
} }
// Filter by more than one priorities like ['VL', 'L', 'N'] // Filter date related to started date from
if (get_class($this) === Search::class && !empty($properties['priorities'])) { if (get_class($this) === Search::class && !empty($properties['startCaseFrom'])) {
$this->setProperties($properties['priorities']); $this->setStartCaseFrom($properties['startCaseFrom']);
} }
// Filter date newest related to delegation/started date // Filter date related to started date to
if (get_class($this) === Search::class && !empty($properties['delegationDateFrom'])) { if (get_class($this) === Search::class && !empty($properties['startCaseTo'])) {
$this->setDelegateFrom($properties['delegationDateFrom']); $this->setStartCaseTo($properties['startCaseTo']);
} }
// Filter date oldest related to delegation/started date // Filter date related to finish date from
if (get_class($this) === Search::class && !empty($properties['delegationDateTo'])) { if (get_class($this) === Search::class && !empty($properties['finishCaseFrom'])) {
$this->setDelegateTo($properties['delegationDateTo']); $this->setFinishCaseFrom($properties['finishCaseFrom']);
} }
// Filter date newest related to due date // Filter date related to finish date to
if (get_class($this) === Search::class && !empty($properties['dueDateFrom'])) { if (get_class($this) === Search::class && !empty($properties['finishCaseTo'])) {
$this->setDueFrom($properties['dueDateFrom']); $this->setFinishCaseTo($properties['finishCaseTo']);
}
// Filter date oldest related to due date
if (get_class($this) === Search::class && !empty($properties['dueDateTo'])) {
$this->setDueTo($properties['dueDateTo']);
} }
// Filter by case uid // Filter by case uid
if (!empty($properties['caseLink'])) { if (!empty($properties['caseLink'])) {

View File

@@ -164,6 +164,9 @@ class Participated extends AbstractCases
$startDate = (string)$item['APP_CREATE_DATE']; $startDate = (string)$item['APP_CREATE_DATE'];
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s"); $endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate); $item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
// todo: we will to complete the real count with other ticket
$item['CASE_NOTES_COUNT'] = 0;
// Define data according to the filters
switch ($filter) { switch ($filter) {
case 'STARTED': case 'STARTED':
$result = []; $result = [];
@@ -192,7 +195,8 @@ class Participated extends AbstractCases
case 'IN_PROGRESS': case 'IN_PROGRESS':
// Get the detail related to the open thread // Get the detail related to the open thread
if (!empty($item['PENDING'])) { if (!empty($item['PENDING'])) {
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']); $result = $this->prepareTaskPending($item['PENDING']);
$item['PENDING'] = !empty($result['THREAD_TASKS']) ? $result['THREAD_TASKS'] : [];
} }
break; break;
case 'COMPLETED': case 'COMPLETED':

View File

@@ -5,6 +5,8 @@ namespace ProcessMaker\BusinessModel\Cases;
use G; use G;
use ProcessMaker\Model\Application; use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\User;
class Search extends AbstractCases class Search extends AbstractCases
{ {
@@ -14,14 +16,9 @@ class Search extends AbstractCases
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.DEL_TITLE', // Case Title 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process 'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'APPLICATION.APP_STATUS', // Status 'APPLICATION.APP_STATUS', // Status
'USERS.USR_USERNAME', // Current UserName 'APPLICATION.APP_CREATE_DATE', // Case create date
'USERS.USR_FIRSTNAME', // Current User FirstName 'APPLICATION.APP_FINISH_DATE', // Case finish date
'USERS.USR_LASTNAME', // Current User LastName
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date
'APP_DELEGATION.DEL_DELEGATE_DATE', // Delegate Date
'APP_DELEGATION.DEL_PRIORITY', // Priority
// Additional column for other functionalities // Additional column for other functionalities
'APP_DELEGATION.APP_UID', // Case Uid for Open case 'APP_DELEGATION.APP_UID', // Case Uid for Open case
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case 'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
@@ -75,25 +72,21 @@ class Search extends AbstractCases
if ($this->getTaskId()) { if ($this->getTaskId()) {
$query->task($this->getTaskId()); $query->task($this->getTaskId());
} }
// Filter one or more priorities like ['VL', 'L', 'N'] // Specific start case date from
if (!empty($this->getPriorities())) { if (!empty($this->getStartCaseFrom())) {
$query->priorities($this->getPriorities()); $query->startDateFrom($this->getStartCaseFrom());
} }
// Filter by delegate from // Specific by start case date to
if (!empty($this->getDelegateFrom())) { if (!empty($this->getStartCaseTo())) {
$query->delegateDateFrom($this->getDelegateFrom()); $query->startDateTo($this->getStartCaseTo());
} }
// Filter by delegate to // Specific finish case date from
if (!empty($this->getDelegateTo())) { if (!empty($this->getFinishCaseFrom())) {
$query->delegateDateTo($this->getDelegateTo()); $query->finishCaseFrom($this->getFinishCaseFrom());
} }
// Filter by due from // Filter by finish case date to
if (!empty($this->getDueFrom())) { if (!empty($this->getFinishCaseTo())) {
$query->dueFrom($this->getDueFrom()); $query->finishCaseTo($this->getFinishCaseTo());
}
// Filter by due to
if (!empty($this->getDueTo())) {
$query->dueTo($this->getDueTo());
} }
/** This filter define the UNION */ /** This filter define the UNION */
@@ -141,14 +134,31 @@ class Search extends AbstractCases
public function getData() public function getData()
{ {
$query = Delegation::query()->select($this->getColumnsView()); $query = Delegation::query()->select($this->getColumnsView());
$query->selectRaw(
'CONCAT(
\'[\',
GROUP_CONCAT(
CONCAT(
\'{"tas_id":\',
APP_DELEGATION.TAS_ID,
\', "user_id":\',
APP_DELEGATION.USR_ID,
\', "del_id":\',
APP_DELEGATION.DELEGATION_ID,
\', "due_date":"\',
APP_DELEGATION.DEL_TASK_DUE_DATE,
\'"}\'
)
),
\']\'
) AS THREADS'
);
// Join with process // Join with process
$query->joinProcess(); $query->joinProcess();
// Join with task
$query->joinTask();
// Join with users
$query->joinUser();
// Join with application // Join with application
$query->joinApplication(); $query->joinApplication();
// Group by AppNumber
$query->groupBy('APP_NUMBER');
/** Apply filters */ /** Apply filters */
$this->filters($query); $this->filters($query);
/** Apply order and pagination */ /** Apply order and pagination */
@@ -160,15 +170,22 @@ class Search extends AbstractCases
$results = $query->get(); $results = $query->get();
// Prepare the result // Prepare the result
$results->transform(function ($item, $key) { $results->transform(function ($item, $key) {
// Get priority label
$priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']];
$item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}");
// 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 // Apply the date format defined in environment
$item['DEL_TASK_DUE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_TASK_DUE_DATE']); $item['APP_CREATE_DATE_LABEL'] = !empty($item['APP_CREATE_DATE']) ? applyMaskDateEnvironment($item['APP_CREATE_DATE']): null;
$item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']); $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);
// todo: we will to complete the real count with other ticket
$item['CASE_NOTES_COUNT'] = 0;
// Get the detail related to the open thread
if (!empty($item['THREADS'])) {
$result = $this->prepareTaskPending($item['THREADS'], false);
$item['THREAD_TASKS'] = !empty($result['THREAD_TASKS']) ? $result['THREAD_TASKS'] : [];
$item['THREAD_USERS'] = !empty($result['THREAD_USERS']) ? $result['THREAD_USERS'] : [];
$item['THREAD_TITLES'] = !empty($result['THREAD_TITLES']) ? $result['THREAD_TITLES'] : [];
}
return $item; return $item;
}); });

View File

@@ -154,9 +154,12 @@ class Supervising extends AbstractCases
$startDate = (string)$item['APP_CREATE_DATE']; $startDate = (string)$item['APP_CREATE_DATE'];
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s"); $endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate); $item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
// todo: we will to complete the real count with other ticket
$item['CASE_NOTES_COUNT'] = 0;
// Get the detail related to the open thread // Get the detail related to the open thread
if (!empty($item['PENDING'])) { if (!empty($item['PENDING'])) {
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']); $result = $this->prepareTaskPending($item['PENDING']);
$item['PENDING'] = !empty($result['THREAD_TASKS']) ? $result['THREAD_TASKS'] : [];
} }
return $item; return $item;

View File

@@ -63,7 +63,7 @@ class Home extends Api
int $task = 0, int $task = 0,
string $caseTitle = '', string $caseTitle = '',
string $paged = '0,15', string $paged = '0,15',
string $sort = 'APP_NUMBER,ASC' string $sort = 'APP_NUMBER,DESC'
) { ) {
try { try {
$list = new Draft(); $list = new Draft();
@@ -118,7 +118,7 @@ class Home extends Api
int $task = 0, int $task = 0,
string $caseTitle = '', string $caseTitle = '',
string $paged = '0,15', string $paged = '0,15',
string $sort = 'APP_NUMBER,ASC' string $sort = 'APP_NUMBER,DESC'
) { ) {
try { try {
$list = new Inbox(); $list = new Inbox();
@@ -173,7 +173,7 @@ class Home extends Api
int $task = 0, int $task = 0,
string $caseTitle = '', string $caseTitle = '',
string $paged = '0,15', string $paged = '0,15',
string $sort = 'APP_NUMBER,ASC' string $sort = 'APP_NUMBER,DESC'
) { ) {
try { try {
$list = new Unassigned(); $list = new Unassigned();
@@ -230,7 +230,7 @@ class Home extends Api
int $task = 0, int $task = 0,
string $caseTitle = '', string $caseTitle = '',
string $paged = '0,15', string $paged = '0,15',
string $sort = 'APP_NUMBER,ASC' string $sort = 'APP_NUMBER,DESC'
) { ) {
try { try {
$list = new Paused(); $list = new Paused();
@@ -269,11 +269,12 @@ class Home extends Api
* @param int $process * @param int $process
* @param int $task * @param int $task
* @param string $caseTitle * @param string $caseTitle
* @param string $filter
* @param string $caseStatus
* @param string $startCaseFrom * @param string $startCaseFrom
* @param string $startCaseTo * @param string $startCaseTo
* @param string $finishCaseFrom * @param string $finishCaseFrom
* @param string $finishCaseTo * @param string $finishCaseTo
* @param string $filter
* @param string $paged * @param string $paged
* @param string $sort * @param string $sort
* *
@@ -290,12 +291,13 @@ class Home extends Api
int $task = 0, int $task = 0,
string $caseTitle = '', string $caseTitle = '',
string $filter = 'IN_PROGRESS', string $filter = 'IN_PROGRESS',
string $caseStatus = '',
string $startCaseFrom = '', string $startCaseFrom = '',
string $startCaseTo = '', string $startCaseTo = '',
string $finishCaseFrom = '', string $finishCaseFrom = '',
string $finishCaseTo = '', string $finishCaseTo = '',
string $paged = '0,15', string $paged = '0,15',
string $sort = 'APP_NUMBER,ASC' string $sort = 'APP_NUMBER,DESC'
) { ) {
// Define the filters to apply // Define the filters to apply
$properties = []; $properties = [];
@@ -307,6 +309,7 @@ class Home extends Api
$usrUid = $this->getUserId(); $usrUid = $this->getUserId();
$properties['user'] = User::find($usrUid)->first()->USR_ID; $properties['user'] = User::find($usrUid)->first()->USR_ID;
$properties['filter'] = $filter; $properties['filter'] = $filter;
$properties['caseStatus'] = $caseStatus;
$properties['startCaseFrom'] = $startCaseFrom; $properties['startCaseFrom'] = $startCaseFrom;
$properties['startCaseTo'] = $startCaseTo; $properties['startCaseTo'] = $startCaseTo;
$properties['finishCaseFrom'] = $finishCaseFrom; $properties['finishCaseFrom'] = $finishCaseFrom;
@@ -413,13 +416,12 @@ class Home extends Api
* @param int $task * @param int $task
* @param int $user * @param int $user
* @param string $caseTitle * @param string $caseTitle
* @param string $priorities
* @param string $caseStatuses * @param string $caseStatuses
* @param string $filterCases * @param string $filterCases
* @param string $dueDateFrom * @param string $startCaseFrom
* @param string $dueDateTo * @param string $startCaseTo
* @param string $delegationDateFrom * @param string $finishCaseFrom
* @param string $delegationDateTo * @param string $finishCaseTo
* @param string $paged * @param string $paged
* @param string $sort * @param string $sort
* *
@@ -436,15 +438,14 @@ class Home extends Api
int $task = 0, int $task = 0,
int $user = 0, int $user = 0,
string $caseTitle = '', string $caseTitle = '',
string $priorities = '',
string $caseStatuses = '', string $caseStatuses = '',
string $filterCases = '', string $filterCases = '',
string $dueDateFrom = '', string $startCaseFrom = '',
string $dueDateTo = '', string $startCaseTo = '',
string $delegationDateFrom = '', string $finishCaseFrom = '',
string $delegationDateTo = '', string $finishCaseTo = '',
string $paged = '0,15', string $paged = '0,15',
string $sort = 'APP_NUMBER,ASC' string $sort = 'APP_NUMBER,DESC'
) { ) {
try { try {
$list = new Search(); $list = new Search();
@@ -455,13 +456,12 @@ class Home extends Api
$properties['process'] = $process; $properties['process'] = $process;
$properties['task'] = $task; $properties['task'] = $task;
$properties['user'] = $user; $properties['user'] = $user;
$properties['priorities'] = explode(',', $priorities);
$properties['caseStatuses'] = explode(',', $caseStatuses); $properties['caseStatuses'] = explode(',', $caseStatuses);
$properties['filterCases'] = $filterCases; $properties['filterCases'] = $filterCases;
$properties['dueDateFrom'] = $dueDateFrom; $properties['startCaseFrom'] = $startCaseFrom;
$properties['dueDateTo'] = $dueDateTo; $properties['startCaseTo'] = $startCaseTo;
$properties['delegationDateFrom'] = $delegationDateFrom; $properties['finishCaseFrom'] = $finishCaseFrom;
$properties['delegationDateTo'] = $delegationDateTo; $properties['finishCaseTo'] = $finishCaseTo;
// Set the pagination parameters // Set the pagination parameters
$paged = explode(',', $paged); $paged = explode(',', $paged);
$sort = explode(',', $sort); $sort = explode(',', $sort);