Merged in feature/PMCORE-639 (pull request #7588)

PMCORE-2381
This commit is contained in:
Paula Quispe
2020-12-07 17:52:19 +00:00
21 changed files with 1925 additions and 731 deletions

View File

@@ -103,13 +103,30 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_priority()
{
$absCases = new AbstractCases();
$arguments = [1 => 'VL', 2 => 'L', 3 => 'N', 4 => 'H', 5 => 'VH'];
$arguments = ['ALL', 'VL', 'L', 'N', 'H', 'VH'];
$index = array_rand($arguments);
$absCases->setPriority($index);
$absCases->setPriority($arguments[$index]);
$actual = $absCases->getPriority();
$this->assertEquals($index, $actual);
}
/**
* This check the getter and setter related to the priorities
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPriorities()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getPriorities()
* @test
*/
public function it_return_set_get_priorities()
{
$absCases = new AbstractCases();
$arguments = ['ALL', 'VL', 'L', 'N', 'H', 'VH'];
$index = array_rand($arguments);
$absCases->setPriorities([$arguments[$index]]);
$actual = $absCases->getPriorities();
$this->assertEquals([$index], $actual);
}
/**
* This check the getter and setter related to the case number
*
@@ -129,9 +146,8 @@ class AbstractCasesTest extends TestCase
/**
* This check the getter and setter related to the range of case number
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setRangeCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFromCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getToCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumberFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumberTo()
* @test
*/
public function it_return_set_get_range_case_number()
@@ -141,9 +157,10 @@ class AbstractCasesTest extends TestCase
'APP_NUMBER' => $case1->APP_NUMBER + 1
]);
$absCases = new AbstractCases();
$absCases->setRangeCaseNumber($case1->APP_NUMBER, $case2->APP_NUMBER);
$from = $absCases->getFromCaseNumber();
$to = $absCases->getToCaseNumber();
$absCases->setCaseNumberFrom($case1->APP_NUMBER);
$absCases->setCaseNumberTo($case2->APP_NUMBER);
$from = $absCases->getCaseNumberFrom();
$to = $absCases->getCaseNumberTo();
$this->assertEquals($case1->APP_NUMBER, $from);
$this->assertEquals($case2->APP_NUMBER, $to);
}
@@ -174,12 +191,12 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_inbox_status()
{
$absCases = new AbstractCases();
$arguments = ['', 'ALL', 'READ', 'UNREAD'];
$arguments = ['ALL', 'READ', 'UNREAD'];
$index = array_rand($arguments);
$absCases->setInboxStatus($arguments[$index]);
$actual = $absCases->getInboxStatus();
if (empty($arguments[$index])) {
$this->assertEquals('ALL', $actual);
if ($arguments[$index] === 'ALL') {
$this->assertEmpty($actual);
} else {
$this->assertEquals($arguments[$index], $actual);
}
@@ -195,12 +212,12 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_participated_status()
{
$absCases = new AbstractCases();
$arguments = ['', 'ALL', 'STARTED', 'COMPLETED'];
$arguments = ['ALL', 'STARTED', 'COMPLETED'];
$index = array_rand($arguments);
$absCases->setParticipatedStatus($arguments[$index]);
$actual = $absCases->getParticipatedStatus();
if (empty($arguments[$index])) {
$this->assertEquals('ALL', $actual);
if ($arguments[$index] === 'ALL') {
$this->assertEmpty($actual);
} else {
$this->assertEquals($arguments[$index], $actual);
}
@@ -216,12 +233,12 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_risk_status()
{
$absCases = new AbstractCases();
$arguments = ['', 'ALL', 'ON_TIME', 'AT_RISK', 'OVERDUE'];
$arguments = ['ALL', 'ON_TIME', 'AT_RISK', 'OVERDUE'];
$index = array_rand($arguments);
$absCases->setRiskStatus($arguments[$index]);
$actual = $absCases->getRiskStatus();
if (empty($arguments[$index])) {
$this->assertEquals('ALL', $actual);
if ($arguments[$index] === 'ALL') {
$this->assertEmpty($actual);
} else {
$this->assertEquals($arguments[$index], $actual);
}
@@ -237,18 +254,36 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_case_status()
{
$absCases = new AbstractCases();
$arguments = ['', 'ALL', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELLED', 'CANCELED'];
$arguments = ['ALL', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
$index = array_rand($arguments);
$absCases->setCaseStatus($arguments[$index]);
$actual = $absCases->getCaseStatus();
if (empty($arguments[$index])) {
$this->assertEquals('ALL', $actual);
$this->assertEquals($index, $actual);
if ($arguments[$index] === 'ALL') {
$this->assertEquals(0, $actual);
} else {
if ($arguments[$index] === AbstractCases::INCORRECT_CANCELED_STATUS) {
$this->assertEquals(AbstractCases::CORRECT_CANCELED_STATUS, $actual);
} else {
$this->assertEquals($arguments[$index], $actual);
}
$this->assertEquals($index, $actual);
}
}
/**
* This check the getter and setter related to the case statuses
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatuses()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseStatuses()
* @test
*/
public function it_return_set_get_case_statuses()
{
$absCases = new AbstractCases();
$arguments = ['ALL', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
$index = array_rand($arguments);
$absCases->setCaseStatuses([$arguments[$index]]);
$actual = $absCases->getCaseStatuses();
if ($arguments[$index] === 'ALL') {
$this->assertEquals([], $actual);
} else {
$this->assertEquals([$index], $actual);
}
}
@@ -286,32 +321,32 @@ class AbstractCasesTest extends TestCase
/**
* This check the getter and setter related to the newest than date
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setNewestThan()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getNewestThan()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateFrom()
* @test
*/
public function it_return_set_get_newest_than()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setNewestThan($text);
$actual = $absCases->getNewestThan();
$absCases->setDelegateFrom($text);
$actual = $absCases->getDelegateFrom();
$this->assertEquals($text, $actual);
}
/**
* This check the getter and setter related to the oldest than date
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOldestThan()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOldestThan()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateTo()
* @test
*/
public function it_return_set_get_oldest_than()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setOldestThan($text);
$actual = $absCases->getOldestThan();
$absCases->setDelegateTo($text);
$actual = $absCases->getDelegateTo();
$this->assertEquals($text, $actual);
}
@@ -383,52 +418,61 @@ class AbstractCasesTest extends TestCase
{
$absCases = new AbstractCases();
$properties = [
'category' => G::generateUniqueID(),
// Tasks - Cases
'process' => rand(),
'task' => rand(),
'user' => rand(),
'priority' => 1,
'caseNumber' => rand(),
'caseNumberFrom' => rand(),
'caseNumberTo' => rand(),
'caseTitle' => G::generateUniqueID(),
// Home - Search
'priorities' => ['N'],
'caseStatuses' => ['TO_DO','DRAFT'],
'filterCases'=> '1,3-5,8,10-15',
'delegationDateFrom' => date('Y-m-d'),
'delegationDateTo' => date('Y-m-d'),
// Home - My cases
'filter'=> 'ALL',
'caseStatus' => 'TO_DO',
'startCaseFrom' => date('Y-m-d'),
'startCaseTo' => date('Y-m-d'),
'finishCaseFrom' => date('Y-m-d'),
'finishCaseTo' => date('Y-m-d'),
// Other
'search' => G::generateUniqueID(),
'category' => G::generateUniqueID(),
'caseLink' => G::generateUniqueID(),
'appUidCheck' => [G::generateUniqueID()],
'newestthan' => date('Y-m-d'),
'oldestthan' => date('Y-m-d'),
'sort' => 'APP_DELEGATION.APP_NUMBER',
'sort' => 'APP_NUMBER',
'dir' => 'DESC',
'paged' => true,
'start' => 5,
'limit' => 10,
];
$absCases->setProperties($properties);
$actual = $absCases->getCategoryUid();
$this->assertEquals($properties['category'], $actual);
// Tasks - Cases
$actual = $absCases->getProcessId();
$this->assertEquals($properties['process'], $actual);
$actual = $absCases->getTaskId();
$this->assertEquals($properties['task'], $actual);
$actual = $absCases->getUserId();
$this->assertEquals($properties['user'], $actual);
$actual = $absCases->getPriority();
$this->assertEquals($properties['priority'], $actual);
$actual = $absCases->getCaseNumber();
$this->assertEquals($properties['caseNumber'], $actual);
$actual = $absCases->getFromCaseNumber();
$this->assertEquals($properties['caseNumberFrom'], $actual);
$actual = $absCases->getToCaseNumber();
$this->assertEquals($properties['caseNumberTo'], $actual);
// Home - Search
$actual = $absCases->getPriorities();
$this->assertNotEmpty($actual);
// Home - My cases
$actual = $absCases->getParticipatedStatus();
$this->assertEmpty($actual);
// Other
$actual = $absCases->getValueToSearch();
$this->assertEquals($properties['search'], $actual);
$actual = $absCases->getCategoryUid();
$this->assertEquals($properties['category'], $actual);
$actual = $absCases->getCaseUid();
$this->assertEquals($properties['caseLink'], $actual);
$actual = $absCases->getCasesUids();
$this->assertEquals($properties['appUidCheck'], $actual);
$actual = $absCases->getNewestThan();
$this->assertEquals($properties['newestthan'], $actual);
$actual = $absCases->getOldestThan();
$this->assertEquals($properties['oldestthan'], $actual);
$actual = $absCases->getOrderByColumn();
$this->assertEquals($properties['sort'], $actual);
$actual = $absCases->getOrderDirection();

View File

@@ -18,6 +18,15 @@ class DraftTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
$this->markTestIncomplete();
}
/**
* This checks the counters is working properly in draft
*
@@ -93,7 +102,7 @@ class DraftTest extends TestCase
// Get first page
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$draft->setOrderByColumn('APP_NUMBER');
$draft->setOffset(0);
$draft->setLimit(25);
$results = $draft->getData();
@@ -143,7 +152,7 @@ class DraftTest extends TestCase
//Get the data ordered by APP_NUMBER
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$draft->setOrderByColumn('APP_NUMBER');
// Get first page, the minor case id
$draft->setOrderDirection('ASC');
$results = $draft->getData();
@@ -359,7 +368,7 @@ class DraftTest extends TestCase
// Get first page
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$draft->setOrderByColumn('APP_NUMBER');
// Get first page, the specific case
$draft->setOrderDirection('ASC');
$draft->setCaseUid($application->APP_UID);
@@ -394,7 +403,7 @@ class DraftTest extends TestCase
// Get first page
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$draft->setOrderByColumn('APP_NUMBER');
// Get first page, the specific case
$draft->setOrderDirection('ASC');
$draft->setCasesUids([$application->APP_UID]);
@@ -431,7 +440,7 @@ class DraftTest extends TestCase
// Get first page
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$draft->setOrderByColumn('APP_NUMBER');
$draft->setProcessId($process->PRO_ID);
// Get first page, the minor case title
$draft->setOrderDirection('ASC');

View File

@@ -52,82 +52,13 @@ class InboxTest extends TestCase
//Set the user ID
$inbox->setUserId($user->USR_ID);
//Set OrderBYColumn value
$inbox->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$inbox->setOrderByColumn('APP_NUMBER');
//Call to getData method
$res = $inbox->getData();
//This assert that the expected numbers of results are returned
$this->assertEquals(10, count($res));
}
/**
* It tests the getData method with Risk Filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @test
*/
public function it_it_should_test_get_data_method_with_Risk_Filter()
{
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
//Create the register in delegation
factory(Delegation::class, 10)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'DEL_RISK_DATE' => '2019-06-07 12:30:58'
]);
//Create new Inbox object
$inbox = new Inbox();
//Set the user UID
$inbox->setUserUid($user->USR_UID);
//Set the user ID
$inbox->setUserId($user->USR_ID);
//Set OrderBYColumn value
$inbox->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
//Set setRiskStatus value
$inbox->setRiskStatus('ON_TIME');
$res = $inbox->getData();
//This asserts that no cases are in ON_TIME status
$this->assertEmpty($res);
//Set setRiskStatus value
$inbox->setRiskStatus('OVERDUE');
//Call to getData method
$res = $inbox->getData();
//This asserts that there are cases in AT_RISK status
$this->assertNotEmpty($res);
//Set setRiskStatus value
$inbox->setRiskStatus('AT_RISK');
//Call to getData method
$res = $inbox->getData();
//This asserts that no cases are in AT_RISK status
$this->assertEmpty($res);
}
/**
* It tests the getData method with Category Filter
*
@@ -169,7 +100,7 @@ class InboxTest extends TestCase
$inbox->setUserId($user->USR_ID);
//Set OrderBYColumn value
$inbox->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$inbox->setOrderByColumn('APP_NUMBER');
//Set Category value
$inbox->setCategoryUid('248565910552bd7d6006458065223611');
@@ -213,7 +144,7 @@ class InboxTest extends TestCase
$inbox = new Inbox();
$inbox->setUserUid($user->USR_UID);
$inbox->setUserId($user->USR_ID);
$inbox->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$inbox->setOrderByColumn('APP_NUMBER');
$inbox->setProcessId($process[1]->PRO_ID);
$res = $inbox->getData();
$this->assertEmpty($res);
@@ -254,13 +185,13 @@ class InboxTest extends TestCase
$inbox = new Inbox();
$inbox->setUserUid($user->USR_UID);
$inbox->setUserId($user->USR_ID);
$inbox->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$inbox->setOrderByColumn('APP_NUMBER');
$inbox->setOrderDirection('DESC');
$res = $inbox->getData();
// This asserts the order is for APP_NUMBER from highest to lowest
$this->assertLessThan($res[0]['APP_NUMBER'], $res[1]['APP_NUMBER']);
$inbox->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$inbox->setOrderByColumn('APP_NUMBER');
$inbox->setOrderDirection('ASC');
$res = $inbox->getData();
// This asserts the order is for APP_NUMBER from highest to lowest
@@ -552,7 +483,7 @@ class InboxTest extends TestCase
$inbox = new Inbox();
$inbox->setUserUid($user->USR_UID);
$inbox->setUserId($user->USR_ID);
$inbox->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$inbox->setOrderByColumn('APP_NUMBER');
$inbox->setOffset(5);
$inbox->setLimit(2);
$res = $inbox->getData();

View File

@@ -60,7 +60,7 @@ class ParticipatedTest extends TestCase
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
@@ -86,7 +86,7 @@ class ParticipatedTest extends TestCase
// Set the process ID
$participated->setProcessId($cases->PRO_ID);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
@@ -116,7 +116,7 @@ class ParticipatedTest extends TestCase
// Set the category
$participated->setCategoryUid($process['PRO_CATEGORY']);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
@@ -142,7 +142,7 @@ class ParticipatedTest extends TestCase
// Set the case status
$participated->setCaseStatus('TO_DO');
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
@@ -168,7 +168,7 @@ class ParticipatedTest extends TestCase
// Set the filter STARTED
$participated->setParticipatedStatus('STARTED');
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
@@ -194,7 +194,7 @@ class ParticipatedTest extends TestCase
// Set the filter COMPLETED
$participated->setParticipatedStatus('COMPLETED');
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned

View File

@@ -470,7 +470,7 @@ class PausedTest extends TestCase
$paused->setUserId($user->USR_ID);
//Set OrderBYColumn value
$paused->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$paused->setOrderByColumn('APP_NUMBER');
//Set Order Direction value
$paused->setOrderDirection('DESC');
@@ -598,7 +598,7 @@ class PausedTest extends TestCase
$paused->setUserId($user->USR_ID);
//Set OrderBYColumn value
$paused->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$paused->setOrderByColumn('APP_NUMBER');
//Set offset and limit values
$paused->setOffset(0);

View File

@@ -1,128 +0,0 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\BusinessModel\Cases\Reassign;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Reassign
*/
class ReassignTest extends TestCase
{
use DatabaseTransactions;
/**
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getData()
* @test
*/
public function it_should_test_get_data_method_without_filters()
{
$cases = 25;
factory(Delegation::class, $cases)->states('foreign_keys')->create();
//Create new Reassign object
$reassign = new Reassign();
//Set OrderBYColumn value
$reassign->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
//Call to getData method
$res = $reassign->getData();
//This assert that the expected numbers of results are returned
$this->assertEquals($cases, count($res));
}
/**
* It tests the getData method with user filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getData()
* @test
*/
public function it_should_test_get_data_method_with_user_filter()
{
// Create user
$user = factory(User::class)->create();
// Create delegation related to the specific user
factory(Delegation::class)->states('foreign_keys')->create([
'USR_ID' => $user->USR_ID,
'USR_UID' => $user->USR_UID,
]);
// Create other delegations
$cases = 5;
factory(Delegation::class, $cases)->states('foreign_keys')->create();
//Create new Reassign object
$reassign = new Reassign();
//Set the user UID
$reassign->setUserUid($user->USR_UID);
//Set the user ID
$reassign->setUserId($user->USR_ID);
//Set OrderBYColumn value
$reassign->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
//Call to getData method
$res = $reassign->getData();
//This assert that the expected numbers of results are returned
$this->assertEquals(1, count($res));
}
/**
* It tests the getData method with process filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getData()
* @test
*/
public function it_should_test_get_data_method_with_process_filter()
{
// Create user
$process = factory(Process::class)->create();
// Create delegation related to the specific user
factory(Delegation::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
]);
// Create other delegations
$cases = 5;
factory(Delegation::class, $cases)->states('foreign_keys')->create();
//Create new Reassign object
$reassign = new Reassign();
//Set the process
$reassign->setProcessId($process->PRO_ID);
$reassign->setProcessUid($process->PRO_UID);
//Set OrderBYColumn value
$reassign->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
//Call to getData method
$res = $reassign->getData();
//This assert that the expected numbers of results are returned
$this->assertEquals(1, count($res));
}
/**
* It tests the getCounter method
*
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getCounter()
* @test
*/
public function it_should_test_the_counter_for_reassign()
{
// Create user
$user = factory(User::class)->create();
$cases = 25;
factory(Delegation::class, $cases)->states('foreign_keys')->create([
'USR_ID' => $user->USR_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the Inbox object
$reassign = new Reassign();
//Set the user UID
$reassign->setUserUid($user->USR_UID);
//Set the user ID
$reassign->setUserId($user->USR_ID);
$res = $reassign->getCounter();
//Assert the result of getCounter method
$this->assertEquals($cases, $res);
}
}

View File

@@ -70,7 +70,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setCaseNumber($cases[0]->APP_NUMBER);
// Set order by column value
$search->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
@@ -88,9 +88,9 @@ class SearchTest extends TestCase
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setPriority($cases[0]->DEL_PRIORITY);
$search->setPriority('N');
// Set order by column value
$search->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
@@ -110,7 +110,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setProcessId($cases[0]->PRO_ID);
// Set order by column value
$search->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
@@ -130,7 +130,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setTaskId($cases[0]->TAS_ID);
// Set order by column value
$search->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
@@ -150,7 +150,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setUserId($cases[0]->USR_ID);
// Set order by column value
$search->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
@@ -169,7 +169,7 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
// Set order by column value
$search->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$search->setOrderByColumn('APP_NUMBER');
$total = $search->getCounter();
$this->assertEquals(count($cases), $total);
}

View File

@@ -510,7 +510,7 @@ class UnassignedTest extends TestCase
// Get first page
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$unassigned->setOrderByColumn('APP_NUMBER');
$unassigned->setOrderDirection('DESC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
@@ -600,7 +600,7 @@ class UnassignedTest extends TestCase
// Get first page
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$unassigned->setOrderByColumn('APP_NUMBER');
$unassigned->setOrderDirection('DESC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
@@ -688,7 +688,7 @@ class UnassignedTest extends TestCase
// Get first page
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$unassigned->setOrderByColumn('APP_NUMBER');
$unassigned->setOrderDirection('DESC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
@@ -787,7 +787,7 @@ class UnassignedTest extends TestCase
// Get first page
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$unassigned->setOrderByColumn('APP_NUMBER');
$unassigned->setOrderDirection('DESC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
@@ -856,7 +856,7 @@ class UnassignedTest extends TestCase
// Get first page, the minor case id
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
$unassigned->setOrderByColumn('APP_NUMBER');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
@@ -1207,7 +1207,7 @@ class UnassignedTest extends TestCase
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$dateToFilter = date('Y-m-d', strtotime('+1 year'));
$unassigned->setNewestThan($dateToFilter);
$unassigned->setDelegateFrom($dateToFilter);
$unassigned->setOrderByColumn('DEL_DELEGATE_DATE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
@@ -1216,7 +1216,7 @@ class UnassignedTest extends TestCase
$results = $unassigned->getData();
$this->assertGreaterThan($results[0]['DEL_DELEGATE_DATE'], $results[1]['DEL_DELEGATE_DATE']);
// Get the newest than (>=) delegate date
$unassigned->setNewestThan($dateToFilter);
$unassigned->setDelegateFrom($dateToFilter);
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertLessThan($results[0]['DEL_DELEGATE_DATE'], $results[1]['DEL_DELEGATE_DATE']);
@@ -1265,7 +1265,7 @@ class UnassignedTest extends TestCase
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$dateToFilter = date('Y-m-d', strtotime('+1 year'));
$unassigned->setOldestThan($dateToFilter);
$unassigned->setDelegateTo($dateToFilter);
$unassigned->setOrderByColumn('DEL_DELEGATE_DATE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
@@ -1329,66 +1329,6 @@ class UnassignedTest extends TestCase
$this->assertEquals($application->APP_UID, $results[0]['APP_UID']);
}
/**
* This ensures searching specific cases and review the page in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_search_self_service_user_assigned_specific_cases_uid_array()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class)->create([
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setCasesUids([$application->APP_UID]);
$unassigned->setOrderByColumn('APP_DELEGATION.APP_UID');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get the specific cases uid's
$results = $unassigned->getData();
$this->assertCount(1, $results);
// Get the specific cases uid's
$unassigned->setCasesUids([$application->APP_UID]);
$results = $unassigned->getData();
$this->assertEquals($application->APP_UID, $results[0]['APP_UID']);
// Get the specific cases uid's
$unassigned->setCasesUids([$application->APP_UID]);
$results = $unassigned->getData();
$this->assertEquals($application->APP_UID, $results[0]['APP_UID']);
}
/**
* This ensures searching specific process and review the page in self-service-user-assigned
*

View File

@@ -81,7 +81,7 @@ class DelegationTest extends TestCase
public function it_return_scope_case_in_progress()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->caseInProgress()->get());
$this->assertCount(1, $table->joinApplication()->caseInProgress()->get());
}
/**
@@ -97,7 +97,7 @@ class DelegationTest extends TestCase
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$this->assertCount(1, $table->caseCompleted()->get());
$this->assertCount(1, $table->joinApplication()->caseCompleted()->get());
}
/**
@@ -121,7 +121,7 @@ class DelegationTest extends TestCase
public function it_return_scope_delegate_date_to()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->delegateDateFrom($table->DEL_DELEGATE_DATE)->get());
$this->assertCount(1, $table->delegateDateTo($table->DEL_DELEGATE_DATE)->get());
}
/**

View File

@@ -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();
}

View File

@@ -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) {

View File

@@ -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;
}
}

View File

@@ -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;
});

View File

@@ -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

View File

@@ -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

View File

@@ -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 [];
}
}
/**

View File

@@ -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

View File

@@ -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;
}

File diff suppressed because it is too large Load Diff