PMCORE-3092
This commit is contained in:
@@ -9,7 +9,7 @@ use Faker\Generator as Faker;
|
|||||||
$factory->define(\ProcessMaker\Model\ProcessCategory::class, function (Faker $faker) {
|
$factory->define(\ProcessMaker\Model\ProcessCategory::class, function (Faker $faker) {
|
||||||
return [
|
return [
|
||||||
'CATEGORY_UID' => G::generateUniqueID(),
|
'CATEGORY_UID' => G::generateUniqueID(),
|
||||||
'CATEGORY_ID' => $faker->randomNumber(8),
|
'CATEGORY_ID' => $faker->unique()->numberBetween(1000),
|
||||||
'CATEGORY_PARENT' => '',
|
'CATEGORY_PARENT' => '',
|
||||||
'CATEGORY_NAME' => $faker->sentence(5),
|
'CATEGORY_NAME' => $faker->sentence(5),
|
||||||
'CATEGORY_ICON' => '',
|
'CATEGORY_ICON' => '',
|
||||||
|
|||||||
@@ -630,7 +630,6 @@ class CasesTest extends TestCase
|
|||||||
|
|
||||||
// Asserts the emails of both users are contained in the result
|
// Asserts the emails of both users are contained in the result
|
||||||
$this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]);
|
$this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]);
|
||||||
$this->assertRegExp("/{$user2->USR_EMAIL}/", $result["to"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -735,7 +734,6 @@ class CasesTest extends TestCase
|
|||||||
|
|
||||||
// Asserts the emails of both users are contained in the result
|
// Asserts the emails of both users are contained in the result
|
||||||
$this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]);
|
$this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]);
|
||||||
$this->assertRegExp("/{$user2->USR_EMAIL}/", $result["to"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ class AbstractCasesTest extends TestCase
|
|||||||
// Incorrect canceled status
|
// Incorrect canceled status
|
||||||
$absCases->setCaseStatus('CANCELLED');
|
$absCases->setCaseStatus('CANCELLED');
|
||||||
$actual = $absCases->getCaseStatus();
|
$actual = $absCases->getCaseStatus();
|
||||||
$this->assertEquals($index, $actual);
|
$this->assertEquals(4, $actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -378,6 +378,6 @@ class CasesTest extends TestCase
|
|||||||
self::assertCount(1, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'TO_DO'));
|
self::assertCount(1, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'TO_DO'));
|
||||||
|
|
||||||
// Get DynaForms assigned as steps for the second task when the application status is COMPLETED
|
// Get DynaForms assigned as steps for the second task when the application status is COMPLETED
|
||||||
self::assertCount(2, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'COMPLETED'));
|
self::assertCount(1, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'COMPLETED'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use ProcessMaker\Model\AppThread;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AppThreadTest
|
||||||
|
*
|
||||||
|
* @coversDefaultClass \ProcessMaker\Model\AppThread
|
||||||
|
*/
|
||||||
|
class AppThreadTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up function.
|
||||||
|
*/
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeAppUid
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\AppThread::scopeAppUid()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_app_uid()
|
||||||
|
{
|
||||||
|
$table = factory(AppThread::class)->create();
|
||||||
|
$this->assertCount(1, $table->appUid($table->APP_UID)->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeIndex
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\AppThread::scopeIndex()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_index()
|
||||||
|
{
|
||||||
|
$table = factory(AppThread::class)->create();
|
||||||
|
$this->assertCount(1, $table->index($table->DEL_INDEX)->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test getThread
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\AppThread::getThread()
|
||||||
|
* @covers \ProcessMaker\Model\AppThread::scopeAppUid()
|
||||||
|
* @covers \ProcessMaker\Model\AppThread::scopeIndex()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_thread()
|
||||||
|
{
|
||||||
|
$table = factory(AppThread::class)->create();
|
||||||
|
$result = AppThread::getThread($table->APP_UID, $table->DEL_INDEX);
|
||||||
|
$this->assertNotEmpty($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -87,6 +87,11 @@ class ApplicationTest extends TestCase
|
|||||||
{
|
{
|
||||||
$table = factory(Application::class)->states('foreign_keys')->create();
|
$table = factory(Application::class)->states('foreign_keys')->create();
|
||||||
$usrId = User::getId($table->APP_INIT_USER);
|
$usrId = User::getId($table->APP_INIT_USER);
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'APP_UID' => $table->APP_UID,
|
||||||
|
'APP_NUMBER' => $table->APP_NUMBER,
|
||||||
|
'USR_ID' => $usrId,
|
||||||
|
]);
|
||||||
$this->assertCount(1, $table->joinDelegation()->userId($usrId)->get());
|
$this->assertCount(1, $table->joinDelegation()->userId($usrId)->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,6 +167,20 @@ class ApplicationTest extends TestCase
|
|||||||
$this->assertCount(1, $table->rangeOfCases([$table->APP_NUMBER.'-'.$table->APP_NUMBER])->get());
|
$this->assertCount(1, $table->rangeOfCases([$table->APP_NUMBER.'-'.$table->APP_NUMBER])->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeCasesOrRangeOfCases
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Application::scopeCasesOrRangeOfCases()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_cases_or_range_of_cases()
|
||||||
|
{
|
||||||
|
$table = factory(Application::class)->states('foreign_keys')->create();
|
||||||
|
$cases = [$table->APP_NUMBER];
|
||||||
|
$rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER];
|
||||||
|
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test scopeCasesFrom
|
* This test scopeCasesFrom
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -139,6 +139,29 @@ class DelegationTest extends TestCase
|
|||||||
$this->assertCount(1, $table->threadOpen()->get());
|
$this->assertCount(1, $table->threadOpen()->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeThreadPause
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeThreadPause()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_thread_pause()
|
||||||
|
{
|
||||||
|
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||||
|
$this->assertCount(0, $table->threadPause()->get());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This test scopeOpenAndPause
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeOpenAndPause()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_thread_open_and_pause()
|
||||||
|
{
|
||||||
|
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||||
|
$this->assertCount(1, $table->openAndPause()->get());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test scopeCaseStarted
|
* This test scopeCaseStarted
|
||||||
*
|
*
|
||||||
@@ -661,8 +684,11 @@ class DelegationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_return_scope_process_in_list()
|
public function it_return_scope_process_in_list()
|
||||||
{
|
{
|
||||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
$process = factory(Process::class)->create();
|
||||||
$this->assertCount(1, $table->processInList([$table->PRO_ID])->get());
|
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'PRO_ID' => $process->PRO_ID
|
||||||
|
]);
|
||||||
|
$this->assertCount(1, $table->joinProcess()->processInList([$table->PRO_ID])->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -677,6 +703,21 @@ class DelegationTest extends TestCase
|
|||||||
$this->assertCount(1, $table->participated($table->USR_ID)->get());
|
$this->assertCount(1, $table->participated($table->USR_ID)->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test scopeCategoryId
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Delegation::scopeCategoryId()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_return_scope_category()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'PRO_ID' => $process->PRO_ID
|
||||||
|
]);
|
||||||
|
$this->assertCount(1, $table->joinProcess()->categoryId($process->CATEGORY_ID)->get());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test scopeJoinCategoryProcess
|
* This test scopeJoinCategoryProcess
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ use ProcessMaker\Cases\CasesTrait;
|
|||||||
use ProcessMaker\ChangeLog\ChangeLog;
|
use ProcessMaker\ChangeLog\ChangeLog;
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
|
use ProcessMaker\Model\AppDelay as Delay;
|
||||||
|
use ProcessMaker\Model\AppThread as Thread;
|
||||||
use ProcessMaker\Model\Delegation;
|
use ProcessMaker\Model\Delegation;
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
use ProcessMaker\Util\DateTime;
|
use ProcessMaker\Util\DateTime;
|
||||||
|
|
||||||
@@ -1913,6 +1916,7 @@ class Cases
|
|||||||
$data = [];
|
$data = [];
|
||||||
foreach ($rowObj as $appDel) {
|
foreach ($rowObj as $appDel) {
|
||||||
$appDel->setDelThreadStatus('CLOSED');
|
$appDel->setDelThreadStatus('CLOSED');
|
||||||
|
$appDel->setDelThreadStatusId(Delegation::$thread_status['CLOSED']);
|
||||||
$appDel->setDelFinishDate('now');
|
$appDel->setDelFinishDate('now');
|
||||||
if ($appDel->Validate()) {
|
if ($appDel->Validate()) {
|
||||||
$appDel->Save();
|
$appDel->Save();
|
||||||
@@ -1952,11 +1956,13 @@ class Cases
|
|||||||
*
|
*
|
||||||
* @param string $appUid
|
* @param string $appUid
|
||||||
* @param string $delIndex
|
* @param string $delIndex
|
||||||
|
* @param string $status
|
||||||
|
* @param int $statusId
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function CloseCurrentDelegation($appUid, $delIndex)
|
public function CloseCurrentDelegation($appUid, $delIndex, string $status = 'CLOSED', int $statusId = 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$criteria = new Criteria();
|
$criteria = new Criteria();
|
||||||
@@ -1965,7 +1971,8 @@ class Cases
|
|||||||
$rowObj = AppDelegationPeer::doSelect($criteria);
|
$rowObj = AppDelegationPeer::doSelect($criteria);
|
||||||
$user = '';
|
$user = '';
|
||||||
foreach ($rowObj as $appDel) {
|
foreach ($rowObj as $appDel) {
|
||||||
$appDel->setDelThreadStatus('CLOSED');
|
$appDel->setDelThreadStatus($status);
|
||||||
|
$appDel->setDelThreadStatusId($statusId);
|
||||||
$appDel->setDelFinishDate('now');
|
$appDel->setDelFinishDate('now');
|
||||||
$user = $appDel->getUsrUid();
|
$user = $appDel->getUsrUid();
|
||||||
if ($appDel->Validate()) {
|
if ($appDel->Validate()) {
|
||||||
@@ -2019,6 +2026,7 @@ class Cases
|
|||||||
$rowObj = AppDelegationPeer::doSelect($c);
|
$rowObj = AppDelegationPeer::doSelect($c);
|
||||||
foreach ($rowObj as $appDel) {
|
foreach ($rowObj as $appDel) {
|
||||||
$appDel->setDelThreadStatus('OPEN');
|
$appDel->setDelThreadStatus('OPEN');
|
||||||
|
$appDel->setDelThreadStatusId(Delegation::$thread_status['OPEN']);
|
||||||
$appDel->setDelFinishDate(null);
|
$appDel->setDelFinishDate(null);
|
||||||
if ($appDel->Validate()) {
|
if ($appDel->Validate()) {
|
||||||
$appDel->Save();
|
$appDel->Save();
|
||||||
@@ -4097,77 +4105,75 @@ class Cases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pause a Case
|
* Pause a Case
|
||||||
|
*
|
||||||
|
* @param string $appUid
|
||||||
|
* @param int $index
|
||||||
|
* @param string $usrUid
|
||||||
|
* @param string $unpauseDate
|
||||||
|
* @param string $appTitle
|
||||||
*
|
*
|
||||||
* @name pauseCase
|
|
||||||
* @param string $sApplicationUID
|
|
||||||
* @param string $iDelegation
|
|
||||||
* @param string $sUserUID
|
|
||||||
* @param string $sUnpauseDate
|
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function pauseCase($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate = null, $appTitle = null)
|
public function pauseCase($appUid, $index, $usrUid, $unpauseDate = null, $appTitle = null)
|
||||||
{
|
{
|
||||||
// Check if the case is unassigned
|
$application = new Application();
|
||||||
if ($this->isUnassignedPauseCase($sApplicationUID, $iDelegation)) {
|
$fields = $application->Load($appUid);
|
||||||
throw new Exception(G::LoadTranslation("ID_CASE_NOT_PAUSED", array(G::LoadTranslation("ID_UNASSIGNED_STATUS"))));
|
$appNumber = $application->getAppNumber();
|
||||||
}
|
// Get the index of appThread
|
||||||
|
$appThread = Thread::getThread($appUid, $index);
|
||||||
$oApplication = new Application();
|
$appThread = head($appThread);
|
||||||
$aFields = $oApplication->Load($sApplicationUID);
|
$threadIndex = $appThread['APP_THREAD_INDEX'];
|
||||||
//get the appthread row id ( APP_THREAD_INDEX' )
|
if (empty($threadIndex)) {
|
||||||
$oCriteria = new Criteria('workflow');
|
|
||||||
$oCriteria->clearSelectColumns();
|
|
||||||
$oCriteria->addSelectColumn(AppThreadPeer::APP_THREAD_INDEX);
|
|
||||||
$oCriteria->add(AppThreadPeer::APP_UID, $sApplicationUID);
|
|
||||||
$oCriteria->add(AppThreadPeer::DEL_INDEX, $iDelegation);
|
|
||||||
$oDataset = AppThreadPeer::doSelectRS($oCriteria);
|
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
|
|
||||||
if ($oDataset->next()) {
|
|
||||||
$aRow = $oDataset->getRow();
|
|
||||||
} else {
|
|
||||||
throw new Exception(G::LoadTranslation("ID_CASE_STOPPED_TRIGGER"));
|
throw new Exception(G::LoadTranslation("ID_CASE_STOPPED_TRIGGER"));
|
||||||
}
|
}
|
||||||
|
/** Close the index for pause */
|
||||||
|
$this->CloseCurrentDelegation($appUid, $index, 'PAUSED', Delegation::$thread_status['PAUSED']);
|
||||||
|
|
||||||
$this->CloseCurrentDelegation($sApplicationUID, $iDelegation);
|
// Prepare the data for pause
|
||||||
//now create a row in APP_DELAY with type PAUSE
|
$attributes = [
|
||||||
$aData['PRO_UID'] = $aFields['PRO_UID'];
|
'APP_DELAY_UID' => G::generateUniqueID(),
|
||||||
$aData['APP_UID'] = $sApplicationUID;
|
'PRO_UID' => $application->getProUid(),
|
||||||
$aData['APP_THREAD_INDEX'] = $aRow['APP_THREAD_INDEX'];
|
'PRO_ID' => $application->getProId(),
|
||||||
$aData['APP_DEL_INDEX'] = $iDelegation;
|
'APP_UID' => $appUid,
|
||||||
$aData['APP_TYPE'] = 'PAUSE';
|
'APP_NUMBER' => $appNumber,
|
||||||
$aData['APP_STATUS'] = $aFields['APP_STATUS'];
|
'APP_THREAD_INDEX' => $threadIndex,
|
||||||
$aData['APP_DELEGATION_USER'] = $sUserUID;
|
'APP_DEL_INDEX' => $index,
|
||||||
$aData['APP_ENABLE_ACTION_USER'] = $sUserUID;
|
'APP_TYPE' => 'PAUSE',
|
||||||
$aData['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
|
'APP_STATUS' => $application->getAppStatus(),
|
||||||
$aData['APP_DISABLE_ACTION_DATE'] = $sUnpauseDate;
|
'APP_DELEGATION_USER' => $usrUid,
|
||||||
$aData['APP_NUMBER'] = $oApplication->getAppNumber();
|
'APP_DELEGATION_USER_ID' => User::getId($usrUid),
|
||||||
$oAppDelay = new AppDelay();
|
'APP_ENABLE_ACTION_USER' => $usrUid,
|
||||||
$oAppDelay->create($aData);
|
'APP_ENABLE_ACTION_DATE' => date('Y-m-d H:i:s'),
|
||||||
|
'APP_DISABLE_ACTION_DATE' => $unpauseDate,
|
||||||
|
];
|
||||||
|
|
||||||
$oApplication->update($aFields);
|
/** Register the pause case */
|
||||||
|
Delay::create($attributes);
|
||||||
|
|
||||||
//update searchindex
|
/** Update the application case */
|
||||||
|
$application->update($fields);
|
||||||
|
|
||||||
|
/** Update search index */
|
||||||
if ($this->appSolr != null) {
|
if ($this->appSolr != null) {
|
||||||
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
|
$this->appSolr->updateApplicationSearchIndex($appUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getExecuteTriggerProcess($sApplicationUID, 'PAUSED');
|
/** Execute the trigger */
|
||||||
|
$this->getExecuteTriggerProcess($appUid, 'PAUSED');
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
$threadTitle = Delegation::getDeltitle($aData['APP_NUMBER'], $aData['APP_DEL_INDEX']);
|
$threadTitle = Delegation::getDeltitle($appNumber, $index);
|
||||||
$data = array(
|
$data = [
|
||||||
'APP_UID' => $sApplicationUID,
|
'APP_UID' => $appUid,
|
||||||
'DEL_INDEX' => $iDelegation,
|
'DEL_INDEX' => $index,
|
||||||
'USR_UID' => $sUserUID,
|
'USR_UID' => $usrUid,
|
||||||
'APP_RESTART_DATE' => $sUnpauseDate,
|
'APP_RESTART_DATE' => $unpauseDate,
|
||||||
'APP_TITLE' => $threadTitle,
|
'APP_TITLE' => $threadTitle,
|
||||||
);
|
];
|
||||||
$data = array_merge($aFields, $data);
|
$data = array_merge($fields, $data);
|
||||||
|
$listPaused = new ListPaused();
|
||||||
$oListPaused = new ListPaused();
|
$listPaused->create($data);
|
||||||
$oListPaused->create($data);
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1482,6 +1482,7 @@ class Derivation
|
|||||||
// Update the DelThreadStatus, the thread is ready for continue
|
// Update the DelThreadStatus, the thread is ready for continue
|
||||||
$appDelegation = AppDelegationPeer::retrieveByPK($newCase['APPLICATION'], $newCase['INDEX']);
|
$appDelegation = AppDelegationPeer::retrieveByPK($newCase['APPLICATION'], $newCase['INDEX']);
|
||||||
$appDelegation->setDelThreadStatus('OPEN');
|
$appDelegation->setDelThreadStatus('OPEN');
|
||||||
|
$appDelegation->setDelThreadStatusId(Delegation::$thread_status['OPEN']);
|
||||||
$appDelegation->save();
|
$appDelegation->save();
|
||||||
|
|
||||||
// Create record in table APP_ASSIGN_SELF_SERVICE_VALUE
|
// Create record in table APP_ASSIGN_SELF_SERVICE_VALUE
|
||||||
|
|||||||
@@ -4147,6 +4147,22 @@ class WorkspaceTools
|
|||||||
WHERE AD.TAS_ID = 0");
|
WHERE AD.TAS_ID = 0");
|
||||||
$con->commit();
|
$con->commit();
|
||||||
|
|
||||||
|
// Populating APP_DELEGATION.DEL_THREAD_STATUS_ID with paused threads
|
||||||
|
CLI::logging("-> Populating APP_DELEGATION.DEL_THREAD_STATUS_ID \n");
|
||||||
|
$con->begin();
|
||||||
|
$stmt = $con->createStatement();
|
||||||
|
$rs = $stmt->executeQuery("UPDATE APP_DELEGATION AS AD
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT APP_DELAY.APP_NUMBER, APP_DELAY.APP_DEL_INDEX
|
||||||
|
FROM APP_DELAY
|
||||||
|
WHERE APP_TYPE = 'PAUSE' AND APP_DELAY.APP_DISABLE_ACTION_USER = '0'
|
||||||
|
) AS DELAY
|
||||||
|
ON (AD.APP_NUMBER = DELAY.APP_NUMBER AND AD.DEL_INDEX = DELAY.APP_DEL_INDEX)
|
||||||
|
SET AD.DEL_THREAD_STATUS_ID = 3,
|
||||||
|
AD.DEL_THREAD_STATUS = 'PAUSED'
|
||||||
|
WHERE AD.DEL_THREAD_STATUS_ID = 0");
|
||||||
|
$con->commit();
|
||||||
|
|
||||||
// Populating APPLICATION.APP_STATUS_ID
|
// Populating APPLICATION.APP_STATUS_ID
|
||||||
CLI::logging("-> Populating APPLICATION.APP_STATUS_ID \n");
|
CLI::logging("-> Populating APPLICATION.APP_STATUS_ID \n");
|
||||||
$con->begin();
|
$con->begin();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use ProcessMaker\Model\Delegation;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,6 +196,7 @@ class AppDelegation extends BaseAppDelegation
|
|||||||
$this->setDelPriority(($iPriority != '' ? $iPriority : '3'));
|
$this->setDelPriority(($iPriority != '' ? $iPriority : '3'));
|
||||||
$this->setDelThread($sAppThread);
|
$this->setDelThread($sAppThread);
|
||||||
$this->setDelThreadStatus($theadStatus);
|
$this->setDelThreadStatus($theadStatus);
|
||||||
|
$this->setDelThreadStatusId(Delegation::$thread_status[$theadStatus]);
|
||||||
$this->setDelDelegateDate('now');
|
$this->setDelDelegateDate('now');
|
||||||
$this->setAppNumber($appNumber);
|
$this->setAppNumber($appNumber);
|
||||||
$this->setTasId($taskId);
|
$this->setTasId($taskId);
|
||||||
|
|||||||
@@ -881,7 +881,7 @@ class Cases
|
|||||||
public function participation($usrUid, $caseNumber, $index)
|
public function participation($usrUid, $caseNumber, $index)
|
||||||
{
|
{
|
||||||
$userId = User::getId($usrUid);
|
$userId = User::getId($usrUid);
|
||||||
$query = Delegation::query()->select(['APP_NUMBER'])->case($caseNumber)->index($index)->isThreadOpen();
|
$query = Delegation::query()->select(['APP_NUMBER'])->case($caseNumber)->index($index)->threadOpen();
|
||||||
$query1 = clone $query;
|
$query1 = clone $query;
|
||||||
$result = $query->userId($userId)->limit(1)->get()->values()->toArray();
|
$result = $query->userId($userId)->limit(1)->get()->values()->toArray();
|
||||||
$permission = empty($result) ? false : true;
|
$permission = empty($result) ? false : true;
|
||||||
@@ -1048,6 +1048,11 @@ class Cases
|
|||||||
Validator::isDate($date, 'Y-m-d', '$unpaused_date');
|
Validator::isDate($date, 'Y-m-d', '$unpaused_date');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the case is unassigned
|
||||||
|
if ($this->isUnassignedPauseCase($appUid, $index)) {
|
||||||
|
throw new Exception(G::LoadTranslation("ID_CASE_NOT_PAUSED", [G::LoadTranslation("ID_UNASSIGNED_STATUS")]));
|
||||||
|
}
|
||||||
|
|
||||||
/** Pause case */
|
/** Pause case */
|
||||||
$case->pauseCase($appUid, $index, $usrUid, $date . ' ' . $time);
|
$case->pauseCase($appUid, $index, $usrUid, $date . ' ' . $time);
|
||||||
|
|
||||||
|
|||||||
@@ -1262,6 +1262,9 @@ class AbstractCases implements CasesInterface
|
|||||||
if ($thread['APP_STATUS'] === 'DRAFT') {
|
if ($thread['APP_STATUS'] === 'DRAFT') {
|
||||||
$status = 'DRAFT';
|
$status = 'DRAFT';
|
||||||
}
|
}
|
||||||
|
if (isset($thread['DEL_THREAD_STATUS']) && $thread['DEL_THREAD_STATUS'] === 'PAUSED') {
|
||||||
|
$status = 'PAUSED';
|
||||||
|
}
|
||||||
if ($thread['APP_STATUS'] === 'COMPLETED') {
|
if ($thread['APP_STATUS'] === 'COMPLETED') {
|
||||||
$finishDate = !empty($thread['APP_FINISH_DATE']) ? $thread['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
$finishDate = !empty($thread['APP_FINISH_DATE']) ? $thread['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||||
$dateToCompare = $finishDate;
|
$dateToCompare = $finishDate;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class Participated extends AbstractCases
|
|||||||
switch ($item['APP_STATUS']) {
|
switch ($item['APP_STATUS']) {
|
||||||
case 'TO_DO':
|
case 'TO_DO':
|
||||||
// Get the pending task
|
// Get the pending task
|
||||||
$taskPending = Delegation::getPendingThreads($item['APP_NUMBER']);
|
$taskPending = Delegation::getPendingThreads($item['APP_NUMBER'], false);
|
||||||
foreach ($taskPending as $thread) {
|
foreach ($taskPending as $thread) {
|
||||||
$thread['APP_STATUS'] = $item['APP_STATUS'];
|
$thread['APP_STATUS'] = $item['APP_STATUS'];
|
||||||
// Get the thread information
|
// Get the thread information
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class Supervising extends AbstractCases
|
|||||||
// Only cases in to_do
|
// Only cases in to_do
|
||||||
$query->caseTodo();
|
$query->caseTodo();
|
||||||
// Only open threads
|
// Only open threads
|
||||||
$query->isThreadOpen();
|
$query->threadOpen();
|
||||||
// For parallel threads the distinct by APP_NUMBER is important
|
// For parallel threads the distinct by APP_NUMBER is important
|
||||||
$query->distinct();
|
$query->distinct();
|
||||||
// Get the list of processes of the supervisor
|
// Get the list of processes of the supervisor
|
||||||
@@ -217,7 +217,7 @@ class Supervising extends AbstractCases
|
|||||||
// Only cases in to_do
|
// Only cases in to_do
|
||||||
$query->caseTodo();
|
$query->caseTodo();
|
||||||
// Only open threads
|
// Only open threads
|
||||||
$query->isThreadOpen();
|
$query->threadOpen();
|
||||||
// For parallel threads the distinct by APP_NUMBER is important
|
// For parallel threads the distinct by APP_NUMBER is important
|
||||||
$query->distinct();
|
$query->distinct();
|
||||||
// Get the list of processes of the supervisor
|
// Get the list of processes of the supervisor
|
||||||
|
|||||||
@@ -8,4 +8,26 @@ class AppDelay extends Model
|
|||||||
{
|
{
|
||||||
protected $table = 'APP_DELAY';
|
protected $table = 'APP_DELAY';
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'APP_DELAY_UID',
|
||||||
|
'PRO_UID',
|
||||||
|
'PRO_ID',
|
||||||
|
'APP_UID',
|
||||||
|
'APP_NUMBER',
|
||||||
|
'APP_THREAD_INDEX',
|
||||||
|
'APP_DEL_INDEX',
|
||||||
|
'APP_TYPE',
|
||||||
|
'APP_STATUS',
|
||||||
|
'APP_DELEGATION_USER',
|
||||||
|
'APP_DELEGATION_USER_ID'.
|
||||||
|
'APP_ENABLE_ACTION_USER',
|
||||||
|
'APP_ENABLE_ACTION_DATE',
|
||||||
|
'APP_DISABLE_ACTION_DATE',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,46 @@ class AppThread extends Model
|
|||||||
protected $table = 'APP_THREAD';
|
protected $table = 'APP_THREAD';
|
||||||
// We do not have create/update timestamps for this table
|
// We do not have create/update timestamps for this table
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope a query to filter a specific case
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param string $appUid
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeAppUid($query, string $appUid)
|
||||||
|
{
|
||||||
|
return $query->where('APP_UID', $appUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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('DEL_INDEX', $index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get thread related to the specific case and index
|
||||||
|
*
|
||||||
|
* @param string $appUid
|
||||||
|
* @param int $index
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getThread(string $appUid, int $index)
|
||||||
|
{
|
||||||
|
$query = AppThread::query()->select(['APP_THREAD_INDEX']);
|
||||||
|
$query->appUid($appUid);
|
||||||
|
$query->index($index);
|
||||||
|
$results = $query->get()->toArray();
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +374,7 @@ class Application extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information related to the created case
|
* Get information related to the case, avoiding to load the APP_DATA
|
||||||
*
|
*
|
||||||
* @param string $appUid
|
* @param string $appUid
|
||||||
*
|
*
|
||||||
@@ -382,7 +382,13 @@ class Application extends Model
|
|||||||
*/
|
*/
|
||||||
public static function getCase($appUid)
|
public static function getCase($appUid)
|
||||||
{
|
{
|
||||||
$query = Application::query()->select(['APP_STATUS', 'APP_INIT_USER']);
|
$query = Application::query()->select([
|
||||||
|
'APP_NUMBER',
|
||||||
|
'APP_STATUS',
|
||||||
|
'PRO_UID',
|
||||||
|
'PRO_ID',
|
||||||
|
'APP_INIT_USER'
|
||||||
|
]);
|
||||||
$query->appUid($appUid);
|
$query->appUid($appUid);
|
||||||
$result = $query->get()->toArray();
|
$result = $query->get()->toArray();
|
||||||
$firstElement = head($result);
|
$firstElement = head($result);
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ class Delegation extends Model
|
|||||||
// Static properties to preserve values
|
// Static properties to preserve values
|
||||||
public static $usrUid = '';
|
public static $usrUid = '';
|
||||||
public static $groups = [];
|
public static $groups = [];
|
||||||
|
// Status name and status id
|
||||||
|
public static $thread_status = ['CLOSED' => 0, 'OPEN' => 1, 'PAUSED' => 3];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the application this delegation belongs to
|
* Returns the application this delegation belongs to
|
||||||
@@ -92,6 +94,34 @@ class Delegation extends Model
|
|||||||
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope a query to only include pause threads
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeThreadPause($query)
|
||||||
|
{
|
||||||
|
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS_ID', '=', 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope a query to only include open and pause threads
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeOpenAndPause($query)
|
||||||
|
{
|
||||||
|
$query->where(function ($query) {
|
||||||
|
$query->threadOpen();
|
||||||
|
$query->orWhere(function ($query) {
|
||||||
|
$query->threadPause();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope to use when the case is IN_PROGRESS like DRAFT or TO_DO
|
* Scope to use when the case is IN_PROGRESS like DRAFT or TO_DO
|
||||||
*
|
*
|
||||||
@@ -101,7 +131,7 @@ class Delegation extends Model
|
|||||||
*/
|
*/
|
||||||
public function scopeCasesInProgress($query, array $ids)
|
public function scopeCasesInProgress($query, array $ids)
|
||||||
{
|
{
|
||||||
$query->isThreadOpen()->statusIds($ids);
|
$query->threadOpen()->statusIds($ids);
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@@ -546,17 +576,6 @@ class Delegation extends Model
|
|||||||
return $query->where('APP_DELEGATION.APP_UID', '=', $appUid);
|
return $query->where('APP_DELEGATION.APP_UID', '=', $appUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope a query to only include open threads
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
|
||||||
*/
|
|
||||||
public function scopeIsThreadOpen($query)
|
|
||||||
{
|
|
||||||
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope a query to get the last thread
|
* Scope a query to get the last thread
|
||||||
*
|
*
|
||||||
@@ -755,6 +774,19 @@ class Delegation extends Model
|
|||||||
return $query->whereIn('APP_DELEGATION.PRO_ID', $processes);
|
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
|
* Scope the Inbox cases
|
||||||
*
|
*
|
||||||
@@ -853,6 +885,33 @@ class Delegation extends Model
|
|||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope process category id
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param int $category
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeCategoryId($query, int $category)
|
||||||
|
{
|
||||||
|
return $query->where('PROCESS.CATEGORY_ID', $category);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope top ten
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param string $column
|
||||||
|
* @param string $order
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeTopTen($query, $column, $order)
|
||||||
|
{
|
||||||
|
return $query->orderBy($column, $order)->limit(10);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope join with delegation for get the previous index
|
* Scope join with delegation for get the previous index
|
||||||
*
|
*
|
||||||
@@ -1015,49 +1074,6 @@ class Delegation extends Model
|
|||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope process category id
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
||||||
* @param int $category
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
|
||||||
*/
|
|
||||||
public function scopeCategoryId($query, $category)
|
|
||||||
{
|
|
||||||
$query->where('PROCESS.CATEGORY_ID', $category);
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope top ten
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
||||||
* @param string $column
|
|
||||||
* @param string $order
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
|
||||||
*/
|
|
||||||
public function scopeTopTen($query, $column, $order)
|
|
||||||
{
|
|
||||||
$query->orderBy($column, $order)->limit(10);
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope where in processes
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
||||||
* @param array $processes
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
|
||||||
*/
|
|
||||||
public function scopeInProcesses($query, $processes)
|
|
||||||
{
|
|
||||||
$query->whereIn('PROCESS.PRO_ID', $processes);
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get specific cases unassigned that the user can view
|
* Get specific cases unassigned that the user can view
|
||||||
*
|
*
|
||||||
@@ -1562,7 +1578,7 @@ class Delegation extends Model
|
|||||||
// Start the second query
|
// Start the second query
|
||||||
$query2 = Delegation::query()->select($selectedColumns);
|
$query2 = Delegation::query()->select($selectedColumns);
|
||||||
$query2->tasksIn($selfServiceTasks);
|
$query2->tasksIn($selfServiceTasks);
|
||||||
$query2->isThreadOpen();
|
$query2->threadOpen();
|
||||||
$query2->noUserInThread();
|
$query2->noUserInThread();
|
||||||
|
|
||||||
// Add join clause with the previous APP_DELEGATION record if required
|
// Add join clause with the previous APP_DELEGATION record if required
|
||||||
@@ -1856,10 +1872,11 @@ class Delegation extends Model
|
|||||||
* Return the open thread related to the task
|
* Return the open thread related to the task
|
||||||
*
|
*
|
||||||
* @param int $appNumber
|
* @param int $appNumber
|
||||||
|
* @param bool $onlyOpen
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getPendingThreads(int $appNumber)
|
public static function getPendingThreads(int $appNumber, $onlyOpen = true)
|
||||||
{
|
{
|
||||||
$query = Delegation::query()->select([
|
$query = Delegation::query()->select([
|
||||||
'TASK.TAS_UID',
|
'TASK.TAS_UID',
|
||||||
@@ -1869,6 +1886,7 @@ class Delegation extends Model
|
|||||||
'APP_DELEGATION.DEL_INDEX',
|
'APP_DELEGATION.DEL_INDEX',
|
||||||
'APP_DELEGATION.DEL_TITLE',
|
'APP_DELEGATION.DEL_TITLE',
|
||||||
'APP_DELEGATION.USR_ID',
|
'APP_DELEGATION.USR_ID',
|
||||||
|
'APP_DELEGATION.DEL_THREAD_STATUS',
|
||||||
'APP_DELEGATION.DEL_DELEGATE_DATE',
|
'APP_DELEGATION.DEL_DELEGATE_DATE',
|
||||||
'APP_DELEGATION.DEL_FINISH_DATE',
|
'APP_DELEGATION.DEL_FINISH_DATE',
|
||||||
'APP_DELEGATION.DEL_INIT_DATE',
|
'APP_DELEGATION.DEL_INIT_DATE',
|
||||||
@@ -1877,7 +1895,11 @@ class Delegation extends Model
|
|||||||
// Join with task
|
// Join with task
|
||||||
$query->joinTask();
|
$query->joinTask();
|
||||||
// Get the open threads
|
// Get the open threads
|
||||||
|
if ($onlyOpen) {
|
||||||
$query->threadOpen();
|
$query->threadOpen();
|
||||||
|
} else {
|
||||||
|
$query->openAndPause();
|
||||||
|
}
|
||||||
// Related to the specific case number
|
// Related to the specific case number
|
||||||
$query->case($appNumber);
|
$query->case($appNumber);
|
||||||
// Get the results
|
// Get the results
|
||||||
|
|||||||
Reference in New Issue
Block a user