Merged in bugfix/PMCORE-514 (pull request #8014)
PMCORE-514 Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
@@ -9,8 +9,8 @@ $factory->define(\ProcessMaker\Model\AppDelay::class, function (Faker $faker) {
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'APP_UID' => G::generateUniqueID(),
|
||||
'APP_NUMBER' => $faker->unique()->numberBetween(1000),
|
||||
'APP_THREAD_INDEX' => 1,
|
||||
'APP_DEL_INDEX' => $faker->unique()->numberBetween(10),
|
||||
'APP_THREAD_INDEX' => $faker->unique()->numberBetween(100),
|
||||
'APP_DEL_INDEX' => $faker->unique()->numberBetween(100),
|
||||
'APP_TYPE' => $faker->randomElement($actions),
|
||||
'APP_STATUS' => 'TO_DO',
|
||||
'APP_NEXT_TASK' => 0,
|
||||
@@ -28,56 +28,33 @@ $factory->define(\ProcessMaker\Model\AppDelay::class, function (Faker $faker) {
|
||||
// Create a delegation with the foreign keys
|
||||
$factory->state(\ProcessMaker\Model\AppDelay::class, 'paused_foreign_keys', function (Faker $faker) {
|
||||
// Create values in the foreign key relations
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
||||
$task = factory(\ProcessMaker\Model\Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
$application = factory(\ProcessMaker\Model\Application::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID
|
||||
]);
|
||||
$delegation1 = factory(\ProcessMaker\Model\Delegation::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation = factory(\ProcessMaker\Model\Delegation::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
$delegation1 = factory(\ProcessMaker\Model\Delegation::class)->states('closed')->create();
|
||||
$delegation2 = factory(\ProcessMaker\Model\Delegation::class)->states('foreign_keys')->create([
|
||||
'PRO_UID' => $delegation1->PRO_UID,
|
||||
'PRO_ID' => $delegation1->PRO_ID,
|
||||
'TAS_UID' => $delegation1->TAS_UID,
|
||||
'TAS_ID' => $delegation1->TAS_ID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_UID' => $delegation1->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'USR_UID' => $delegation1->USR_UID,
|
||||
'USR_ID' => $delegation1->USR_ID,
|
||||
'DEL_PREVIOUS' => $delegation1->DEL_INDEX,
|
||||
'DEL_INDEX' => $delegation1->DEL_INDEX++
|
||||
'DEL_INDEX' => $faker->unique()->numberBetween(2000),
|
||||
]);
|
||||
|
||||
// Return with default values
|
||||
return [
|
||||
'APP_DELAY_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'PRO_UID' => $delegation2->PRO_UID,
|
||||
'PRO_ID' => $delegation2->PRO_ID,
|
||||
'APP_UID' => $delegation2->APP_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_TYPE' => 'PAUSE',
|
||||
'APP_STATUS' => $application->APP_STATUS,
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'APP_DELEGATION_USER_ID' => $user->USR_ID,
|
||||
'APP_STATUS' => 'TO_DO',
|
||||
'APP_DELEGATION_USER' => $delegation2->USR_UID,
|
||||
'APP_DELEGATION_USER_ID' => $delegation2->USR_ID,
|
||||
'APP_ENABLE_ACTION_USER' => G::generateUniqueID(),
|
||||
'APP_ENABLE_ACTION_DATE' => $faker->dateTime(),
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
|
||||
@@ -69,7 +69,7 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
|
||||
return [
|
||||
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_INDEX' => $faker->unique()->numberBetween(2000),
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
@@ -176,7 +176,17 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'closed', function (Faker
|
||||
|
||||
// Create a last delegation
|
||||
$factory->state(\ProcessMaker\Model\Delegation::class, 'last_thread', function (Faker $faker) {
|
||||
|
||||
return [
|
||||
'DEL_LAST_INDEX' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
// Create a first delegation
|
||||
$factory->state(\ProcessMaker\Model\Delegation::class, 'first_thread', function (Faker $faker) {
|
||||
|
||||
return [
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -354,6 +354,7 @@ class DraftTest extends TestCase
|
||||
* It tests the getCountersByProcesses() method with the category filter
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByProcesses()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCountersByProcesses()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_counters_by_processes_method_category()
|
||||
@@ -643,6 +644,7 @@ class DraftTest extends TestCase
|
||||
* It tests the getCountersByRange() method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByRange()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCountersByProcesses()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_counters_by_range_method()
|
||||
|
||||
@@ -199,6 +199,7 @@ class InboxTest extends TestCase
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeTask()
|
||||
* @test
|
||||
*/
|
||||
public function it_filter_by_task()
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace ProcessMaker\BusinessModel;
|
||||
use Exception;
|
||||
use G;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Documents;
|
||||
@@ -380,4 +381,45 @@ class CasesTest extends TestCase
|
||||
// Get DynaForms assigned as steps for the second task when the application status is COMPLETED
|
||||
self::assertCount(1, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'COMPLETED'));
|
||||
}
|
||||
|
||||
/**
|
||||
* It test the case info used in the PMFCaseLink
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getStatusInfo()
|
||||
* @covers \ProcessMaker\Model\AppDelay::getPaused()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_case_status_info()
|
||||
{
|
||||
// Get status info when the case is PAUSED
|
||||
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
|
||||
$cases = new Cases();
|
||||
$result = $cases->getStatusInfo($table->APP_UID, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER);
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertArrayHasKey('APP_STATUS', $result);
|
||||
$this->assertArrayHasKey('DEL_INDEX', $result);
|
||||
$this->assertArrayHasKey('PRO_UID', $result);
|
||||
// Get status info when the case is UNASSIGNED
|
||||
// Get status info when the case is TO_DO
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$cases = new Cases();
|
||||
$result = $cases->getStatusInfo($table->APP_UID, $table->DEL_INDEX, $table->USR_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertArrayHasKey('APP_STATUS', $result);
|
||||
$this->assertArrayHasKey('DEL_INDEX', $result);
|
||||
$this->assertArrayHasKey('PRO_UID', $result);
|
||||
// Get status info when the case is COMPLETED
|
||||
$table = factory(Application::class)->states('completed')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $table->APP_NUMBER,
|
||||
'APP_UID' => $table->APP_UID,
|
||||
]);
|
||||
$cases = new Cases();
|
||||
$result = $cases->getStatusInfo($table->APP_UID, $table->DEL_INDEX, $table->USR_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertArrayHasKey('APP_STATUS', $result);
|
||||
$this->assertArrayHasKey('DEL_INDEX', $result);
|
||||
$this->assertArrayHasKey('PRO_UID', $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AppDelayTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\Model\AppDelay
|
||||
*/
|
||||
class AppDelayTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Set up function.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
AppDelay::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeType
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeType()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_type()
|
||||
{
|
||||
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
|
||||
$this->assertCount(1, $table->type('PAUSE')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeNotDisabled
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeNotDisabled()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_not_action_disable()
|
||||
{
|
||||
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
|
||||
$this->assertCount(1, $table->notDisabled()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeCase
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_case()
|
||||
{
|
||||
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
|
||||
$this->assertCount(1, $table->case($table->APP_NUMBER)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeIndex
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeIndex()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_index()
|
||||
{
|
||||
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
|
||||
$this->assertCount(1, $table->index($table->APP_DEL_INDEX)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeDelegateUser
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeDelegateUser()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_delegate_user()
|
||||
{
|
||||
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
|
||||
$this->assertCount(1, $table->delegateUser($table->APP_DELEGATION_USER)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test getPaused
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppDelay::getPaused()
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeCase()
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeIndex()
|
||||
* @covers \ProcessMaker\Model\AppDelay::scopeDelegateUser()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_paused_threads()
|
||||
{
|
||||
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
|
||||
$result = AppDelay::getPaused($table->APP_NUMBER, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ class DelegationTest extends TestCase
|
||||
*/
|
||||
public function it_return_scope_case_started()
|
||||
{
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$table = factory(Delegation::class)->states('first_thread')->create();
|
||||
$this->assertCount(1, $table->caseStarted($table->DEL_INDEX)->get());
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ class DelegationTest extends TestCase
|
||||
{
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$cases = [$table->APP_NUMBER];
|
||||
$rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER];
|
||||
$rangeCases = [$table->APP_NUMBER . '-' . $table->APP_NUMBER];
|
||||
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
|
||||
}
|
||||
|
||||
@@ -2150,6 +2150,8 @@ class DelegationTest extends TestCase
|
||||
//Review the self-service records
|
||||
$result = Delegation::getSelfService($user->USR_UID);
|
||||
$this->assertEquals(25, count($result));
|
||||
$result = Delegation::getSelfService($user->USR_UID, ['APP_DELEGATION.APP_NUMBER', 'APP_DELEGATION.DEL_INDEX'], null, null,null, null, null, 0, 15);
|
||||
$this->assertEquals(15, count($result));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3369,7 +3371,7 @@ class DelegationTest extends TestCase
|
||||
*/
|
||||
public function it_get_cases_started_by_specific_user()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$delegation = factory(Delegation::class)->states('first_thread')->create();
|
||||
$result = Delegation::casesStartedBy($delegation->USR_ID);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ use ProcessMaker\BusinessModel\User as BmUser;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Exception\UploadException;
|
||||
use ProcessMaker\Exception\CaseNoteUploadFile;
|
||||
use ProcessMaker\Model\AppDelay as Delay;
|
||||
use ProcessMaker\Model\Application as ModelApplication;
|
||||
use ProcessMaker\Model\AppNotes as Notes;
|
||||
use ProcessMaker\Model\AppTimeoutAction;
|
||||
@@ -2456,33 +2457,25 @@ class Cases
|
||||
/**
|
||||
* This function get the status information
|
||||
*
|
||||
* @param object $rsCriteria
|
||||
* @param array $result
|
||||
* @param string $status
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getStatusInfoDataByRsCriteria($rsCriteria)
|
||||
private function getStatusInfoFormatted(array $result, string $status = '')
|
||||
{
|
||||
try {
|
||||
$arrayData = [];
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$record = $rsCriteria->getRow();
|
||||
|
||||
$arrayData = [
|
||||
'APP_STATUS' => $record['APP_STATUS'],
|
||||
'DEL_INDEX' => [],
|
||||
'PRO_UID' => $record['PRO_UID']
|
||||
];
|
||||
$record = head($result);
|
||||
$arrayData = [
|
||||
'APP_STATUS' => empty($status) ? $record['APP_STATUS'] : $status,
|
||||
'DEL_INDEX' => [],
|
||||
'PRO_UID' => $record['PRO_UID']
|
||||
];
|
||||
$arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
|
||||
foreach ($result as $record) {
|
||||
$arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$record = $rsCriteria->getRow();
|
||||
|
||||
$arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayData;
|
||||
} catch (Exception $e) {
|
||||
@@ -2493,8 +2486,8 @@ class Cases
|
||||
/**
|
||||
* Get status info Case
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param int $delIndex Delegation index
|
||||
* @param string $appUid Unique id of Case
|
||||
* @param int $index Delegation index
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* @return array Return an array with status info Case, array empty otherwise
|
||||
@@ -2502,179 +2495,120 @@ class Cases
|
||||
*
|
||||
* @see workflow/engine/methods/cases/main_init.php
|
||||
* @see workflow/engine/methods/cases/opencase.php
|
||||
* @see ProcessMaker\BusinessModel\Cases->setCaseVariables()
|
||||
* @see ProcessMaker\BusinessModel\Cases\InputDocument->getCasesInputDocuments()
|
||||
* @see ProcessMaker\BusinessModel\Cases\InputDocument->throwExceptionIfHaventPermissionToDelete()
|
||||
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfCaseNotIsInInbox()
|
||||
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfHaventPermissionToDelete()
|
||||
* @see \ProcessMaker\BusinessModel\Cases::setCaseVariables()
|
||||
* @see \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocuments()
|
||||
* @see \ProcessMaker\BusinessModel\Cases\InputDocument::throwExceptionIfHaventPermissionToDelete()
|
||||
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::throwExceptionIfCaseNotIsInInbox()
|
||||
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument::throwExceptionIfHaventPermissionToDelete()
|
||||
*/
|
||||
public function getStatusInfo($applicationUid, $delIndex = 0, $userUid = "")
|
||||
public function getStatusInfo(string $appUid, int $index = 0, string $userUid = "")
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$this->throwExceptionIfNotExistsCase($applicationUid, $delIndex,
|
||||
$this->getFieldNameByFormatFieldName("APP_UID"));
|
||||
|
||||
//Get data
|
||||
//Status is PAUSED
|
||||
$delimiter = DBAdapter::getStringDelimiter();
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->setDistinct();
|
||||
$criteria->addSelectColumn($delimiter . 'PAUSED' . $delimiter . ' AS APP_STATUS');
|
||||
$criteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX . " AS DEL_INDEX");
|
||||
$criteria->addSelectColumn(AppDelayPeer::PRO_UID);
|
||||
|
||||
$criteria->add(AppDelayPeer::APP_UID, $applicationUid, Criteria::EQUAL);
|
||||
$criteria->add(AppDelayPeer::APP_TYPE, "PAUSE", Criteria::EQUAL);
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->addOr(
|
||||
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL))
|
||||
);
|
||||
|
||||
if ($delIndex != 0) {
|
||||
$criteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex, Criteria::EQUAL);
|
||||
$arrayData = [];
|
||||
// Verify data
|
||||
$this->throwExceptionIfNotExistsCase($appUid, $index, $this->getFieldNameByFormatFieldName("APP_UID"));
|
||||
// Get the case number
|
||||
$caseNumber = ModelApplication::getCaseNumber($appUid);
|
||||
// Status is PAUSED
|
||||
$result = Delay::getPaused($caseNumber, $index, $userUid);
|
||||
if (!empty($result)) {
|
||||
$arrayData = $this->getStatusInfoFormatted($result, 'PAUSED');
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
if ($userUid != "") {
|
||||
$criteria->add(AppDelayPeer::APP_DELEGATION_USER, $userUid, Criteria::EQUAL);
|
||||
// Status is UNASSIGNED
|
||||
$query = Delegation::query()->select([
|
||||
'APP_DELEGATION.APP_NUMBER',
|
||||
'APP_DELEGATION.DEL_INDEX',
|
||||
'APP_DELEGATION.PRO_UID'
|
||||
]);
|
||||
$query->taskAssignType('SELF_SERVICE');
|
||||
$query->threadOpen()->withoutUserId();
|
||||
// Filter specific user
|
||||
if (!empty($userUid)) {
|
||||
$delegation = new Delegation();
|
||||
$delegation->casesUnassigned($query, $userUid);
|
||||
}
|
||||
// Filter specific case
|
||||
$query->case($caseNumber);
|
||||
// Filter specific index
|
||||
if (is_int($index)) {
|
||||
$query->index($index);
|
||||
}
|
||||
$results = $query->get();
|
||||
$arrayData = $results->values()->toArray();
|
||||
if (!empty($arrayData)) {
|
||||
$arrayData = $this->getStatusInfoFormatted($arrayData, 'UNASSIGNED');
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
$rsCriteria = AppDelayPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
// Status is TO_DO, DRAFT
|
||||
$query = Delegation::query()->select([
|
||||
'APPLICATION.APP_STATUS',
|
||||
'APP_DELEGATION.APP_NUMBER',
|
||||
'APP_DELEGATION.DEL_INDEX',
|
||||
'APP_DELEGATION.PRO_UID'
|
||||
]);
|
||||
$query->joinApplication();
|
||||
// Filter the status TO_DO and DRAFT
|
||||
$query->casesInProgress([1, 2]);
|
||||
// Filter the OPEN thread
|
||||
$query->threadOpen();
|
||||
// Filter specific case
|
||||
$query->case($caseNumber);
|
||||
// Filter specific index
|
||||
if ($index > 0) {
|
||||
$query->index($index);
|
||||
}
|
||||
// Filter specific user
|
||||
if (!empty($userUid)) {
|
||||
$userId = !empty($userUid) ? User::getId($userUid) : 0;
|
||||
$query->userId($userId);
|
||||
}
|
||||
$results = $query->get();
|
||||
$arrayData = $results->values()->toArray();
|
||||
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
if (!empty($arrayData)) {
|
||||
$arrayData = $this->getStatusInfoFormatted($arrayData);
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
// Status is CANCELLED, COMPLETED
|
||||
$query = Delegation::query()->select([
|
||||
'APPLICATION.APP_STATUS',
|
||||
'APP_DELEGATION.APP_NUMBER',
|
||||
'APP_DELEGATION.DEL_INDEX',
|
||||
'APP_DELEGATION.PRO_UID'
|
||||
]);
|
||||
$query->joinApplication();
|
||||
// Filter the status COMPLETED and CANCELLED
|
||||
$query->casesDone([3, 4]);
|
||||
// Filter specific case
|
||||
$query->case($caseNumber);
|
||||
// Filter specific index
|
||||
if ($index > 0) {
|
||||
$query->index($index);
|
||||
}
|
||||
// Filter specific user
|
||||
if (!empty($userUid)) {
|
||||
$userId = !empty($userUid) ? User::getId($userUid) : 0;
|
||||
$query->userId($userId);
|
||||
}
|
||||
$query->lastThread();
|
||||
$results = $query->get();
|
||||
$arrayData = $results->values()->toArray();
|
||||
if (!empty($arrayData)) {
|
||||
$arrayData = $this->getStatusInfoFormatted($arrayData);
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
// Status is PARTICIPATED
|
||||
$arrayData = Delegation::getParticipatedInfo($appUid);
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
//Status is UNASSIGNED
|
||||
if ($userUid != '') {
|
||||
$appCacheView = new AppCacheView();
|
||||
|
||||
$criteria = $appCacheView->getUnassignedListCriteria($userUid);
|
||||
} else {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, '', Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->setDistinct();
|
||||
$criteria->clearSelectColumns();
|
||||
$criteria->addSelectColumn($delimiter . 'UNASSIGNED' . $delimiter . ' AS APP_STATUS');
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
|
||||
|
||||
$criteria->add(AppCacheViewPeer::APP_UID, $applicationUid, Criteria::EQUAL);
|
||||
|
||||
if ($delIndex != 0) {
|
||||
$criteria->add(AppCacheViewPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
//Status is TO_DO, DRAFT
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->setDistinct();
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(ApplicationPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(
|
||||
ApplicationPeer::APP_UID,
|
||||
$delimiter . $applicationUid . $delimiter,
|
||||
Criteria::EQUAL
|
||||
);
|
||||
$criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
|
||||
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(ApplicationPeer::APP_STATUS, "TO_DO", Criteria::EQUAL)->addAnd(
|
||||
$criteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL))->addAnd(
|
||||
$criteria->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))
|
||||
)->addOr(
|
||||
$criteria->getNewCriterion(ApplicationPeer::APP_STATUS, "DRAFT", Criteria::EQUAL)->addAnd(
|
||||
$criteria->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))
|
||||
);
|
||||
|
||||
if ($delIndex != 0) {
|
||||
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
if ($userUid != "") {
|
||||
$criteria->add(AppDelegationPeer::USR_UID, $userUid, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$rsCriteria = ApplicationPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
//Status is CANCELLED, COMPLETED
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(ApplicationPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
|
||||
$arrayCondition[] = array(
|
||||
ApplicationPeer::APP_UID,
|
||||
$delimiter . $applicationUid . $delimiter,
|
||||
Criteria::EQUAL
|
||||
);
|
||||
$criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
|
||||
|
||||
if ($delIndex != 0) {
|
||||
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
if ($userUid != "") {
|
||||
$criteria->add(AppDelegationPeer::USR_UID, $userUid, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria2 = clone $criteria;
|
||||
|
||||
$criteria2->setDistinct();
|
||||
|
||||
$criteria2->add(ApplicationPeer::APP_STATUS, ['CANCELLED', 'COMPLETED'], Criteria::IN);
|
||||
$criteria2->add(AppDelegationPeer::DEL_LAST_INDEX, 1, Criteria::EQUAL);
|
||||
|
||||
$rsCriteria2 = ApplicationPeer::doSelectRS($criteria2);
|
||||
$rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria2);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
//Status is PARTICIPATED
|
||||
$arrayData = Delegation::getParticipatedInfo($applicationUid);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
//Return
|
||||
return array();
|
||||
return $arrayData;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -1492,8 +1492,7 @@ class AbstractCases implements CasesInterface
|
||||
|
||||
/**
|
||||
* Count how many cases has each process
|
||||
*
|
||||
* @param string $list
|
||||
*
|
||||
* @param int $category
|
||||
* @param bool $topTen
|
||||
* @param array $processes
|
||||
@@ -1528,7 +1527,7 @@ class AbstractCases implements CasesInterface
|
||||
$query->topTen('TOTAL', 'DESC');
|
||||
}
|
||||
if (!empty($processes)) {
|
||||
$query->inProcesses($processes);
|
||||
$query->processInList($processes);
|
||||
}
|
||||
return $query->get()->values()->toArray();
|
||||
}
|
||||
@@ -1574,7 +1573,7 @@ class AbstractCases implements CasesInterface
|
||||
}
|
||||
$query->joinProcess();
|
||||
if (!is_null($processId)) {
|
||||
$query->inProcesses([$processId]);
|
||||
$query->processInList([$processId]);
|
||||
}
|
||||
if (!is_null($dateFrom)) {
|
||||
$query->where('APP_DELEGATION.DEL_DELEGATE_DATE', '>=', $dateFrom);
|
||||
|
||||
@@ -30,4 +30,94 @@ class AppDelay extends Model
|
||||
'APP_ENABLE_ACTION_DATE',
|
||||
'APP_DISABLE_ACTION_DATE',
|
||||
];
|
||||
|
||||
/**
|
||||
* Scope a query to filter a specific type
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $type
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeType($query, string $type = 'PAUSE')
|
||||
{
|
||||
return $query->where('APP_DELAY.APP_TYPE', $type);
|
||||
}
|
||||
/**
|
||||
* Scope a query to filter a specific disable action
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeNotDisabled($query)
|
||||
{
|
||||
return $query->where('APP_DELAY.APP_DISABLE_ACTION_USER', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter a specific case
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $appNumber
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCase($query, int $appNumber)
|
||||
{
|
||||
return $query->where('APP_DELAY.APP_NUMBER', $appNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter a specific index
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $index
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeIndex($query, int $index)
|
||||
{
|
||||
return $query->where('APP_DELAY.APP_DEL_INDEX', $index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter a specific user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $user
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeDelegateUser($query, string $user)
|
||||
{
|
||||
return $query->where('APP_DELAY.APP_DELEGATION_USER', $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thread paused
|
||||
*
|
||||
* @param int $appNumber
|
||||
* @param int $index
|
||||
* @param string $userUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPaused(int $appNumber, int $index, string $userUid = '')
|
||||
{
|
||||
$query = AppDelay::query()->select([
|
||||
'APP_NUMBER',
|
||||
'APP_DEL_INDEX AS DEL_INDEX',
|
||||
'PRO_UID'
|
||||
]);
|
||||
$query->type('PAUSE')->notDisabled();
|
||||
$query->case($appNumber);
|
||||
// Filter specific index
|
||||
if ($index > 0) {
|
||||
$query->index($index);
|
||||
}
|
||||
// Filter specific delegate user
|
||||
if (!empty($userUid)) {
|
||||
$query->delegateUser($userUid);
|
||||
}
|
||||
// Get the result
|
||||
$results = $query->get();
|
||||
|
||||
return $results->values()->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,18 +173,6 @@ class Delegation extends Model
|
||||
return $query->where('DEL_INDEX', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the in-progress
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCaseInProgress($query)
|
||||
{
|
||||
return $query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the to_do cases
|
||||
*
|
||||
@@ -777,19 +765,6 @@ class Delegation extends Model
|
||||
return $query->whereIn('APP_DELEGATION.PRO_ID', $processes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope where in processes
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $processes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeInProcesses($query, array $processes)
|
||||
{
|
||||
return $query->whereIn('PROCESS.PRO_ID', $processes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Inbox cases
|
||||
*
|
||||
@@ -812,26 +787,6 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Inbox cases
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeInboxWithoutUser($query)
|
||||
{
|
||||
// This scope is for the join with the APP_DELEGATION table
|
||||
$query->joinApplication();
|
||||
$query->status(Application::STATUS_TODO);
|
||||
// Scope for the restriction of the task that must not be searched for
|
||||
$query->excludeTaskTypes(Task::DUMMY_TASKS);
|
||||
// Scope that establish that the DEL_THREAD_STATUS must be OPEN
|
||||
$query->threadOpen();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a self service cases
|
||||
*
|
||||
@@ -1417,7 +1372,7 @@ class Delegation extends Model
|
||||
* @param string $appUid
|
||||
* @return array
|
||||
*
|
||||
* @see \ProcessMaker\BusinessModel\Cases:getStatusInfo()
|
||||
* @see \ProcessMaker\BusinessModel\Cases::getStatusInfo()
|
||||
*/
|
||||
public static function getParticipatedInfo($appUid)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user