Merged in bugfix/PMCORE-532 (pull request #7266)
PMCORE-532 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
39a5ea27ed
16
database/factories/StepFactory.php
Normal file
16
database/factories/StepFactory.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\Step::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'STEP_UID' => G::generateUniqueID(),
|
||||||
|
'PRO_UID' => G::generateUniqueID(),
|
||||||
|
'TAS_UID' => G::generateUniqueID(),
|
||||||
|
'STEP_TYPE_OBJ' => 'DYNAFORM',
|
||||||
|
'STEP_UID_OBJ' => '0',
|
||||||
|
'STEP_CONDITION' => 'None',
|
||||||
|
'STEP_POSITION' => 0,
|
||||||
|
'STEP_MODE' => 'EDIT'
|
||||||
|
];
|
||||||
|
});
|
||||||
370
tests/unit/workflow/engine/classes/CasesTest.php
Normal file
370
tests/unit/workflow/engine/classes/CasesTest.php
Normal file
@@ -0,0 +1,370 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\engine\classes;
|
||||||
|
|
||||||
|
use Cases;
|
||||||
|
use ProcessMaker\Model\Application;
|
||||||
|
use ProcessMaker\Model\Delegation;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
|
use ProcessMaker\Model\Step;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class CasesTest extends TestCase
|
||||||
|
{
|
||||||
|
protected $preserveGlobalState = false;
|
||||||
|
protected $runTestInSeparateProcess = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call setUp method
|
||||||
|
*/
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp(); // TODO: Change the autogenerated stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test getNextStep method with no steps
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX);
|
||||||
|
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method with step
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_position()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 2,
|
||||||
|
'STEP_CONDITION' => '1 == 1'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method with output document
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_output_document()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 2,
|
||||||
|
'STEP_CONDITION' => '1 == 1',
|
||||||
|
'STEP_TYPE_OBJ' => 'OUTPUT_DOCUMENT'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method with input document
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_input_document()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 2,
|
||||||
|
'STEP_CONDITION' => '1 == 1',
|
||||||
|
'STEP_TYPE_OBJ' => 'INPUT_DOCUMENT'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method with external document
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_external()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 2,
|
||||||
|
'STEP_CONDITION' => '1 == 1',
|
||||||
|
'STEP_TYPE_OBJ' => 'EXTERNAL'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method with message step
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_message()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 2,
|
||||||
|
'STEP_CONDITION' => '1 == 1',
|
||||||
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method when the step does not exist
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_step_does_not_exists()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$this->expectExceptionMessage("**ID_STEP_DOES_NOT_EXIST**");
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method when there is an exception
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_step_exception()
|
||||||
|
{
|
||||||
|
$cases = new Cases();
|
||||||
|
$this->expectExceptionMessage("The Application row '' doesn't exist!");
|
||||||
|
$res = $cases->getNextStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method when the result is false
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_step_false()
|
||||||
|
{
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create();
|
||||||
|
$appDelegation = factory(Delegation::class)->create();
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX);
|
||||||
|
$this->assertFalse($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method when there is a gmail account
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_gmail()
|
||||||
|
{
|
||||||
|
$_SESSION['gmail'] = '';
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 2,
|
||||||
|
'STEP_CONDITION' => '1 == 1',
|
||||||
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method when there is a gmail account related to the next step
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_gmail_nextstep()
|
||||||
|
{
|
||||||
|
$_SESSION['gmail'] = '';
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 1,
|
||||||
|
'STEP_CONDITION' => '1 == 1',
|
||||||
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the getNextStep method when the step condition is empty
|
||||||
|
*
|
||||||
|
* @covers \Cases::getNextStep()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_next_step_method_condition_empty()
|
||||||
|
{
|
||||||
|
$_SESSION['gmail'] = '';
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]);
|
||||||
|
$appDelegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => $appDelegation->DEL_INDEX
|
||||||
|
]);
|
||||||
|
factory(Step::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'TAS_UID' => $appDelegation->TAS_UID,
|
||||||
|
'STEP_POSITION' => 2,
|
||||||
|
'STEP_CONDITION' => '',
|
||||||
|
'STEP_TYPE_OBJ' => 'MESSAGE'
|
||||||
|
]);
|
||||||
|
$cases = new Cases();
|
||||||
|
$res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX, 1);
|
||||||
|
$this->assertCount(4, $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call the tearDown method
|
||||||
|
*/
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
// The parent method needs to be override due to errors appearing
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2288,127 +2288,134 @@ class Cases
|
|||||||
* Get the next step
|
* Get the next step
|
||||||
*
|
*
|
||||||
* @name getNextStep
|
* @name getNextStep
|
||||||
* @param string $sProUid
|
* @param string $proUid
|
||||||
* @param string $sAppUid
|
* @param string $appUid
|
||||||
* @param integer $iDelIndex
|
* @param integer $delIndex
|
||||||
* @param integer $iPosition
|
* @param integer $position
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getNextStep($sProUid = '', $sAppUid = '', $iDelIndex = 0, $iPosition = 0)
|
public function getNextStep($proUid = '', $appUid = '', $delIndex = 0, $position = 0)
|
||||||
{
|
{
|
||||||
$oPMScript = new PMScript();
|
$pmScript = new PMScript();
|
||||||
$oApplication = new Application();
|
$application = new Application();
|
||||||
$aFields = $oApplication->Load($sAppUid);
|
$fields = $application->Load($appUid);
|
||||||
if (!is_array($aFields['APP_DATA'])) {
|
$data = Cases::unserializeData($fields['APP_DATA']);
|
||||||
$aFields['APP_DATA'] = G::array_merges(G::getSystemConstants(), unserialize($aFields['APP_DATA']));
|
unset($data['USER_LOGGED']);
|
||||||
|
unset($data['USR_USERNAME']);
|
||||||
|
|
||||||
|
if (!is_array($fields['APP_DATA'])) {
|
||||||
|
$fields['APP_DATA'] = G::array_merges(G::getSystemConstants(), $data);
|
||||||
}
|
}
|
||||||
$oPMScript->setFields($aFields['APP_DATA']);
|
|
||||||
|
$pmScript->setFields($fields['APP_DATA']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//get the current Delegation, and TaskUID
|
//get the current Delegation, and TaskUID
|
||||||
$c = new Criteria('workflow');
|
$c = new Criteria('workflow');
|
||||||
$c->add(AppDelegationPeer::PRO_UID, $sProUid);
|
$c->add(AppDelegationPeer::PRO_UID, $proUid);
|
||||||
$c->add(AppDelegationPeer::APP_UID, $sAppUid);
|
$c->add(AppDelegationPeer::APP_UID, $appUid);
|
||||||
$c->add(AppDelegationPeer::DEL_INDEX, $iDelIndex);
|
$c->add(AppDelegationPeer::DEL_INDEX, $delIndex);
|
||||||
$aRow = AppDelegationPeer::doSelect($c);
|
$rows = AppDelegationPeer::doSelect($c);
|
||||||
|
|
||||||
if (!isset($aRow[0])) {
|
if (!isset($rows[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sTaskUid = $aRow[0]->getTasUid();
|
$taskUid = $rows[0]->getTasUid();
|
||||||
|
|
||||||
//get max step for this task
|
//get max step for this task
|
||||||
$c = new Criteria();
|
$c = new Criteria();
|
||||||
$c->clearSelectColumns();
|
$c->clearSelectColumns();
|
||||||
$c->addSelectColumn('MAX(' . StepPeer::STEP_POSITION . ')');
|
$c->addSelectColumn('MAX(' . StepPeer::STEP_POSITION . ')');
|
||||||
$c->add(StepPeer::PRO_UID, $sProUid);
|
$c->add(StepPeer::PRO_UID, $proUid);
|
||||||
$c->add(StepPeer::TAS_UID, $sTaskUid);
|
$c->add(StepPeer::TAS_UID, $taskUid);
|
||||||
$rs = StepPeer::doSelectRS($c);
|
$rs = StepPeer::doSelectRS($c);
|
||||||
$rs->next();
|
$rs->next();
|
||||||
$row = $rs->getRow();
|
$row = $rs->getRow();
|
||||||
$iLastStep = intval($row[0]);
|
$lastStep = intval($row[0]);
|
||||||
if ($iPosition != 10000 && $iPosition > $iLastStep) {
|
if ($position != 10000 && $position > $lastStep) {
|
||||||
throw (new Exception(G::LoadTranslation('ID_STEP_DOES_NOT_EXIST', array(G::LoadTranslation('ID_POSITION'), $iPosition))));
|
throw (new Exception(G::LoadTranslation('ID_STEP_DOES_NOT_EXIST',
|
||||||
|
[G::LoadTranslation('ID_POSITION'), $position])));
|
||||||
}
|
}
|
||||||
$iPosition += 1;
|
$position += 1;
|
||||||
$aNextStep = null;
|
$nextStep = null;
|
||||||
if ($iPosition <= $iLastStep) {
|
if ($position <= $lastStep) {
|
||||||
while ($iPosition <= $iLastStep) {
|
while ($position <= $lastStep) {
|
||||||
$bAccessStep = false;
|
$accessStep = false;
|
||||||
//step
|
//step
|
||||||
$oStep = new Step;
|
$step = new Step;
|
||||||
$oStep = $oStep->loadByProcessTaskPosition($sProUid, $sTaskUid, $iPosition);
|
$step = $step->loadByProcessTaskPosition($proUid, $taskUid, $position);
|
||||||
if ($oStep) {
|
if ($step) {
|
||||||
if (trim($oStep->getStepCondition()) !== '') {
|
if (trim($step->getStepCondition()) !== '') {
|
||||||
$oPMScript->setScript($oStep->getStepCondition());
|
$pmScript->setScript($step->getStepCondition());
|
||||||
$oPMScript->setExecutedOn(PMScript::CONDITION);
|
$pmScript->setExecutedOn(PMScript::CONDITION);
|
||||||
$bAccessStep = $oPMScript->evaluate();
|
$accessStep = $pmScript->evaluate();
|
||||||
} else {
|
} else {
|
||||||
$bAccessStep = true;
|
$accessStep = true;
|
||||||
}
|
}
|
||||||
if ($bAccessStep) {
|
if ($accessStep) {
|
||||||
switch ($oStep->getStepTypeObj()) {
|
switch ($step->getStepTypeObj()) {
|
||||||
case 'DYNAFORM':
|
case 'DYNAFORM':
|
||||||
$sAction = 'EDIT';
|
$action = 'EDIT';
|
||||||
break;
|
break;
|
||||||
case 'OUTPUT_DOCUMENT':
|
case 'OUTPUT_DOCUMENT':
|
||||||
$sAction = 'GENERATE';
|
$action = 'GENERATE';
|
||||||
break;
|
break;
|
||||||
case 'INPUT_DOCUMENT':
|
case 'INPUT_DOCUMENT':
|
||||||
$sAction = 'ATTACH';
|
$action = 'ATTACH';
|
||||||
break;
|
break;
|
||||||
case 'EXTERNAL':
|
case 'EXTERNAL':
|
||||||
$sAction = 'EDIT';
|
$action = 'EDIT';
|
||||||
break;
|
break;
|
||||||
case 'MESSAGE':
|
case 'MESSAGE':
|
||||||
$sAction = '';
|
$action = '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (array_key_exists('gmail', $_SESSION) || (array_key_exists('gmail', $_GET) && $_GET['gmail'] == 1)) {
|
if (array_key_exists('gmail', $_SESSION) || (array_key_exists('gmail',
|
||||||
$aNextStep = array(
|
$_GET) && $_GET['gmail'] == 1)) {
|
||||||
'TYPE' => $oStep->getStepTypeObj(),
|
$nextStep = [
|
||||||
'UID' => $oStep->getStepUidObj(),
|
'TYPE' => $step->getStepTypeObj(),
|
||||||
'POSITION' => $oStep->getStepPosition(),
|
'UID' => $step->getStepUidObj(),
|
||||||
'PAGE' => 'cases_Step?TYPE=' . $oStep->getStepTypeObj() . '&UID=' .
|
'POSITION' => $step->getStepPosition(),
|
||||||
$oStep->getStepUidObj() . '&POSITION=' . $oStep->getStepPosition() .
|
'PAGE' => 'cases_Step?TYPE=' . $step->getStepTypeObj() . '&UID=' .
|
||||||
'&ACTION=' . $sAction .
|
$step->getStepUidObj() . '&POSITION=' . $step->getStepPosition() .
|
||||||
|
'&ACTION=' . $action .
|
||||||
'&gmail=1'
|
'&gmail=1'
|
||||||
);
|
];
|
||||||
} else {
|
} else {
|
||||||
$aNextStep = array(
|
$nextStep = [
|
||||||
'TYPE' => $oStep->getStepTypeObj(),
|
'TYPE' => $step->getStepTypeObj(),
|
||||||
'UID' => $oStep->getStepUidObj(),
|
'UID' => $step->getStepUidObj(),
|
||||||
'POSITION' => $oStep->getStepPosition(),
|
'POSITION' => $step->getStepPosition(),
|
||||||
'PAGE' => 'cases_Step?TYPE=' . $oStep->getStepTypeObj() . '&UID=' .
|
'PAGE' => 'cases_Step?TYPE=' . $step->getStepTypeObj() . '&UID=' .
|
||||||
$oStep->getStepUidObj() . '&POSITION=' . $oStep->getStepPosition() .
|
$step->getStepUidObj() . '&POSITION=' . $step->getStepPosition() .
|
||||||
'&ACTION=' . $sAction
|
'&ACTION=' . $action
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
$iPosition = $iLastStep;
|
$position = $lastStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$iPosition += 1;
|
$position += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$aNextStep) {
|
if (!$nextStep) {
|
||||||
if (array_key_exists('gmail', $_SESSION) || (array_key_exists('gmail', $_GET) && $_GET['gmail'] == 1)) {
|
if (array_key_exists('gmail', $_SESSION) || (array_key_exists('gmail', $_GET) && $_GET['gmail'] == 1)) {
|
||||||
$aNextStep = array(
|
$nextStep = [
|
||||||
'TYPE' => 'DERIVATION',
|
'TYPE' => 'DERIVATION',
|
||||||
'UID' => -1,
|
'UID' => -1,
|
||||||
'POSITION' => ($iLastStep + 1),
|
'POSITION' => ($lastStep + 1),
|
||||||
'PAGE' => 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN&gmail=1'
|
'PAGE' => 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN&gmail=1'
|
||||||
);
|
];
|
||||||
} else {
|
} else {
|
||||||
$aNextStep = array(
|
$nextStep = [
|
||||||
'TYPE' => 'DERIVATION',
|
'TYPE' => 'DERIVATION',
|
||||||
'UID' => -1,
|
'UID' => -1,
|
||||||
'POSITION' => ($iLastStep + 1),
|
'POSITION' => ($lastStep + 1),
|
||||||
'PAGE' => 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN'
|
'PAGE' => 'cases_Step?TYPE=ASSIGN_TASK&UID=-1&POSITION=10000&ACTION=ASSIGN'
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $aNextStep;
|
return $nextStep;
|
||||||
} catch (exception $e) {
|
} catch (exception $e) {
|
||||||
throw ($e);
|
throw ($e);
|
||||||
}
|
}
|
||||||
|
|||||||
11
workflow/engine/src/ProcessMaker/Model/Step.php
Normal file
11
workflow/engine/src/ProcessMaker/Model/Step.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Step extends Model
|
||||||
|
{
|
||||||
|
protected $table = "STEP";
|
||||||
|
public $timestamps = false;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user