$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");
/** * 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; }
/** * 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; } }
/** * 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; } }