diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index af91558f0..2959f3d92 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -5336,20 +5336,20 @@ class Cases * This function sends notifications in a task * * @name sendNotifications - * @param string $sCurrentTask - * @param array $aTasks - * @param array $aFields - * @param string $sApplicationUID - * @param string $iDelegation - * @param string $sFrom + * @param string $taskUid + * @param array $arrayTask + * @param array $arrayData + * @param string $applicationUid + * @param string $delIndex + * @param string $from * @return void */ - public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "") + public function sendNotifications($taskUid, $arrayTask, $arrayData, $applicationUid, $delIndex, $from = '') { try { - $applicationData = $this->loadCase($sApplicationUID); - $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"]; + $arrayApplicationData = $this->loadCase($applicationUid); + $arrayData['APP_NUMBER'] = $arrayApplicationData['APP_NUMBER']; if (!class_exists('System')) { G::LoadClass('system'); @@ -5364,16 +5364,16 @@ class Cases //Send derivation notification - Start $oTask = new Task(); - $aTaskInfo = $oTask->load($sCurrentTask); + $aTaskInfo = $oTask->load($taskUid); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } - $sFrom = G::buildFrom($aConfiguration, $sFrom); + $from = G::buildFrom($aConfiguration, $from); if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { - $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields); + $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $arrayData); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } @@ -5417,9 +5417,9 @@ class Cases } } - $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields, false); + $sBody = file_get_contents($fileTemplate); } else { - $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields, false)); + $sBody = nl2br($aTaskInfo['TAS_DEF_MESSAGE']); } G::LoadClass("tasks"); @@ -5430,10 +5430,25 @@ class Cases $group = new Groups(); $oUser = new Users(); - foreach ($aTasks as $aTask) { + foreach ($arrayTask as $aTask) { $sTo = null; $sCc = null; + if (isset($aTask['DEL_INDEX'])) { + $arrayData2 = $arrayData; + + $appDelegation = AppDelegationPeer::retrieveByPK($applicationUid, $aTask['DEL_INDEX']); + + if (!is_null($appDelegation)) { + $arrayData2['TAS_TITLE'] = Content::load('TAS_TITLE', '', $appDelegation->getTasUid(), SYS_LANG); + $arrayData2['DEL_TASK_DUE_DATE'] = $appDelegation->getDelTaskDueDate(); + } + } else { + $arrayData2 = $arrayData; + } + + $sBody2 = G::replaceDataGridField($sBody, $arrayData2, false); + switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { @@ -5444,7 +5459,7 @@ class Cases @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate); } - $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); + $sBody2 = G::replaceDataField(file_get_contents($fileTemplate), $arrayData2); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { @@ -5542,13 +5557,13 @@ class Cases $oSpool->setConfig($aConfiguration); $oSpool->create(array( "msg_uid" => "", - "app_uid" => $sApplicationUID, - "del_index" => $iDelegation, + 'app_uid' => $applicationUid, + 'del_index' => $delIndex, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, - "app_msg_from" => $sFrom, + 'app_msg_from' => $from, "app_msg_to" => $sTo, - "app_msg_body" => $sBody, + 'app_msg_body' => $sBody2, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", diff --git a/workflow/engine/classes/class.derivation.php b/workflow/engine/classes/class.derivation.php index 065897856..653e93c1a 100755 --- a/workflow/engine/classes/class.derivation.php +++ b/workflow/engine/classes/class.derivation.php @@ -974,6 +974,8 @@ class Derivation */ function derivate(array $currentDelegation, array $nextDelegations, $removeList = true) { + $arrayDerivationResult = []; + //define this... if (! defined( 'TASK_FINISH_PROCESS' )) { define( 'TASK_FINISH_PROCESS', - 1 ); @@ -1081,7 +1083,7 @@ class Derivation $taskDummy = TaskPeer::retrieveByPK($nextDel["TAS_UID_DUMMY"]); if (preg_match("/^(?:END-MESSAGE-EVENT|END-EMAIL-EVENT)$/", $taskDummy->getTasType())) { //Throw Events - $this->throwEventsBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true); + $this->throwEventsBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true); } else { $this->throwEventsBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields, $flagFirstIteration, true, $nextDel['ROU_CONDITION']); } @@ -1177,10 +1179,14 @@ class Derivation $flagUpdateCounters = false; $removeList = false; + + $arrayDerivationResult[] = ['DEL_INDEX' => $iNewDelIndex, 'TAS_UID' => $nextDelAux['TAS_UID'], 'USR_UID' => (isset($nextDelAux['USR_UID']))? $nextDelAux['USR_UID'] : '']; } break; default: $iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP); + + $arrayDerivationResult[] = ['DEL_INDEX' => $iNewDelIndex, 'TAS_UID' => $nextDel['TAS_UID'], 'USR_UID' => (isset($nextDel['USR_UID']))? $nextDel['USR_UID'] : '']; break; } @@ -1335,6 +1341,9 @@ class Derivation $this->derivate($value["currentDelegation"], $value["nextDelegations"]); } } + + //Return + return $arrayDerivationResult; } function doDerivation ($currentDelegation, $nextDel, $appFields, $aSP = null) diff --git a/workflow/engine/methods/cases/cases_Derivate.php b/workflow/engine/methods/cases/cases_Derivate.php index 6c8de7614..b8f7b4af6 100755 --- a/workflow/engine/methods/cases/cases_Derivate.php +++ b/workflow/engine/methods/cases/cases_Derivate.php @@ -32,7 +32,7 @@ if (!isset($_SESSION['USER_LOGGED'])) { var data = olink.split("?"); var odata = data[1].split("&"); var appUid = odata[0].split("="); - + var dataToSend = { "action": "credentials", "operation": "refreshPmSession", @@ -121,7 +121,20 @@ try { $aCurrentDerivation = array ('APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'APP_STATUS' => $sStatus,'TAS_UID' => $_SESSION['TASK'],'ROU_TYPE' => $_POST['form']['ROU_TYPE'] ); - $oDerivation->derivate( $aCurrentDerivation, $_POST['form']['TASKS'] ); + $arrayDerivationResult = $oDerivation->derivate($aCurrentDerivation, $_POST['form']['TASKS']); + + if (!empty($arrayDerivationResult)) { + foreach ($_POST['form']['TASKS'] as $key => $value) { + if (isset($value['TAS_UID'])) { + foreach ($arrayDerivationResult as $value2) { + if ($value2['TAS_UID'] == $value['TAS_UID']) { + $_POST['form']['TASKS'][$key]['DEL_INDEX'] = $value2['DEL_INDEX']; + break; + } + } + } + } + } $appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); //refresh appFields, because in derivations should change some values $triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'AFTER' ); //load the triggers after derivation @@ -217,7 +230,7 @@ try { if(preg_match("/^.*\(.*MSIE (\d+)\..+\).*$/", $_SERVER["HTTP_USER_AGENT"], $arrayMatch) || preg_match("/^.*\(.*rv.(\d+)\..+\).*$/", $_SERVER["HTTP_USER_AGENT"], $arrayMatch)){ $ieVersion = intval($arrayMatch[1]); } - + if (isset( $_SESSION['TRIGGER_DEBUG']['ISSET'] ) && $ieVersion != 11) { if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) { $oTemplatePower = new TemplatePower( PATH_TPL . 'cases/cases_Step.html' ); @@ -234,18 +247,18 @@ try { unset( $_SESSION['TRIGGER_DEBUG'] ); } } - + //close tab only if IE11 - + if($ieVersion == 11 && !isset($_SESSION['__OUTLOOK_CONNECTOR__'])) { $script = ""; die($script); }