Example #1
0
    public function startCase($sTasUid, $sUsrUid, $isSubprocess = false, $dataPreviusApplication = array())

    {

        if ($sTasUid != '') {

            try {

                $task = TaskPeer::retrieveByPK($sTasUid);



                if (is_null($task)) {

                    throw new Exception(G::LoadTranslation("ID_TASK_NOT_EXIST", array("TAS_UID", $sTasUid)));

                }



                //To allow Self Service as the first task

                $arrayTaskTypeToExclude = array("START-TIMER-EVENT");



                if (!is_null($task) && !in_array($task->getTasType(), $arrayTaskTypeToExclude) && $task->getTasAssignType() != "SELF_SERVICE" && $sUsrUid == "") {

                    throw (new Exception('You tried to start a new case without send the USER UID!'));

                }



                //Process

                $sProUid = $task->getProUid();

                $this->Process = new Process;

                $proFields = $this->Process->Load($sProUid);



                //application

                $Application = new Application;

                $sAppUid = $Application->create($sProUid, $sUsrUid);



                //appDelegation

                $AppDelegation = new AppDelegation;

                $iAppThreadIndex = 1; // Start Thread

                $iAppDelPrio = 3; // Priority

                $iDelIndex = $AppDelegation->createAppDelegation(

                        $sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iAppDelPrio, $isSubprocess

                );



                //appThread

                $AppThread = new AppThread;

                $iAppThreadIndex = $AppThread->createAppThread($sAppUid, $iDelIndex, 0);



                //DONE: Al ya existir un delegation, se puede "calcular" el caseTitle.

                $Fields = $Application->toArray(BasePeer::TYPE_FIELDNAME);

                $aApplicationFields = $Fields['APP_DATA'];

                $newValues = $this->newRefreshCaseTitleAndDescription($sAppUid, $Fields, $aApplicationFields);

                if (!isset($newValues['APP_TITLE'])) {

                    $newValues['APP_TITLE'] = '';

                }



                $caseNumber = $Fields['APP_NUMBER'];

                $Application->update($Fields);



                //Update the task last assigned (for web entry and web services)

                G::LoadClass('derivation');

                $oDerivation = new Derivation();

                $oDerivation->setTasLastAssigned($sTasUid, $sUsrUid);



                // Execute Events

                require_once 'classes/model/Event.php';

                $event = new Event();

                $event->createAppEvents($sProUid, $sAppUid, $iDelIndex, $sTasUid);



                //update searchindex

                if ($this->appSolr != null) {

                    $this->appSolr->updateApplicationSearchIndex($sAppUid);

                }



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

            } catch (exception $e) {

                throw ($e);

            }

        } else {

            throw (new Exception('You tried to start a new case without send the USER UID or TASK UID!'));

        }



        //call plugin

        if (class_exists('folderData')) {

            $folderData = new folderData(

                            $sProUid,

                            $proFields['PRO_TITLE'],

                            $sAppUid,

                            $newValues['APP_TITLE'],

                            $sUsrUid

            );

            $oPluginRegistry = &PMPluginRegistry::getSingleton();

            $oPluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);

        }

        //end plugin

        return array(

            'APPLICATION' => $sAppUid,

            'INDEX' => $iDelIndex,

            'PROCESS' => $sProUid,

            'CASE_NUMBER' => $caseNumber

        );

    }
Example #2
0
 public function startCase($sTasUid, $sUsrUid, $isSubprocess = false)
 {
     if ($sTasUid != '') {
         try {
             $this->Task = new Task();
             $Fields = $this->Task->Load($sTasUid);
             //To allow Self Service as the first task
             if ($Fields['TAS_ASSIGN_TYPE'] != 'SELF_SERVICE' && $sUsrUid == '') {
                 throw new Exception('You tried to start a new case without send the USER UID!');
             }
             //Process
             $sProUid = $this->Task->getProUid();
             $this->Process = new Process();
             $proFields = $this->Process->Load($sProUid);
             //application
             $Application = new Application();
             $sAppUid = $Application->create($sProUid, $sUsrUid);
             //appDelegation
             $AppDelegation = new AppDelegation();
             $iAppThreadIndex = 1;
             // Start Thread
             $iAppDelPrio = 3;
             // Priority
             $iDelIndex = $AppDelegation->createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iAppDelPrio, $isSubprocess);
             //appThread
             $AppThread = new AppThread();
             $iAppThreadIndex = $AppThread->createAppThread($sAppUid, $iDelIndex, 0);
             //DONE: Al ya existir un delegation, se puede "calcular" el caseTitle.
             $Fields = $Application->toArray(BasePeer::TYPE_FIELDNAME);
             $aApplicationFields = $Fields['APP_DATA'];
             $newValues = $this->newRefreshCaseTitleAndDescription($sAppUid, $Fields, $aApplicationFields);
             if (!isset($newValues['APP_TITLE'])) {
                 $newValues['APP_TITLE'] = '';
             }
             $caseNumber = $Fields['APP_NUMBER'];
             $Application->update($Fields);
             //Update the task last assigned (for web entry and web services)
             G::LoadClass('derivation');
             $oDerivation = new Derivation();
             $oDerivation->setTasLastAssigned($sTasUid, $sUsrUid);
             //update searchindex
             if ($this->appSolr != null) {
                 $this->appSolr->updateApplicationSearchIndex($sAppUid);
             }
         } catch (exception $e) {
             throw $e;
         }
     } else {
         throw new Exception('You tried to start a new case without send the USER UID or TASK UID!');
     }
     //call plugin
     if (class_exists('folderData')) {
         $folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $newValues['APP_TITLE'], $sUsrUid);
         $oPluginRegistry =& PMPluginRegistry::getSingleton();
         $oPluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);
     }
     //end plugin
     return array('APPLICATION' => $sAppUid, 'INDEX' => $iDelIndex, 'PROCESS' => $sProUid, 'CASE_NUMBER' => $caseNumber);
 }