Esempio n. 1
0
 /**
  * Get data of Cases InputDocument
  *
  * @param string $applicationUid
  * @param string $userUid
  * @param string $inputDocumentUid
  *
  * return array Return an array with data of an InputDocument
  */
 public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid)
 {
     try {
         $sApplicationUID = $applicationUid;
         $sUserUID = $userUid;
         \G::LoadClass('case');
         $oCase = new \Cases();
         $fields = $oCase->loadCase( $sApplicationUID );
         $sProcessUID = $fields['PRO_UID'];
         $sTaskUID = '';
         $oCaseRest = new \ProcessMaker\BusinessModel\Cases();
         $oCaseRest->getAllUploadedDocumentsCriteria( $sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID );
         $result = array ();
         global $_DBArray;
         foreach ($_DBArray['inputDocuments'] as $key => $row) {
             if (isset( $row['DOC_VERSION'] )) {
                 $docrow = array ();
                 $docrow['app_doc_uid'] = $row['APP_DOC_UID'];
                 $docrow['app_doc_filename'] = $row['APP_DOC_FILENAME'];
                 $docrow['doc_uid'] = $row['DOC_UID'];
                 $docrow['app_doc_version'] = $row['DOC_VERSION'];
                 $docrow['app_doc_create_date'] = $row['CREATE_DATE'];
                 $docrow['app_doc_create_user'] = $row['CREATED_BY'];
                 $docrow['app_doc_type'] = $row['TYPE'];
                 $docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
                 $docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
                 if ($docrow['app_doc_uid'] == $inputDocumentUid) {
                     $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, $row['DOC_VERSION'] );
                     if (is_null( $oAppDocument )) {
                         throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid)));
                     }
                     $result = $docrow;
                 }
             }
         }
         $oResponse = json_decode(json_encode($result), false);
         return $oResponse;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Esempio n. 2
0
    /**
     * Get in base64 the image process (processmap)
     *
     * @url GET /process/:pro_uid/case
     *
     * @param string $prj_uid {@min 32}{@max 32}
     * @param string $app_uid {@min 32}{@max 32}{@from path}
     */
    public function doGetProcessMapImage($pro_uid, $app_uid = null)
    {
        $return = array();
        try {
            $oPMap = new \ProcessMaker\BusinessModel\ProcessMap();
            $schema = Adapter\BpmnWorkflow::getStruct($pro_uid);

            $schemaStatus = array();
            if (!is_null($app_uid)) {
                $case = new \ProcessMaker\BusinessModel\Cases();
                $case->setFormatFieldNameInUppercase(false);
                $schemaStatus = $case->getTasks($app_uid);
            }

            $file = $oPMap->get_image($schema, $schemaStatus);
            ob_start();
            imagepng($file);
            $image  = ob_get_clean();
            $return["map"] = base64_encode($image);

        } catch (\Exception $e) {
            throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
        }
        return $return;
    }
Esempio n. 3
0
    function derivate($currentDelegation = array(), $nextDelegations = array(), $removeList = true)

    {

        //define this...

        if (! defined( 'TASK_FINISH_PROCESS' )) {

            define( 'TASK_FINISH_PROCESS', - 1 );

        }

        if (! defined( 'TASK_FINISH_TASK' )) {

            define( 'TASK_FINISH_TASK', - 2 );

        }



        $this->case = new cases();



        //Get data for this DEL_INDEX current

        $appFields = $this->case->loadCase( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );



        //We close the current derivation, then we'll try to derivate to each defined route

        $this->case->CloseCurrentDelegation( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );



        //Get data for current delegation (current Task)

        $task = TaskPeer::retrieveByPK($currentDelegation["TAS_UID"]);



        $currentDelegation["TAS_ASSIGN_TYPE"] = $task->getTasAssignType();

        $currentDelegation["TAS_MI_COMPLETE_VARIABLE"] = $task->getTasMiCompleteVariable();

        $currentDelegation["TAS_MI_INSTANCE_VARIABLE"] = $task->getTasMiInstanceVariable();



        //Count how many tasks should be derivated.

        //$countNextTask = count($nextDelegations);

        //$removeList = true;



        foreach ($nextDelegations as $nextDel) {

            //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT

            //Check and get unique id

            if (preg_match("/^(.{32})\/(\-1)$/", $nextDel["TAS_UID"], $arrayMatch)) {

                $nextDel["TAS_UID"] = $arrayMatch[2];

                $nextDel["TAS_UID_DUMMY"] = $arrayMatch[1];

            }



            //subprocesses??

            if ($nextDel['TAS_PARENT'] != '') {

                $oCriteria = new Criteria( 'workflow' );

                $oCriteria->add( SubProcessPeer::PRO_PARENT, $appFields['PRO_UID'] );

                $oCriteria->add( SubProcessPeer::TAS_PARENT, $nextDel['TAS_PARENT'] );

                if (SubProcessPeer::doCount( $oCriteria ) > 0) {

                    $oDataset = SubProcessPeer::doSelectRS( $oCriteria );

                    $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

                    $oDataset->next();

                    $aSP = $oDataset->getRow();

                    $aSP['USR_UID'] = $nextDel['USR_UID'];

                    $oTask = new Task();

                    $aTask = $oTask->load( $nextDel['TAS_PARENT'] );

                    $nextDel = array ('TAS_UID' => $aTask['TAS_UID'],'USR_UID' => $aSP['USR_UID'],'TAS_ASSIGN_TYPE' => $aTask['TAS_ASSIGN_TYPE'],'TAS_DEF_PROC_CODE' => $aTask['TAS_DEF_PROC_CODE'],'DEL_PRIORITY' => 3,'TAS_PARENT' => ''

                    );

                } else {

                    continue;

                }

            }



            //get open threads

            $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );

            //if we are derivating to finish process but there are no more open thread then we are finishing only the task, we are not finishing the whole process

            if (($nextDel['TAS_UID'] == TASK_FINISH_PROCESS) && (($openThreads + 1) > 1)) {

                $nextDel['TAS_UID'] = TASK_FINISH_TASK;

            }



            $taskNextDel = TaskPeer::retrieveByPK($nextDel["TAS_UID"]); //Get data for next delegation (next Task)



            switch ($nextDel['TAS_UID']) {

                case TASK_FINISH_PROCESS:

                    /*Close all delegations of $currentDelegation['APP_UID'] */

                    $this->case->closeAllDelegations( $currentDelegation['APP_UID'] );

                    $this->case->closeAllThreads( $currentDelegation['APP_UID'] );

                    //I think we need to change the APP_STATUS to completed,



                    //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT

                    if (isset($nextDel["TAS_UID_DUMMY"])) {

                        $taskDummy = TaskPeer::retrieveByPK($nextDel["TAS_UID_DUMMY"]);



                        switch ($taskDummy->getTasType()) {

                            case "END-MESSAGE-EVENT":

                                //Throw Message-Events - BpmnEvent - END-MESSAGE-EVENT

                                $case = new \ProcessMaker\BusinessModel\Cases();



                                $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields);

                                break;

                            case "END-EMAIL-EVENT":

                                //Email Event

                                $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();



                                $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields);

                                break;

                        }

                    }

                    break;

                case TASK_FINISH_TASK:

                    $iAppThreadIndex = $appFields['DEL_THREAD'];

                    $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                    break;

                default:

                    // get all siblingThreads

                    //if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI')

                    switch ($currentDelegation['TAS_ASSIGN_TYPE']) {

                        case 'CANCEL_MI':

                        case 'STATIC_MI':

                            $siblingThreads = $this->case->GetAllOpenDelegation( $currentDelegation );

                            $aData = $this->case->loadCase( $currentDelegation['APP_UID'] );



                            if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )] )) {

                                $sMIinstanceVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )];

                            } else {

                                $sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE'];

                            }



                            if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )] )) {

                                $sMIcompleteVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )];

                            } else {

                                $sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];

                            }



                            $discriminateThread = $sMIinstanceVar - $sMIcompleteVar;



                            // -1 because One App Delegation is closed by above Code

                            if ($discriminateThread == count( $siblingThreads )) {

                                $canDerivate = true;

                            } else {

                                $canDerivate = false;

                            }

                            break;

                        default:

                            if ($currentDelegation["ROU_TYPE"] == "SEC-JOIN") {

                                $siblingThreads = $this->case->getOpenSiblingThreads($nextDel["TAS_UID"], $currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"], $currentDelegation["TAS_UID"]);



                                $canDerivate = empty($siblingThreads);

                            } else {

                                $canDerivate = true;

                            }

                    } //end switch



                    if ($canDerivate) {

                        //Throw Message-Events

                        $case = new \ProcessMaker\BusinessModel\Cases();



                        $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields);



                        //Throw Email-Events

                        $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();



                        $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields);



                        //Derivate

                        $aSP = isset( $aSP ) ? $aSP : null;



                        $iNewDelIndex = $this->doDerivation( $currentDelegation, $nextDel, $appFields, $aSP );



                        //Execute Script-Task

                        $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask();



                        $appFields["APP_DATA"] = $scriptTask->execScriptByActivityUid($nextDel["TAS_UID"], $appFields);



                        //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE

                        $arrayTaskTypeToExclude = array("SCRIPT-TASK");



                        if (!in_array($taskNextDel->getTasType(), $arrayTaskTypeToExclude)) {

                            if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") {

                                $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#");



                                if (isset($appFields["APP_DATA"][$nextTaskGroupVariable]) && trim($appFields["APP_DATA"][$nextTaskGroupVariable]) != "") {

                                    $appAssignSelfServiceValue = new AppAssignSelfServiceValue();



                                    $appAssignSelfServiceValue->create($appFields["APP_UID"], $iNewDelIndex, array("PRO_UID" => $appFields["PRO_UID"], "TAS_UID" => $nextDel["TAS_UID"], "GRP_UID" => trim($appFields["APP_DATA"][$nextTaskGroupVariable])));

                                }

                            }

                        }



                        //Check if $taskNextDel is Script-Task

                        if ($taskNextDel->getTasType() == "SCRIPT-TASK") {

                            $this->case->CloseCurrentDelegation($currentDelegation["APP_UID"], $iNewDelIndex);



                            //Get for $nextDel["TAS_UID"] your next Task

                            $taskNextDelNextDelegations = $this->prepareInformation(array(

                                "USER_UID"  => $_SESSION["USER_LOGGED"],

                                "APP_UID"   => $_SESSION["APPLICATION"],

                                "DEL_INDEX" => $iNewDelIndex

                            ));



                            //New next delegation

                            $newNextDelegation = array();



                            $newNextDelegation[1] = array(

                                "TAS_UID"           => $taskNextDelNextDelegations[1]["NEXT_TASK"]["TAS_UID"],

                                "USR_UID"           => $taskNextDelNextDelegations[1]["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"],

                                "TAS_ASSIGN_TYPE"   => $taskNextDelNextDelegations[1]["NEXT_TASK"]["TAS_ASSIGN_TYPE"],

                                "TAS_DEF_PROC_CODE" => "",

                                "DEL_PRIORITY"      => "",

                                "TAS_PARENT"        => ""

                            );



                            $this->derivate($currentDelegation, $newNextDelegation, $removeList);

                        }

                    } else {

                        //when the task doesnt generate a new AppDelegation

                        $iAppThreadIndex = $appFields['DEL_THREAD'];

                        switch ($currentDelegation['ROU_TYPE']) {

                            case 'SEC-JOIN':

                                $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                                break;

                            default:

                                if ($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI') {

                                    $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                                }

                                break;

                        } //switch

                    }

            }



            //SETS THE APP_PROC_CODE

            //if (isset($nextDel['TAS_DEF_PROC_CODE']))

            //$appFields['APP_PROC_CODE'] = $nextDel['TAS_DEF_PROC_CODE'];

            /*----------------------------------********---------------------------------*/



            unset( $aSP );



            $removeList = false;

        } //end foreach



        /* Start Block : UPDATES APPLICATION */



        //Set THE APP_STATUS

        $appFields['APP_STATUS'] = $currentDelegation['APP_STATUS'];

        /* Start Block : Count the open threads of $currentDelegation['APP_UID'] */

        $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );



        ///////

        $sw = 0;



        if ($openThreads == 0) {

            //Close case

            $appFields["APP_STATUS"] = "COMPLETED";

            $appFields["APP_FINISH_DATE"] = "now";

            $this->verifyIsCaseChild($currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"]);



            $sw = 1;

        }



        if (isset( $iNewDelIndex )) {

            $appFields["DEL_INDEX"] = $iNewDelIndex;

            $appFields["TAS_UID"] = $nextDel["TAS_UID"];



            $sw = 1;

        }



        if ($sw == 1) {

            //Start Block : UPDATES APPLICATION

            $this->case->updateCase( $currentDelegation["APP_UID"], $appFields );

            //End Block : UPDATES APPLICATION

        }

    }
Esempio n. 4
0
    /**
     * @url GET /:app_uid/:del_index/steps
     *
     * @param string $app_uid {@min 32}{@max 32}
     * @param int $del_index
     *
     */
    public function doGetSteps($app_uid, $del_index)
    {
        try {
            $case = new \ProcessMaker\BusinessModel\Cases();
            $case->setFormatFieldNameInUppercase(false);

            $response = $case->getSteps($app_uid, $del_index);

            return $response;
        } catch (\Exception $e) {
            throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
        }
    }
Esempio n. 5
0
    /**
     * Return Informaction User for derivate
     * assignment Users
     *
     * return array Return an array with Task Case
     */
    public function GetPrepareInformation($usr_uid, $tas_uid, $app_uid, $del_index = null)
    {
        try {
            $oCase = new \Cases();

            $triggers = $oCase->loadTriggers( $tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE');
            if (isset($triggers)){
                $cases = new \ProcessMaker\BusinessModel\Cases();
                foreach($triggers as $trigger){
                    $cases->putExecuteTriggerCase($app_uid, $trigger['TRI_UID'], $usr_uid);
                }
            }
            $oDerivation = new \Derivation();
            $aData = array();
            $aData['APP_UID'] = $app_uid;
            $aData['DEL_INDEX'] = $del_index;
            $aData['USER_UID'] = $usr_uid;
            $derive = $oDerivation->prepareInformation( $aData );
            $response = array();
            foreach ($derive as $sKey => &$aValues) {
                $sPriority = ''; //set priority value
                if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') {
                    //TO DO: review this type of assignment
                    if (isset( $aData['APP_DATA'][str_replace( '@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] )] )) {
                        $sPriority = $aData['APP_DATA'][str_replace( '@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] )];
                    }
                } //set priority value

                switch ($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']) {
                    case 'EVALUATE':
                    case 'REPORT_TO':
                    case 'BALANCED':
                    case 'SELF_SERVICE':
                        $taskAss = array();
                        $taskAss['taskId'] = $aValues['NEXT_TASK']['TAS_UID'];
                        $taskAss['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE'];
                        $taskAss['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'];
                        $taskAss['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'];
                        $taskAss['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY'])?$aValues['NEXT_TASK']['DEL_PRIORITY']:"";
                        $taskAss['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT'];
                        $users = array();
                        $users['userId'] = $derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_UID'];
                        $users['userFullName'] = strip_tags($derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME']);
                        $taskAss['users'][]    = $users;
                        $response[] = $taskAss;
                        break;
                    case 'MANUAL':
                        $manual = array();
                        $manual['taskId'] = $aValues['NEXT_TASK']['TAS_UID'];
                        $manual['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE'];
                        $manual['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'];
                        $manual['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'];
                        $manual['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY'])?$aValues['NEXT_TASK']['DEL_PRIORITY']:"";
                        $manual['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT'];
                        $Aux = array ();
                        foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser) {
                            $Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME'];
                        }
                        asort( $Aux );
                        $users = array();
                        foreach ($Aux as $id => $fullname) {
                            $user['userId'] = $id;
                            $user['userFullName'] = $fullname;
                            $users[] = $user;
                        }
                        $manual['users'] = $users;
                        $response[] = $manual;
                        break;
                    case '': //when this task is the Finish process
                    case 'nobody':
                        $userFields = $oDerivation->getUsersFullNameFromArray( $derive[$sKey]['USER_UID'] );
                        $taskAss['routeFinishFlag'] = true;
                        $user['userId'] = $derive[$sKey]['USER_UID'];
                        $user['userFullName'] = $userFields['USR_FULLNAME'];
                        $taskAss['users'][]   = $user;
                        $response[] = $taskAss;
                        break;
                }
            }

            if (empty( $response )) {
                throw (new Exception( G::LoadTranslation( 'ID_NO_DERIVATION_RULE' ) ));
            }
        } catch (\Exception $e) {
            throw $e;
        }
        return $response;
    }
    function derivate ($currentDelegation = array(), $nextDelegations = array())

    {

        //define this...

        if (! defined( 'TASK_FINISH_PROCESS' )) {

            define( 'TASK_FINISH_PROCESS', - 1 );

        }

        if (! defined( 'TASK_FINISH_TASK' )) {

            define( 'TASK_FINISH_TASK', - 2 );

        }



        $this->case = new cases();



        //first, we close the current derivation, then we'll try to derivate to each defined route

        $appFields = $this->case->loadCase( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );

        $this->case->CloseCurrentDelegation( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );



        //Count how many tasks should be derivated.

        //$countNextTask = count($nextDelegations);

        $removeList = true;

        foreach ($nextDelegations as $nextDel) {

            //BpmnEvent - END-MESSAGE-EVENT - Check and get unique id

            if (preg_match("/^(.{32})\/(\-1)$/", $nextDel["TAS_UID"], $arrayMatch)) {

                $nextDel["TAS_UID"] = $arrayMatch[2];

                $nextDel["TAS_UID_DUMMY"] = $arrayMatch[1];

            }



            //subprocesses??

            if ($nextDel['TAS_PARENT'] != '') {

                $oCriteria = new Criteria( 'workflow' );

                $oCriteria->add( SubProcessPeer::PRO_PARENT, $appFields['PRO_UID'] );

                $oCriteria->add( SubProcessPeer::TAS_PARENT, $nextDel['TAS_PARENT'] );

                if (SubProcessPeer::doCount( $oCriteria ) > 0) {

                    $oDataset = SubProcessPeer::doSelectRS( $oCriteria );

                    $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

                    $oDataset->next();

                    $aSP = $oDataset->getRow();

                    $aSP['USR_UID'] = $nextDel['USR_UID'];

                    $oTask = new Task();

                    $aTask = $oTask->load( $nextDel['TAS_PARENT'] );

                    $nextDel = array ('TAS_UID' => $aTask['TAS_UID'],'USR_UID' => $aSP['USR_UID'],'TAS_ASSIGN_TYPE' => $aTask['TAS_ASSIGN_TYPE'],'TAS_DEF_PROC_CODE' => $aTask['TAS_DEF_PROC_CODE'],'DEL_PRIORITY' => 3,'TAS_PARENT' => ''

                    );

                } else {

                    continue;

                }

            }

            //get TAS_ASSIGN_TYPE for current Delegation

            $oTask = new Task();

            $aTask = $oTask->load( $currentDelegation['TAS_UID'] );

            $currentDelegation['TAS_ASSIGN_TYPE'] = $aTask['TAS_ASSIGN_TYPE'];

            $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] = $aTask['TAS_MI_COMPLETE_VARIABLE'];

            $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] = $aTask['TAS_MI_INSTANCE_VARIABLE'];



            //get open threads

            $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );

            //if we are derivating to finish process but there are no more open thread then we are finishing only the task, we are not finishing the whole process

            if (($nextDel['TAS_UID'] == TASK_FINISH_PROCESS) && (($openThreads + 1) > 1)) {

                $nextDel['TAS_UID'] = TASK_FINISH_TASK;

            }

            switch ($nextDel['TAS_UID']) {

                case TASK_FINISH_PROCESS:

                    /*Close all delegations of $currentDelegation['APP_UID'] */

                    $this->case->closeAllDelegations( $currentDelegation['APP_UID'] );

                    $this->case->closeAllThreads( $currentDelegation['APP_UID'] );

                    //I think we need to change the APP_STATUS to completed,



                    //Throw Message-Events - BpmnEvent - END-MESSAGE-EVENT

                    if (isset($nextDel["TAS_UID_DUMMY"])) {

                        $case = new \ProcessMaker\BusinessModel\Cases();



                        $case->throwMessageEventBetweenElementOriginAndElementDest(

                            $currentDelegation["TAS_UID"],

                            $nextDel["TAS_UID_DUMMY"],

                            $appFields

                        );

                    }

                    break;

                case TASK_FINISH_TASK:

                    $iAppThreadIndex = $appFields['DEL_THREAD'];

                    $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                    break;

                default:

                    // get all siblingThreads

                    //if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI')

                    switch ($currentDelegation['TAS_ASSIGN_TYPE']) {

                        case 'CANCEL_MI':

                        case 'STATIC_MI':

                            $siblingThreads = $this->case->GetAllOpenDelegation( $currentDelegation );

                            $aData = $this->case->loadCase( $currentDelegation['APP_UID'] );



                            if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )] )) {

                                $sMIinstanceVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )];

                            } else {

                                $sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE'];

                            }



                            if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )] )) {

                                $sMIcompleteVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )];

                            } else {

                                $sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];

                            }



                            $discriminateThread = $sMIinstanceVar - $sMIcompleteVar;



                            // -1 because One App Delegation is closed by above Code

                            if ($discriminateThread == count( $siblingThreads )) {

                                $canDerivate = true;

                            } else {

                                $canDerivate = false;

                            }

                            break;

                        default:

                            if ($currentDelegation['ROU_TYPE'] == 'SEC-JOIN') {

                                $siblingThreads = $this->case->getOpenSiblingThreads( $nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'], $currentDelegation['ROU_TYPE'] );

                                $canDerivate = count( $siblingThreads ) == 0;

                            } elseif ($currentDelegation['ROU_TYPE'] == 'DISCRIMINATOR') {

                                //First get the total threads of Next Task where route type='Discriminator'

                                $siblingThreads = $this->case->getOpenSiblingThreads( $nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'], $currentDelegation['ROU_TYPE'] );

                                $siblingThreadsCount = count( $siblingThreads );

                                $discriminateThread = $currentDelegation['ROU_CONDITION'];

                                //$checkThread = count($totalThreads) - $cond;

                                if ($discriminateThread == $siblingThreadsCount) {

                                    $canDerivate = true;

                                } else {

                                    $canDerivate = false;

                                }

                            } else {

                                $canDerivate = true;

                            }

                    } //end switch



                    if ($canDerivate) {

                        $aSP = isset( $aSP ) ? $aSP : null;

                        $iNewDelIndex = $this->doDerivation( $currentDelegation, $nextDel, $appFields, $aSP );



                        //Throw Message-Events

                        $case = new \ProcessMaker\BusinessModel\Cases();



                        $case->throwMessageEventBetweenElementOriginAndElementDest(

                            $currentDelegation["TAS_UID"],

                            $nextDel["TAS_UID"],

                            $appFields

                        );



                        //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE

                        $task = new Task();

                        $arrayNextTaskData = $task->load($nextDel["TAS_UID"]);



                        if ($arrayNextTaskData["TAS_ASSIGN_TYPE"] == "SELF_SERVICE" && trim($arrayNextTaskData["TAS_GROUP_VARIABLE"]) != "") {

                            $nextTaskGroupVariable = trim($arrayNextTaskData["TAS_GROUP_VARIABLE"], " @#");



                            if (isset($appFields["APP_DATA"][$nextTaskGroupVariable]) && trim($appFields["APP_DATA"][$nextTaskGroupVariable]) != "") {

                                $appAssignSelfServiceValue = new AppAssignSelfServiceValue();



                                $appAssignSelfServiceValue->create($appFields["APP_UID"], $iNewDelIndex, array("PRO_UID" => $appFields["PRO_UID"], "TAS_UID" => $nextDel["TAS_UID"], "GRP_UID" => trim($appFields["APP_DATA"][$nextTaskGroupVariable])));

                            }

                        }

                    } else {

                        //when the task doesnt generate a new AppDelegation

                        $iAppThreadIndex = $appFields['DEL_THREAD'];

                        switch ($currentDelegation['ROU_TYPE']) {

                            case 'DISCRIMINATOR':

                            case 'SEC-JOIN':

                                $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                                break;

                            default:

                                if ($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI') {

                                    $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                                }

                        } //switch

                    }

            }



            //SETS THE APP_PROC_CODE

            //if (isset($nextDel['TAS_DEF_PROC_CODE']))

            //$appFields['APP_PROC_CODE'] = $nextDel['TAS_DEF_PROC_CODE'];

            /*----------------------------------********---------------------------------*/

            unset( $aSP );

        } //end foreach





        /* Start Block : UPDATES APPLICATION */



        //Set THE APP_STATUS

        $appFields['APP_STATUS'] = $currentDelegation['APP_STATUS'];

        /* Start Block : Count the open threads of $currentDelegation['APP_UID'] */

        $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );



        ///////

        $sw = 0;



        if ($openThreads == 0) {

            //Close case

            $appFields["APP_STATUS"] = "COMPLETED";

            $appFields["APP_FINISH_DATE"] = "now";

            $this->verifyIsCaseChild($currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"]);



            $sw = 1;

        }



        if (isset( $iNewDelIndex )) {

            $appFields["DEL_INDEX"] = $iNewDelIndex;

            $appFields["TAS_UID"] = $nextDel["TAS_UID"];



            $sw = 1;

        }



        if ($sw == 1) {

            //Start Block : UPDATES APPLICATION

            $this->case->updateCase( $currentDelegation["APP_UID"], $appFields );

            //End Block : UPDATES APPLICATION

        }

    }
    function derivate($currentDelegation = array(), $nextDelegations = array(), $removeList = true)

    {

        //define this...

        if (! defined( 'TASK_FINISH_PROCESS' )) {

            define( 'TASK_FINISH_PROCESS', - 1 );

        }

        if (! defined( 'TASK_FINISH_TASK' )) {

            define( 'TASK_FINISH_TASK', - 2 );

        }



        $this->case = new cases();



        //Get data for this DEL_INDEX current

        $appFields = $this->case->loadCase( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );



        //We close the current derivation, then we'll try to derivate to each defined route

        $this->case->CloseCurrentDelegation( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );



        //Get data for current delegation (current Task)

        $task = TaskPeer::retrieveByPK($currentDelegation["TAS_UID"]);

        $bpmnActivity = BpmnActivityPeer::retrieveByPK($currentDelegation["TAS_UID"]);



        $flagTaskIsMultipleInstance = false;

        $flagTaskAssignTypeIsMultipleInstance = false;



        if (!is_null($task) && !is_null($bpmnActivity)) {

            $flagTaskIsMultipleInstance = $bpmnActivity->getActType() == "TASK" && preg_match("/^(?:EMPTY|USERTASK|MANUALTASK)$/", $bpmnActivity->getActTaskType()) && $bpmnActivity->getActLoopType() == "PARALLEL";

            $flagTaskAssignTypeIsMultipleInstance = preg_match("/^(?:MULTIPLE_INSTANCE|MULTIPLE_INSTANCE_VALUE_BASED)$/", $task->getTasAssignType());

        }



        $currentDelegation["TAS_ASSIGN_TYPE"] = $task->getTasAssignType();

        $currentDelegation["TAS_MI_COMPLETE_VARIABLE"] = $task->getTasMiCompleteVariable();

        $currentDelegation["TAS_MI_INSTANCE_VARIABLE"] = $task->getTasMiInstanceVariable();



        //Count how many tasks should be derivated.

        //$countNextTask = count($nextDelegations);

        //$removeList = true;



        foreach ($nextDelegations as $nextDel) {

            //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT

            //Check and get unique id

            if (preg_match("/^(.{32})\/(\-1)$/", $nextDel["TAS_UID"], $arrayMatch)) {

                $nextDel["TAS_UID"] = $arrayMatch[2];

                $nextDel["TAS_UID_DUMMY"] = $arrayMatch[1];

            }



            //subprocesses??

            if ($nextDel['TAS_PARENT'] != '') {

                $oCriteria = new Criteria( 'workflow' );

                $oCriteria->add( SubProcessPeer::PRO_PARENT, $appFields['PRO_UID'] );

                $oCriteria->add( SubProcessPeer::TAS_PARENT, $nextDel['TAS_PARENT'] );

                if (SubProcessPeer::doCount( $oCriteria ) > 0) {

                    $oDataset = SubProcessPeer::doSelectRS( $oCriteria );

                    $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

                    $oDataset->next();

                    $aSP = $oDataset->getRow();

                    $aSP['USR_UID'] = $nextDel['USR_UID'];

                    $oTask = new Task();

                    $aTask = $oTask->load( $nextDel['TAS_PARENT'] );

                    $nextDel = array ('TAS_UID' => $aTask['TAS_UID'],'USR_UID' => $aSP['USR_UID'],'TAS_ASSIGN_TYPE' => $aTask['TAS_ASSIGN_TYPE'],'TAS_DEF_PROC_CODE' => $aTask['TAS_DEF_PROC_CODE'],'DEL_PRIORITY' => 3,'TAS_PARENT' => ''

                    );

                } else {

                    continue;

                }

            }



            //get open threads

            $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );

            //if we are derivating to finish process but there are no more open thread then we are finishing only the task, we are not finishing the whole process

            if (($nextDel['TAS_UID'] == TASK_FINISH_PROCESS) && (($openThreads + 1) > 1)) {

                $nextDel['TAS_UID'] = TASK_FINISH_TASK;

            }



            $taskNextDel = TaskPeer::retrieveByPK($nextDel["TAS_UID"]); //Get data for next delegation (next Task)

            $bpmnActivityNextDel = BpmnActivityPeer::retrieveByPK($nextDel["TAS_UID"]);



            $flagTaskNextDelIsMultipleInstance = false;

            $flagTaskNextDelAssignTypeIsMultipleInstance = false;



            if (!is_null($taskNextDel) && !is_null($bpmnActivityNextDel)) {

                $flagTaskNextDelIsMultipleInstance = $bpmnActivityNextDel->getActType() == "TASK" && preg_match("/^(?:EMPTY|USERTASK|MANUALTASK)$/", $bpmnActivityNextDel->getActTaskType()) && $bpmnActivityNextDel->getActLoopType() == "PARALLEL";

                $flagTaskNextDelAssignTypeIsMultipleInstance = preg_match("/^(?:MULTIPLE_INSTANCE|MULTIPLE_INSTANCE_VALUE_BASED)$/", $taskNextDel->getTasAssignType());

            }



            $flagUpdateCounters = true;



            switch ($nextDel['TAS_UID']) {

                case TASK_FINISH_PROCESS:

                    /*Close all delegations of $currentDelegation['APP_UID'] */

                    $this->case->closeAllDelegations( $currentDelegation['APP_UID'] );

                    $this->case->closeAllThreads( $currentDelegation['APP_UID'] );

                    //I think we need to change the APP_STATUS to completed,



                    //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT

                    if (isset($nextDel["TAS_UID_DUMMY"])) {

                        $taskDummy = TaskPeer::retrieveByPK($nextDel["TAS_UID_DUMMY"]);



                        switch ($taskDummy->getTasType()) {

                            case "END-MESSAGE-EVENT":

                                //Throw Message-Events - BpmnEvent - END-MESSAGE-EVENT

                                $case = new \ProcessMaker\BusinessModel\Cases();



                                $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields);

                                break;

                            case "END-EMAIL-EVENT":

                                //Email Event

                                $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();



                                $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields);

                                break;

                        }

                    }

                    break;

                case TASK_FINISH_TASK:

                    $iAppThreadIndex = $appFields['DEL_THREAD'];

                    $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                    break;

                default:

                    //Get all siblingThreads

                    $canDerivate = false;



                    switch ($currentDelegation['TAS_ASSIGN_TYPE']) {

                        case 'CANCEL_MI':

                        case 'STATIC_MI':

                            $arrayOpenThread = $this->case->GetAllOpenDelegation($currentDelegation);

                            $aData = $this->case->loadCase( $currentDelegation['APP_UID'] );



                            if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )] )) {

                                $sMIinstanceVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )];

                            } else {

                                $sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE'];

                            }



                            if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )] )) {

                                $sMIcompleteVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )];

                            } else {

                                $sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];

                            }



                            $discriminateThread = $sMIinstanceVar - $sMIcompleteVar;



                            // -1 because One App Delegation is closed by above Code

                            if ($discriminateThread == count($arrayOpenThread)) {

                                $canDerivate = true;

                            } else {

                                $canDerivate = false;

                            }

                            break;

                        default:

                            $routeType = $currentDelegation["ROU_TYPE"];

                            $routeType = ($flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance)? "SEC-JOIN" : $routeType;



                            switch ($routeType) {

                                case "SEC-JOIN":

                                    $arrayOpenThread = ($flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance)? $this->case->searchOpenPreviousTasks($currentDelegation["TAS_UID"], $currentDelegation["APP_UID"]) : array();

                                    $arrayOpenThread = array_merge($arrayOpenThread, $this->case->getOpenSiblingThreads($nextDel["TAS_UID"], $currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"], $currentDelegation["TAS_UID"]));



                                    $canDerivate = empty($arrayOpenThread);

                                    break;

                                default:

                                    $canDerivate = true;

                                    break;

                            }

                            break;

                    }



                    if ($canDerivate) {

                        //Throw Message-Events

                        $case = new \ProcessMaker\BusinessModel\Cases();



                        $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields);



                        //Throw Email-Events

                        $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();



                        $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields);



                        //Derivate

                        $aSP = (isset($aSP))? $aSP : null;



                        $taskNextDelAssignType = ($flagTaskNextDelIsMultipleInstance && $flagTaskNextDelAssignTypeIsMultipleInstance)? $taskNextDel->getTasAssignType() : "";



                        switch ($taskNextDelAssignType) {

                            case "MULTIPLE_INSTANCE":

                            case "MULTIPLE_INSTANCE_VALUE_BASED":

                                $arrayUser = $this->getNextAssignedUser(array("APP_UID" => $currentDelegation["APP_UID"], "NEXT_TASK" => $taskNextDel->toArray(BasePeer::TYPE_FIELDNAME)));



                                if (empty($arrayUser)) {

                                    throw new Exception(G::LoadTranslation("ID_NO_USERS"));

                                }



                                foreach ($arrayUser as $value2) {

                                    $currentDelegationAux = array_merge($currentDelegation, array("ROU_TYPE" => "PARALLEL"));

                                    $nextDelAux = array_merge($nextDel, array("USR_UID" => $value2["USR_UID"]));



                                    $iNewDelIndex = $this->doDerivation($currentDelegationAux, $nextDelAux, $appFields, $aSP);



                                    $this->derivateUpdateCounters($currentDelegationAux, $nextDelAux, $taskNextDel, $appFields, $iNewDelIndex, $aSP, $removeList);



                                    $flagUpdateCounters = false;

                                    $removeList = false;

                                }

                                break;

                            default:

                                $iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);

                                break;

                        }



                        //Execute Script-Task

                        $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask();



                        $appFields["APP_DATA"] = $scriptTask->execScriptByActivityUid($nextDel["TAS_UID"], $appFields);



                        //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE

                        $regexpTaskTypeToExclude = "SCRIPT-TASK";



                        if (!is_null($taskNextDel) && !preg_match("/^(?:" . $regexpTaskTypeToExclude . ")$/", $taskNextDel->getTasType())) {

                            if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") {

                                $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#");



                                if (isset($appFields["APP_DATA"][$nextTaskGroupVariable])) {

                                    $dataVariable = $appFields["APP_DATA"][$nextTaskGroupVariable];

                                    $dataVariable = (is_array($dataVariable))? $dataVariable : trim($dataVariable);



                                    if (!empty($dataVariable)) {

                                        $appAssignSelfServiceValue = new AppAssignSelfServiceValue();



                                        $appAssignSelfServiceValue->create($appFields["APP_UID"], $iNewDelIndex, array("PRO_UID" => $appFields["PRO_UID"], "TAS_UID" => $nextDel["TAS_UID"], "GRP_UID" => serialize($dataVariable)));

                                    }

                                }

                            }

                        }



                        //Check if $taskNextDel is Script-Task

                        if (!is_null($taskNextDel) && $taskNextDel->getTasType() == "SCRIPT-TASK") {

                            $this->case->CloseCurrentDelegation($currentDelegation["APP_UID"], $iNewDelIndex);



                            //Get for $nextDel["TAS_UID"] your next Task

                            $taskNextDelNextDelegations = $this->prepareInformation(array(

                                "USER_UID"  => $_SESSION["USER_LOGGED"],

                                "APP_UID"   => $_SESSION["APPLICATION"],

                                "DEL_INDEX" => $iNewDelIndex

                            ));



                            //New next delegation

                            $newNextDelegation = array();



                            $newNextDelegation[1] = array(

                                "TAS_UID"           => $taskNextDelNextDelegations[1]["NEXT_TASK"]["TAS_UID"],

                                "USR_UID"           => $taskNextDelNextDelegations[1]["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"],

                                "TAS_ASSIGN_TYPE"   => $taskNextDelNextDelegations[1]["NEXT_TASK"]["TAS_ASSIGN_TYPE"],

                                "TAS_DEF_PROC_CODE" => "",

                                "DEL_PRIORITY"      => "",

                                "TAS_PARENT"        => ""

                            );



                            $this->derivate($currentDelegation, $newNextDelegation, $removeList);

                        }

                    } else {

                        //when the task doesnt generate a new AppDelegation

                        $iAppThreadIndex = $appFields['DEL_THREAD'];



                        $routeType = $currentDelegation["ROU_TYPE"];

                        $routeType = ($flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance)? "SEC-JOIN" : $routeType;



                        switch ($routeType) {

                            case 'SEC-JOIN':

                                $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                                break;

                            default:

                                if ($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI') {

                                    $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );

                                }

                                break;

                        }

                    }

                    break;

            }



            if ($flagUpdateCounters) {

                $this->derivateUpdateCounters($currentDelegation, $nextDel, $taskNextDel, $appFields, (isset($iNewDelIndex))? $iNewDelIndex : 0, (isset($aSP))? $aSP : null, $removeList);

            }



            $removeList = false;



            unset($aSP);

        }



        /* Start Block : UPDATES APPLICATION */



        //Set THE APP_STATUS

        $appFields['APP_STATUS'] = $currentDelegation['APP_STATUS'];

        /* Start Block : Count the open threads of $currentDelegation['APP_UID'] */

        $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );



        ///////

        $flag = false;



        if ($openThreads == 0) {

            //Close case

            $appFields["APP_STATUS"] = "COMPLETED";

            $appFields["APP_FINISH_DATE"] = "now";

            $this->verifyIsCaseChild($currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"]);



            $flag = true;

        }



        if (isset( $iNewDelIndex )) {

            $appFields["DEL_INDEX"] = $iNewDelIndex;

            $appFields["TAS_UID"] = $nextDel["TAS_UID"];



            $flag = true;

        }



        if ($flag) {

            //Start Block : UPDATES APPLICATION

            $this->case->updateCase( $currentDelegation["APP_UID"], $appFields );

            //End Block : UPDATES APPLICATION

        }

    }
Esempio n. 8
0
 /**
  * Get process list bookmark for start case
  *
  * @url GET /bookmark-start-cases
  *
  * @param string $type_view {@from path}
  * @return array
  *
  */
 public function doGetCasesListBookmarkStarCase($type_view = '')
 {
     try {
         $usr_uid = $this->getUserId();
         $case = new \ProcessMaker\BusinessModel\Cases();
         $response = $case->getCasesListBookmarkStarCase($usr_uid, $type_view);
         return $response;
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }
        $pro["datasources"]["rp"]["adapter"] = $DB_ADAPTER;
        //$pro["datasources"]["dbarray"]["connection"] = "dbarray://*****:*****@localhost/pm_os";
        //$pro["datasources"]["dbarray"]["adapter"]    = "dbarray";
        $oFile = fopen(PATH_CORE . "config" . PATH_SEP . "_databases_.php", "w");
        fwrite($oFile, "<?php global \$pro; return \$pro; ?>");
        fclose($oFile);
        Propel::init(PATH_CORE . "config" . PATH_SEP . "_databases_.php");
        //Creole::registerDriver("dbarray", "creole.contrib.DBArrayConnection");
        //Enable RBAC
        Bootstrap::LoadSystem("rbac");
        $rbac =& RBAC::getSingleton(PATH_DATA, session_id());
        $rbac->sSystem = "PROCESSMAKER";
        if (!defined("DB_ADAPTER")) {
            define("DB_ADAPTER", $DB_ADAPTER);
        }
        eprintln("Processing workspace: " . $workflow, "green");
        try {
            $case = new \ProcessMaker\BusinessModel\Cases();
            $case->catchMessageEvent(true);
        } catch (Exception $e) {
            echo $e->getMessage() . "\n";
            eprintln("Problem in workspace: " . $workflow . " it was omitted.", "red");
        }
        eprintln();
    }
    if (file_exists(PATH_CORE . "config" . PATH_SEP . "_databases_.php")) {
        unlink(PATH_CORE . "config" . PATH_SEP . "_databases_.php");
    }
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}