Ejemplo n.º 1
0
    /**
     * consolidatedUpdate
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    function consolidatedUpdate($dynaformUid, $dataUpdate, $usr_uid)
    {
        G::LoadClass("case");
        G::LoadClass("pmFunctions");

        $delIndex = 1;
        $oCase = new \Cases();

        $array = array();
        $array["form"] = $dataUpdate;
        $appUid = $array["form"]["APP_UID"];

        $fields = $oCase->loadCase($appUid);
        if (!isset($fields["DEL_INIT_DATE"])) {
            $oCase->setDelInitDate($appUid, $delIndex);
            //$aFields = $oCase->loadCase($appUid, $delIndex);
            $fields = $oCase->loadCase($appUid, $delIndex);
        }

        $auxAppDataApplication = $fields["APP_DATA"]["APPLICATION"];
        $auxAppDataProcess     = $fields["APP_DATA"]["PROCESS"];
        $auxAppDataTask        = $fields["APP_DATA"]["TASK"];
        $auxAppDataIndex       = $fields["APP_DATA"]["INDEX"];

        foreach ($array["form"] as $key => $value) {
            $array["form"][$key] = (string)$array["form"][$key];
            if (isset($fields["APP_DATA"][$key.'_label'])) {
                $array["form"][$key.'_label']   = (string)$array["form"][$key];
            }
        }
        /*
        $_POST['form'] = $array["form"];
        if (!class_exists('Smarty')) {
            require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php');  
        }
        $oForm = new \Form( $auxAppDataProcess . "/" . $dynaformUid , PATH_DYNAFORM );
        $oForm->validatePost();
        $array["form"] = $_POST['form'];
        */

        $fields["APP_DATA"] = array_merge($fields["APP_DATA"], G::getSystemConstants());
        $fields["APP_DATA"] = array_merge($fields["APP_DATA"], $array["form"]);

        $fields["APP_DATA"]["APPLICATION"] = $auxAppDataApplication;
        $fields["APP_DATA"]["PROCESS"]     = $auxAppDataProcess;
        $fields["APP_DATA"]["TASK"]        = $auxAppDataTask;
        $fields["APP_DATA"]["INDEX"]       = $auxAppDataIndex;

        $aData = array();
        $aData["APP_NUMBER"]       = $fields["APP_NUMBER"];
        $aData["APP_PROC_STATUS"]  = $fields["APP_PROC_STATUS"];
        $aData["APP_DATA"]         = $fields["APP_DATA"];
        $aData["DEL_INDEX"]        = $delIndex;
        $aData["TAS_UID"]          = $fields["APP_DATA"]["TASK"];
        $aData["CURRENT_DYNAFORM"] = $dynaformUid;
        $aData["USER_UID"]         = $usr_uid;
        $aData["APP_STATUS"]       = $fields["APP_STATUS"];
        $aData["PRO_UID"]          = $fields["APP_DATA"]["PROCESS"];

        $oCase->updateCase($appUid, $aData);
    }
Ejemplo n.º 2
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();

            $messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
            $messageApplication->setFrontEnd($frontEnd);

            //Get data
            $totalMessageEvent = 0;

            $counterStartMessageEvent = 0;
            $counterIntermediateCatchMessageEvent = 0;
            $counter = 0;

            $flagFirstTime = false;

            $messageApplication->frontEndShow("START");

            do {
                $flagNextRecords = false;

                $arrayMessageApplicationUnread = $messageApplication->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 = $messageApplication->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 = $messageApplication->update($messageApplicationUid, array("MSGAPP_STATUS" => "READ"));
                    }

                    $counter++;

                    //Progress bar
                    $messageApplication->frontEndShow("BAR", "Message-Events (unread): " . $counter . "/" . $totalMessageEvent . " " . $messageApplication->progressBar($totalMessageEvent, $counter));

                    $flagNextRecords = true;
                }
            } while ($flagNextRecords);

            $messageApplication->frontEndShow("TEXT", "Total Message-Events unread: " . $totalMessageEvent);
            $messageApplication->frontEndShow("TEXT", "Total cases started: " . $counterStartMessageEvent);
            $messageApplication->frontEndShow("TEXT", "Total cases continued: " . $counterIntermediateCatchMessageEvent);
            $messageApplication->frontEndShow("TEXT", "Total Message-Events pending: " . ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent)));

            $messageApplication->frontEndShow("END");
        } catch (\Exception $e) {
            throw $e;
        }
    }
Ejemplo n.º 3
0
 /**
  * Get information for status paused and participated or other status
  *
  * @param $userUid
  * @param $type
  * @param $app_uid
  * @throws \Exception
  */
 public function getInformation($userUid, $type, $app_uid)
 {
     $response = array();
     switch ($type) {
         case 'unassigned':
         case 'paused':
         case 'participated':
             $oCase = new \Cases();
             $iDelIndex = $oCase->getCurrentDelegationCase( $app_uid );
             $aFields = $oCase->loadCase( $app_uid, $iDelIndex );
             $response = $this->getInfoResume($userUid, $aFields, $type);
             break;
     }
     return $response;
 }
Ejemplo n.º 4
0
 /**
  * Get Steps evaluate
  *
  * @access public
  * @param string $app_uid, Uid for case
  * @param int $del_index , Index for case
  * @return array
  *
  * @copyright Colosa - Bolivia
  */
 public function getSteps($app_uid, $del_index)
 {
     Validator::isString($app_uid, '$app_uid');
     Validator::appUid($app_uid, '$app_uid');
     Validator::isInteger($del_index, '$del_index');
     $oCase = new \Cases();
     $aCaseField = $oCase->loadCase($app_uid, $del_index);
     $tas_uid = $aCaseField["TAS_UID"];
     $pro_uid = $aCaseField["PRO_UID"];
     $oApplication = new \Applications();
     $aField = $oApplication->getSteps($app_uid, $del_index, $tas_uid, $pro_uid);
     return $aField;
 }