/** * Get available Steps of a Task * * @param string $taskUid Unique id of Task * * return array Return an array with the Steps available of a Task */ public function getAvailableSteps($taskUid) { try { $arrayAvailableStep = array(); //Verify data $this->throwExceptionIfNotExistsTask("", $taskUid, $this->arrayParamException["taskUid"]); //Load Task $task = new \Task(); $arrayTaskData = $task->load($taskUid); $processUid = $arrayTaskData["PRO_UID"]; //Get data //Get Uids $arrayUid = array(); $task = new \Tasks(); $arrayStep = $task->getStepsOfTask($taskUid); foreach ($arrayStep as $step) { $arrayUid[] = $step["STEP_UID_OBJ"]; } //Array DB $arraydbStep = array(); $delimiter = \DBAdapter::getStringDelimiter(); //DynaForms $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\DynaformPeer::DYN_UID); $criteria->addAsColumn("DYN_TITLE", "CT.CON_VALUE"); $criteria->addAsColumn("DYN_DESCRIPTION", "CD.CON_VALUE"); $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); $criteria->addAlias("CD", \ContentPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(\DynaformPeer::DYN_UID, "CT.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "DYN_TITLE" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array(\DynaformPeer::DYN_UID, "CD.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "DYN_DESCRIPTION" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL); $criteria->add(\DynaformPeer::DYN_UID, $arrayUid, \Criteria::NOT_IN); $criteria->add(\DynaformPeer::DYN_TYPE, "xmlform", \Criteria::EQUAL); $rsCriteria = \DynaformPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); if ($row["DYN_TITLE"] . "" == "") { //There is no transaltion for this Document name, try to get/regenerate the label $row["DYN_TITLE"] = \Content::Load("DYN_TITLE", "", $row["DYN_UID"], SYS_LANG); } $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $row["DYN_UID"], $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $row["DYN_TITLE"], $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => $row["DYN_DESCRIPTION"], $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "DYNAFORM"); } //InputDocuments $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID); $criteria->addAsColumn("INP_DOC_TITLE", "CT.CON_VALUE"); $criteria->addAsColumn("INP_DOC_DESCRIPTION", "CD.CON_VALUE"); $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); $criteria->addAlias("CD", \ContentPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CT.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "INP_DOC_TITLE" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CD.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "INP_DOC_DESCRIPTION" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL); $criteria->add(\InputDocumentPeer::INP_DOC_UID, $arrayUid, \Criteria::NOT_IN); $rsCriteria = \InputDocumentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); if ($row["INP_DOC_TITLE"] . "" == "") { //There is no transaltion for this Document name, try to get/regenerate the label $row["INP_DOC_TITLE"] = \Content::Load("INP_DOC_TITLE", "", $row["INP_DOC_UID"], SYS_LANG); } $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $row["INP_DOC_UID"], $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $row["INP_DOC_TITLE"], $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => $row["INP_DOC_DESCRIPTION"], $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "INPUT_DOCUMENT"); } //OutputDocuments $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID); $criteria->addAsColumn("OUT_DOC_TITLE", "CT.CON_VALUE"); $criteria->addAsColumn("OUT_DOC_DESCRIPTION", "CD.CON_VALUE"); $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); $criteria->addAlias("CD", \ContentPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(\OutputDocumentPeer::OUT_DOC_UID, "CT.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "OUT_DOC_TITLE" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array(\OutputDocumentPeer::OUT_DOC_UID, "CD.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "OUT_DOC_DESCRIPTION" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $criteria->add(\OutputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL); $criteria->add(\OutputDocumentPeer::OUT_DOC_UID, $arrayUid, \Criteria::NOT_IN); $rsCriteria = \OutputDocumentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); if ($row["OUT_DOC_TITLE"] . "" == "") { //There is no transaltion for this Document name, try to get/regenerate the label $row["OUT_DOC_TITLE"] = \Content::Load("OUT_DOC_TITLE", "", $row["OUT_DOC_UID"], SYS_LANG); } $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $row["OUT_DOC_UID"], $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $row["OUT_DOC_TITLE"], $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => $row["OUT_DOC_DESCRIPTION"], $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "OUTPUT_DOCUMENT"); } //Call plugin $pluginRegistry =& \PMPluginRegistry::getSingleton(); $externalSteps = $pluginRegistry->getSteps(); if (is_array($externalSteps) && count($externalSteps) > 0) { foreach ($externalSteps as $key => $value) { $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $value->sStepId, $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $value->sStepTitle, $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => "", $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "EXTERNAL"); } } if (!empty($arraydbStep)) { $arraydbStep = Util\ArrayUtil::sort($arraydbStep, array($this->getFieldNameByFormatFieldName("OBJ_TYPE"), $this->getFieldNameByFormatFieldName("OBJ_TITLE")), SORT_ASC); } return $arraydbStep; } catch (\Exception $e) { throw $e; } }
} //end plugin //update AppData with the current file uploaded $oCase = new Cases(); $aAppDataFields = $oCase->loadCase($_GET['APP_UID']); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID); $oCriteria->add(AppDelegationPeer::APP_UID, $_GET['APP_UID'], CRITERIA::EQUAL); $oCriteria->addAscendingOrderByColumn(AppDelegationPeer::DEL_INDEX); $oDataset = AppDelegationPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $oTask = new Tasks(); $aDynaforms = array(); while ($aRow = $oDataset->getRow()) { $aSteps = $oTask->getStepsOfTask($aRow['TAS_UID']); if (is_array($aSteps)) { foreach ($aSteps as $key => $value) { $oCriteriaStep = new Criteria('workflow'); $oCriteriaStep->addSelectColumn(StepPeer::STEP_UID_OBJ); $sStepId = isset($value['STEP_UID']) ? $value['STEP_UID'] : 0; $oCriteriaStep->add(StepPeer::STEP_UID, $sStepId, CRITERIA::EQUAL); $oCriteriaStep->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM', CRITERIA::EQUAL); $oDataSetStep = StepPeer::doSelectRS($oCriteriaStep); $oDataSetStep->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataSetStep->next(); $aRows = $oDataSetStep->getRow(); if (is_array($aRows) && !in_array($aRows['STEP_UID_OBJ'], $aDynaforms)) { $aDynaforms[] = $aRows['STEP_UID_OBJ']; } }
/** * new Case begins a new case under the name of the logged-in user. * * @param string $processId * @param string $userId * @param string $taskId * @param string $variables * @param int $executeTriggers : Optional parameter. The execution all triggers of the task, according to your steps, 1 yes 0 no. * @return $result will return an object */ public function newCase($processId, $userId, $taskId, $variables, $executeTriggers = 0) { //$executeTriggers, this parameter is not important, it may be the last parameter in the method $g = new G(); try { $g->sessionVarSave(); $_SESSION["PROCESS"] = $processId; $_SESSION["TASK"] = $taskId; $_SESSION["USER_LOGGED"] = $userId; $Fields = array (); if (is_array( $variables ) && count( $variables ) > 0) { $Fields = $variables; } $oProcesses = new Processes(); $pro = $oProcesses->processExists( $processId ); if (! $pro) { $result = new wsResponse( 11, G::loadTranslation( 'ID_INVALID_PROCESS' ) . " " . $processId ); $g->sessionVarRestore(); return $result; } $oCase = new Cases(); $startingTasks = $oCase->getStartCases( $userId ); array_shift( $startingTasks ); //remove the first row, the header row $founded = ''; $tasksInThisProcess = 0; $validTaskId = $taskId; foreach ($startingTasks as $key => $val) { if ($val['pro_uid'] == $processId) { $tasksInThisProcess ++; $validTaskId = $val['uid']; } if ($val['uid'] == $taskId) { $founded = $val['value']; } } if ($taskId == '') { if ($tasksInThisProcess == 1) { $founded = $validTaskId; $taskId = $validTaskId; } if ($tasksInThisProcess > 1) { $result = new wsResponse( 13, G::loadTranslation( 'ID_MULTIPLE_STARTING_TASKS' ) ); $g->sessionVarRestore(); return $result; } } $task = TaskPeer::retrieveByPK($taskId); $arrayTaskTypeToExclude = array("START-TIMER-EVENT"); if (!is_null($task) && !in_array($task->getTasType(), $arrayTaskTypeToExclude) && $founded == "") { $result = new wsResponse( 14, G::loadTranslation( 'ID_TASK_INVALID_USER_NOT_ASSIGNED_TASK' ) ); $g->sessionVarRestore(); return $result; } //Start case $case = $oCase->startCase( $taskId, $userId ); $_SESSION['APPLICATION'] = $case['APPLICATION']; $_SESSION['PROCESS'] = $case['PROCESS']; $_SESSION['TASK'] = $taskId; $_SESSION['INDEX'] = $case['INDEX']; $_SESSION['USER_LOGGED'] = $userId; $_SESSION['USR_USERNAME'] = (isset($case['USR_USERNAME'])) ? $case['USR_USERNAME'] : ''; $_SESSION['STEP_POSITION'] = 0; $caseId = $case['APPLICATION']; $caseNr = $case['CASE_NUMBER']; $oldFields = $oCase->loadCase( $caseId ); $oldFields['APP_DATA'] = array_merge( $oldFields['APP_DATA'], $Fields ); $oldFields['DEL_INDEX'] = $case['INDEX']; $oldFields['TAS_UID'] = $taskId; $up_case = $oCase->updateCase( $caseId, $oldFields ); //Execute all triggers of the task, according to your steps if ($executeTriggers == 1) { $task = new Tasks(); $arrayStep = $task->getStepsOfTask($taskId); foreach ($arrayStep as $step) { $arrayField = $oCase->loadCase($caseId); $arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "BEFORE", $arrayField["APP_DATA"]); $arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "AFTER", $arrayField["APP_DATA"]); unset($arrayField['APP_STATUS']); unset($arrayField['APP_PROC_STATUS']); unset($arrayField['APP_PROC_CODE']); unset($arrayField['APP_PIN']); $arrayField = $oCase->updateCase($caseId, $arrayField); } } //Response $result = new wsResponse( 0, G::loadTranslation( 'ID_STARTED_SUCCESSFULLY' ) ); $result->caseId = $caseId; $result->caseNumber = $caseNr; $g->sessionVarRestore(); return $result; } catch (Exception $e) { $result = new wsResponse( 100, $e->getMessage() ); $g->sessionVarRestore(); return $result; } }
/** * Return the available building blocks list criteria object * @param string $sProcessUID * @param string $sTaskUID * @return object */ public function getExtAvailableBBCriteria($sProcessUID = '', $sTaskUID = '') { try { $_SESSION['TASK'] = $sTaskUID; $oTasks = new Tasks(); $_SESSION['TASK'] = $sTaskUID; $aSteps = $oTasks->getStepsOfTask($sTaskUID); $sUIDs = array(); foreach ($aSteps as $aStep) { $sUIDs[] = $aStep['STEP_UID_OBJ']; } $aBB = array(); $aBB[] = array('STEP_UID' => 'char', 'STEP_TITLE' => 'char', 'STEP_TYPE_OBJ' => 'char', 'STEP_MODE' => 'char', 'STEP_UID_OBJ' => 'char'); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(DynaformPeer::DYN_UID); $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); $aConditions[] = array(DynaformPeer::DYN_UID, 'C.CON_ID'); $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter); $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID); $oCriteria->add(DynaformPeer::DYN_UID, $sUIDs, Criteria::NOT_IN); $oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform'); $oDataset = DynaformPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $i = 0; while ($aRow = $oDataset->getRow()) { $i++; /*$aBB [] = array ('STEP_UID' => $aRow ['DYN_UID'], 'STEP_TITLE' => $aRow ['DYN_TITLE'], 'STEP_TYPE_OBJ' => 'DYNAFORM', 'STEP_MODE' => '<select id="STEP_MODE_' . $aRow ['DYN_UID'] . '"> <option value="EDIT">Edit</option> <option value="VIEW">View</option> </select>' );*/ $aBB[] = array('STEP_UID' => $aRow['DYN_UID'], 'STEP_TITLE' => $aRow['DYN_TITLE'], 'STEP_TYPE_OBJ' => 'DYNAFORM', 'STEP_MODE' => 'EDIT', 'STEP_UID_OBJ' => $aRow['DYN_UID']); $oDataset->next(); } $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(InputDocumentPeer::INP_DOC_UID); $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); $aConditions[] = array(InputDocumentPeer::INP_DOC_UID, 'C.CON_ID'); $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter); $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID); $oCriteria->add(InputDocumentPeer::INP_DOC_UID, $sUIDs, Criteria::NOT_IN); $oDataset = InputDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aBB[] = array('STEP_UID' => $aRow['INP_DOC_UID'], 'STEP_UID_OBJ' => $aRow['INP_DOC_UID'], 'STEP_TITLE' => $aRow['INP_DOC_TITLE'], 'STEP_TYPE_OBJ' => 'INPUT_DOCUMENT', 'STEP_MODE' => '<input type="hidden" id="STEP_MODE_' . $aRow['INP_DOC_UID'] . '">'); $oDataset->next(); } $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(OutputDocumentPeer::OUT_DOC_UID); $oCriteria->addAsColumn('OUT_DOC_TITLE', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); $aConditions[] = array(OutputDocumentPeer::OUT_DOC_UID, 'C.CON_ID'); $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'OUT_DOC_TITLE' . $sDelimiter); $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID); $oCriteria->add(OutputDocumentPeer::OUT_DOC_UID, $sUIDs, Criteria::NOT_IN); $oDataset = OutputDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aBB[] = array('STEP_UID' => $aRow['OUT_DOC_UID'], 'STEP_UID_OBJ' => $aRow['OUT_DOC_UID'], 'STEP_TITLE' => $aRow['OUT_DOC_TITLE'], 'STEP_TYPE_OBJ' => 'OUTPUT_DOCUMENT', 'STEP_MODE' => '<input type="hidden" id="STEP_MODE_' . $aRow['OUT_DOC_UID'] . '">'); $oDataset->next(); } //call plugin $oPluginRegistry =& PMPluginRegistry::getSingleton(); $externalSteps = $oPluginRegistry->getSteps(); if (is_array($externalSteps) && count($externalSteps) > 0) { foreach ($externalSteps as $key => $stepVar) { $aBB[] = array('STEP_UID' => $stepVar->sStepId, 'STEP_TITLE' => $stepVar->sStepTitle, 'STEP_TYPE_OBJ' => 'EXTERNAL', 'STEP_MODE' => '<input type="hidden" id="STEP_MODE_' . $stepVar->sStepId . '">'); } } global $_DBArray; $_DBArray = isset($_SESSION['_DBArray']) ? $_SESSION['_DBArray'] : ''; $_DBArray['availableBB'] = $aBB; $_SESSION['_DBArray'] = $_DBArray; G::LoadClass('ArrayPeer'); $oCriteria = new Criteria('dbarray'); $oCriteria->setDBArrayTable('availableBB'); $oCriteria->addAscendingOrderByColumn('STEP_TYPE_OBJ'); $oCriteria->addAscendingOrderByColumn('STEP_TITLE'); //return $oCriteria; return $_SESSION['_DBArray']['availableBB']; } catch (Exception $oError) { throw $oError; } }