PMCORE-540

This commit is contained in:
Paula Quispe
2020-02-17 14:09:54 -04:00
parent 8851292713
commit 4280cdfe37
3 changed files with 124 additions and 17 deletions

View File

@@ -1,20 +1,27 @@
<?php
/**
* Route case
*/
use ProcessMaker\Model\Application as ModelApplication;
class Derivation
{
var $case;
protected $appCurrentUser;
protected $arraySiblings;
protected $aSP;
protected $context;
protected $flagControl;
protected $flagControlMulInstance;
protected $sys;
protected $context;
protected $flagUpdateList;
protected $iNewDelIndex;
protected $regexpTaskTypeToInclude;
protected $removeList;
protected $sys;
public $node;
public $userLogged = null;
protected $flagUpdateList;
protected $removeList;
protected $aSP;
protected $iNewDelIndex;
protected $arraySiblings;
public function __construct()
{
@@ -888,7 +895,10 @@ class Derivation
$aContext['appUid'] = $currentDelegation['APP_UID'];
$aContext['delIndex'] = $currentDelegation['DEL_INDEX'];
// Remove the fields that will update with the thread creation
unset($appFields['APP_ROUTING_DATA']);
$this->appCurrentUser = $appFields['APP_CUR_USER'];
unset($appFields['APP_CUR_USER']);
//We close the current derivation, then we'll try to derivate to each defined route
$this->case->CloseCurrentDelegation( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );
@@ -1237,6 +1247,7 @@ class Derivation
$nextDel['DEL_PRIORITY'] = 3;
}
$newDelegationUser = '';
switch ($nextDel['TAS_ASSIGN_TYPE']) {
case 'CANCEL_MI':
case 'STATIC_MI':
@@ -1266,12 +1277,14 @@ class Derivation
$row = $criteriaMultiR->getRow();
$delPrevious = $row['DEL_PREVIOUS'];
}
// Get the user that will create the new case
$newDelegationUser = $this->verifyCurrentUserInTask($nextDel, $aSP);
// Create new delegation
$iNewDelIndex = $this->case->newAppDelegation(
$appFields['PRO_UID'],
$currentDelegation['APP_UID'],
$nextDel['TAS_UID'],
$this->verifyCurrentUserInTask($nextDel, $aSP),
$newDelegationUser,
$currentDelegation['DEL_INDEX'],
$nextDel['DEL_PRIORITY'],
$delType,
@@ -1297,10 +1310,15 @@ class Derivation
}
}
$application = new Application();
$result = $application->update(['APP_UID' => $currentDelegation['APP_UID'], 'APP_ROUTING_DATA' => serialize($arrayRoutingData)]);
/** Update the table application */
$applicationFields = [
'APP_ROUTING_DATA' => $arrayRoutingData,
'APP_CUR_USER' => $newDelegationUser
];
$colUpdated = ModelApplication::updateColumns($currentDelegation['APP_UID'], $applicationFields);
$appFields['APP_CUR_USER'] = !empty($colUpdated['APP_CUR_USER']) ? $colUpdated['APP_CUR_USER'] : $this->appCurrentUser;
//We updated the information relate to APP_THREAD
// We updated the information relate to APP_THREAD
$iAppThreadIndex = $appFields['DEL_THREAD'];
$isUpdatedThread = false;
if (isset($currentDelegation['ROUTE_TYPES']) && sizeof($currentDelegation['ROUTE_TYPES']) > 1) {