Exemple #1
0
    /**
     * @url GET /project/:prj_uid/activity/:act_uid/steps
     *
     * @param string $act_uid {@min 32}{@max 32}
     * @param string $prj_uid {@min 32}{@max 32}
     */
    public function doGetActivitySteps($act_uid, $prj_uid)
    {
        try {
            $task = new \ProcessMaker\BusinessModel\Task();
            $task->setFormatFieldNameInUppercase(false);
            $task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));

            $activitySteps = $task->getSteps($act_uid);
            $_SESSION['PROCESS'] = $prj_uid;
            $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
            $dynaForm->setFormatFieldNameInUppercase(false);
            $oMobile = new \ProcessMaker\BusinessModel\Light();
            $step = new \ProcessMaker\Services\Api\Project\Activity\Step();
            \G::LoadClass("pmDynaform");
            $pmDynaForm = new \pmDynaform();
            $response = array();
            for ($i = 0; $i < count($activitySteps); $i++) {
                if ($activitySteps[$i]['step_type_obj'] == "DYNAFORM") {
                    $dataForm = $dynaForm->getDynaForm($activitySteps[$i]['step_uid_obj']);
                    $result   = $this->parserDataDynaForm($dataForm);
                    $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):"";
                    $pmDynaForm->jsonr($result['formContent']);
                    $result['index']        = $i;
                    $result['stepId']       = $activitySteps[$i]["step_uid"];
                    $result['stepUidObj']   = $activitySteps[$i]["step_uid_obj"];
                    $result['stepMode']     = $activitySteps[$i]['step_mode'];
                    $result['stepPosition'] = $activitySteps[$i]['step_position'];
                    $trigger = $oMobile->statusTriggers($step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"], $act_uid, $prj_uid));
                    $result["triggers"]    = $trigger;
                    $response[] = $result;
                }
            }
        } catch (\Exception $e) {
            throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
        }
        return $response;
    }
Exemple #2
0
    /**
     * Execute Trigger case
     *
     * @param string $prj_uid  {@min 1}{@max 32}
     * @param string $act_uid  {@min 1}{@max 32}
     * @param string $cas_uid  {@min 1}{@max 32}
     * @param string $step_uid {@min 32}{@max 32}
     * @param string $type     {@choice before,after}
     *
     * @copyright Colosa - Bolivia
     *
     * @url POST /process/:prj_uid/task/:act_uid/case/:cas_uid/step/:step_uid/execute-trigger/:type
     */
    public function doPutExecuteTriggerCase($prj_uid, $act_uid, $cas_uid, $step_uid, $type)
    {
        try {
            $userUid = $this->getUserId();
            $step = new \ProcessMaker\Services\Api\Project\Activity\Step();
            $triggers= $step->doGetActivityStepTriggers($step_uid, $act_uid, $prj_uid);

            $step = new \ProcessMaker\BusinessModel\Step();
            $step->setFormatFieldNameInUppercase(false);
            $step->setArrayParamException(array("stepUid" => "step_uid", "taskUid" => "act_uid", "processUid" => "prj_uid"));

            $cases = new \ProcessMaker\BusinessModel\Cases();
            foreach($triggers as $trigger){
                if (strtolower($trigger['st_type']) == $type) {
                    $cases->putExecuteTriggerCase($cas_uid, $trigger['tri_uid'], $userUid);
                }
            }
        } catch (\Exception $e) {
            throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
        }
    }
Exemple #3
0
    /**

     * @url GET /:prj_uid/activity/:act_uid/steps

     *

     * @param string $act_uid {@min 32}{@max 32}

     * @param string $prj_uid {@min 32}{@max 32}

     */

    public function doGetActivitySteps($act_uid, $prj_uid)

    {

        try {

            $task = new \ProcessMaker\BusinessModel\Task();

            $task->setFormatFieldNameInUppercase(false);

            $task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));



            $response = $task->getSteps($act_uid);



            $step = new \ProcessMaker\Services\Api\Project\Activity\Step();



            for ($i = 0; $i < count($response); $i++) {

                $response[$i]["triggers"] = $step->doGetActivityStepTriggers($response[$i]["step_uid"], $act_uid, $prj_uid);

            }



            return $response;

        } catch (\Exception $e) {

            throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));

        }

    }
Exemple #4
0
    /**
     * Method get list start case
     *
     * @param $userId User id
     * @return array
     * @throws \Exception
     */
    public function getProcessListStartCase($userId)
    {
        $response = null;
        try {
            $oProcess = new \Process();
            $oCase    = new \Cases();

            //Get ProcessStatistics Info
            $start   = 0;
            $limit   = '';
            $proData = $oProcess->getAllProcesses( $start, $limit, null, null, false, true );

            $processListInitial = $oCase->getStartCasesPerType( $userId, 'category' );

            $processList = array ();
            foreach ($processListInitial as $key => $procInfo) {
                if (isset( $procInfo['pro_uid'] )) {
                    if (trim( $procInfo['cat'] ) == "") {
                        $procInfo['cat'] = "_OTHER_";
                    }
                    $processList[$procInfo['catname']][$procInfo['value']] = $procInfo;
                }
            }

            ksort( $processList );
            foreach ($processList as $key => $processInfo) {
                ksort( $processList[$key] );
            }

            foreach ($proData as $key => $proInfo) {
                $proData[$proInfo['PRO_UID']] = $proInfo;
            }

            $task = new \ProcessMaker\BusinessModel\Task();
            $task->setFormatFieldNameInUppercase(false);
            $task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));
            $step = new \ProcessMaker\Services\Api\Project\Activity\Step();
            $response = array();
            foreach ($processList as $key => $processInfo) {
                $tempTreeChildren = array ();
                foreach ($processList[$key] as $keyChild => $processInfoChild) {
                    $tempTreeChild['text']      = htmlentities($keyChild, ENT_QUOTES, 'UTF-8'); //ellipsis ( $keyChild, 50 );
                    $tempTreeChild['processId'] = $processInfoChild['pro_uid'];
                    $tempTreeChild['taskId']    = $processInfoChild['uid'];
                    $forms = $task->getSteps($processInfoChild['uid']);
                    $newForm = array();
                    $c = 0;
                    foreach ($forms as $k => $form) {
                        if ($form['step_type_obj'] == "DYNAFORM") {
                            $newForm[$c]['formId'] = $form['step_uid_obj'];
                            $newForm[$c]['index'] = $c+1;
                            $newForm[$c]['title'] = $form['obj_title'];
                            $newForm[$c]['description'] = $form['obj_description'];
                            $newForm[$c]['stepId']      = $form["step_uid"];
                            $newForm[$c]['stepMode']    = $form['step_mode'];
                            $trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"], $tempTreeChild['taskId'], $tempTreeChild['processId']));
                            $newForm[$c]["triggers"]    = $trigger;
                            $c++;
                        }
                    }
                    $tempTreeChild['forms'] = $newForm;
                    if (isset( $proData[$processInfoChild['pro_uid']] )) {
                        $tempTreeChildren[] = $tempTreeChild;
                    }
                }
                $response = array_merge($response, $tempTreeChildren);
            }
        } catch (\Exception $e) {
            throw $e;
        }
        return $response;
    }