/** * Email-event for the Case * * @param string $elementOriginUid Unique id of Element Origin (unique id of Task) * @param string $elementDestUid Unique id of Element Dest (unique id of Task) * @param array $arrayApplicationData Case data * * return void */ public function emailEventBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData) { try { //Verify if the Project is BPMN $bpmn = new \ProcessMaker\Project\Bpmn(); if (!$bpmn->exists($arrayApplicationData["PRO_UID"])) { return; } //Element origin and dest $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation(); $arrayElement = array( "elementOrigin" => array("uid" => $elementOriginUid, "type" => "bpmnActivity"), "elementDest" => array("uid" => $elementDestUid, "type" => "bpmnActivity") ); foreach ($arrayElement as $key => $value) { $arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere( array( \ElementTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"], \ElementTaskRelationPeer::ELEMENT_TYPE => "bpmnEvent", \ElementTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"] ), true ); if (!is_null($arrayElementTaskRelationData)) { $arrayElement[$key]["uid"] = $arrayElementTaskRelationData["ELEMENT_UID"]; $arrayElement[$key]["type"] = "bpmnEvent"; } } $elementOriginUid = $arrayElement["elementOrigin"]["uid"]; $elementOriginType = $arrayElement["elementOrigin"]["type"]; $elementDestUid = $arrayElement["elementDest"]["uid"]; $elementDestType = $arrayElement["elementDest"]["type"]; //Get Message-Events of throw type $arrayEvent = $bpmn->getEmailEventTypeBetweenElementOriginAndElementDest( $elementOriginUid, $elementOriginType, $elementDestUid, $elementDestType ); //Email-event foreach ($arrayEvent as $value) { $result = $this->sendEmail($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData); } } catch (\Exception $e) { throw $e; } }
$oHeadPublisher->addScriptFile('/jscore/tracker/tracker.js'); G::LoadClass('case'); $oCase = new Cases(); $aFields = $oCase->loadCase($_SESSION['APPLICATION']); $idProcess = $_SESSION['PROCESS']; $oProcess = new Process(); $aProcessFieds = $oProcess->load($idProcess); $noShowTitle = 0; if (isset($aProcessFieds['PRO_SHOW_MESSAGE'])) { $noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE']; } if (isset($aFields['TITLE'])) { $aFields['APP_TITLE'] = $aFields['TITLE']; } if ($aFields['APP_PROC_CODE'] != '') { $aFields['APP_NUMBER'] = $aFields['APP_PROC_CODE']; } $aFields['CASE'] = G::LoadTranslation('ID_CASE'); $aFields['TITLE'] = G::LoadTranslation('ID_TITLE'); $G_PUBLISH = new Publisher(); if ($noShowTitle == 0) { $G_PUBLISH->AddContent('smarty', 'cases/cases_title', '', '', $aFields); } $G_PUBLISH->AddContent('propeltable', 'paged-table', 'tracker/tracker_Messages', Cases::getHistoryMessagesTracker($_SESSION['APPLICATION']), array('VIEW' => G::LoadTranslation('ID_VIEW'))); $bpmn = new ProcessMaker\Project\Bpmn(); $flagIsBpmn = $bpmn->exists($_SESSION["PROCESS"]) ? true : false; if ($flagIsBpmn) { $urlTrackerProcessMap = "../designer?prj_uid=" . $_SESSION["PROCESS"] . "&prj_readonly=true&app_uid=" . $_SESSION["APPLICATION"] . "&tracker_designer=1"; $_SESSION["TRACKER_JAVASCRIPT"] = "\r\n <script type=\"text/javascript\">\r\n var winTracker;\r\n\r\n if ((navigator.userAgent.indexOf(\"MSIE\") != -1) || (navigator.userAgent.indexOf(\"Trident\") != -1)) {\r\n var li1 = document.getElementById(\"MAP\");\r\n var a1 = li1.getElementsByTagName(\"a\");\r\n a1[0].onclick = function () {\r\n winTracker = window.open(\"{$urlTrackerProcessMap}\", \"winTracker\");\r\n li1.className = \"SelectedMenu\";\r\n li2.className = \"mainMenu\";\r\n li3.className = \"mainMenu\";\r\n li4.className = \"mainMenu\";\r\n document.getElementById(\"trackerContainer\").innerHTML = \"\";\r\n \r\n return false;\r\n };\r\n\r\n var li2 = document.getElementById(\"DYNADOC\");\r\n var a2= li2.getElementsByTagName(\"a\");\r\n a2[0].onclick = function () { if (winTracker) { winTracker.close(); } };\r\n\r\n var li3 = document.getElementById(\"HISTORY\");\r\n var a3 = li3.getElementsByTagName(\"a\");\r\n a3[0].onclick = function () { if (winTracker) { winTracker.close(); } };\r\n\r\n var li4 = document.getElementById(\"MESSAGES\");\r\n var a4 = li4.getElementsByTagName(\"a\");\r\n a4[0].onclick = function () { if (winTracker) { winTracker.close(); } };\r\n }\r\n </script>\r\n "; } G::RenderPage("publish");
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); G::header( 'location: ../login/login' ); die(); break; } } //G::LoadClass( 'processMap' ); //$oProcessMap = new ProcessMap(); $uids = explode(',', $_POST['PRO_UIDS']); try { foreach ($uids as $uid) { //$oProcessMap->deleteProcess($uid); ProcessMaker\Project\Workflow::removeIfExists($uid); ProcessMaker\Project\Bpmn::removeIfExists($uid); } $resp = new StdClass(); $resp->status = 0; $resp->msg = 'All process was deleted successfully'; echo G::json_encode($resp); } catch (Exception $e) { $resp->status = 1; $resp->msg = $e->getMessage(); echo G::json_encode($resp); }
/** * Create WebEntry * * @param string $projectUid Unique id of Project * @param string $eventUid Unique id of Event * @param string $activityUid Unique id of Activity * @param string $dynaFormUid WebEntry, unique id of DynaForm * @param string $userUid WebEntry, unique id of User * @param string $title WebEntry, title * @param string $description WebEntry, description * @param string $userUidCreator WebEntry, unique id of creator User * * return void */ public function createWebEntry($projectUid, $eventUid, $activityUid, $dynaFormUid, $userUid, $title, $description, $userUidCreator) { try { $bpmn = new \ProcessMaker\Project\Bpmn(); $arrayEventData = $bpmn->getEvent($eventUid); //Task $task = new \Task(); $prefix = "wee-"; $this->webEntryEventWebEntryTaskUid = $task->create(array("TAS_UID" => $prefix . substr(\ProcessMaker\Util\Common::generateUID(), (32 - strlen($prefix)) * -1), "PRO_UID" => $projectUid, "TAS_TYPE" => "WEBENTRYEVENT", "TAS_TITLE" => "WEBENTRYEVENT", "TAS_START" => "TRUE", "TAS_POSX" => (int) $arrayEventData["BOU_X"], "TAS_POSY" => (int) $arrayEventData["BOU_Y"]), false); //Task - Step $step = new \Step(); $stepUid = $step->create(array("PRO_UID" => $projectUid, "TAS_UID" => $this->webEntryEventWebEntryTaskUid)); $result = $step->update(array("STEP_UID" => $stepUid, "STEP_TYPE_OBJ" => "DYNAFORM", "STEP_UID_OBJ" => $dynaFormUid, "STEP_POSITION" => 1, "STEP_MODE" => "EDIT")); //Task - User $task = new \Tasks(); $result = $task->assignUser($this->webEntryEventWebEntryTaskUid, $userUid, 1); //Route $workflow = \ProcessMaker\Project\Workflow::load($projectUid); $result = $workflow->addRoute($this->webEntryEventWebEntryTaskUid, $activityUid, "SEQUENTIAL"); //WebEntry $arrayWebEntryData = $this->webEntry->create($projectUid, $userUidCreator, array("TAS_UID" => $this->webEntryEventWebEntryTaskUid, "DYN_UID" => $dynaFormUid, "USR_UID" => $userUid, "WE_TITLE" => $title, "WE_DESCRIPTION" => $description, "WE_METHOD" => "WS", "WE_INPUT_DOCUMENT_ACCESS" => 1)); $this->webEntryEventWebEntryUid = $arrayWebEntryData[$this->getFieldNameByFormatFieldName("WE_UID")]; } catch (\Exception $e) { throw $e; } }
/** * create an application delegation * * @param $sProUid process Uid * @param $sAppUid Application Uid * @param $sTasUid Task Uid * @param $sUsrUid User Uid * @param $iPriority delegation priority * @param $isSubprocess is a subprocess inside a process? * @return delegation index of the application delegation. */ public function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null) { if (! isset( $sProUid ) || strlen( $sProUid ) == 0) { throw (new Exception( 'Column "PRO_UID" cannot be null.' )); } if (! isset( $sAppUid ) || strlen( $sAppUid ) == 0) { throw (new Exception( 'Column "APP_UID" cannot be null.' )); } if (! isset( $sTasUid ) || strlen( $sTasUid ) == 0) { throw (new Exception( 'Column "TAS_UID" cannot be null.' )); } if (! isset( $sUsrUid ) /*|| strlen($sUsrUid ) == 0*/ ) { throw (new Exception( 'Column "USR_UID" cannot be null.' )); } if (! isset( $sAppThread ) || strlen( $sAppThread ) == 0) { throw (new Exception( 'Column "APP_THREAD" cannot be null.' )); } //Get max DEL_INDEX $criteria = new Criteria("workflow"); $criteria->add(AppDelegationPeer::APP_UID, $sAppUid); $criteria->add(AppDelegationPeer::DEL_LAST_INDEX, 1); $criteriaIndex = clone $criteria; $rs = AppDelegationPeer::doSelectRS($criteriaIndex); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $delIndex = 1; $delPreviusUsrUid = $sUsrUid; if ($rs->next()) { $row = $rs->getRow(); $delIndex = (isset($row["DEL_INDEX"]))? $row["DEL_INDEX"] + 1 : 1; $delPreviusUsrUid = $row["USR_UID"]; } else { $criteriaDelIndex = new Criteria("workflow"); $criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_INDEX); $criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE); $criteriaDelIndex->add(AppDelegationPeer::APP_UID, $sAppUid); $criteriaDelIndex->addDescendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE); $rsCriteriaDelIndex = AppDelegationPeer::doSelectRS($criteriaDelIndex); $rsCriteriaDelIndex->setFetchmode(ResultSet::FETCHMODE_ASSOC); if ($rsCriteriaDelIndex->next()) { $row = $rsCriteriaDelIndex->getRow(); $delIndex = (isset($row["DEL_INDEX"]))? $row["DEL_INDEX"] + 1 : 1; } } //Update set $criteriaUpdate = new Criteria('workflow'); $criteriaUpdate->add(AppDelegationPeer::DEL_LAST_INDEX, 0); BasePeer::doUpdate($criteria, $criteriaUpdate, Propel::getConnection('workflow')); $this->setAppUid( $sAppUid ); $this->setProUid( $sProUid ); $this->setTasUid( $sTasUid ); $this->setDelIndex( $delIndex ); $this->setDelLastIndex(1); $this->setDelPrevious( $sPrevious == - 1 ? 0 : $sPrevious ); $this->setUsrUid( $sUsrUid ); $this->setDelType( 'NORMAL' ); $this->setDelPriority( ($iPriority != '' ? $iPriority : '3') ); $this->setDelThread( $sAppThread ); $this->setDelThreadStatus( 'OPEN' ); $this->setDelDelegateDate( 'now' ); //The function return an array now. By JHL $delTaskDueDate = $this->calculateDueDate($sNextTasParam); $delRiskDate = $this->calculateRiskDate($sNextTasParam, $this->getRisk()); //$this->setDelTaskDueDate( $delTaskDueDate['DUE_DATE'] ); // Due date formatted $this->setDelTaskDueDate($delTaskDueDate); $this->setDelRiskDate($delRiskDate); if ((defined( "DEBUG_CALENDAR_LOG" )) && (DEBUG_CALENDAR_LOG)) { //$this->setDelData( $delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine $this->setDelData( $delTaskDueDate ); } else { $this->setDelData( '' ); } // this condition assures that an internal delegation like a subprocess dont have an initial date setted if ($delIndex == 1 && ! $isSubprocess) { //the first delegation, init date this should be now for draft applications, in other cases, should be null. $this->setDelInitDate( 'now' ); } if ($this->validate()) { try { $res = $this->save(); } catch (PropelException $e) { throw ($e); } } else { // Something went wrong. We can now get the validationFailures and handle them. $msg = ''; $validationFailuresArray = $this->getValidationFailures(); foreach ($validationFailuresArray as $objValidationFailure) { $msg .= $objValidationFailure->getMessage() . "<br/>"; } throw (new Exception( 'Failed Data validation. ' . $msg )); } $delIndex = $this->getDelIndex(); // Hook for the trigger PM_CREATE_NEW_DELEGATION if (defined( 'PM_CREATE_NEW_DELEGATION' )) { $bpmn = new \ProcessMaker\Project\Bpmn(); $flagActionsByEmail = true; $data = new stdclass(); $data->TAS_UID = $sTasUid; $data->APP_UID = $sAppUid; $data->DEL_INDEX = $delIndex; $data->USR_UID = $sUsrUid; $data->PREVIOUS_USR_UID = $delPreviusUsrUid; if ($bpmn->exists($sProUid)) { /*----------------------------------********---------------------------------*/ } if ($flagActionsByEmail) { $oPluginRegistry = &PMPluginRegistry::getSingleton(); $oPluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data); } } return $delIndex; }
/** * Validate the data if they are invalid (INSERT and UPDATE) * * @param string $messageEventRelationUid Unique id of Message-Event-Relation * @param string $projectUid Unique id of Project * @param array $arrayData Data * * return void Throw exception if data has an invalid value */ public function throwExceptionIfDataIsInvalid($messageEventRelationUid, $projectUid, array $arrayData) { try { //Set variables $arrayMessageEventRelationData = $messageEventRelationUid == "" ? array() : $this->getMessageEventRelation($messageEventRelationUid, true); $flagInsert = $messageEventRelationUid == "" ? true : false; $arrayFinalData = array_merge($arrayMessageEventRelationData, $arrayData); //Verify data - Field definition $process = new \ProcessMaker\BusinessModel\Process(); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); //Verify data if (isset($arrayData["EVN_UID_THROW"]) || isset($arrayData["EVN_UID_CATCH"])) { $this->throwExceptionIfEventRelationIsRegistered($projectUid, $arrayFinalData["EVN_UID_THROW"], $arrayFinalData["EVN_UID_CATCH"], $messageEventRelationUid); } if (isset($arrayData["EVN_UID_THROW"]) || isset($arrayData["EVN_UID_CATCH"])) { //Flow $bpmnFlow = \BpmnFlow::findOneBy(array(\BpmnFlowPeer::FLO_TYPE => "MESSAGE", \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $arrayFinalData["EVN_UID_THROW"], \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent", \BpmnFlowPeer::FLO_ELEMENT_DEST => $arrayFinalData["EVN_UID_CATCH"], \BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnEvent")); if (is_null($bpmnFlow)) { throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_RELATION_DOES_NOT_EXIST_MESSAGE_FLOW", array($this->arrayFieldNameForException["eventUidThrow"], $arrayFinalData["EVN_UID_THROW"], $this->arrayFieldNameForException["eventUidCatch"], $arrayFinalData["EVN_UID_CATCH"]))); } //Check and validate Message Flow $bpmn = new \ProcessMaker\Project\Bpmn(); $bpmn->throwExceptionFlowIfIsAnInvalidMessageFlow(array("FLO_TYPE" => "MESSAGE", "FLO_ELEMENT_ORIGIN" => $arrayFinalData["EVN_UID_THROW"], "FLO_ELEMENT_ORIGIN_TYPE" => "bpmnEvent", "FLO_ELEMENT_DEST" => $arrayFinalData["EVN_UID_CATCH"], "FLO_ELEMENT_DEST_TYPE" => "bpmnEvent")); } } catch (\Exception $e) { throw $e; } }
/** * Throw Events for the Case * * @param string $eventUid Unique id of Event * @param array $appFields Case data * * @return void */ private function throwEventsElemntOriginToElementDest($eventUid, $appFields) { try { //Verify if the Project is BPMN $bpmn = new \ProcessMaker\Project\Bpmn(); if (!$bpmn->exists($appFields["PRO_UID"])) { return; } //Throw Events $messageApplication = new \ProcessMaker\BusinessModel\MessageApplication(); $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); $event = \BpmnEventPeer::retrieveByPK($eventUid); if (!is_null($event)) { if (preg_match("/^(?:END|INTERMEDIATE)\$/", $event->getEvnType()) && $event->getEvnMarker() == "MESSAGETHROW") { //Message-Application throw $result = $messageApplication->create($appFields["APP_UID"], $appFields["PRO_UID"], $value[0], $appFields); } if (preg_match("/^(?:END|INTERMEDIATE)\$/", $event->getEvnType()) && $event->getEvnMarker() == "EMAIL") { //Email-Event throw $result = $emailEvent->sendEmail($appFields["APP_UID"], $appFields["PRO_UID"], $eventUid, $appFields); } } } catch (Exception $e) { throw $e; } }