Example #1
0
         $G_PUBLISH = new Publisher();
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'steps/triggers_Assign', '', $aFields, '../steps/steps_Ajax');
         G::RenderPage('publish', 'raw');
     } else {
         global $G_PUBLISH;
         $G_PUBLISH = new Publisher();
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'steps/triggers_NoAssign', '');
         G::RenderPage('publish', 'raw');
     }
     break;
 case 'assignTrigger':
     $aFields = array('STEP_UID' => $aData['STEP_UID'], 'TAS_UID' => $_SESSION['TASK'], 'TRI_UID' => $aData['TRI_UID'], 'ST_TYPE' => $aData['ST_TYPE']);
     $oStepTrigger = new StepTrigger();
     $oStepTrigger->create($aFields);
     $aFields['ST_CONDITION'] = $aData['ST_CONDITION'];
     $aFields['ST_POSITION'] = $oStepTrigger->getNextPosition($aData['STEP_UID'], $aData['ST_TYPE']) - 1;
     $oStepTrigger->update($aFields);
     break;
 case 'editTriggerCondition':
     require_once 'classes/model/Step.php';
     require_once 'classes/model/Triggers.php';
     $oStep = new Step();
     $aFields['STEP_UID'] = $aData['sStep'];
     $aFields['TRI_UID'] = $aData['sTrigger'];
     $aFields['ST_TYPE'] = $aData['sType'];
     $Trigger = new Triggers();
     $aRow = $Trigger->load($aData['sTrigger']);
     $oStepTrigger = new StepTrigger();
     $aFields = $oStepTrigger->load($aFields['STEP_UID'], $_SESSION['TASK'], $aFields['TRI_UID'], $aFields['ST_TYPE']);
     $aFields['action'] = 'saveTriggerCondition';
     $aFields['PROCESS'] = $aRow['PRO_UID'];
Example #2
0
 /**
  * Assign Trigger to a Step
  *
  * @param string $stepUid    Unique id of Step
  * @param string $type       Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
  * @param string $taskUid    Unique id of Task
  * @param string $triggerUid Unique id of Trigger
  * @param array  $arrayData  Data
  *
  * return array Data of the Trigger assigned to a Step
  */
 public function create($stepUid, $type, $taskUid, $triggerUid, $arrayData)
 {
     try {
         $stepUidIni = $stepUid;
         $typeIni = $type;
         $flagStepAssignTask = 0;
         if ($stepUid == "") {
             $flagStepAssignTask = 1;
             switch ($type) {
                 case "BEFORE_ASSIGNMENT":
                     $stepUid = "-1";
                     $type = "BEFORE";
                     break;
                 case "BEFORE_ROUTING":
                     $stepUid = "-2";
                     $type = "BEFORE";
                     break;
                 case "AFTER_ROUTING":
                     $stepUid = "-2";
                     $type = "AFTER";
                     break;
             }
         }
         //Verify data
         if ($flagStepAssignTask == 0) {
             $step = new \Step();
             if (!$step->StepExists($stepUid)) {
                 throw new \Exception(\G::LoadTranslation("ID_STEP_DOES_NOT_EXIST", array("step_uid", $stepUid)));
             }
         }
         $task = new \Task();
         if (!$task->taskExists($taskUid)) {
             throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array("act_uid", $taskUid)));
         }
         $trigger = new \Triggers();
         if (!$trigger->TriggerExists($triggerUid)) {
             throw new \Exception(\G::LoadTranslation("ID_TRIGGER_DOES_NOT_EXIST", array("tri_uid", $triggerUid)));
         }
         if ($this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
             throw new \Exception(\G::LoadTranslation("ID_RECORD_EXISTS_IN_TABLE", array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER")));
         }
         //Create
         $stepTrigger = new \StepTrigger();
         $posIni = $stepTrigger->getNextPosition($stepUid, $type, $taskUid);
         $stepTrigger->createRow(array("STEP_UID" => $stepUid, "TAS_UID" => $taskUid, "TRI_UID" => $triggerUid, "ST_TYPE" => $type, "ST_CONDITION" => isset($arrayData['st_condition']) ? $arrayData['st_condition'] : '', "ST_POSITION" => $posIni));
         $arrayData = $this->update($stepUid, $typeIni, $taskUid, $triggerUid, $arrayData);
         return $arrayData;
     } catch (\Exception $e) {
         throw $e;
     }
 }