leimnud.make(); leimnud.Package.Load("rpc,drag,drop,panel,app,validator,fx,dom,abbr",{Instance:leimnud,Type:"module"}); leimnud.exec(leimnud.fix.memoryLeak); leimnud.event.add(window,"load",function(){ ' . (isset($_SESSION['showCasesWindow']) ? 'try{' . $_SESSION['showCasesWindow'] . '}catch(e){}' : '') . ' }); '); $G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower); $oCase = new Cases(); $Fields = $oCase->loadCase($_SESSION['APPLICATION']); $Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants()); $sStatus = $Fields['APP_STATUS']; $APP_NUMBER = $Fields['APP_NUMBER']; $APP_TITLE = $Fields['TITLE']; $oProcess = new Process(); $oProcessFieds = $oProcess->Load($_SESSION['PROCESS']); #trigger debug routines... if (isset($oProcessFieds['PRO_DEBUG']) && $oProcessFieds['PRO_DEBUG']) { #here we must verify if is a debugg session $_SESSION['TRIGGER_DEBUG']['ISSET'] = 1; $_SESSION['PMDEBUGGER'] = true; } else { $_SESSION['TRIGGER_DEBUG']['ISSET'] = 0; $_SESSION['PMDEBUGGER'] = false; } //cleaning debug variables if (!isset($_GET['breakpoint'])) { if (isset($_SESSION['TRIGGER_DEBUG']['info'])) { unset($_SESSION['TRIGGER_DEBUG']['info']); } if (!isset($_SESSION['_NO_EXECUTE_TRIGGERS_'])) {
/** * derivate Case moves the case to the next task in the process according to the routing rules * * @param string $userId * @param string $caseId * @param string $delIndex * @param array $tasks * @param bool $bExecuteTriggersBeforeAssignment * @return $result will return an object */ public function derivateCase ($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks = array()) { $g = new G(); try { $g->sessionVarSave(); $_SESSION["APPLICATION"] = $caseId; $_SESSION["INDEX"] = $delIndex; $_SESSION["USER_LOGGED"] = $userId; $sStatus = 'TO_DO'; $varResponse = ''; $varTriggers = "\n"; if ($delIndex == '') { $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX ); $oCriteria->add( AppDelegationPeer::APP_UID, $caseId ); $oCriteria->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL ); if (AppDelegationPeer::doCount( $oCriteria ) > 1) { $result = new wsResponse( 20, G::loadTranslation( 'ID_SPECIFY_DELEGATION_INDEX' ) ); return $result; } $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); $delIndex = $aRow['DEL_INDEX']; } $oAppDel = new AppDelegation(); $appdel = $oAppDel->Load( $caseId, $delIndex ); if ($userId != $appdel['USR_UID']) { $result = new wsResponse( 17, G::loadTranslation( 'ID_CASE_ASSIGNED_ANOTHER_USER' ) ); return $result; } if ($appdel['DEL_FINISH_DATE'] != null) { $result = new wsResponse( 18, G::loadTranslation( 'ID_CASE_DELEGATION_ALREADY_CLOSED' ) ); return $result; } $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( AppDelayPeer::APP_UID ); $oCriteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX ); $oCriteria->add( AppDelayPeer::APP_TYPE, '' ); $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'PAUSE' )->addOr( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'CANCEL' ) ) ); $oCriteria->addAscendingOrderByColumn( AppDelayPeer::APP_ENABLE_ACTION_DATE ); $oDataset = AppDelayPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (is_array( $aRow )) { if (isset( $aRow['APP_DISABLE_ACTION_USER'] ) && $aRow['APP_DISABLE_ACTION_USER'] != 0 && isset( $aRow['APP_DISABLE_ACTION_DATE'] ) && $aRow['APP_DISABLE_ACTION_DATE'] != '') { $result = new wsResponse( 19, G::loadTranslation( 'ID_CASE_IN_STATUS' ) . " " . $aRow['APP_TYPE'] ); return $result; } } $aData = array(); $aData['APP_UID'] = $caseId; $aData['DEL_INDEX'] = $delIndex; $aData['USER_UID'] = $userId; //Load data $oCase = new Cases(); $appFields = $oCase->loadCase( $caseId, $delIndex ); if (is_null( $appFields["DEL_INIT_DATE"] )) { $oCase->setDelInitDate( $caseId, $delIndex ); $appFields = $oCase->loadCase( $caseId, $delIndex ); } $appFields["APP_DATA"]["APPLICATION"] = $caseId; if (! isset( $_SESSION["PROCESS"] )) { $_SESSION["PROCESS"] = $appFields["PRO_UID"]; } if ($bExecuteTriggersBeforeAssignment) { //Execute triggers before assignment $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 1, 'BEFORE' ); if (count( $aTriggers ) > 0) { $varTriggers = $varTriggers . "<br /><b>-= Before Assignment =-</b><br />"; $oPMScript = new PMScript(); foreach ($aTriggers as $aTrigger) { //$appFields = $oCase->loadCase( $caseId ); //$appFields['APP_DATA']['APPLICATION'] = $caseId; //Set variables $params = new stdClass(); $params->appData = $appFields["APP_DATA"]; if ($this->stored_system_variables) { $params->option = "STORED SESSION"; $params->SID = $this->wsSessionId; } $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); //PMScript $oPMScript->setFields( $appFields['APP_DATA'] ); $bExecute = true; if ($aTrigger['ST_CONDITION'] !== '') { $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); $bExecute = $oPMScript->evaluate(); } if ($bExecute) { $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); $oPMScript->execute(); $trigger = TriggersPeer::retrieveByPk($aTrigger["TRI_UID"]); $varTriggers = $varTriggers . " - " . nl2br(htmlentities($trigger->getTriTitle(), ENT_QUOTES)) . "<br />"; //$appFields = $oCase->loadCase( $caseId ); $appFields['APP_DATA'] = $oPMScript->aFields; unset($appFields['APP_STATUS']); unset($appFields['APP_PROC_STATUS']); unset($appFields['APP_PROC_CODE']); unset($appFields['APP_PIN']); $oCase->updateCase( $caseId, $appFields ); } } } } //Execute triggers before derivation BEFORE_ROUTING $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 2, 'BEFORE' ); if (count( $aTriggers ) > 0) { $varTriggers .= "<b>-= Before Derivation =-</b><br/>"; $oPMScript = new PMScript(); foreach ($aTriggers as $aTrigger) { //$appFields = $oCase->loadCase( $caseId ); //$appFields['APP_DATA']['APPLICATION'] = $caseId; //Set variables $params = new stdClass(); $params->appData = $appFields["APP_DATA"]; if ($this->stored_system_variables) { $params->option = "STORED SESSION"; $params->SID = $this->wsSessionId; } $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); //PMScript $oPMScript->setFields( $appFields['APP_DATA'] ); $bExecute = true; if ($aTrigger['ST_CONDITION'] !== '') { $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); $bExecute = $oPMScript->evaluate(); } if ($bExecute) { $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); $oPMScript->execute(); $oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] ); $varTriggers .= " - " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "<br/>"; //$appFields = $oCase->loadCase( $caseId ); $appFields['APP_DATA'] = $oPMScript->aFields; unset($appFields['APP_STATUS']); unset($appFields['APP_PROC_STATUS']); unset($appFields['APP_PROC_CODE']); unset($appFields['APP_PIN']); //$appFields['APP_DATA']['APPLICATION'] = $caseId; $oCase->updateCase( $caseId, $appFields ); } } } $oDerivation = new Derivation(); if (!empty($tasks)) { $nextDelegations = $tasks; } else { $derive = $oDerivation->prepareInformation($aData); if (isset($derive[1])) { if ($derive[1]['ROU_TYPE'] == 'SELECT') { $result = new wsResponse(21, G::loadTranslation('ID_CAN_NOT_ROUTE_CASE_USING_WEBSERVICES')); return $result; } } else { $result = new wsResponse(22, G::loadTranslation('ID_TASK_DOES_NOT_HAVE_ROUTING_RULE')); return $result; } foreach ($derive as $key => $val) { if ($val['NEXT_TASK']['TAS_ASSIGN_TYPE'] == 'MANUAL') { $result = new wsResponse(15, G::loadTranslation('ID_TASK_DEFINED_MANUAL_ASSIGNMENT')); return $result; } //Routed to the next task, if end process then not exist user $nodeNext = array(); $usrasgdUid = null; $usrasgdUserName = null; if (isset($val['NEXT_TASK']['USER_ASSIGNED'])) { $usrasgdUid = $val['NEXT_TASK']['USER_ASSIGNED']['USR_UID']; $usrasgdUserName = '******' . $val['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'] . ')'; } $nodeNext['TAS_UID'] = $val['NEXT_TASK']['TAS_UID']; $nodeNext['USR_UID'] = $usrasgdUid; $nodeNext['TAS_ASSIGN_TYPE'] = $val['NEXT_TASK']['TAS_ASSIGN_TYPE']; $nodeNext['TAS_DEF_PROC_CODE'] = $val['NEXT_TASK']['TAS_DEF_PROC_CODE']; $nodeNext['DEL_PRIORITY'] = $appdel['DEL_PRIORITY']; $nodeNext['TAS_PARENT'] = $val['NEXT_TASK']['TAS_PARENT']; $nextDelegations[] = $nodeNext; $varResponse = $varResponse . (($varResponse != '') ? ',' : '') . $val['NEXT_TASK']['TAS_TITLE'] . $usrasgdUserName; } } $appFields['DEL_INDEX'] = $delIndex; if (isset( $derive['TAS_UID'] )) { $appFields['TAS_UID'] = $derive['TAS_UID']; } //Save data - Start //$appFields = $oCase->loadCase( $caseId ); //$oCase->updateCase ( $caseId, $appFields ); //Save data - End $row = array (); $oCriteria = new Criteria( 'workflow' ); $del = DBAdapter::getStringDelimiter(); $oCriteria->addSelectColumn( RoutePeer::ROU_TYPE ); $oCriteria->addSelectColumn( RoutePeer::ROU_NEXT_TASK ); $oCriteria->add( RoutePeer::TAS_UID, $appdel['TAS_UID'] ); $oDataset = TaskPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $row[] = array ('ROU_TYPE' => $aRow['ROU_TYPE'],'ROU_NEXT_TASK' => $aRow['ROU_NEXT_TASK'] ); $oDataset->next(); } //derivate case $aCurrentDerivation = array ('APP_UID' => $caseId,'DEL_INDEX' => $delIndex,'APP_STATUS' => $sStatus,'TAS_UID' => $appdel['TAS_UID'],'ROU_TYPE' => $row[0]['ROU_TYPE'] ); $oDerivation->derivate( $aCurrentDerivation, $nextDelegations ); $appFields = $oCase->loadCase( $caseId ); //Execute triggers after derivation $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 2, 'AFTER' ); if (count( $aTriggers ) > 0) { //$appFields['APP_DATA']['APPLICATION'] = $caseId; //Set variables $params = new stdClass(); $params->appData = $appFields["APP_DATA"]; if ($this->stored_system_variables) { $params->option = "STORED SESSION"; $params->SID = $this->wsSessionId; } $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); //PMScript $oPMScript = new PMScript(); $oPMScript->setFields( $appFields['APP_DATA'] ); $varTriggers .= "<b>-= After Derivation =-</b><br/>"; foreach ($aTriggers as $aTrigger) { $bExecute = true; if ($aTrigger['ST_CONDITION'] !== '') { $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); $bExecute = $oPMScript->evaluate(); } if ($bExecute) { $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); $oPMScript->execute(); $oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] ); $varTriggers .= " - " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "<br/>"; //$appFields = $oCase->loadCase($caseId); $appFields['APP_DATA'] = $oPMScript->aFields; //$appFields['APP_DATA']['APPLICATION'] = $caseId; //$appFields = $oCase->loadCase($caseId); unset($aFields['APP_STATUS']); unset($aFields['APP_PROC_STATUS']); unset($aFields['APP_PROC_CODE']); unset($aFields['APP_PIN']); $oCase->updateCase( $caseId, $appFields ); } } } $sFromName = ""; if ($userId != "") { $user = new Users(); $arrayUserData = $user->load($userId); if (trim($arrayUserData["USR_EMAIL"]) == "") { $arrayUserData["USR_EMAIL"] = "info@" . $_SERVER["HTTP_HOST"]; } $sFromName = "\"" . $arrayUserData["USR_FIRSTNAME"] . " " . $arrayUserData["USR_LASTNAME"] . "\" <" . $arrayUserData["USR_EMAIL"] . ">"; } $oCase->sendNotifications( $appdel['TAS_UID'], $nextDelegations, $appFields['APP_DATA'], $caseId, $delIndex, $sFromName ); // Send notifications Mobile - Start try { $oLight = new \ProcessMaker\BusinessModel\Light(); $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $delIndex); $notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice(); $notificationMobile->routeCaseNotification($userId, $_SESSION["PROCESS"], $appdel['TAS_UID'], $appFields, $nextDelegations, $nextIndex); } catch (Exception $e) { \G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log"); } // Send notifications Mobile - End //Save data - Start //$appFields = $oCase->loadCase($caseId); //$oCase->updateCase($caseId, $appFields); //Save data - End $oProcess = new Process(); $oProcessFieds = $oProcess->Load( $appFields['PRO_UID'] ); //here dubug mode in web entry if (isset( $oProcessFieds['PRO_DEBUG'] ) && $oProcessFieds['PRO_DEBUG']) { $result = new wsResponse( 0, $varResponse . " <br><br><table width='100%' cellpadding='0' cellspacing='0'><tr><td class='FormTitle'> " . G::LoadTranslation( 'ID_DEBUG_MESSAGE' ) . "</td></tr></table>" . $varTriggers ); } else { $result = new wsResponse( 0, $varResponse . " --- " . $oProcessFieds['PRO_DEBUG'] ); } $res = $result->getPayloadArray(); //now fill the array of AppDelegationPeer $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX ); $oCriteria->addSelectColumn( AppDelegationPeer::USR_UID ); $oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_THREAD ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_THREAD_STATUS ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE ); $oCriteria->add( AppDelegationPeer::APP_UID, $caseId ); $oCriteria->add( AppDelegationPeer::DEL_PREVIOUS, $delIndex ); $oCriteria->addAscendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $aCurrentUsers = array (); while ($oDataset->next()) { $aAppDel = $oDataset->getRow(); $oUser = new Users(); try { $oUser->load( $aAppDel['USR_UID'] ); $uFields = $oUser->toArray( BasePeer::TYPE_FIELDNAME ); $currentUserName = $oUser->getUsrFirstname() . ' ' . $oUser->getUsrLastname(); } catch (Exception $e) { $currentUserName = ''; } $oTask = new Task(); try { $uFields = $oTask->load( $aAppDel['TAS_UID'] ); $taskName = $uFields['TAS_TITLE']; } catch (Exception $e) { $taskName = ''; } // execute events $eventPro = $_SESSION["PROCESS"]; $eventApp = $caseId; $eventInd = $aAppDel['DEL_INDEX']; $eventTas = $aAppDel['TAS_UID']; $oEvent = new Event(); $oEvent->createAppEvents( $eventPro, $eventApp, $eventInd, $eventTas ); // end events $currentUser = new stdClass(); $currentUser->userId = $aAppDel['USR_UID']; $currentUser->userName = $currentUserName; $currentUser->taskId = $aAppDel['TAS_UID']; $currentUser->taskName = $taskName; $currentUser->delIndex = $aAppDel['DEL_INDEX']; $currentUser->delThread = $aAppDel['DEL_THREAD']; $currentUser->delThreadStatus = $aAppDel['DEL_THREAD_STATUS']; $aCurrentUsers[] = $currentUser; } $res['routing'] = $aCurrentUsers; $g->sessionVarRestore(); return $res; } catch (Exception $e) { $result = new wsResponse( 100, $e->getMessage() ); $g->sessionVarRestore(); return $result; } }
/** * prepareInformation * * @param array $arrayData Data * @param string $taskUid Unique id of Task * * return array Return array */ public function prepareInformation(array $arrayData, $taskUid = "") { try { if (!class_exists("Cases")) { G::LoadClass("case"); } $this->case = new Cases(); $task = new Task(); $arrayNextTask = array(); $arrayNextTaskDefault = array(); $i = 0; //SELECT * //FROM APP_DELEGATION AS A //LEFT JOIN TASK AS T ON(T.TAS_UID = A.TAS_UID) //LEFT JOIN ROUTE AS R ON(R.TAS_UID = A.TAS_UID) //WHERE //APP_UID = '$arrayData["APP_UID"]' //AND DEL_INDEX = '$arrayData["DEL_INDEX"]' $criteria = new Criteria("workflow"); $criteria->addSelectColumn(RoutePeer::TAS_UID); $criteria->addSelectColumn(RoutePeer::ROU_NEXT_TASK); $criteria->addSelectColumn(RoutePeer::ROU_TYPE); $criteria->addSelectColumn(RoutePeer::ROU_DEFAULT); $criteria->addSelectColumn(RoutePeer::ROU_CONDITION); if ($taskUid != "") { $criteria->add(RoutePeer::TAS_UID, $taskUid, Criteria::EQUAL); $criteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE); $rsCriteria = RoutePeer::doSelectRS($criteria); } else { $criteria->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $criteria->addJoin(AppDelegationPeer::TAS_UID, RoutePeer::TAS_UID, Criteria::LEFT_JOIN); $criteria->add(AppDelegationPeer::APP_UID, $arrayData["APP_UID"], Criteria::EQUAL); $criteria->add(AppDelegationPeer::DEL_INDEX, $arrayData["DEL_INDEX"], Criteria::EQUAL); $criteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE); $rsCriteria = AppDelegationPeer::doSelectRS($criteria); } $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $flagDefault = false; while ($rsCriteria->next()) { $arrayRouteData = G::array_merges($rsCriteria->getRow(), $arrayData); if ((int)($arrayRouteData["ROU_DEFAULT"]) == 1) { $arrayNextTaskDefault = $arrayRouteData; $flagDefault = true; continue; } $flagContinue = true; //Evaluate the condition if there are conditions defined if (isset($arrayRouteData["ROU_CONDITION"]) && trim($arrayRouteData["ROU_CONDITION"]) != "" && ($arrayRouteData["ROU_TYPE"] != "SELECT" || $arrayRouteData["ROU_TYPE"] == "PARALLEL-BY-EVALUATION")) { G::LoadClass("pmScript"); $arrayApplicationData = $this->case->loadCase($arrayData["APP_UID"]); $pmScript = new PMScript(); $pmScript->setFields($arrayApplicationData["APP_DATA"]); $pmScript->setScript($arrayRouteData["ROU_CONDITION"]); $flagContinue = $pmScript->evaluate(); } if (isset($arrayRouteData["ROU_CONDITION"]) && trim($arrayRouteData["ROU_CONDITION"]) == "" && $arrayRouteData["ROU_NEXT_TASK"] != "-1") { $arrayTaskData = $task->load($arrayRouteData["ROU_NEXT_TASK"]); if ($arrayTaskData["TAS_TYPE"] == "GATEWAYTOGATEWAY") { $flagContinue = false; } } if ($arrayRouteData["ROU_TYPE"] == "EVALUATE" && count($arrayNextTask) > 0) { $flagContinue = false; } if ($flagContinue) { $arrayNextTask[++$i] = $this->prepareInformationTask($arrayRouteData); } } if (count($arrayNextTask) == 0 && count($arrayNextTaskDefault) > 0) { $arrayNextTask[++$i] = $this->prepareInformationTask($arrayNextTaskDefault); } //Check Task GATEWAYTOGATEWAY or END-MESSAGE-EVENT or END-EMAIL-EVENT $arrayNextTaskBackup = $arrayNextTask; $arrayNextTask = array(); $i = 0; foreach ($arrayNextTaskBackup as $value) { $arrayNextTaskData = $value; if ($arrayNextTaskData["NEXT_TASK"]["TAS_UID"] != "-1" && in_array($arrayNextTaskData["NEXT_TASK"]["TAS_TYPE"], array("GATEWAYTOGATEWAY", "END-MESSAGE-EVENT", "END-EMAIL-EVENT")) ) { $arrayAux = $this->prepareInformation($arrayData, $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]); foreach ($arrayAux as $value2) { $arrayNextTask[++$i] = $value2; } } else { if (in_array($arrayNextTaskData["TAS_TYPE"], array("END-MESSAGE-EVENT", "END-EMAIL-EVENT")) && $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] == "-1" ) { $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] = $arrayNextTaskData["TAS_UID"] . "/" . $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]; } $arrayNextTask[++$i] = $arrayNextTaskData; } } //1. There is no rule if (count($arrayNextTask) == 0) { $oProcess = new Process(); $oProcessFieds = $oProcess->Load( $_SESSION['PROCESS'] ); if(isset($oProcessFieds['PRO_BPMN']) && $oProcessFieds['PRO_BPMN'] == 1){ throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_BPMN_RULE")); }else{ throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE")); } } //Return return $arrayNextTask; } catch (Exception $e) { throw $e; } }
/** * get a Process with a search based in the process Uid * * @param $sProUid string process Uid * @return $oProcess Process object */ public function getProcessRow ($sProUid, $getAllLang = false) { $oProcess = new Process(); return $oProcess->Load( $sProUid, $getAllLang ); }
public function getCompleteDocumentInfo ($appUid, $appDocUid, $docVersion, $docUid, $usrId) { //require_once ("classes/model/AppDocument.php"); //require_once ("classes/model/InputDocument.php"); //require_once ("classes/model/OutputDocument.php"); //require_once ("classes/model/Users.php"); //**** start get Doc Info $oApp = new Application(); $oAppDocument = new AppDocument(); G::LoadClass( 'case' ); $oCase = new Cases(); G::LoadClass( 'process' ); $oProcess = new Process(); if (($oApp->exists( $appUid )) || ($appUid == "00000000000000000000000000000000")) { if ($appUid == "00000000000000000000000000000000") { //External Files $row1 = $oAppDocument->load( $appDocUid, $docVersion ); $row2 = array ('PRO_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); $row3 = array ('APP_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); } else { $row1 = $oAppDocument->load( $appDocUid, $docVersion ); $row2 = $oCase->loadCase( $appUid ); $row3 = $oProcess->Load( $row2['PRO_UID'] ); } $lastVersion = $oAppDocument->getLastAppDocVersion( $appDocUid, $appUid ); switch ($row1['APP_DOC_TYPE']) { case "OUTPUT": $oOutputDocument = new OutputDocument(); $row4 = array(); $swOutDocExists = 0; if ($oOutputDocument->OutputExists($docUid)) { $row4 = $oOutputDocument->load($docUid); $swOutDocExists = 1; } if ($swOutDocExists == 0) { $swpdf = 0; $swdoc = 0; $info = pathinfo($oAppDocument->getAppDocFilename()); $version = (!empty($docVersion))? "_" . $docVersion : "_1"; $outDocPath = PATH_DOCUMENT . G::getPathFromUID($row1["APP_UID"]) . PATH_SEP . "outdocs" . PATH_SEP; if (file_exists($outDocPath . $appDocUid . $version . ".pdf") || file_exists($outDocPath . $info["basename"] . $version . ".pdf") || file_exists($outDocPath . $info["basename"] . ".pdf") ) { $swpdf = 1; } if (file_exists($outDocPath . $appDocUid . $version . ".doc") || file_exists($outDocPath . $info["basename"] . $version . ".doc") || file_exists($outDocPath . $info["basename"] . ".doc") ) { $swdoc = 1; } if ($swpdf == 1 && $swdoc == 1) { $row4["OUT_DOC_GENERATE"] = "BOTH"; } else { if ($swpdf == 1) { $row4["OUT_DOC_GENERATE"] = "PDF"; } else { if ($swdoc == 1) { $row4["OUT_DOC_GENERATE"] = "DOC"; } else { $row4["OUT_DOC_GENERATE"] = "NOFILE"; } } } } $versioningEnabled = false; //$row4['OUT_DOC_VERSIONING']; //Only enabled for Input or Attached documents. Need to study the best way for Output docs. switch ($row4['OUT_DOC_GENERATE']) { case "PDF": $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); $downloadLink1 = ""; $downloadLabel = ".pdf"; $downloadLabel1 = ""; break; case "DOC": $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); $downloadLink1 = ""; $downloadLabel = ".doc"; $downloadLabel1 = ""; break; case "BOTH": $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); $downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); $downloadLabel = ".pdf"; $downloadLabel1 = ".doc"; break; case "NOFILE": $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation("ID_DOWNLOAD"); $downloadLabel1 = ""; break; } if ($swOutDocExists == 0) { $row4 = array(); } break; case "INPUT": $oInputDocument = new InputDocument(); if ($docUid != - 1) { if ($oInputDocument->InputExists( $docUid )) { $row4 = $oInputDocument->load( $docUid ); $versioningEnabled = $row4['INP_DOC_VERSIONING']; } else { $row4 = array (); $versioningEnabled = false; } $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); $downloadLabel1 = ""; } else { $row4 = array (); $versioningEnabled = false; $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); $downloadLabel1 = ""; } if (! empty( $row1["APP_DOC_PLUGIN"] )) { $pluginRegistry = &PMPluginRegistry::getSingleton(); $pluginName = $row1["APP_DOC_PLUGIN"]; $fieldValue = ""; if (file_exists( PATH_PLUGINS . $pluginName . ".php" )) { $pluginDetail = $pluginRegistry->getPluginDetails( $pluginName . ".php" ); if ($pluginDetail) { if ($pluginDetail->enabled) { require_once (PATH_PLUGINS . $pluginName . ".php"); $pluginNameClass = $pluginName . "Plugin"; $objPluginClass = new $pluginNameClass( $pluginName ); if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) { if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) { require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php"); $pluginNameClass = $pluginName . "Class"; $objClass = new $pluginNameClass(); if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) { eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" ); $downloadLink = $url; $fieldValue = $row1["APP_DOC_PLUGIN"]; } } } } } } $row1["APP_DOC_PLUGIN"] = $fieldValue; } break; default: $row4 = array (); $versioningEnabled = false; $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; $downloadLink1 = ""; $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); $downloadLabel1 = ""; break; } $oUser = new Users(); if (($usrId != "-1") && ($oUser->userExists( $usrId ))) { $row5 = $oUser->load( $usrId ); } else { $row5['USR_USERNAME'] = "******"; } //Labels/Links $row6 = array (); $row6['DELETE_LABEL'] = G::LoadTranslation( 'ID_DELETE' ); $row6['DOWNLOAD_LABEL'] = $downloadLabel; $row6['DOWNLOAD_LINK'] = $downloadLink; $row6['DOWNLOAD_LABEL1'] = $downloadLabel1; $row6['DOWNLOAD_LINK1'] = $downloadLink1; //if(($docVersion>1)&&($row1['APP_DOC_TYPE']!="OUTPUT")){ if (($docVersion > 1)) { $row6['VERSIONHISTORY_LABEL'] = G::LoadTranslation( 'ID_VERSION_HISTORY' ); } if ($versioningEnabled) { $row6['NEWVERSION_LABEL'] = G::LoadTranslation( 'ID_NEW_VERSION' ); } $row6['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion; if ($appUid == "00000000000000000000000000000000") { //External Files $row1['APP_DOC_TYPE'] = G::LoadTranslation( 'ID_EXTERNAL_FILE' ); } //**** End get docinfo $infoMerged = array_merge( $row1, $row2, $row3, $row4, $row5, $row6 ); $sUserUID = $_SESSION['USER_LOGGED']; $aObjectPermissions = array (); if (isset( $infoMerged['PRO_UID'] )) { $aObjectPermissions = $oCase->getAllObjects( $infoMerged['PRO_UID'], $infoMerged['APP_UID'], '', $sUserUID ); } if (! is_array( $aObjectPermissions )) { $aObjectPermissions = array ('DYNAFORMS' => array (- 1), 'INPUT_DOCUMENTS' => array (- 1), 'OUTPUT_DOCUMENTS' => array (- 1) ); } if (! isset( $aObjectPermissions['DYNAFORMS'] )) { $aObjectPermissions['DYNAFORMS'] = array (- 1); } else { if (! is_array( $aObjectPermissions['DYNAFORMS'] )) { $aObjectPermissions['DYNAFORMS'] = array (- 1); } } if (! isset( $aObjectPermissions['INPUT_DOCUMENTS'] )) { $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); } else { if (! is_array( $aObjectPermissions['INPUT_DOCUMENTS'] )) { $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); } } if (! isset( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); } else { if (! is_array( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); } } return array_merge( $infoMerged, $aObjectPermissions ); } }
// $t->is ( $e->getMessage(), "This row doesn't exist!", "update() This row doesn't exist!" ); $t->todo(" {$e->getMessage}() This row doesn't exist! <> The row '' in table Process doesn't exist! " . " line 171"); } //update with $fields $newTitle = 'new title ' . rand(1000, 5000); $newDescription = 'new Description ' . rand(1000, 5000); $Fields['PRO_UID'] = $proUid; $Fields['PRO_TITLE'] = $newTitle; $Fields['PRO_PARENT'] = rand(1000, 5000); $Fields['PRO_CREATE_DATE'] = 'now'; try { $obj = new Process(); $res = $obj->update($Fields); //#30 $t->is($res, 1, "update() update 1 row"); $Fields = $obj->Load($proUid); //#26 $t->is($obj->getproUid(), $proUid, "update() APP_UID = " . $proUid); //#27 $t->is($obj->getProTitle(), $newTitle, "update() getAppTitle"); //#28 $t->is($Fields['PRO_TITLE'], $newTitle, "update() PRO_TITLE= " . $newTitle); //#29 $t->is($Fields['PRO_CREATE_DATE'], date('Y-m-d H:i:s'), "update() PRO_CREATE_DATE= " . date('Y-m-d H:i:s')); } catch (Exception $e) { //#14 $t->isa_ok($e, 'PropelException', 'update() return error ' . $e->getMessage()); print $e->getMessage(); } //remove with empty try {
G::LoadClass('dynaFormField'); G::LoadClass('process'); G::LoadClass('dynaform'); //G::LoadClass('configuration'); G::LoadSystem('inputfilter'); $filter = new InputFilter(); $G_MAIN_MENU = 'processmaker'; $G_SUB_MENU = 'processes'; $G_ID_MENU_SELECTED = 'PROCESSES'; $G_ID_SUB_MENU_SELECTED = 'FIELDS'; $dbc = new DBConnection(); $ses = new DBSession($dbc); //Hardcode: UID of the library by default $PRO_UID = isset($_POST['PRO_UID']) ? $_POST['PRO_UID'] : '746B734DC23311'; $process = new Process($dbc); $process->Load($PRO_UID); $dynaform = new dynaform($dbc); $dynaform->Fields['DYN_UID'] = isset($_POST['DYN_UID']) ? urldecode($_POST['DYN_UID']) : '0'; $dynaform->Load($dynaform->Fields['DYN_UID']); if (isset($_POST['DYN_UID']) && $_POST['DYN_UID'] !== '') { $file = $dynaform->Fields['DYN_FILENAME']; } else { //Hardcode: Sample of xmlform. $file = $PRO_UID . '/' . 'myInfo'; } /* Start Comment: If file doesn't exist, it is created */ if (!file_exists(PATH_DYNAFORM . $file . '.xml')) { $newDoc = new Xml_Document(); $newDoc->addChildNode(new Xml_Node('dynaForm', 'open', '', array('type' => 'xmlform', 'name' => $file))); $newDoc->children[0]->addChildNode(new Xml_Node('', 'cdata', "\n")); G::verifyPath(dirname(PATH_DYNAFORM . $file . '.xml'), true);
/** * prepareInformation * * @param array $arrayData Data * @param string $taskUid Unique id of Task * * @return array Return array */ public function prepareInformation(array $arrayData, $taskUid = "") { try { if (!class_exists("Cases")) { G::LoadClass("case"); } $this->case = new Cases(); $task = new Task(); $arrayApplicationData = $this->case->loadCase($arrayData["APP_UID"]); $arrayNextTask = array(); $arrayNextTaskDefault = array(); $i = 0; //SELECT * //FROM APP_DELEGATION AS A //LEFT JOIN TASK AS T ON(T.TAS_UID = A.TAS_UID) //LEFT JOIN ROUTE AS R ON(R.TAS_UID = A.TAS_UID) //WHERE //APP_UID = '$arrayData["APP_UID"]' //AND DEL_INDEX = '$arrayData["DEL_INDEX"]' $criteria = new Criteria("workflow"); $criteria->addSelectColumn(RoutePeer::TAS_UID); $criteria->addSelectColumn(RoutePeer::ROU_NEXT_TASK); $criteria->addSelectColumn(RoutePeer::ROU_TYPE); $criteria->addSelectColumn(RoutePeer::ROU_DEFAULT); $criteria->addSelectColumn(RoutePeer::ROU_CONDITION); if ($taskUid != "") { $criteria->add(RoutePeer::TAS_UID, $taskUid, Criteria::EQUAL); $criteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE); $rsCriteria = RoutePeer::doSelectRS($criteria); } else { $criteria->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $criteria->addJoin(AppDelegationPeer::TAS_UID, RoutePeer::TAS_UID, Criteria::LEFT_JOIN); $criteria->add(AppDelegationPeer::APP_UID, $arrayData["APP_UID"], Criteria::EQUAL); $criteria->add(AppDelegationPeer::DEL_INDEX, $arrayData["DEL_INDEX"], Criteria::EQUAL); $criteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE); $rsCriteria = AppDelegationPeer::doSelectRS($criteria); } $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $flagDefault = false; $aSecJoin = array(); $count = 0; while ($rsCriteria->next()) { $arrayRouteData = G::array_merges($rsCriteria->getRow(), $arrayData); if ((int) $arrayRouteData["ROU_DEFAULT"] == 1) { $arrayNextTaskDefault = $arrayRouteData; $flagDefault = true; continue; } $flagAddDelegation = true; //Evaluate the condition if there are conditions defined if (trim($arrayRouteData["ROU_CONDITION"]) != "" && $arrayRouteData["ROU_TYPE"] != "SELECT") { G::LoadClass("pmScript"); $pmScript = new PMScript(); $pmScript->setFields($arrayApplicationData["APP_DATA"]); $pmScript->setScript($arrayRouteData["ROU_CONDITION"]); $flagAddDelegation = $pmScript->evaluate(); } if (trim($arrayRouteData["ROU_CONDITION"]) == "" && $arrayRouteData["ROU_NEXT_TASK"] != "-1") { $arrayTaskData = $task->load($arrayRouteData["ROU_NEXT_TASK"]); if ($arrayRouteData["ROU_TYPE"] != "SEC-JOIN" && $arrayTaskData["TAS_TYPE"] == "GATEWAYTOGATEWAY") { $flagAddDelegation = true; } if ($arrayRouteData["ROU_TYPE"] == "SEC-JOIN") { $aSecJoin[$count]["ROU_PREVIOUS_TASK"] = $arrayRouteData["ROU_NEXT_TASK"]; $aSecJoin[$count]["ROU_PREVIOUS_TYPE"] = "SEC-JOIN"; $count++; } } if ($arrayRouteData["ROU_TYPE"] == "EVALUATE" && !empty($arrayNextTask)) { $flagAddDelegation = false; } if ($flagAddDelegation && preg_match("/^(?:EVALUATE|PARALLEL-BY-EVALUATION)\$/", $arrayRouteData["ROU_TYPE"]) && trim($arrayRouteData["ROU_CONDITION"]) == "") { $flagAddDelegation = false; } if ($flagAddDelegation) { $arrayNextTask[++$i] = $this->prepareInformationTask($arrayRouteData); } } if (count($arrayNextTask) == 0 && count($arrayNextTaskDefault) > 0) { $arrayNextTask[++$i] = $this->prepareInformationTask($arrayNextTaskDefault); } //Check Task GATEWAYTOGATEWAY, END-MESSAGE-EVENT, END-EMAIL-EVENT $arrayNextTaskBackup = $arrayNextTask; $arrayNextTask = array(); $i = 0; foreach ($arrayNextTaskBackup as $value) { $arrayNextTaskData = $value; $regexpTaskTypeToInclude = "GATEWAYTOGATEWAY|END-MESSAGE-EVENT|END-EMAIL-EVENT"; if ($arrayNextTaskData["NEXT_TASK"]["TAS_UID"] != "-1" && preg_match("/^(?:" . $regexpTaskTypeToInclude . ")\$/", $arrayNextTaskData["NEXT_TASK"]["TAS_TYPE"])) { $arrayAux = $this->prepareInformation($arrayData, $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]); foreach ($arrayAux as $value2) { $arrayNextTask[++$i] = $value2; foreach ($aSecJoin as $rsj) { $arrayNextTask[$i]["NEXT_TASK"]["ROU_PREVIOUS_TASK"] = $rsj["ROU_PREVIOUS_TASK"]; $arrayNextTask[$i]["NEXT_TASK"]["ROU_PREVIOUS_TYPE"] = "SEC-JOIN"; } } } else { $regexpTaskTypeToInclude = "END-MESSAGE-EVENT|END-EMAIL-EVENT"; if ($arrayNextTaskData["NEXT_TASK"]["TAS_UID"] == "-1" && preg_match("/^(?:" . $regexpTaskTypeToInclude . ")\$/", $arrayNextTaskData["TAS_TYPE"])) { $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] = $arrayNextTaskData["TAS_UID"] . "/" . $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]; } $arrayNextTask[++$i] = $arrayNextTaskData; foreach ($aSecJoin as $rsj) { $arrayNextTask[$i]["NEXT_TASK"]["ROU_PREVIOUS_TASK"] = $rsj["ROU_PREVIOUS_TASK"]; $arrayNextTask[$i]["NEXT_TASK"]["ROU_PREVIOUS_TYPE"] = "SEC-JOIN"; } //Start-Timer with Script-task $criteriaE = new Criteria("workflow"); $criteriaE->addSelectColumn(ElementTaskRelationPeer::ELEMENT_UID); $criteriaE->addJoin(BpmnEventPeer::EVN_UID, ElementTaskRelationPeer::ELEMENT_UID, Criteria::LEFT_JOIN); $criteriaE->add(ElementTaskRelationPeer::TAS_UID, $arrayNextTaskData["TAS_UID"], Criteria::EQUAL); $criteriaE->add(BpmnEventPeer::EVN_TYPE, 'START', Criteria::EQUAL); $criteriaE->add(BpmnEventPeer::EVN_MARKER, 'TIMER', Criteria::EQUAL); $rsCriteriaE = AppDelegationPeer::doSelectRS($criteriaE); $rsCriteriaE->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($rsCriteriaE->next()) { if ($arrayNextTaskData["NEXT_TASK"]["TAS_TYPE"] == "SCRIPT-TASK") { if (isset($arrayNextTaskData["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"]) && $arrayNextTaskData["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"] == "") { $useruid = "00000000000000000000000000000001"; $userFields = $this->getUsersFullNameFromArray($useruid); $arrayNextTask[$i]["NEXT_TASK"]["USER_ASSIGNED"] = $userFields; } } } } } //1. There is no rule if (empty($arrayNextTask)) { $oProcess = new Process(); $oProcessFieds = $oProcess->Load($_SESSION['PROCESS']); if (isset($oProcessFieds['PRO_BPMN']) && $oProcessFieds['PRO_BPMN'] == 1) { throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_BPMN_RULE")); } else { throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE")); } } //Return return $arrayNextTask; } catch (Exception $e) { throw $e; } }