HOR-358 "Create a PMFunction to get next derivation info" SOLVED

Issue:
    Create a PMFunction to get next derivation info
Cause:
    Requerimiento de nuevo "PM Function"
Solution:
    Se ha creado la funcion: PMFGetNextDerivationInfo($caseUid, $delIndex)
This commit is contained in:
Victor Saisa Lopez
2016-03-08 16:59:43 -04:00
parent 62e5ebd5c0
commit 14800ae76e
2 changed files with 106 additions and 20 deletions

View File

@@ -297,13 +297,11 @@ class Derivation
//1. There is no rule
if (empty($arrayNextTask)) {
$oProcess = new Process();
$oProcessFieds = $oProcess->Load( $_SESSION['PROCESS'] );
if(isset($oProcessFieds['PRO_BPMN']) && $oProcessFieds['PRO_BPMN'] == 1){
throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_BPMN_RULE"));
}else{
throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE"));
}
$bpmn = new \ProcessMaker\Project\Bpmn();
throw new Exception(G::LoadTranslation(
'ID_NO_DERIVATION_' . (($bpmn->exists($arrayApplicationData['PRO_UID']))? 'BPMN_RULE' : 'RULE')
));
}
//Return

View File

@@ -3230,3 +3230,91 @@ function PMFGetGroupUsers($GroupUID)
return $usersGroup;
}
/**
* @method
*
* Get next derivation info
*
* @name PMFGetNextDerivationInfo
* @label PMF Get next derivation info
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFGetNextDerivationInfo.28.29
*
* @param string(32) | $caseUid | ID of the case | The unique ID of the case
* @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case
*
* @return array | $arrayNextDerivationInfo | Next derivation info | Returns the next derivation info, FALSE otherwise
*/
function PMFGetNextDerivationInfo($caseUid, $delIndex)
{
try {
$arrayNextDerivationInfo = [];
//Verify data and Set variables
$case = new \ProcessMaker\BusinessModel\Cases();
$arrayAppDelegationData = $case->getAppDelegationRecordByPk(
$caseUid,
$delIndex,
['$applicationUid' => '$caseUid', '$delIndex' => '$delIndex'],
false
);
if ($arrayAppDelegationData === false) {
return false;
}
//Set variables
$processUid = $arrayAppDelegationData['PRO_UID'];
$userUid = $arrayAppDelegationData['USR_UID'];
//Get next derivation
$derivation = new Derivation();
$arrayData = $derivation->prepareInformation([
'APP_UID' => $caseUid,
'DEL_INDEX' => $delIndex,
'USER_UID' => $userUid //User logged
]);
$task = new \ProcessMaker\BusinessModel\Task();
foreach ($arrayData as $value) {
$arrayInfo = $value;
$nextTaskUid = $arrayInfo['NEXT_TASK']['TAS_UID'];
$arrayUserUid = [];
$arrayGroupUid = [];
if ($nextTaskUid != '-1') {
$arrayResult = $task->getTaskAssignees($processUid, $nextTaskUid, 'ASSIGNEE', 1);
foreach ($arrayResult['data'] as $value2) {
$arrayAssigneeData = $value2;
switch ($arrayAssigneeData['aas_type']) {
case 'user':
$arrayUserUid[] = $arrayAssigneeData['aas_uid'];
break;
case 'group':
$arrayGroupUid[] = $arrayAssigneeData['aas_uid'];
break;
}
}
}
$arrayNextDerivationInfo[] = [
'taskUid' => $nextTaskUid,
'users' => $arrayUserUid,
'groups' => $arrayGroupUid,
];
}
//Return
return $arrayNextDerivationInfo;
} catch (Exception $e) {
throw $e;
}
}