예제 #1
0
function RouteCase($params)
{
    $oSession = new Sessions();
    $vsResult = isValidSession($params->sessionId);
    if ($vsResult->status_code !== 0) {
        return $vsResult;
    }
    if (ifPermission($params->sessionId, 'PM_CASES') == 0) {
        $result = new wsResponse(2, G::LoadTranslation('ID_NOT_PRIVILEGES'));
        return $result;
    }
    $user = $oSession->getSessionUser($params->sessionId);
    $oStd->stored_system_variables = true;
    $oStd->wsSessionId = $params->sessionId;
    $ws = new wsBase($oStd);
    $res = $ws->derivateCase($user["USR_UID"], $params->caseId, $params->delIndex, true);
    return $res;
}
예제 #2
0
function DerivateCase($params)
{
    ifSessionExpiredBreakThis($params->sessionId);
    $x = ifPermission($params->sessionId, 'PM_CASES');
    if ($x == 0) {
        G::LoadClass('wsResponse');
        $result = new wsResponse(24, G::LoadTranslation('ID_NOT_PRIVILEGES'));
        return $result;
    }
    $oSession = new Sessions();
    $user = $oSession->getSessionUser($params->sessionId);
    G::LoadClass('wsBase');
    $ws = new wsBase();
    $res = $ws->derivateCase($user['USR_UID'], $params->caseId, $params->delIndex);
    return $res;
    //return  $res->getPayloadArray ( );
}
예제 #3
0
    /**
     * Put Data Generate
     *
     * @access public
     * @param string $app_uid, Process Uid
     * @param string $app_number, Task Uid
     * @param string $del_index, Task Uid
     * @param string $usr_uid, Task Uid
     * @return string
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    public function postDerivate ($app_uid, $app_number, $del_index, $usr_uid)
    {
        G::LoadClass("library");
        G::LoadClass("wsBase");
        G::LoadClass("case");

        $ws = new \wsBase();
        $oCase = new \Cases();

        if (!isset($Fields["DEL_INIT_DATE"])) {
            $oCase->setDelInitDate($app_uid, $del_index);
            $aFields = $oCase->loadCase($app_uid, $del_index);
        }

        $res = $ws->derivateCase($usr_uid, $app_uid, $del_index, true);
        $messageDerivateCase = null;

        if (is_array($res)) {
            $messageDerivateCase = "<ul type='square'>";

            if (count($res["routing"]) > 0) {
                foreach ($res["routing"] as $k => $field) {
                    $messageDerivateCase = $messageDerivateCase . "<li>" . $res["routing"][$k]->taskName . " - " . $res["routing"][$k]->userName;
                }
            } else {
                $messageDerivateCase = explode("-", $res["message"]);
                $messageDerivateCase = "<li>" . $messageDerivateCase[0];
            }

            $messageDerivateCase = $messageDerivateCase . "</ul>";
        }

        $response = array();

        $response["casesNumRec"] = \Library::getCasesNumRec($usr_uid);

        if (is_array($res)) {
            $response ["message"] = "<b>" . G::LoadTranslation("ID_CASE") . " " . $app_number . "</b> Summary of Derivations: <br> " . $messageDerivateCase;
        } else {
            $response ["message"] = G::LoadTranslation("ID_CASE") . " " . $app_number . " " . $res->message;
        }
        return $response;
    }
예제 #4
0
 $dataResponses['ABE_REQ_UID'] = $_REQUEST['ABER'];
 $dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
 $dataResponses['ABE_RES_DATA'] = serialize($_REQUEST['VALUE']);
 $dataResponses['ABE_RES_STATUS'] = 'PENDING';
 $dataResponses['ABE_RES_MESSAGE'] = '';
 try {
     require_once 'classes/model/AbeResponses.php';
     $abeAbeResponsesInstance = new AbeResponses();
     $dataResponses['ABE_RES_UID'] = $abeAbeResponsesInstance->createOrUpdate($dataResponses);
 } catch (Exception $error) {
     throw $error;
 }
 $cases->updateCase($_REQUEST['APP_UID'], $caseFieldsABE);
 G::LoadClass('wsBase');
 $ws = new wsBase();
 $result = $ws->derivateCase($caseFieldsABE['CURRENT_USER_UID'], $_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX'], true);
 $code = is_array($result) ? $result['status_code'] : $result->status_code;
 if ($code != 0) {
     throw new Exception('An error occurred while the application was being processed.<br /><br />
              Error code: ' . $result->status_code . '<br />
              Error message: ' . $result->message . '<br /><br />');
 }
 // Update
 $dataResponses['ABE_RES_STATUS'] = $code == 0 ? 'SENT' : 'ERROR';
 $dataResponses['ABE_RES_MESSAGE'] = $code == 0 ? '-' : $result->message;
 try {
     $abeAbeResponsesInstance = new AbeResponses();
     $abeAbeResponsesInstance->createOrUpdate($dataResponses);
 } catch (Exception $error) {
     throw $error;
 }
 
         $casesFields["APP_DATA"]["USER_LOGGED"]  = $current_user_uid;
         $casesFields["APP_DATA"]["USR_USERNAME"] = $currentUsrName;
     }
 
     foreach ($casesFields["APP_DATA"] as $index => $value) {
         $_SESSION[$index] = $value;
     }
 
     //Update case info
     $case->updateCase($_REQUEST['APP_UID'], $casesFields);
 
     G::LoadClass('wsBase');
 
     $wsBaseInstance = new wsBase();
     $result = $wsBaseInstance->derivateCase($casesFields['CURRENT_USER_UID'], $_REQUEST['APP_UID'], $_REQUEST ['DEL_INDEX'], true);
     $code = (is_array($result) ? $result['status_code'] : $result->status_code);
 
     $dataResponses = array();
     $dataResponses['ABE_REQ_UID'] = $_REQUEST['ABER'];
     $dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
     $dataResponses['ABE_RES_DATA'] = serialize($_REQUEST['form']);
     $dataResponses['ABE_RES_STATUS'] = 'PENDING';
     $dataResponses['ABE_RES_MESSAGE'] = '';
 
     try {
         set_include_path(PATH_PLUGINS . 'actionsByEmail' . PATH_SEPARATOR . get_include_path());
         require_once 'classes/model/AbeResponses.php';
 
         $abeAbeResponsesInstance = new AbeResponses();
         $dataResponses['ABE_RES_UID'] = $abeAbeResponsesInstance->createOrUpdate($dataResponses);
예제 #6
0
/**
 *
 * @method
 *
 * Derivates (routes) a case to the next task in the process.
 *
 * @name PMFDerivateCase
 * @label PMF Derivate Case
 * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFDerivateCase.28.29
 *
 * @param string(32) | $caseId | Case ID | The unique ID for the case to be derivated (routed)
 * @param int | $delIndex | delegation index for the case | The delegation index for the case to derivated (routed).
 * @param boolean | $bExecuteTriggersBeforeAssignment = false | Trigger | Optional parameter. If set to true, any triggers which are assigned to pending steps in the current task will be executed before the case is assigned to the next user.
 * @param boolean | $sUserLogged = null | User ID | Optional parameter. The unique ID of the user who will route the case. This should be set to the user who is currently designated to work on the case. If omitted or set to NULL, then the currently logged-in user will route the case.
 * @return int | $result | Result of Derivate case | Returns 1 if new case was derivated (routed) successfully; otherwise, returns 0 if an error occurred.
 *
 */
function PMFDerivateCase($caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $sUserLogged = null)
{
    if (!$sUserLogged) {
        $sUserLogged = $_SESSION['USER_LOGGED'];
    }
    G::LoadClass('wsBase');
    $ws = new wsBase();
    $result = $ws->derivateCase($sUserLogged, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment);
    if (isset($result->status_code)) {
        $resultArray = (array) $result;
        return $result['status_code'];
    } else {
        return 0;
    }
    if ($result->status_code == 0) {
        return 1;
    } else {
        return 0;
    }
}
예제 #7
0
 /**
  * Catch Message-Events for the Cases
  *
  * @param bool $frontEnd Flag to represent progress bar
  *
  * @return void
  */
 public function catchMessageEvent($frontEnd = false)
 {
     try {
         \G::LoadClass("wsBase");
         //Set variables
         $ws = new \wsBase();
         $case = new \Cases();
         $common = new \ProcessMaker\Util\Common();
         $common->setFrontEnd($frontEnd);
         //Get data
         $totalMessageEvent = 0;
         $counterStartMessageEvent = 0;
         $counterIntermediateCatchMessageEvent = 0;
         $counter = 0;
         $flagFirstTime = false;
         $common->frontEndShow("START");
         do {
             $flagNextRecords = false;
             $arrayMessageApplicationUnread = $this->getMessageApplications(array("messageApplicationStatus" => "UNREAD"), null, null, 0, 1000);
             if (!$flagFirstTime) {
                 $totalMessageEvent = $arrayMessageApplicationUnread["total"];
                 $flagFirstTime = true;
             }
             foreach ($arrayMessageApplicationUnread["data"] as $value) {
                 if ($counter + 1 > $totalMessageEvent) {
                     $flagNextRecords = false;
                     break;
                 }
                 $arrayMessageApplicationData = $value;
                 $processUid = $arrayMessageApplicationData["PRJ_UID"];
                 $taskUid = $arrayMessageApplicationData["TAS_UID"];
                 $messageApplicationUid = $arrayMessageApplicationData["MSGAPP_UID"];
                 $messageApplicationCorrelation = $arrayMessageApplicationData["MSGAPP_CORRELATION"];
                 $messageEventDefinitionUserUid = $arrayMessageApplicationData["MSGED_USR_UID"];
                 $messageEventDefinitionCorrelation = $arrayMessageApplicationData["MSGED_CORRELATION"];
                 $arrayVariable = $this->mergeVariables($arrayMessageApplicationData["MSGED_VARIABLES"], $arrayMessageApplicationData["MSGAPP_VARIABLES"]);
                 $flagCatched = false;
                 switch ($arrayMessageApplicationData["EVN_TYPE"]) {
                     case "START":
                         if ($messageEventDefinitionCorrelation == $messageApplicationCorrelation && $messageEventDefinitionUserUid != "") {
                             //Start and derivate new Case
                             $result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, $arrayVariable);
                             $arrayResult = json_decode(json_encode($result), true);
                             if ($arrayResult["status_code"] == 0) {
                                 $applicationUid = $arrayResult["caseId"];
                                 $result = $ws->derivateCase($messageEventDefinitionUserUid, $applicationUid, 1);
                                 $flagCatched = true;
                                 //Counter
                                 $counterStartMessageEvent++;
                             }
                         }
                         break;
                     case "INTERMEDIATE":
                         $criteria = new \Criteria("workflow");
                         $criteria->addSelectColumn(\AppDelegationPeer::APP_UID);
                         $criteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
                         $criteria->addSelectColumn(\AppDelegationPeer::USR_UID);
                         $criteria->add(\AppDelegationPeer::PRO_UID, $processUid, \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
                         $criteria->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
                         $rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
                         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                         while ($rsCriteria->next()) {
                             $row = $rsCriteria->getRow();
                             $applicationUid = $row["APP_UID"];
                             $delIndex = $row["DEL_INDEX"];
                             $userUid = $row["USR_UID"];
                             $arrayApplicationData = $case->loadCase($applicationUid);
                             if (\G::replaceDataField($messageEventDefinitionCorrelation, $arrayApplicationData["APP_DATA"]) == $messageApplicationCorrelation) {
                                 //"Unpause" and derivate Case
                                 $arrayApplicationData["APP_DATA"] = array_merge($arrayApplicationData["APP_DATA"], $arrayVariable);
                                 $arrayResult = $case->updateCase($applicationUid, $arrayApplicationData);
                                 $result = $ws->derivateCase($userUid, $applicationUid, $delIndex);
                                 $flagCatched = true;
                             }
                         }
                         //Counter
                         if ($flagCatched) {
                             $counterIntermediateCatchMessageEvent++;
                         }
                         break;
                 }
                 //Message-Application catch
                 if ($flagCatched) {
                     $result = $this->update($messageApplicationUid, array("MSGAPP_STATUS" => "READ"));
                 }
                 $counter++;
                 //Progress bar
                 $common->frontEndShow("BAR", "Message-Events (unread): " . $counter . "/" . $totalMessageEvent . " " . $common->progressBar($totalMessageEvent, $counter));
                 $flagNextRecords = true;
             }
         } while ($flagNextRecords);
         $common->frontEndShow("TEXT", "Total Message-Events unread: " . $totalMessageEvent);
         $common->frontEndShow("TEXT", "Total cases started: " . $counterStartMessageEvent);
         $common->frontEndShow("TEXT", "Total cases continued: " . $counterIntermediateCatchMessageEvent);
         $common->frontEndShow("TEXT", "Total Message-Events pending: " . ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent)));
         $common->frontEndShow("END");
     } catch (\Exception $e) {
         throw $e;
     }
 }
예제 #8
0
 /**
  * Start/Continue case by Timer-Event
  *
  * @param string $datetime Datetime (yyyy-mm-dd hh:ii:ss)
  * @param bool   $frontEnd Flag to represent the terminal front-end
  *
  * return void
  */
 public function startContinueCaseByTimerEvent($datetime, $frontEnd = false)
 {
     try {
         \G::LoadClass("wsBase");
         //Set variables
         $ws = new \wsBase();
         $case = new \Cases();
         $common = new \ProcessMaker\Util\Common();
         $common->setFrontEnd($frontEnd);
         list($year, $month, $day, $hour, $minute) = $this->getYearMonthDayHourMinuteSecondByDatetime($datetime);
         $date = "{$year}-{$month}-{$day}";
         $dateIni = "{$year}-{$month}-{$day} 00:00:00";
         $dateEnd = "{$year}-{$month}-{$day} 23:59:59";
         //Start Timer-Event (start new case) ///////////////////////////////////////////////////////////////////////
         $common->frontEndShow("START");
         $this->log("START-NEW-CASES", "Date \"{$datetime}\": Start new cases");
         //Query
         $criteria = $this->getTimerEventCriteria();
         $criteria->addSelectColumn(\BpmnEventPeer::EVN_NAME);
         $criteria->addSelectColumn(\ElementTaskRelationPeer::TAS_UID);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \ProcessPeer::PRO_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\ProcessPeer::PRO_STATUS, "ACTIVE", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \ElementTaskRelationPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \ElementTaskRelationPeer::ELEMENT_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\ElementTaskRelationPeer::ELEMENT_TYPE, "bpmnEvent", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\ElementTaskRelationPeer::PRJ_UID, \TaskPeer::PRO_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\ElementTaskRelationPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\TaskPeer::TAS_TYPE, "START-TIMER-EVENT", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \BpmnEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \BpmnEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteria->add(\BpmnEventPeer::EVN_TYPE, "START", \Criteria::EQUAL);
         $criteria->add(\BpmnEventPeer::EVN_MARKER, "TIMER", \Criteria::EQUAL);
         $criteria->add(\TimerEventPeer::TMREVN_OPTION, array("HOURLY", "DAILY", "MONTHLY", "EVERY", "ONE-DATE-TIME"), \Criteria::IN);
         $criteria->add(\TimerEventPeer::TMREVN_STATUS, "ACTIVE", \Criteria::EQUAL);
         $criteria->add($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateIni, \Criteria::GREATER_EQUAL)->addAnd($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateEnd, \Criteria::LESS_EQUAL))->addOr($criteria->getNewCriterion(\TimerEventPeer::TMREVN_NEXT_RUN_DATE, $dateIni, \Criteria::LESS_THAN)));
         $criteria->add($criteria->getNewCriterion(\TimerEventPeer::TMREVN_END_DATE, $date, \Criteria::GREATER_EQUAL)->addOr($criteria->getNewCriterion(\TimerEventPeer::TMREVN_END_DATE, null, \Criteria::EQUAL)));
         $rsCriteria = \TimerEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $flagRecord = false;
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]);
             //Set variables
             $arrayTimerEventData = $row;
             $bpmnEventName = $row["EVN_NAME"];
             $taskUid = $row["TAS_UID"];
             //Create the new case
             $timerEventNextRunDate = $arrayTimerEventData["TMREVN_NEXT_RUN_DATE"];
             $timerEventNextRunDateNew = "";
             $flagCase = false;
             if (strtotime($timerEventNextRunDate) < strtotime($dateIni)) {
                 $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime);
                 //Generate new date for old TMREVN_NEXT_RUN_DATE
                 $flagCase = true;
                 //Create the old case
             } else {
                 list(, , , $hourCase, $minuteCase) = $this->getYearMonthDayHourMinuteSecondByDatetime($timerEventNextRunDate);
                 if ((int) ($hour . $minute) <= (int) ($hourCase . $minuteCase)) {
                     $flagCase = $hourCase == $hour && $minuteCase == $minute;
                 } else {
                     $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime);
                     //Generate new date for old TMREVN_NEXT_RUN_DATE
                     $flagCase = true;
                     //Create the old case
                 }
             }
             if ($flagCase) {
                 if ($flagRecord) {
                     $common->frontEndShow("TEXT", "");
                 }
                 if ($bpmnEventName != "") {
                     $common->frontEndShow("TEXT", "> Name Timer-Event: {$bpmnEventName}");
                 }
                 $common->frontEndShow("TEXT", "> Creating the new case...");
                 //Start new case
                 $result = $ws->newCase($arrayTimerEventData["PRJ_UID"], "", $taskUid, array());
                 $arrayResult = json_decode(json_encode($result), true);
                 if ($arrayResult["status_code"] == 0) {
                     $applicationUid = $arrayResult["caseId"];
                     $applicationNumber = $arrayResult["caseNumber"];
                     $common->frontEndShow("TEXT", "    - OK case #{$applicationNumber} was created");
                     $common->frontEndShow("TEXT", "> Routing the case #{$applicationNumber}...");
                     $this->log("CREATED-NEW-CASE", "Case #{$applicationNumber} created, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     //Derivate new case
                     $result = $ws->derivateCase("", $applicationUid, 1);
                     $arrayResult = json_decode(json_encode($result), true);
                     if ($arrayResult["status_code"] == 0) {
                         $common->frontEndShow("TEXT", "    - OK");
                         $this->log("ROUTED-NEW-CASE", "Case #{$applicationNumber} routed, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     } else {
                         $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                         $this->log("ROUTED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                     }
                 } else {
                     $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                     $this->log("CREATED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                 }
                 //Update Timer-Event
                 $arrayData = array();
                 switch ($arrayTimerEventData["TMREVN_OPTION"]) {
                     case "HOURLY":
                     case "DAILY":
                     case "MONTHLY":
                     case "EVERY":
                         if ($timerEventNextRunDateNew == "") {
                             $timerEventNextRunDateNew = $this->getNextRunDateByDataAndDatetime($arrayTimerEventData, $timerEventNextRunDate, false);
                         }
                         if ($arrayTimerEventData["TMREVN_OPTION"] != "EVERY" && $arrayTimerEventData["TMREVN_END_DATE"] . "" != "" && strtotime($timerEventNextRunDateNew) > strtotime($arrayTimerEventData["TMREVN_END_DATE"] . " 23:59:59")) {
                             $arrayData["TMREVN_STATUS"] = "PROCESSED";
                         } else {
                             $arrayData["TMREVN_NEXT_RUN_DATE"] = $timerEventNextRunDateNew;
                         }
                         break;
                     case "ONE-DATE-TIME":
                         $arrayData["TMREVN_STATUS"] = "PROCESSED";
                         break;
                 }
                 $arrayData["TMREVN_LAST_RUN_DATE"] = $timerEventNextRunDate;
                 $arrayData["TMREVN_LAST_EXECUTION_DATE"] = date("Y-m-d H:i:s");
                 $result = $this->singleUpdate($arrayTimerEventData["TMREVN_UID"], $arrayData);
                 $flagRecord = true;
             }
         }
         if (!$flagRecord) {
             $common->frontEndShow("TEXT", "Not exists any record to start a new case, on date \"{$datetime}\"");
             $this->log("NO-RECORDS", "Not exists any record to start a new case");
         }
         $common->frontEndShow("END");
         $this->log("END-NEW-CASES", "Date \"{$datetime}\": End new cases");
         //Intermediate Catch Timer-Event (continue the case) ///////////////////////////////////////////////////////
         $this->log("START-CONTINUE-CASES", "Date \"{$datetime}\": Start continue the cases");
         //Query
         $criteriaMain = $this->getTimerEventCriteria();
         $criteriaMain->addSelectColumn(\AppDelegationPeer::APP_UID);
         $criteriaMain->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
         $criteriaMain->addSelectColumn(\AppDelegationPeer::DEL_DELEGATE_DATE);
         $criteriaMain->addSelectColumn(\BpmnEventPeer::EVN_NAME);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::PRO_UID, \ProcessPeer::PRO_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ProcessPeer::PRO_STATUS, "ACTIVE", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::APP_UID, \ApplicationPeer::APP_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ApplicationPeer::APP_STATUS, "DRAFT", \Criteria::NOT_EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\AppDelegationPeer::PRO_UID, \TaskPeer::PRO_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\AppDelegationPeer::TAS_UID, \TaskPeer::TAS_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\TaskPeer::TAS_TYPE, "INTERMEDIATE-CATCH-TIMER-EVENT", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\TaskPeer::PRO_UID, \ElementTaskRelationPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TaskPeer::TAS_UID, \ElementTaskRelationPeer::TAS_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\ElementTaskRelationPeer::ELEMENT_TYPE, "bpmnEvent", \Criteria::EQUAL);
         $arrayCondition = array();
         $arrayCondition[] = array(\ElementTaskRelationPeer::PRJ_UID, \TimerEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\ElementTaskRelationPeer::ELEMENT_UID, \TimerEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $arrayCondition = array();
         $arrayCondition[] = array(\TimerEventPeer::PRJ_UID, \BpmnEventPeer::PRJ_UID, \Criteria::EQUAL);
         $arrayCondition[] = array(\TimerEventPeer::EVN_UID, \BpmnEventPeer::EVN_UID, \Criteria::EQUAL);
         $criteriaMain->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
         $criteriaMain->add(\BpmnEventPeer::EVN_TYPE, "INTERMEDIATE", \Criteria::EQUAL);
         $criteriaMain->add(\BpmnEventPeer::EVN_MARKER, "TIMER", \Criteria::EQUAL);
         $criteriaMain->add(\TimerEventPeer::TMREVN_OPTION, array("WAIT-FOR", "WAIT-UNTIL-SPECIFIED-DATE-TIME"), \Criteria::IN);
         $criteriaMain->add(\TimerEventPeer::TMREVN_STATUS, "ACTIVE", \Criteria::EQUAL);
         $criteriaMain->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
         $criteriaMain->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
         //Number records total
         $criteriaCount = clone $criteriaMain;
         $criteriaCount->clearSelectColumns();
         $criteriaCount->addSelectColumn("COUNT(" . \AppDelegationPeer::APP_UID . ") AS NUM_REC");
         $rsCriteriaCount = \AppDelegationPeer::doSelectRS($criteriaCount);
         $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $result = $rsCriteriaCount->next();
         $row = $rsCriteriaCount->getRow();
         $numRecTotal = $row["NUM_REC"];
         //Query
         $total = $numRecTotal;
         $counter = 0;
         $start = 0;
         $limit = 1000;
         $flagRecord = false;
         do {
             $flagNextRecord = false;
             $criteria = clone $criteriaMain;
             $criteria->setOffset($start);
             $criteria->setLimit($limit);
             $rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             while ($rsCriteria->next()) {
                 if ($counter + 1 > $total) {
                     $flagNextRecord = false;
                     break;
                 }
                 $row = $rsCriteria->getRow();
                 $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]);
                 //Set variables
                 $arrayTimerEventData = $row;
                 $arrayApplicationData = $case->loadCase($row["APP_UID"]);
                 $applicationUid = $row["APP_UID"];
                 $applicationNumber = $arrayApplicationData["APP_NUMBER"];
                 $delIndex = $row["DEL_INDEX"];
                 $delDelegateDate = $row["DEL_DELEGATE_DATE"];
                 $bpmnEventName = $row["EVN_NAME"];
                 //Continue the case
                 $continueCaseDate = $delDelegateDate;
                 switch ($arrayTimerEventData["TMREVN_OPTION"]) {
                     case "WAIT-FOR":
                         if ($arrayTimerEventData["TMREVN_DAY"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_DAY"] . " days"));
                         }
                         if ($arrayTimerEventData["TMREVN_HOUR"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_HOUR"] . " hours"));
                         }
                         if ($arrayTimerEventData["TMREVN_MINUTE"] . "" != "") {
                             $continueCaseDate = date("Y-m-d H:i:s", strtotime("{$continueCaseDate} +" . (int) $arrayTimerEventData["TMREVN_MINUTE"] . " minutes"));
                         }
                         break;
                     case "WAIT-UNTIL-SPECIFIED-DATE-TIME":
                         $continueCaseDate = \G::replaceDataField($arrayTimerEventData["TMREVN_CONFIGURATION_DATA"], $arrayApplicationData["APP_DATA"]);
                         break;
                 }
                 $arrayContinueCaseDateData = $this->getYearMonthDayHourMinuteSecondByDatetime($continueCaseDate);
                 if (!empty($arrayContinueCaseDateData)) {
                     $flagCase = false;
                     if (strtotime($continueCaseDate) < strtotime($dateIni)) {
                         $flagCase = true;
                         //Continue the old case
                     } else {
                         $yearCase = $arrayContinueCaseDateData[0];
                         $monthCase = $arrayContinueCaseDateData[1];
                         $dayCase = $arrayContinueCaseDateData[2];
                         $hourCase = $arrayContinueCaseDateData[3];
                         $minuteCase = $arrayContinueCaseDateData[4];
                         if ("{$yearCase}-{$monthCase}-{$dayCase}" == "{$year}-{$month}-{$day}") {
                             if ((int) ($hour . $minute) <= (int) ($hourCase . $minuteCase)) {
                                 $flagCase = $hourCase == $hour && $minuteCase == $minute;
                             } else {
                                 $flagCase = true;
                                 //Continue the old case
                             }
                         }
                     }
                     if ($flagCase) {
                         if ($flagRecord) {
                             $common->frontEndShow("TEXT", "");
                         }
                         if ($bpmnEventName != "") {
                             $common->frontEndShow("TEXT", "> Name Timer-Event: {$bpmnEventName}");
                         }
                         $common->frontEndShow("TEXT", "> Continue the case #{$applicationNumber}");
                         $common->frontEndShow("TEXT", "> Routing the case #{$applicationNumber}...");
                         //Continue the case
                         //Derivate case
                         $result = $ws->derivateCase("", $applicationUid, $delIndex);
                         $arrayResult = json_decode(json_encode($result), true);
                         if ($arrayResult["status_code"] == 0) {
                             $common->frontEndShow("TEXT", "    - OK");
                             $this->log("CONTINUED-CASE", "Case #{$applicationNumber} continued, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                         } else {
                             $common->frontEndShow("TEXT", "    - Failed: " . $arrayResult["message"]);
                             $this->log("CONTINUED-CASE", "Failed: " . $arrayResult["message"] . ", Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                         }
                         $flagRecord = true;
                     }
                 } else {
                     $this->log("INVALID-CONTINUE-DATE", "Continue date: {$continueCaseDate}, Case: #{$applicationNumber}, APP_UID: {$applicationUid}, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
                 }
                 $counter++;
                 $flagNextRecord = true;
             }
             $start = $start + $limit;
         } while ($flagNextRecord);
         if (!$flagRecord) {
             $common->frontEndShow("TEXT", "Not exists any record to continue a case, on date \"{$datetime}\"");
             $this->log("NO-RECORDS", "Not exists any record to continue a case");
         }
         $common->frontEndShow("END");
         $this->log("END-CONTINUE-CASES", "Date \"{$datetime}\": End continue the cases");
     } catch (\Exception $e) {
         throw $e;
     }
 }
예제 #9
0
파일: Light.php 프로젝트: rrsc/processmaker
 /**
  * Route Case
  *
  * @param string $applicationUid Unique id of Case
  * @param string $userUid Unique id of User
  * @param string $delIndex
  * @param array $tasks
  * @param string $bExecuteTriggersBeforeAssignment
  *
  * return array Return an array with Task Case
  */
 public function updateRouteCase($applicationUid, $userUid, $delIndex, $tasks)
 {
     try {
         if (!$delIndex) {
             $delIndex = \AppDelegation::getCurrentIndex($applicationUid);
         }
         \G::LoadClass('wsBase');
         $ws = new \wsBase();
         $fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks);
         $fields['message'] = trim(strip_tags($fields['message']));
         $array = json_decode(json_encode($fields), true);
         if ($array ["status_code"] != 0) {
             throw (new \Exception($array ["message"]));
         } else {
             unset($array['status_code']);
             unset($array['message']);
             unset($array['timestamp']);
         }
     } catch (\Exception $e) {
         throw $e;
     }
     return $fields;
 }
예제 #10
0
function RouteCase($params)
{
    $oSession = new Sessions();
    $vsResult = isValidSession($params->sessionId);
    if ($vsResult->status_code !== 0) {
        return $vsResult;
    }
    if (ifPermission($params->sessionId, 'PM_CASES') == 0) {
        $result = new wsResponse(2, "You do not have privileges");
        return $result;
    }
    $user = $oSession->getSessionUser($params->sessionId);
    $oStd->stored_system_variables = true;
    $oStd->wsSessionId = $params->sessionId;
    $ws = new wsBase($oStd);
    $res = $ws->derivateCase($user['USR_UID'], $params->caseId, $params->delIndex);
    return $res;
}