HOR-1504 "Almacenar la info de la(s) siguiente(s) derivaciones..." SOLVED
Issue:
Almacenar la info de la(s) siguiente(s) derivaciones, solo cuando sea necesario (asignacion manual)
Cause:
Nuevo requerimiento de funciones
Solution:
Se a implementado esta nueva funcionalidad
This commit is contained in:
@@ -803,6 +803,47 @@ class Derivation
|
||||
/*----------------------------------********---------------------------------*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Get valid origin Task
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param int $delIndex Delegation index
|
||||
*
|
||||
* @return string Returns valid origin Task
|
||||
*/
|
||||
private function __getTaskUidOrigin($applicationUid, $delIndex)
|
||||
{
|
||||
$taskUidOrigin = '';
|
||||
|
||||
do {
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_TYPE);
|
||||
|
||||
$criteria->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::INNER_JOIN);
|
||||
$criteria->add(AppDelegationPeer::APP_UID, $applicationUid, Criteria::EQUAL);
|
||||
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = AppDelegationPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$record = $rsCriteria->getRow();
|
||||
|
||||
if (preg_match('/^(?:' . 'NORMAL|SCRIPT\-TASK|WEBENTRYEVENT|START\-MESSAGE\-EVENT|START\-TIMER\-EVENT' . ')$/', $record['TAS_TYPE'])) {
|
||||
$taskUidOrigin = $record['TAS_UID'];
|
||||
}
|
||||
|
||||
$delIndex = $record['DEL_PREVIOUS'];
|
||||
}
|
||||
} while ($taskUidOrigin == '');
|
||||
|
||||
//Return
|
||||
return $taskUidOrigin;
|
||||
}
|
||||
|
||||
/** Derivate
|
||||
*
|
||||
* @param array $currentDelegation
|
||||
@@ -828,6 +869,8 @@ class Derivation
|
||||
//Get data for this DEL_INDEX current
|
||||
$appFields = $this->case->loadCase( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );
|
||||
|
||||
unset($appFields['APP_ROUTING_DATA']);
|
||||
|
||||
//We close the current derivation, then we'll try to derivate to each defined route
|
||||
$this->case->CloseCurrentDelegation( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );
|
||||
|
||||
@@ -1043,6 +1086,7 @@ class Derivation
|
||||
break;
|
||||
default:
|
||||
$iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);
|
||||
|
||||
if($iNewDelIndex !== 0){
|
||||
$arrayDerivationResult[] = ['DEL_INDEX' => $iNewDelIndex, 'TAS_UID' => $nextDel['TAS_UID'], 'USR_UID' => (isset($nextDel['USR_UID']))? $nextDel['USR_UID'] : ''];
|
||||
}
|
||||
@@ -1091,15 +1135,22 @@ class Derivation
|
||||
foreach ($arrayTaskNextDelNextDelegations as $key2 => $value2) {
|
||||
$arrayTaskNextDelNextDel = $value2;
|
||||
|
||||
if($arrayTaskNextDelNextDel["NEXT_TASK"]["TAS_ASSIGN_TYPE"] == 'MULTIPLE_INSTANCE'){
|
||||
$aUserAssigned = true;
|
||||
if(!isset($arrayTaskNextDelNextDel["NEXT_TASK"]["USER_ASSIGNED"]["0"]["USR_UID"])){
|
||||
throw new Exception(G::LoadTranslation("ID_NO_USERS"));
|
||||
}
|
||||
} else {
|
||||
if (!isset($arrayTaskNextDelNextDel["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"])) {
|
||||
throw new Exception(G::LoadTranslation("ID_NO_USERS"));
|
||||
}
|
||||
switch ($arrayTaskNextDelNextDel['NEXT_TASK']['TAS_ASSIGN_TYPE']) {
|
||||
case 'MANUAL':
|
||||
$arrayTaskNextDelNextDel['NEXT_TASK']['USER_ASSIGNED']['USR_UID'] = '';
|
||||
break;
|
||||
case 'MULTIPLE_INSTANCE':
|
||||
if (!isset($arrayTaskNextDelNextDel['NEXT_TASK']['USER_ASSIGNED']['0']['USR_UID'])) {
|
||||
throw new Exception(G::LoadTranslation('ID_NO_USERS'));
|
||||
}
|
||||
|
||||
$arrayTaskNextDelNextDel['NEXT_TASK']['USER_ASSIGNED']['USR_UID'] = '';
|
||||
break;
|
||||
default:
|
||||
if (!isset($arrayTaskNextDelNextDel['NEXT_TASK']['USER_ASSIGNED']['USR_UID'])) {
|
||||
throw new Exception(G::LoadTranslation('ID_NO_USERS'));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$rouPreType = "";
|
||||
@@ -1110,6 +1161,7 @@ class Derivation
|
||||
$rouPreType = $arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TYPE"];
|
||||
$rouPreTask = $arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TASK"];
|
||||
}
|
||||
|
||||
$nextDelegationsAux[++$i] = array(
|
||||
"TAS_UID" => $arrayTaskNextDelNextDel["NEXT_TASK"]["TAS_UID"],
|
||||
"USR_UID" => $arrayTaskNextDelNextDel["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"],
|
||||
@@ -1217,15 +1269,39 @@ class Derivation
|
||||
|
||||
function doDerivation ($currentDelegation, $nextDel, $appFields, $aSP = null)
|
||||
{
|
||||
$case = new \ProcessMaker\BusinessModel\Cases();
|
||||
$arrayApplicationData = $case->getApplicationRecordByPk($currentDelegation['APP_UID'], [], false);
|
||||
|
||||
$arrayRoutingData = (!is_null($arrayApplicationData['APP_ROUTING_DATA']) && $arrayApplicationData['APP_ROUTING_DATA'] != '')? unserialize($arrayApplicationData['APP_ROUTING_DATA']) : [];
|
||||
|
||||
$iAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
$delType = 'NORMAL';
|
||||
$sendNotificationsMobile = false;
|
||||
|
||||
$taskNextDel = TaskPeer::retrieveByPK($nextDel["TAS_UID"]);
|
||||
|
||||
$taskUidOrigin = $this->__getTaskUidOrigin($currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX']);
|
||||
$taskUidDest = $taskNextDel->getTasUid();
|
||||
|
||||
if (array_key_exists($taskUidOrigin . '/' . $taskUidDest, $arrayRoutingData)) {
|
||||
$nextDel['USR_UID'] = $arrayRoutingData[$taskUidOrigin . '/' . $taskUidDest]['USR_UID'];
|
||||
|
||||
unset($arrayRoutingData[$taskUidOrigin . '/' . $taskUidDest]);
|
||||
}
|
||||
|
||||
if ($taskNextDel->getTasType() == 'NORMAL' &&
|
||||
$taskNextDel->getTasAssignType() != 'SELF_SERVICE' &&
|
||||
(is_null($nextDel['USR_UID']) || $nextDel['USR_UID'] == '')
|
||||
) {
|
||||
throw new Exception(G::LoadTranslation('ID_NO_USERS'));
|
||||
}
|
||||
|
||||
if (is_numeric( $nextDel['DEL_PRIORITY'] )) {
|
||||
$nextDel['DEL_PRIORITY'] = (isset( $nextDel['DEL_PRIORITY'] ) ? ($nextDel['DEL_PRIORITY'] >= 1 && $nextDel['DEL_PRIORITY'] <= 5 ? $nextDel['DEL_PRIORITY'] : '3') : '3');
|
||||
} else {
|
||||
$nextDel['DEL_PRIORITY'] = 3;
|
||||
}
|
||||
|
||||
switch ($nextDel['TAS_ASSIGN_TYPE']) {
|
||||
case 'CANCEL_MI':
|
||||
case 'STATIC_MI':
|
||||
@@ -1267,6 +1343,20 @@ class Derivation
|
||||
break;
|
||||
}
|
||||
|
||||
if (array_key_exists('NEXT_ROUTING', $nextDel) && is_array($nextDel['NEXT_ROUTING']) && !empty($nextDel['NEXT_ROUTING'])) {
|
||||
if (array_key_exists('TAS_UID', $nextDel['NEXT_ROUTING'])) {
|
||||
$arrayRoutingData[$currentDelegation['TAS_UID'] . '/' . $nextDel['NEXT_ROUTING']['TAS_UID']] = $nextDel['NEXT_ROUTING'];
|
||||
} else {
|
||||
foreach ($nextDel['NEXT_ROUTING'] as $value) {
|
||||
$arrayRoutingData[$currentDelegation['TAS_UID'] . '/' . $value['TAS_UID']] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$application = new Application();
|
||||
$result = $application->update(['APP_UID' => $currentDelegation['APP_UID'], 'APP_ROUTING_DATA' => serialize($arrayRoutingData)]);
|
||||
|
||||
//APP_THREAD
|
||||
$iAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
|
||||
switch ($currentDelegation['ROU_TYPE']) {
|
||||
|
||||
Reference in New Issue
Block a user