Exemplo n.º 1
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;
    }