/** * Verify if does not exist the Case in table APPLICATION * * @param string $applicationUid Unique id of Case * @param string $delIndex Delegation index * @param string $fieldNameForException Field name for the exception * * return void Throw exception if does not exist the Case in table APPLICATION */ public function throwExceptionIfNotExistsCase($applicationUid, $delIndex, $fieldNameForException) { try { $obj = \ApplicationPeer::retrieveByPK($applicationUid); $flag = is_null($obj); if (!$flag && $delIndex > 0) { $obj = \AppDelegationPeer::retrieveByPK($applicationUid, $delIndex); $flag = is_null($obj); } if ($flag) { throw new \Exception(\G::LoadTranslation("ID_CASE_DOES_NOT_EXIST2", array($fieldNameForException, $applicationUid))); } } catch (\Exception $e) { throw $e; } }
function doDerivation ($currentDelegation, $nextDel, $appFields, $aSP = null) { $iAppThreadIndex = $appFields['DEL_THREAD']; $delType = 'NORMAL'; 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': // Create new delegation depending on the no of users in the group $iNewAppThreadIndex = $appFields['DEL_THREAD']; $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); foreach ($nextDel['NEXT_TASK']['USER_ASSIGNED'] as $key => $aValue) { //Incrementing the Del_thread First so that new delegation has new del_thread $iNewAppThreadIndex += 1; //Creating new delegation according to users in group $iMIDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'], $currentDelegation['APP_UID'], $nextDel['TAS_UID'], (isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''), $currentDelegation['DEL_INDEX'], $nextDel['DEL_PRIORITY'], $delType, $iNewAppThreadIndex, $nextDel ); $iNewThreadIndex = $this->case->newAppThread( $currentDelegation['APP_UID'], $iMIDelIndex, $iAppThreadIndex ); //Setting the del Index for Updating the AppThread delIndex if ($key == 0) { $iNewDelIndex = $iMIDelIndex - 1; } } //end foreach break; case 'BALANCED': $this->setTasLastAssigned( $nextDel['TAS_UID'], $nextDel['USR_UID'] ); //No Break, need no execute the default ones.... default: // Create new delegation $iNewDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'], $currentDelegation['APP_UID'], $nextDel['TAS_UID'], (isset( $nextDel['USR_UID'] ) ? $nextDel['USR_UID'] : ''), $currentDelegation['DEL_INDEX'], $nextDel['DEL_PRIORITY'], $delType, $iAppThreadIndex, $nextDel ); break; } $iAppThreadIndex = $appFields['DEL_THREAD']; switch ($currentDelegation['ROU_TYPE']) { case 'PARALLEL': case 'PARALLEL-BY-EVALUATION': $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); $iNewThreadIndex = $this->case->newAppThread( $currentDelegation['APP_UID'], $iNewDelIndex, $iAppThreadIndex ); $this->case->updateAppDelegation( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex ); break; default: $this->case->updateAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex, $iNewDelIndex ); break; } //en switch //if there are subprocess to create if (isset( $aSP )) { //Create the new case in the sub-process // set the initial date to null the time its created $aNewCase = $this->case->startCase( $aSP['TAS_UID'], $aSP['USR_UID'], true, $appFields); $taskNextDel = TaskPeer::retrieveByPK($aSP["TAS_UID"]); //Sub-Process //Copy case variables to sub-process case $aFields = unserialize( $aSP['SP_VARIABLES_OUT'] ); $aNewFields = array (); $aOldFields = $this->case->loadCase( $aNewCase['APPLICATION'] ); foreach ($aFields as $sOriginField => $sTargetField) { $sOriginField = trim($sOriginField, " @#%?$="); $sTargetField = trim($sTargetField, " @#%?$="); $aNewFields[$sTargetField] = isset( $appFields['APP_DATA'][$sOriginField] ) ? $appFields['APP_DATA'][$sOriginField] : ''; } $aOldFields['APP_DATA'] = array_merge( $aOldFields['APP_DATA'], $aNewFields ); $aOldFields['APP_STATUS'] = 'TO_DO'; $this->case->updateCase( $aNewCase['APPLICATION'], $aOldFields ); //Create a registry in SUB_APPLICATION table $aSubApplication = array ('APP_UID' => $aNewCase['APPLICATION'],'APP_PARENT' => $currentDelegation['APP_UID'],'DEL_INDEX_PARENT' => $iNewDelIndex,'DEL_THREAD_PARENT' => $iAppThreadIndex,'SA_STATUS' => 'ACTIVE','SA_VALUES_OUT' => serialize( $aNewFields ),'SA_INIT_DATE' => date( 'Y-m-d H:i:s' ) ); if ($aSP['SP_SYNCHRONOUS'] == 0) { $aSubApplication['SA_STATUS'] = 'FINISHED'; $aSubApplication['SA_FINISH_DATE'] = $aSubApplication['SA_INIT_DATE']; } $oSubApplication = new SubApplication(); $oSubApplication->create( $aSubApplication ); //Update the AppDelegation to execute the update trigger $AppDelegation = AppDelegationPeer::retrieveByPK( $aNewCase['APPLICATION'], $aNewCase['INDEX'] ); // note added by krlos pacha carlos[at]colosa[dot]com // the following line of code was commented because it is related to the 6878 bug //$AppDelegation->setDelInitDate("+1 second"); $AppDelegation->save(); //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") { $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#"); if (isset($aOldFields["APP_DATA"][$nextTaskGroupVariable]) && trim($aOldFields["APP_DATA"][$nextTaskGroupVariable]) != "") { $appAssignSelfServiceValue = new AppAssignSelfServiceValue(); $appAssignSelfServiceValue->create($aNewCase["APPLICATION"], $aNewCase["INDEX"], array("PRO_UID" => $aNewCase["PROCESS"], "TAS_UID" => $aSP["TAS_UID"], "GRP_UID" => trim($aOldFields["APP_DATA"][$nextTaskGroupVariable]))); } } //If not is SYNCHRONOUS derivate one more time if ($aSP['SP_SYNCHRONOUS'] == 0) { $this->case->setDelInitDate( $currentDelegation['APP_UID'], $iNewDelIndex ); $aDeriveTasks = $this->prepareInformation( array ('USER_UID' => -1,'APP_UID' => $currentDelegation['APP_UID'],'DEL_INDEX' => $iNewDelIndex ) ); if (isset( $aDeriveTasks[1] )) { if ($aDeriveTasks[1]['ROU_TYPE'] != 'SELECT') { $nextDelegations2 = array (); foreach ($aDeriveTasks as $aDeriveTask) { $nextDelegations2[] = array ('TAS_UID' => $aDeriveTask['NEXT_TASK']['TAS_UID'],'USR_UID' => $aDeriveTask['NEXT_TASK']['USER_ASSIGNED']['USR_UID'],'TAS_ASSIGN_TYPE' => $aDeriveTask['NEXT_TASK']['TAS_ASSIGN_TYPE'],'TAS_DEF_PROC_CODE' => $aDeriveTask['NEXT_TASK']['TAS_DEF_PROC_CODE'],'DEL_PRIORITY' => 3,'TAS_PARENT' => $aDeriveTask['NEXT_TASK']['TAS_PARENT'] ); } $currentDelegation2 = array ('APP_UID' => $currentDelegation['APP_UID'],'DEL_INDEX' => $iNewDelIndex,'APP_STATUS' => 'TO_DO','TAS_UID' => $currentDelegation['TAS_UID'],'ROU_TYPE' => $aDeriveTasks[1]['ROU_TYPE'] ); $this->derivate( $currentDelegation2, $nextDelegations2 ); } } } } //end switch return $iNewDelIndex; }
public function remove($sApplicationUID, $iDelegationIndex) { $oConnection = Propel::getConnection(StepTriggerPeer::DATABASE_NAME); try { $oConnection->begin(); $oApp = AppDelegationPeer::retrieveByPK($sApplicationUID, $iDelegationIndex); if (is_object($oApp) && get_class($oApp) == 'AppDelegation') { $result = $oApp->delete(); } $oConnection->commit(); return $result; } catch (Exception $e) { $oConnection->rollback(); throw $e; } }
/** * Verify if not exists input Document in Steps * * @param string $applicationUid Unique id of Case * @param string $delIndex Delegataion index * @param string $appDocumentUid * * return void Throw exception if not exists input Document in Steps */ public function throwExceptionIfInputDocumentNotExistsInSteps($applicacionUid, $delIndex, $appDocumentUid) { try { //Verify Case $appDelegation = \AppDelegationPeer::retrieveByPK($applicacionUid, $delIndex); if (is_null($appDelegation)) { throw new \Exception(\G::LoadTranslation("ID_CASE_DEL_INDEX_DOES_NOT_EXIST", array("app_uid", $applicacionUid, "del_index", $delIndex))); } $taskUid = $appDelegation->getTasUid(); //Verify Steps $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\AppDocumentPeer::DOC_UID); $criteria->add(\AppDocumentPeer::APP_DOC_UID, $appDocumentUid, \Criteria::EQUAL); $criteria->add(\AppDocumentPeer::APP_UID, $applicacionUid, \Criteria::EQUAL); $criteria->add(\AppDocumentPeer::APP_DOC_TYPE, "INPUT", \Criteria::EQUAL); $rsCriteria = \AppDocumentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); if ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $inputDocumentUid = $row["DOC_UID"]; $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\StepPeer::STEP_UID); $criteria->add(\StepPeer::TAS_UID, $taskUid, \Criteria::EQUAL); $criteria->add(\StepPeer::STEP_TYPE_OBJ, "INPUT_DOCUMENT", \Criteria::EQUAL); $criteria->add(\StepPeer::STEP_UID_OBJ, $inputDocumentUid, \Criteria::EQUAL); $rsCriteria = \StepPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); if (!$rsCriteria->next()) { throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOCUMENT_DOES_NOT_EXIST", array($appDocumentUid))); } } } catch (\Exception $e) { throw $e; } }
/** * Verify if not exists OuputDocument in Steps * * @param string $applicationUid Unique id of Case * @param string $delIndex Delegation index * @param string $outDocUuid * * return void Throw exception if not exists OuputDocument in Steps */ public function throwExceptionIfOuputDocumentNotExistsInSteps($applicacionUid, $delIndex, $outputDocumentUid) { try { //Verify data $appDelegation = \AppDelegationPeer::retrieveByPK($applicacionUid, $delIndex); $taskUid = $appDelegation->getTasUid(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\StepPeer::STEP_UID); $criteria->add(\StepPeer::TAS_UID, $taskUid, \Criteria::EQUAL); $criteria->add(\StepPeer::STEP_TYPE_OBJ, "OUTPUT_DOCUMENT", \Criteria::EQUAL); $criteria->add(\StepPeer::STEP_UID_OBJ, $outputDocumentUid, \Criteria::EQUAL); $rsCriteria = \StepPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); if (!$rsCriteria->next()) { throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($outputDocumentUid))); } } catch (\Exception $e) { throw $e; } }
$filters['sort'] = G::toUpper($filters['sort']); $columnsList = $listpeer::getFieldNames(BasePeer::TYPE_FIELDNAME); if (!in_array($filters['sort'], $columnsList)) { $filters['sort'] = ''; } $filters['dir'] = G::toUpper($filters['dir']); if (!($filters['dir'] == 'DESC' || $filters['dir'] == 'ASC')) { $filters['dir'] = 'DESC'; } $result = $list->loadList($userUid, $filters, function (array $record) { try { if (isset($record["DEL_PREVIOUS_USR_UID"])) { if ($record["DEL_PREVIOUS_USR_UID"] == "") { $appDelegation = AppDelegationPeer::retrieveByPK($record["APP_UID"], $record["DEL_INDEX"]); if (!is_null($appDelegation)) { $appDelegationPrevious = AppDelegationPeer::retrieveByPK($record["APP_UID"], $appDelegation->getDelPrevious()); if (!is_null($appDelegationPrevious)) { $taskPrevious = TaskPeer::retrieveByPK($appDelegationPrevious->getTasUid()); if (!is_null($taskPrevious)) { switch ($taskPrevious->getTasType()) { case "SCRIPT-TASK": $record["DEL_PREVIOUS_USR_UID"] = $taskPrevious->getTasType(); break; } } } } } $record["PREVIOUS_USR_UID"] = $record["DEL_PREVIOUS_USR_UID"]; $record["PREVIOUS_USR_USERNAME"] = $record["DEL_PREVIOUS_USR_USERNAME"]; $record["PREVIOUS_USR_FIRSTNAME"] = $record["DEL_PREVIOUS_USR_FIRSTNAME"];
/** * Implementation for 'GET' method for Rest API * * @param mixed $appUid, $delIndex Primary key * * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ protected function get($appUid = null, $delIndex = null) { $result = array(); try { $noArguments = true; $argumentList = func_get_args(); foreach ($argumentList as $arg) { if (!is_null($arg)) { $noArguments = false; } } if ($noArguments) { $criteria = new Criteria('workflow'); $criteria->addSelectColumn(AppDelegationPeer::APP_UID); $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); $criteria->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS); $criteria->addSelectColumn(AppDelegationPeer::PRO_UID); $criteria->addSelectColumn(AppDelegationPeer::TAS_UID); $criteria->addSelectColumn(AppDelegationPeer::USR_UID); $criteria->addSelectColumn(AppDelegationPeer::DEL_TYPE); $criteria->addSelectColumn(AppDelegationPeer::DEL_THREAD); $criteria->addSelectColumn(AppDelegationPeer::DEL_THREAD_STATUS); $criteria->addSelectColumn(AppDelegationPeer::DEL_PRIORITY); $criteria->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE); $criteria->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE); $criteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE); $criteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE); $criteria->addSelectColumn(AppDelegationPeer::DEL_DURATION); $criteria->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION); $criteria->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION); $criteria->addSelectColumn(AppDelegationPeer::DEL_STARTED); $criteria->addSelectColumn(AppDelegationPeer::DEL_FINISHED); $criteria->addSelectColumn(AppDelegationPeer::DEL_DELAYED); $criteria->addSelectColumn(AppDelegationPeer::DEL_DATA); $criteria->addSelectColumn(AppDelegationPeer::APP_OVERDUE_PERCENTAGE); $dataset = AppEventPeer::doSelectRS($criteria); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($dataset->next()) { $result[] = $dataset->getRow(); } } else { $record = AppDelegationPeer::retrieveByPK($appUid, $delIndex); if ($record) { $result = $record->toArray(BasePeer::TYPE_FIELDNAME); } else { $paramValues = ""; foreach ($argumentList as $arg) { $paramValues .= strlen($paramValues) ? ', ' : ''; if (!is_null($arg)) { $paramValues .= "{$arg}"; } else { $paramValues .= "NULL"; } } throw new RestException(417, "table AppDelegation ({$paramValues})"); } } } catch (RestException $e) { throw new RestException($e->getCode(), $e->getMessage()); } catch (Exception $e) { throw new RestException(412, $e->getMessage()); } return $result; }
public function sendNotifications($taskUid, $arrayTask, $arrayData, $applicationUid, $delIndex, $from = '') { try { $arrayApplicationData = $this->loadCase($applicationUid); $arrayData['APP_NUMBER'] = $arrayApplicationData['APP_NUMBER']; if (!class_exists('System')) { G::LoadClass('system'); } $aConfiguration = System::getEmailConfiguration(); $msgError = ""; if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { $msgError = "The default configuration wasn't defined"; $aConfiguration['MESS_ENGINE'] = ''; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($taskUid); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } $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'], $arrayData); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP; $swtplDefault = 0; $sBody = null; if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") { if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") { $swtplDefault = 1; } $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"]; if (!file_exists($fileTemplate)) { $tempale = PATH_CORE . "templates" . PATH_SEP . "mails" . PATH_SEP . "alert_message.html"; $copied = @copy($tempale, $fileTemplate); if ($copied) { $dataTemplate = array("prf_filename" => $conf["TAS_DEF_MESSAGE_TEMPLATE"], "prf_path" => $fileTemplate, "pro_uid" => $aTaskInfo["PRO_UID"], "usr_uid" => "00000000000000000000000000000001", "prf_uid" => G::generateUniqueID(), "prf_type" => "file", "prf_create_date" => date("Y-m-d H:i:s")); $filesManager = new ProcessMaker\BusinessModel\FilesManager(); $filesManager->addProcessFilesManagerInDb($dataTemplate); } else { throw new Exception("Template file \"{$fileTemplate}\" does not exist."); } } $sBody = file_get_contents($fileTemplate); } else { $sBody = nl2br($aTaskInfo['TAS_DEF_MESSAGE']); } G::LoadClass("tasks"); G::LoadClass("groups"); G::LoadClass("spool"); $task = new Tasks(); $group = new Groups(); $oUser = new Users(); 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; } if (isset($aTask['USR_UID']) && !empty($aTask['USR_UID'])) { $user = new \ProcessMaker\BusinessModel\User(); $arrayUserData = $user->getUser($aTask['USR_UID'], true); $arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2, trim($arrayUserData['USR_TIME_ZONE']) != '' ? trim($arrayUserData['USR_TIME_ZONE']) : \ProcessMaker\Util\System::getTimeZone()); } else { $arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2); } $sBody2 = G::replaceDataGridField($sBody, $arrayData2, false); switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { G::verifyPath($pathEmail, true); //Create if it does not exist $fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'); if (!file_exists($fileTemplate) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) { @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate); } $sBody2 = G::replaceDataField(file_get_contents($fileTemplate), $arrayData2); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayTaskUser = array(); $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } $criteria = new Criteria("workflow"); $criteria->addSelectColumn(UsersPeer::USR_UID); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_EMAIL); $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN); $rsCriteria = UsersPeer::doSelectRs($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $to = null; $cc = null; $sw = 1; while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; case "MULTIPLE_INSTANCE": $to = null; $cc = null; $sw = 1; $oDerivation = new Derivation(); $userFields = $oDerivation->getUsersFullNameFromArray($oDerivation->getAllUsersFromAnyTask($aTask["TAS_UID"])); if (isset($userFields)) { foreach ($userFields as $row) { $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; case "MULTIPLE_INSTANCE_VALUE_BASED": $aTaskNext = $oTask->load($aTask["TAS_UID"]); if (isset($aTaskNext["TAS_ASSIGN_VARIABLE"]) && !empty($aTaskNext["TAS_ASSIGN_VARIABLE"])) { $to = null; $cc = null; $sw = 1; $nextTaskAssignVariable = trim($aTaskNext["TAS_ASSIGN_VARIABLE"], " @#"); $arrayUsers = $arrayData[$nextTaskAssignVariable]; $oDerivation = new Derivation(); $userFields = $oDerivation->getUsersFullNameFromArray($arrayUsers); foreach ($userFields as $row) { $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $aUser = $oUser->load($aTask["USR_UID"]); $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">"; } break; } if ($sTo != null) { $oSpool = new spoolRun(); $oSpool->setConfig($aConfiguration); $oSpool->create(array("msg_uid" => "", 'app_uid' => $applicationUid, 'del_index' => $delIndex, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, 'app_msg_from' => $from, "app_msg_to" => $sTo, 'app_msg_body' => $sBody2, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_error" => $msgError)); if ($msgError == '') { if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") { $oSpool->sendMail(); } } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }