/** * reassign Case * * @param string sessionId : The session ID (which was obtained during login) * @param string caseId : The case ID (which can be obtained with the caseList() function) * @param string delIndex : The delegation index number of the case (which can be obtained with the caseList() * function). * @param string userIdSource : The user who is currently assigned the case. * @param string userIdTarget : The target user who will be newly assigned to the case. * @return $result will return an object */ public function reassignCase ($sessionId, $caseId, $delIndex, $userIdSource, $userIdTarget) { $g = new G(); try { $g->sessionVarSave(); $_SESSION["APPLICATION"] = $caseId; $_SESSION["INDEX"] = $delIndex; $_SESSION["USER_LOGGED"] = $userIdSource; if ($userIdTarget == $userIdSource) { $result = new wsResponse( 30, G::loadTranslation( 'ID_TARGET_ORIGIN_USER_SAME' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 1 )***************** */ $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); $oCriteria->add( UsersPeer::USR_UID, $userIdSource ); $oDataset = UsersPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (! is_array( $aRow )) { $result = new wsResponse( 31, G::loadTranslation( 'ID_INVALID_ORIGIN_USER' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 2 )***************** */ $oCase = new Cases(); $rows = $oCase->loadCase( $caseId ); if (! is_array( $aRow )) { $result = new wsResponse( 32, G::loadTranslation( 'ID_CASE_NOT_OPEN' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 3 )***************** */ $oCriteria = new Criteria( 'workflow' ); $aConditions = array (); // $aConditions[] = array(AppDelegationPeer::USR_UID, TaskUserPeer::USR_UID); // $aConditions[] = array(AppDelegationPeer::TAS_UID, TaskUserPeer::TAS_UID); // $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); //$oCriteria->addJoin(AppDelegationPeer::USR_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN); $oCriteria->add( AppDelegationPeer::APP_UID, $caseId ); $oCriteria->add( AppDelegationPeer::USR_UID, $userIdSource ); $oCriteria->add( AppDelegationPeer::DEL_INDEX, $delIndex ); $oCriteria->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL ); $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (! is_array( $aRow )) { $result = new wsResponse( 33, G::loadTranslation( 'ID_INVALID_CASE_DELEGATION_INDEX' ) ); $g->sessionVarRestore(); return $result; } $tasUid = $aRow['TAS_UID']; $derivation = new Derivation(); $userList = $derivation->getAllUsersFromAnyTask($tasUid, true); if (! in_array( $userIdTarget, $userList )) { $result = new wsResponse( 34, G::loadTranslation( 'ID_TARGET_USER_DOES_NOT_HAVE_RIGHTS' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 4 )***************** */ $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); $oCriteria->add( UsersPeer::USR_UID, $userIdTarget ); $oDataset = UsersPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (! is_array( $aRow )) { $result = new wsResponse( 35, G::loadTranslation( 'ID_TARGET_USER_DESTINATION_INVALID' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 5 )***************** */ $var = $oCase->reassignCase( $caseId, $delIndex, $userIdSource, $userIdTarget ); if (! $var) { $result = new wsResponse( 36, G::loadTranslation( 'ID_CASE_COULD_NOT_REASSIGNED' ) ); $g->sessionVarRestore(); return $result; } $result = new wsResponse( 0, G::loadTranslation( 'ID_COMMAND_EXECUTED_SUCCESSFULLY' ) ); $g->sessionVarRestore(); return $result; } catch (Exception $e) { $result[] = array ('guid' => $e->getMessage(),'name' => $e->getMessage() ); $g->sessionVarRestore(); return $result; } }
} } if ($aGields['OUT_DOC_GENERATE'] == 'BOTH' || $aGields['OUT_DOC_GENERATE'] == '') { $G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument1', '', G::array_merges($aOD, $aFields), ''); } if ($aGields['OUT_DOC_GENERATE'] == 'DOC') { $G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument2', '', G::array_merges($aOD, $aFields), ''); } if ($aGields['OUT_DOC_GENERATE'] == 'PDF') { $G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewOutputDocument3', '', G::array_merges($aOD, $aFields), ''); } break; } break; case 'ASSIGN_TASK': $oDerivation = new Derivation(); $oProcess = new Process(); $aData = $oCase->loadCase($_SESSION['APPLICATION']); $aFields['PROCESS'] = $oProcess->load($_SESSION['PROCESS']); $aFields['PREVIOUS_PAGE'] = $aPreviousStep['PAGE']; $aFields['PREVIOUS_PAGE_LABEL'] = G::LoadTranslation('ID_PREVIOUS_STEP'); $aFields['ASSIGN_TASK'] = G::LoadTranslation('ID_ASSIGN_TASK'); $aFields['END_OF_PROCESS'] = G::LoadTranslation('ID_END_OF_PROCESS'); $aFields['NEXT_TASK_LABEL'] = G::LoadTranslation('ID_NEXT_TASK'); $aFields['EMPLOYEE'] = G::LoadTranslation('ID_EMPLOYEE'); $aFields['LAST_EMPLOYEE'] = G::LoadTranslation('ID_LAST_EMPLOYEE'); $aFields['OPTION_LABEL'] = G::LoadTranslation('ID_OPTION'); $aFields['CONTINUE'] = G::LoadTranslation('ID_CONTINUE'); $aFields['FINISH'] = G::LoadTranslation('ID_FINISH'); $aFields['CONTINUE_WITH_OPTION'] = G::LoadTranslation('ID_CONTINUE_WITH_OPTION'); $aFields['FINISH_WITH_OPTION'] = G::LoadTranslation('ID_FINISH_WITH_OPTION');
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ G::LoadClass("derivation"); $dbc = new DBConnection(); $obj = new Derivation(); /* derivando el primer caso */ $frm['APP_UID'] = '44706CAEA62AE0'; $frm['DEL_INDEX'] = '1'; $obj->executeDerivation($frm); die; /* derivando el primer caso */ /* CREANDO UN NUEVO CASO */ /* $frm['TAS_UID'] ='246F2CD0D4C79E'; $frm['USER_UID'] ='00000000000000000000000000000001'; $obj->startCase($frm); die; */ /* CREANDO UN NUEVO CASO END */ /** Application */
public function cancelCase($sApplicationUID, $iIndex, $user_logged) { $this->getExecuteTriggerProcess($sApplicationUID, 'CANCELED'); $oApplication = new Application(); $aFields = $oApplication->load($sApplicationUID); $appStatusCurrent = $aFields['APP_STATUS']; $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); if (AppDelegationPeer::doCount($oCriteria) == 1) { $aFields['APP_STATUS'] = 'CANCELLED'; $oApplication->update($aFields); G::LoadClass('reportTables'); require_once 'classes/model/AdditionalTables.php'; $oReportTables = new ReportTables(); $addtionalTables = new additionalTables(); $oReportTables->updateTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $aFields['APP_DATA']); $addtionalTables->updateReportTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $aFields['APP_DATA'], $aFields['APP_STATUS']); } $this->CloseCurrentDelegation($sApplicationUID, $iIndex); $oAppDel = new AppDelegation(); $oAppDel->Load($sApplicationUID, $iIndex); $aAppDel = $oAppDel->toArray(BasePeer::TYPE_FIELDNAME); $this->closeAppThread($sApplicationUID, $aAppDel['DEL_THREAD']); $delay = new AppDelay(); $array['PRO_UID'] = $aFields['PRO_UID']; $array['APP_UID'] = $sApplicationUID; $c = new Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(AppThreadPeer::APP_THREAD_INDEX); $c->add(AppThreadPeer::APP_UID, $sApplicationUID); $c->add(AppThreadPeer::DEL_INDEX, $iIndex); $oDataset = AppThreadPeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); $array['APP_THREAD_INDEX'] = $aRow['APP_THREAD_INDEX']; $array['APP_DEL_INDEX'] = $iIndex; $array['APP_TYPE'] = 'CANCEL'; $c = new Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(ApplicationPeer::APP_STATUS); $c->add(ApplicationPeer::APP_UID, $sApplicationUID); $oDataset = ApplicationPeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow1 = $oDataset->getRow(); $array['APP_STATUS'] = $aRow1['APP_STATUS']; $array['APP_DELEGATION_USER'] = $user_logged; $array['APP_ENABLE_ACTION_USER'] = $user_logged; $array['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s'); $delay->create($array); //Before cancel a case verify if is a child case $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(SubApplicationPeer::APP_UID, $sApplicationUID); $oCriteria2->add(SubApplicationPeer::SA_STATUS, 'ACTIVE'); if (SubApplicationPeer::doCount($oCriteria2) > 0) { G::LoadClass('derivation'); $oDerivation = new Derivation(); $oDerivation->verifyIsCaseChild($sApplicationUID, $iIndex); } //update searchindex if ($this->appSolr != null) { $this->appSolr->updateApplicationSearchIndex($sApplicationUID); } /*----------------------------------********---------------------------------*/ }
public function load($sProcessUID, $bView = false, $sApplicationUID = '', $iDelegation = 0, $sTask = '', $bCT = false) { try { $oProcess = new Process(); $aRow = $oProcess->load($sProcessUID); $oPM->title->label = strip_tags($aRow['PRO_TITLE']); $oPM->title->position->x = $aRow['PRO_TITLE_X']; $oPM->title->position->y = $aRow['PRO_TITLE_Y']; $oPM->task = array(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(TaskPeer::PRO_UID); $oCriteria->addSelectColumn(TaskPeer::TAS_UID); $oCriteria->addSelectColumn(ContentPeer::CON_VALUE); $oCriteria->addSelectColumn(TaskPeer::TAS_START); $oCriteria->addSelectColumn(TaskPeer::TAS_POSX); $oCriteria->addSelectColumn(TaskPeer::TAS_POSY); $oCriteria->addSelectColumn(TaskPeer::TAS_COLOR); $oCriteria->addSelectColumn(TaskPeer::TAS_TYPE); $aConditions = array(); $aConditions[] = array(0 => TaskPeer::TAS_UID, 1 => ContentPeer::CON_ID); $aConditions[] = array(0 => ContentPeer::CON_CATEGORY, 1 => DBAdapter::getStringDelimiter() . 'TAS_TITLE' . DBAdapter::getStringDelimiter()); $aConditions[] = array(0 => ContentPeer::CON_LANG, 1 => DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter()); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID); $oDataset = TaskPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow1 = $oDataset->getRow()) { $oTask = null; $oTask->uid = $aRow1['TAS_UID']; $oTask->task_type = $aRow1['TAS_TYPE']; if ($aRow1['TAS_TYPE'] == 'NORMAL') { if ($aRow1['CON_VALUE'] == "") { //There is no Label in Current SYS_LANG language so try to find in English - by default $oTask1 = new Task(); $aFields1 = $oTask1->load($oTask->uid); $aRow1['CON_VALUE'] = $oTask1->getTasTitle(); } $oTask->label = strip_tags($aRow1['CON_VALUE']); } else { $oCriteria = new Criteria('workflow'); $del = DBAdapter::getStringDelimiter(); $oCriteria->add(SubProcessPeer::PRO_PARENT, $aRow1['PRO_UID']); $oCriteria->add(SubProcessPeer::TAS_PARENT, $aRow1['TAS_UID']); $oCriteria->addAsColumn('TAS_TITLE', 'C1.CON_VALUE'); $oCriteria->addAlias("C1", 'CONTENT'); $tasTitleConds = array(); $tasTitleConds[] = array(SubProcessPeer::TAS_PARENT, 'C1.CON_ID'); $tasTitleConds[] = array('C1.CON_CATEGORY', $del . 'TAS_TITLE' . $del); $tasTitleConds[] = array('C1.CON_LANG', $del . SYS_LANG . $del); $oCriteria->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN); $oDatasetX = SubProcessPeer::doSelectRS($oCriteria); $oDatasetX->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDatasetX->next(); $aRowx = $oDatasetX->getRow(); if ($oProcess->exists($aRowx['PRO_UID'])) { //$aRowy = $oProcess->load($aRowx['PRO_UID']); //$oTask->label = $aRowy['PRO_TITLE']; $oTask->label = $aRowx['TAS_TITLE']; } else { $oTask->label = strip_tags($aRow1['CON_VALUE']); } } $oTask->taskINI = strtolower($aRow1['TAS_START']) == 'true' ? true : false; $oTask->position->x = (int) $aRow1['TAS_POSX']; $oTask->position->y = (int) $aRow1['TAS_POSY']; $oTask->derivation = null; $oTask->derivation->to = array(); $oCriteria = new Criteria('workflow'); $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID); $oCriteria->add(RoutePeer::TAS_UID, $aRow1['TAS_UID']); $oDataset2 = RoutePeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); while ($aRow2 = $oDataset2->getRow()) { switch ($aRow2['ROU_TYPE']) { case 'SEQUENTIAL': $aRow2['ROU_TYPE'] = 0; break; case 'SELECT': $aRow2['ROU_TYPE'] = 1; break; case 'EVALUATE': $aRow2['ROU_TYPE'] = 2; break; case 'PARALLEL': $aRow2['ROU_TYPE'] = 3; break; case 'PARALLEL-BY-EVALUATION': $aRow2['ROU_TYPE'] = 4; break; case 'SEC-JOIN': $aRow2['ROU_TYPE'] = 5; break; case 'DISCRIMINATOR': $aRow2['ROU_TYPE'] = 8; break; } $oTo = null; $oTo->task = $aRow2['ROU_NEXT_TASK']; $oTo->condition = $aRow2['ROU_CONDITION']; $oTo->executant = $aRow2['ROU_TO_LAST_USER']; $oTo->optional = $aRow2['ROU_OPTIONAL']; $oTask->derivation->type = $aRow2['ROU_TYPE']; $oTask->derivation->to[] = $oTo; $oDataset2->next(); } if ($bCT) { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS CANT'); $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('DEL_FINISH_DATE'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow3 = $oDataset2->getRow(); if ($aRow3) { $aRow2['FINISH'] = ''; } /* if (($aRow2['FINISH'] == null) && ($aRow1['TAS_UID'] == $sTask)) { $oTask->color = '#FF0000'; } else { if ($aRow2['CANT'] != 0) { if ($aRow2['FINISH'] == null) { //$oTask->color = '#FF9900'; $oTask->color = '#FF0000'; } else { $oTask->color = '#006633'; } } else { $oTask->color = "#939598"; } } */ if (empty($aRow2["FINISH"]) && $aRow1["TAS_UID"] == $sTask) { $oTask->color = "#FF0000"; //Red } else { if (!empty($aRow2["FINISH"])) { $oTask->color = "#006633"; //Green } else { if ($aRow2["CANT"] == 0 || $oTask->derivation->type != 5) { $oTask->color = "#939598"; //Gray } else { //$oTask->color = "#FF9900"; //Yellow $oTask->color = "#FF0000"; //Red } } } } else { if ($bView && $sApplicationUID != '' && $iDelegation > 0 && $sTask != '') { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS CANT'); $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('DEL_FINISH_DATE'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow3 = $oDataset2->getRow(); if ($aRow3) { $aRow2['FINISH'] = ''; } /* if (($aRow2['FINISH'] == null) && ($aRow1['TAS_UID'] == $sTask)) { $oTask->color = '#FF0000'; } else { if ($aRow2['CANT'] != 0) { if ($aRow2['FINISH'] == null) { $oTask->color = '#FF9900'; } else { $oTask->color = '#006633'; } } else { $oTask->color = '#939598'; } } */ if (empty($aRow2["FINISH"]) && $aRow1["TAS_UID"] == $sTask) { $oTask->color = "#FF0000"; //Red } else { if (!empty($aRow2["FINISH"])) { $oTask->color = "#006633"; //Green } else { if ($aRow2["CANT"] == 0 || $oTask->derivation->type != 5) { $oTask->color = "#939598"; //Gray } else { $oTask->color = "#FF9900"; //Yellow } } } } } $msg = array(); G::LoadClass('derivation'); $Derivation = new Derivation(); $users = $Derivation->getAllUsersFromAnyTask($aRow1['TAS_UID']); $sw_error = false; if (count($users) == 0) { $sw_error = true; $msg[] = G::LoadTranslation('ID_NO_USERS'); } G::LoadClass('ArrayPeer'); $stepsCriteria = $this->getStepsCriteria($aRow1['TAS_UID']); $oDatasetSteps = ArrayBasePeer::doSelectRS($stepsCriteria); $oDatasetSteps->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDatasetSteps->next(); $countDynaform = 0; $countOutput = 0; $countInput = 0; $countExternal = 0; while ($aRowSteps = $oDatasetSteps->getRow()) { switch ($aRowSteps['STEP_TYPE_OBJ']) { case 'DYNAFORM': $countDynaform++; break; case 'INPUT_DOCUMENT': $countInput++; break; case 'OUTPUT_DOCUMENT': $countOutput++; break; case 'EXTERNAL': $countExternal++; break; } $oDatasetSteps->next(); } $totalSteps = $countDynaform + $countInput + $countOutput + $countExternal; if ($totalSteps == 0) { $sw_error = true; $msg[] = G::LoadTranslation('ID_TASK_NO_STEPS'); } if ($sw_error) { $oTask->statusIcons[] = array('label' => implode(",", $msg), 'icon' => '/images/alert.gif', 'message' => implode(", ", $msg), 'url' => ''); } $oPM->task[] = $oTask; $oDataset->next(); } $oPM->executant[] = G::LoadTranslation('ID_RULES_AND_USER_GROUPS'); $oPM->executant[] = G::LoadTranslation('ID_ADD_USER_OF_TASK'); $oPM->tasExtra[0]->label = '-- ' . G::LoadTranslation('ID_END_OF_PROCESS') . ' --'; $oPM->tasExtra[0]->uid = 'end'; $oPM->tasExtra[1]->label = '-- ' . G::LoadTranslation('ID_TAREA_COLGANTE') . ' --'; $oPM->tasExtra[1]->uid = 'leaf'; $oPM->guide = array(); $oPM->text = array(); $oPM->statusIcons = array(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_UID); // $oCriteria->addSelectColumn ( ContentPeer::CON_VALUE ); $oCriteria->addAsColumn("CON_VALUE", "CASE WHEN CONTENT.CON_VALUE IS NULL THEN (SELECT DISTINCT MAX(A.CON_VALUE) FROM CONTENT A WHERE SWIMLANES_ELEMENTS.SWI_UID=A.CON_ID ) ELSE CONTENT.CON_VALUE END "); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_TYPE); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_X); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_Y); $aConditions = array(); $aConditions[] = array(0 => SwimlanesElementsPeer::SWI_UID, 1 => ContentPeer::CON_ID); $aConditions[] = array(0 => ContentPeer::CON_CATEGORY, 1 => DBAdapter::getStringDelimiter() . 'SWI_TEXT' . DBAdapter::getStringDelimiter()); $aConditions[] = array(0 => ContentPeer::CON_LANG, 1 => DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter()); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID); $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { switch (strtolower($aRow['SWI_TYPE'])) { case 'line': $oGuide = null; $oGuide->uid = $aRow['SWI_UID']; $oGuide->position = $aRow['SWI_X'] > 0 ? $aRow['SWI_X'] : $aRow['SWI_Y']; $oGuide->direction = $aRow['SWI_X'] > 0 ? 'vertical' : 'horizontal'; $oPM->guide[] = $oGuide; break; case 'text': $oText = null; $oText->uid = $aRow['SWI_UID']; $oText->label = strip_tags($aRow['CON_VALUE'] != '' ? str_replace(chr(92), '\', str_replace('<', '<', $aRow['CON_VALUE'])) : '-'); // $oText->label = '->' . $aRow ['CON_VALUE'] . '<-' ; $oText->position->x = $aRow['SWI_X']; $oText->position->y = $aRow['SWI_Y']; $oPM->text[] = $oText; break; } $oDataset->next(); } $oPM->derivation = array('Sequential', 'Evaluate (manual)', 'Evaluate (auto)', 'Parallel (fork)', 'Parallel by evaluation (fork)', 'Parallel (sequential join)', 'Parallel (sequential main join)'); //Load extended task properties from plugin. By JHL Jan 18, 2011 $oPluginRegistry =& PMPluginRegistry::getSingleton(); $activePluginsForTaskProperties = $oPluginRegistry->getTaskExtendedProperties(); $oPM->taskOptions = array(); foreach ($activePluginsForTaskProperties as $key => $taskPropertiesInfo) { $taskOption['title'] = $taskPropertiesInfo->sName; $taskOption['id'] = $taskPropertiesInfo->sNamespace . "--" . $taskPropertiesInfo->sName; $oPM->taskOptions[] = $taskOption; } //$oJSON = new Services_JSON(); return Bootstrap::json_encode($oPM); //$oJSON->encode( $oPM ); } catch (Exception $oError) { throw $oError; } }
function StartCaseTest($testCase, $Fields) { global $dbc; $der = new Derivation($dbc); $result = $der->startCase($Fields); return $result; }
//if there are some triggers to execute if (sizeof($triggers) > 0) { //Execute triggers before derivation $appFields['APP_DATA'] = $oCase->ExecuteTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'BEFORE', $appFields['APP_DATA']); //save trigger variables for debugger $_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof($triggers); $_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = 'BEFORE'; $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames($triggers); $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers; } $appFields['DEL_INDEX'] = $_SESSION['INDEX']; $appFields['TAS_UID'] = $_SESSION['TASK']; $oCase->updateCase($_SESSION['APPLICATION'], $appFields); //Save data //derivate case $oDerivation = new Derivation(); $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']); $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 if (sizeof($triggers) > 0) { $appFields['APP_DATA'] = $oCase->ExecuteTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'AFTER', $appFields['APP_DATA']); //Execute triggers after derivation $_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof($triggers); $_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = 'AFTER'; $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames($triggers); $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers; } $oCase->updateCase($_SESSION['APPLICATION'], $appFields);
<?php try { require_once "classes/model/Task.php"; require_once "classes/model/Users.php"; G::LoadClass('case'); G::LoadClass('derivation'); $oTask = new Task(); $TaskFields = $oTask->load($_POST['TASKS']); $aDerivation['NEXT_TASK'] = $TaskFields; $oDerivation = new Derivation(); $deriva = $oDerivation->getNextAssignedUser($aDerivation); $oCase = new Cases(); $aData = $oCase->startCase($_POST['TASKS'], $deriva['USR_UID']); $case = $oCase->loadCase($aData['APPLICATION'], 1); $Fields = array(); $Fields['APP_NUMBER'] = $case['APP_NUMBER']; $Fields['APP_PROC_STATUS'] = 'draft'; $Fields['APP_DATA'] = $_POST['form']; $Fields['DEL_INDEX'] = 1; $Fields['TAS_UID'] = $_POST['TASKS']; //$Fields = $oCase->loadCase($aData['APPLICATION'], 1); $oCase->updateCase($aData['APPLICATION'], $Fields); $s = 0; if (isset($_SERVER['HTTP_REFERER'])) { $dir = explode('?', $_SERVER['HTTP_REFERER']); if ($dir[1] == '__flag__=1') { $s = 1; } else { $dire = explode('&', $dir[1]); for ($i = 0; $i <= count($dire); $i++) {
/** * * @method Returns a list of the next assigned users to a case. * * @name PMFGetNextAssignedUser * @label PMFGet Next Assigned User * * @param string(32) | $application | Case ID | Id of the case * @param string(32) | $task | Task ID | Id of the task * @return array | $array | List of users | Return a list of users * */ function PMFGetNextAssignedUser($application, $task) { require_once 'classes/model/AppDelegation.php'; require_once 'classes/model/Task.php'; require_once 'classes/model/TaskUser.php'; require_once 'classes/model/Users.php'; require_once 'classes/model/Groupwf.php'; require_once 'classes/model/GroupUser.php'; $oTask = new Task(); $TaskFields = $oTask->load($task); $typeTask = $TaskFields['TAS_ASSIGN_TYPE']; if ($typeTask == 'BALANCED') { G::LoadClass('derivation'); $oDerivation = new Derivation(); $aDeriv = $oDerivation->prepareInformation(array('USER_UID' => $_SESSION['USER_LOGGED'], 'APP_UID' => $application, 'DEL_INDEX' => $_SESSION['INDEX'])); foreach ($aDeriv as $derivation) { $aUser = array('USR_UID' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_UID'], 'USR_USERNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'], 'USR_FIRSTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_FIRSTNAME'], 'USR_LASTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_LASTNAME'], 'USR_EMAIL' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_EMAIL']); $aUsers[] = $aUser; } if (count($aUsers) == 1) { return $aUser; } else { return $aUsers; } } else { return false; } }
/** * * @method * * Returns a list of the next assigned users to a case. * * @name PMFGetNextAssignedUser * @label PMFGet Next Assigned User * * @param string(32) | $application | Case ID | Id of the case * @param string(32) | $task | Task ID | Id of the task * @return array | $array | List of users | Return a list of users * */ function PMFGetNextAssignedUser($application, $task, $delIndex = null, $userUid = null) { require_once 'classes/model/AppDelegation.php'; require_once 'classes/model/Task.php'; require_once 'classes/model/TaskUser.php'; require_once 'classes/model/Users.php'; require_once 'classes/model/Groupwf.php'; require_once 'classes/model/GroupUser.php'; $oTask = new Task(); $TaskFields = $oTask->load($task); $typeTask = $TaskFields['TAS_ASSIGN_TYPE']; $g = new G(); $g->sessionVarSave(); $_SESSION['INDEX'] = !is_null($delIndex) ? $delIndex : (isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : null); $_SESSION['USER_LOGGED'] = !is_null($userUid) ? $userUid : (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : null); if ($typeTask == 'BALANCED' && !is_null($_SESSION['INDEX']) && !is_null($_SESSION['USER_LOGGED'])) { G::LoadClass('derivation'); $oDerivation = new Derivation(); $aDeriv = $oDerivation->prepareInformation(array('USER_UID' => $_SESSION['USER_LOGGED'], 'APP_UID' => $application, 'DEL_INDEX' => $_SESSION['INDEX'])); foreach ($aDeriv as $derivation) { $aUser = array('USR_UID' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_UID'], 'USR_USERNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'], 'USR_FIRSTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_FIRSTNAME'], 'USR_LASTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_LASTNAME'], 'USR_EMAIL' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_EMAIL']); $aUsers[] = $aUser; } $g->sessionVarRestore(); if (count($aUsers) == 1) { return $aUser; } else { return $aUsers; } } else { $g->sessionVarRestore(); return false; } }
/** * Return Informaction User for derivate * assignment Users * * return array Return an array with Task Case */ public function GetPrepareInformation($usr_uid, $tas_uid, $app_uid, $del_index = null) { try { $oCase = new \Cases(); $triggers = $oCase->loadTriggers( $tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE'); if (isset($triggers)){ $cases = new \ProcessMaker\BusinessModel\Cases(); foreach($triggers as $trigger){ $cases->putExecuteTriggerCase($app_uid, $trigger['TRI_UID'], $usr_uid); } } $oDerivation = new \Derivation(); $aData = array(); $aData['APP_UID'] = $app_uid; $aData['DEL_INDEX'] = $del_index; $aData['USER_UID'] = $usr_uid; $derive = $oDerivation->prepareInformation( $aData ); $response = array(); foreach ($derive as $sKey => &$aValues) { $sPriority = ''; //set priority value if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') { //TO DO: review this type of assignment if (isset( $aData['APP_DATA'][str_replace( '@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] )] )) { $sPriority = $aData['APP_DATA'][str_replace( '@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] )]; } } //set priority value switch ($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']) { case 'EVALUATE': case 'REPORT_TO': case 'BALANCED': case 'SELF_SERVICE': $taskAss = array(); $taskAss['taskId'] = $aValues['NEXT_TASK']['TAS_UID']; $taskAss['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE']; $taskAss['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']; $taskAss['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE']; $taskAss['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY'])?$aValues['NEXT_TASK']['DEL_PRIORITY']:""; $taskAss['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT']; $users = array(); $users['userId'] = $derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_UID']; $users['userFullName'] = strip_tags($derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME']); $taskAss['users'][] = $users; $response[] = $taskAss; break; case 'MANUAL': $manual = array(); $manual['taskId'] = $aValues['NEXT_TASK']['TAS_UID']; $manual['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE']; $manual['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']; $manual['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE']; $manual['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY'])?$aValues['NEXT_TASK']['DEL_PRIORITY']:""; $manual['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT']; $Aux = array (); foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser) { $Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME']; } asort( $Aux ); $users = array(); foreach ($Aux as $id => $fullname) { $user['userId'] = $id; $user['userFullName'] = $fullname; $users[] = $user; } $manual['users'] = $users; $response[] = $manual; break; case '': //when this task is the Finish process case 'nobody': $userFields = $oDerivation->getUsersFullNameFromArray( $derive[$sKey]['USER_UID'] ); $taskAss['routeFinishFlag'] = true; $user['userId'] = $derive[$sKey]['USER_UID']; $user['userFullName'] = $userFields['USR_FULLNAME']; $taskAss['users'][] = $user; $response[] = $taskAss; break; } } if (empty( $response )) { throw (new Exception( G::LoadTranslation( 'ID_NO_DERIVATION_RULE' ) )); } } catch (\Exception $e) { throw $e; } return $response; }
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames($triggers); $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers; } unset($appFields['APP_STATUS']); unset($appFields['APP_PROC_STATUS']); unset($appFields['APP_PROC_CODE']); unset($appFields['APP_PIN']); $appFields["DEL_INDEX"] = $_SESSION["INDEX"]; $appFields["TAS_UID"] = $_SESSION["TASK"]; $appFields["USER_UID"] = $_SESSION["USER_LOGGED"]; $appFields["CURRENT_DYNAFORM"] = "-2"; $appFields["OBJECT_TYPE"] = "ASSIGN_TASK"; $oCase->updateCase($_SESSION["APPLICATION"], $appFields); //Save data //derivate case $oDerivation = new Derivation(); $aCurrentDerivation = array('APP_UID' => $_SESSION['APPLICATION'], 'DEL_INDEX' => $_SESSION['INDEX'], 'APP_STATUS' => $sStatus, 'TAS_UID' => $_SESSION['TASK'], 'ROU_TYPE' => $_POST['form']['ROU_TYPE']); $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']);
/** * This function creates transitions * @param array $routes * @param array $tasks * @return array */ function createTransitionsXpdl($routes, $tasks, $taskHidden) { $cont = 0; $dataRoutes = ''; $endEvent = 1; $taskParallel = ''; $routeParallel = ''; $taskSecJoin = ''; $routeSecJoin = ''; $taskEvaluate = ''; $routeEvaluate = ''; $taskParallelEv = ''; $routeParallelEv = ''; $taskSelect = ''; $routeSelect = ''; $routeEnd = ''; $arraySecJoin = array(); $position = 0; $fillColor = ''; $transitions = ''; $condition = ''; $nextTask = ''; $findFrom = 0; $findTo = 0; $routesTasks = $routes; foreach ($routes as $key => $row) { if ($row['ROU_TYPE'] == 'SEC-JOIN') { $arraySecJoin[$position] = array(); $arraySecJoin[$position] = $row; $position = $position + 1; unset($routes[$key]); } } $aux = $arraySecJoin; foreach ($arraySecJoin as $key => $row) { $aux[$key] = $row['ROU_NEXT_TASK']; } if (sizeof($arraySecJoin) > 0) { array_multisort($aux, SORT_ASC, $arraySecJoin); unset($aux); } foreach ($routes as $key => $row) { $uid[$key] = $row['TAS_UID']; $case[$key] = $row['ROU_CASE']; } if (sizeof($routes) > 0) { array_multisort($uid, SORT_ASC, $case, SORT_ASC, $routes); } $routes = array_merge($routes, $arraySecJoin); $routesTasks = $routes; foreach ($routes as $key => $val) { $end = 0; $idRoute = $val['ROU_UID']; $idTask = $val['TAS_UID']; $nextTask = $val['ROU_NEXT_TASK']; $condition = htmlentities($val['ROU_CONDITION']); if ($nextTask == "-1") { $end = 1; } $typeRoute = $val['ROU_TYPE']; $route = ''; if ($typeRoute != "SEQUENTIAL") { switch ($typeRoute) { case 'PARALLEL': $coordinateX = 0; $coordinateY = 0; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } foreach ($taskHidden as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; $idRoute = $idTask; } } $positionX = $coordinateX + 60; $positionY = $coordinateY + 40; if ($idTask != $taskParallel) { $taskParallel = $idTask; $routeParallel = $idRoute; $dataRoutes .= ' <Activity Id="' . $routeParallel . '"> <Description /> <Route GatewayType="AND" /> <Documentation /> <ExtendedAttributes /> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="Processmaker" Height="30" Width="30" BorderColor="-5855715" FillColor="' . $fillColor . '"> <Coordinates XCoordinate="' . $positionX . '" YCoordinate="' . $positionY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; if ($taskParallel != $routeParallel) { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $taskParallel . '" To="' . $routeParallel . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeParallel . '" To="' . $nextTask . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeParallel . '" To="' . $nextTask . '" Name=""> <Condition/> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } break; case 'SEC-JOIN': $coordinateX = 0; $coordinateY = 0; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $nextTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } foreach ($taskHidden as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; $idRoute = $idTask; } } $positionX = $coordinateX + 60; $positionY = $coordinateY - 45; if ($nextTask != $taskSecJoin) { $taskSecJoin = $nextTask; $routeSecJoin = $idRoute; $dataRoutes .= ' <Activity Id="' . $routeSecJoin . '"> <Description /> <Route GatewayType="AND" /> <Documentation /> <ExtendedAttributes /> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="Processmaker" Height="30" Width="30" BorderColor="-5855715" FillColor="' . $fillColor . '"> <Coordinates XCoordinate="' . $positionX . '" YCoordinate="' . $positionY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; if ($routeSecJoin != $taskSecJoin) { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeSecJoin . '" To="' . $taskSecJoin . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $idTask . '" To="' . $routeSecJoin . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $idTask . '" To="' . $routeSecJoin . '" Name=""> <Condition/> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } break; case 'EVALUATE': $coordinateX = 0; $coordinateY = 0; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } foreach ($taskHidden as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; $idRoute = $idTask; } } $positionX = $coordinateX + 60; $positionY = $coordinateY + 40; if ($idTask != $taskEvaluate) { $taskEvaluate = $idTask; $routeEvaluate = $idRoute; if ($nextTask != "-1") { $dataRoutes .= ' <Activity Id="' . $routeEvaluate . '"> <Description /> <Route MarkerVisible="true"/> <Documentation /> <ExtendedAttributes /> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="Processmaker" Height="30" Width="30" BorderColor="-5855715" FillColor="' . $fillColor . '"> <Coordinates XCoordinate="' . $positionX . '" YCoordinate="' . $positionY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; if ($taskEvaluate != $routeEvaluate) { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $taskEvaluate . '" To="' . $routeEvaluate . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeEvaluate . '" To="' . $nextTask . '" Name=""> <Condition Type="CONDITION"> <Expression>' . $condition . '</Expression> </Condition> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } } else { if ($nextTask != "-1") { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeEvaluate . '" To="' . $nextTask . '" Name=""> <Condition Type="CONDITION"> <Expression>' . $condition . '</Expression> </Condition> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { $routeEnd = $routeEvaluate; } } break; case 'PARALLEL-BY-EVALUATION': $coordinateX = 0; $coordinateY = 0; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } foreach ($taskHidden as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; $idRoute = $idTask; } } $positionX = $coordinateX + 60; $positionY = $coordinateY + 40; if ($idTask != $taskParallelEv) { $taskParallelEv = $idTask; $routeParallelEv = $idRoute; $dataRoutes .= ' <Activity Id="' . $routeParallelEv . '"> <Description /> <Route GatewayType="OR"/> <Documentation /> <ExtendedAttributes /> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="Processmaker" Height="30" Width="30" BorderColor="-5855715" FillColor="' . $fillColor . '"> <Coordinates XCoordinate="' . $positionX . '" YCoordinate="' . $positionY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; if ($taskParallelEv != $routeParallelEv) { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $taskParallelEv . '" To="' . $routeParallelEv . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeParallelEv . '" To="' . $nextTask . '" Name=""> <Condition Type="CONDITION"> <Expression>' . $condition . '</Expression> </Condition> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeParallelEv . '" To="' . $nextTask . '" Name=""> <Condition Type="CONDITION"> <Expression>' . $condition . '</Expression> </Condition> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } break; case 'SELECT': $coordinateX = 0; $coordinateY = 0; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } foreach ($taskHidden as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; $idRoute = $idTask; } } $positionX = $coordinateX + 60; $positionY = $coordinateY + 40; if ($idTask != $taskSelect) { $taskSelect = $idTask; $routeSelect = $idRoute; $dataRoutes .= ' <Activity Id="' . $routeSelect . '"> <Description /> <Route GatewayType="Complex" /> <Documentation /> <ExtendedAttributes /> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="Processmaker" Height="30" Width="30" BorderColor="-5855715" FillColor="' . $fillColor . '"> <Coordinates XCoordinate="' . $positionX . '" YCoordinate="' . $positionY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; if ($taskSelect != $routeSelect) { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $taskSelect . '" To="' . $routeSelect . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeSelect . '" To="' . $nextTask . '" Name=""> <Condition Type="CONDITION"> <Expression>' . $condition . '</Expression> </Condition> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { if ($nextTask != "-1") { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeSelect . '" To="' . $nextTask . '" Name=""> <Condition Type="CONDITION"> <Expression>' . $condition . '</Expression> </Condition> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { $routeEnd = $routeSelect; } } break; case 'DISCRIMINATOR': $coordinateX = 0; $coordinateY = 0; $optional = $val['ROU_OPTIONAL']; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $nextTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } foreach ($taskHidden as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; $idRoute = $idTask; } } $positionX = $coordinateX + 60; $positionY = $coordinateY - 45; if ($nextTask != $taskSecJoin) { $taskDiscriminator = $nextTask; $routeDiscriminator = $idRoute; $dataRoutes .= ' <Activity Id="' . $routeDiscriminator . '"> <Description /> <Route GatewayType="Complex" /> <Documentation /> <ExtendedAttributes> <ExtendedAttribute Name="option" Value="' . $optional . '" /> <ExtendedAttribute Name="condition" Value="' . $condition . '" /> </ExtendedAttributes> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="Processmaker" Height="30" Width="30" BorderColor="-5855715" FillColor="' . $fillColor . '"> <Coordinates XCoordinate="' . $positionX . '" YCoordinate="' . $positionY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; if ($routeDiscriminator != $taskDiscriminator) { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $routeDiscriminator . '" To="' . $taskDiscriminator . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $idTask . '" To="' . $routeDiscriminator . '" Name=""> <Condition /> <Description /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $idTask . '" To="' . $routeDiscriminator . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } break; } } if ($end == 1) { if ($typeRoute == "SEQUENTIAL") { $coordinateX = 0; $coordinateY = 0; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } $positionX = $coordinateX + 65; $positionY = $coordinateY + 40; $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $idTask . '" To="' . $idRoute . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } else { $coordinateX = 0; $coordinateY = 0; foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX']; $coordinateY = $idVal['TAS_POSY']; } } $positionX = $coordinateX + 120; $positionY = $coordinateY + 40; $idTask = $routeEnd; $transitions .= ' <Transition Id="' . G::generateUniqueID() . '" From="' . $idTask . '" To="' . $idRoute . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="4" ToPort="3"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } $dataRoutes .= ' <Activity Id="' . $idRoute . '"> <Description /> <Event> <EndEvent /> </Event> <Documentation /> <ExtendedAttributes /> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="Processmaker" Height="30" Width="30" BorderColor="-6750208" FillColor="' . $fillColor . '"> <Coordinates XCoordinate="' . $positionX . '" YCoordinate="' . $positionY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; $end = 0; $endEvent = 0; } else { if ($typeRoute == "SEQUENTIAL") { $transitions .= ' <Transition Id="' . $idRoute . '" From="' . $idTask . '" To="' . $nextTask . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="2" ToPort="1"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } foreach ($tasks as $taskVal => $idVal) { if ($idVal['TAS_UID'] == $idTask) { $coordinateX = $idVal['TAS_POSX'] + 190; $coordinateY = $idVal['TAS_POSY'] + 5; if (isset($idVal['TAS_DEF_MESSAGE'])) { if ($idVal['TAS_DEF_MESSAGE'] != '' and $idVal['TAS_DEF_MESSAGE'] != Null) { $idEvent = G::generateUniqueID(); $example = new Derivation(); $fieldUserTo = $example->getAllUsersFromAnyTask($nextTask); $fieldUserTo = $example->getUsersFullNameFromArray($fieldUserTo); $fieldUserFrom = $example->getAllUsersFromAnyTask($idTask); $fieldUserFrom = $example->getUsersFullNameFromArray($fieldUserFrom); /*$oUser = new Users(); $aUser = $oUser->load($_SESSION['USER_LOGGED']); $from = $aUser['USR_USERNAME'];*/ $description = ''; $userFrom = ''; $userTo = ''; if (isset($fieldUserFrom[0]['USR_USERNAME'])) { $userFrom = $fieldUserFrom[0]['USR_USERNAME']; } if (isset($fieldUserTo[0]['USR_USERNAME'])) { $userTo = $fieldUserTo[0]['USR_USERNAME']; } $dataRoutes .= ' <Activity Id="' . $idEvent . '" Name="' . $description . '"> <Description>' . $description . '</Description> <Event> <IntermediateEvent Trigger="Message" Implementation="Other"> <TriggerResultMessage CatchThrow="THROW"> <Message Id="' . $idEvent . '" From="' . $userFrom . '" To="' . $userTo . '" Name="' . $description . '"> </Message> </TriggerResultMessage> </IntermediateEvent> </Event> <Documentation>' . $description . '</Documentation> <ExtendedAttributes /> <NodeGraphicsInfos> <NodeGraphicsInfo ToolId="BizAgi_Process_Modeler" Height="30" Width="30" BorderColor="-6909623" FillColor="-66833"> <Coordinates XCoordinate="' . $coordinateX . '" YCoordinate="' . $coordinateY . '" /> </NodeGraphicsInfo> </NodeGraphicsInfos> <IsForCompensationSpecified>false</IsForCompensationSpecified> </Activity>'; $transitions .= ' <Transition Id="t' . $idEvent . '" From="' . $idTask . '" To="' . $idEvent . '" Name=""> <Condition /> <Description /> <ExtendedAttributes /> <ConnectorGraphicsInfos> <ConnectorGraphicsInfo ToolId="Processmaker" BorderColor="0" FromPort="4" ToPort="3"> </ConnectorGraphicsInfo> </ConnectorGraphicsInfos> </Transition>'; } } } } } } $data = array(); $data['ACTIVITIES'] = $dataRoutes; $data['TRANSITION'] = $transitions; return $data; }
/** * Return Informaction User for derivate * assignment Users * * return array Return an array with Task Case */ public function GetPrepareInformation($usr_uid, $tas_uid, $app_uid, $del_index = null) { try { $oCase = new \Cases(); $Fields = $oCase->loadCase($app_uid); $_SESSION["APPLICATION"] = $app_uid; $_SESSION["PROCESS"] = $Fields['PRO_UID']; $_SESSION["TASK"] = $tas_uid; $_SESSION["INDEX"] = $del_index; $_SESSION["USER_LOGGED"] = $usr_uid; $_SESSION["USR_USERNAME"] = isset($Fields['APP_DATA']['USR_USERNAME']) ? $Fields['APP_DATA']['USR_USERNAME'] : ''; $triggers = $oCase->loadTriggers($tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE'); if (isset($triggers)) { $Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants()); $Fields['APP_DATA'] = $oCase->ExecuteTriggers($tas_uid, 'DYNAFORM', '-1', 'BEFORE', $Fields['APP_DATA']); $oCase->updateCase($app_uid, $Fields); } $oDerivation = new \Derivation(); $aData = array(); $aData['APP_UID'] = $app_uid; $aData['DEL_INDEX'] = $del_index; $aData['USER_UID'] = $usr_uid; $derive = $oDerivation->prepareInformation($aData); $response = array(); foreach ($derive as $sKey => &$aValues) { $sPriority = ''; //set priority value if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') { //TO DO: review this type of assignment if (isset($aData['APP_DATA'][str_replace('@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])])) { $sPriority = $aData['APP_DATA'][str_replace('@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])]; } } //set priority value $taskType = isset($aValues["NEXT_TASK"]["TAS_TYPE"]) ? $aValues["NEXT_TASK"]["TAS_TYPE"] : false; $taskMessage = ""; switch ($taskType) { case "SCRIPT-TASK": $taskMessage = G::LoadTranslation("ID_ROUTE_TO_TASK_SCRIPT_TASK"); break; case "INTERMEDIATE-CATCH-TIMER-EVENT": $taskMessage = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_TIMER_EVENT"); break; } switch ($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']) { case 'EVALUATE': case 'REPORT_TO': case 'BALANCED': case 'SELF_SERVICE': $taskAss = array(); $taskAss['taskId'] = $aValues['NEXT_TASK']['TAS_UID']; $taskAss['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE']; $taskAss['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']; $taskAss['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE']; $taskAss['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY']) ? $aValues['NEXT_TASK']['DEL_PRIORITY'] : ""; $taskAss['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT']; $taskAss['taskMessage'] = $taskType ? $taskMessage : ""; $users = array(); $users['userId'] = $derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_UID']; $users['userFullName'] = strip_tags($derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME']); $taskAss['users'][] = $users; $response[] = $taskAss; break; case 'MANUAL': case "MULTIPLE_INSTANCE": case "MULTIPLE_INSTANCE_VALUE_BASED": $manual = array(); $manual['taskId'] = $aValues['NEXT_TASK']['TAS_UID']; $manual['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE']; $manual['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']; $manual['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE']; $manual['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY']) ? $aValues['NEXT_TASK']['DEL_PRIORITY'] : ""; $manual['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT']; $manual['taskMessage'] = $taskType ? $taskMessage : ""; $Aux = array(); foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser) { $Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME']; } asort($Aux); $users = array(); foreach ($Aux as $id => $fullname) { $user['userId'] = $id; $user['userFullName'] = $fullname; $users[] = $user; } $manual['users'] = $users; $response[] = $manual; break; case '': //when this task is the Finish process //when this task is the Finish process case 'nobody': $userFields = $oDerivation->getUsersFullNameFromArray($derive[$sKey]['USER_UID']); $taskAss = array(); $taskAss['routeFinishFlag'] = true; $user['userId'] = $derive[$sKey]['USER_UID']; $user['userFullName'] = $userFields['USR_FULLNAME']; $taskAss['users'][] = $user; $response[] = $taskAss; break; } } if (empty($response)) { throw new \Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE")); } } catch (\Exception $e) { throw $e; } return $response; }
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; } }