コード例 #1
0
 public function calculateDueDate($sNextTasParam)
 {
     //Get Task properties
     $task = TaskPeer::retrieveByPK($this->getTasUid());
     $aData['TAS_UID'] = $this->getTasUid();
     //Added to allow User defined Timing Control at Run time from Derivation screen
     if (isset($sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
         $aData['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
         $aData['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
         $aData['TAS_TYPE_DAY'] = $sNextTasParam['NEXT_TASK']['TAS_TYPE_DAY'];
         if (isset($sNextTasParam['NEXT_TASK']['TAS_CALENDAR']) && $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] != '') {
             $aCalendarUID = $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'];
         } else {
             $aCalendarUID = '';
         }
         //Updating the task Table , so that user will see updated values in the assign screen in consequent cases
         $oTask = new Task();
         $oTask->update($aData);
     } else {
         if (is_null($task)) {
             return 0;
         }
         $aData['TAS_DURATION'] = $task->getTasDuration();
         $aData['TAS_TIMEUNIT'] = $task->getTasTimeUnit();
         $aData['TAS_TYPE_DAY'] = $task->getTasTypeDay();
         $aCalendarUID = '';
     }
     //use the dates class to calculate dates
     $calendar = new calendar();
     if ($calendar->pmCalendarUid == '') {
         $calendar->getCalendar(null, $task->getProUid(), $aData['TAS_UID']);
         $calendar->getCalendarData();
     }
     $iDueDate = $calendar->calculateDate($this->getDelDelegateDate(), $aData['TAS_DURATION'], $aData['TAS_TIMEUNIT']);
     return $iDueDate;
 }
コード例 #2
0
ファイル: Task.php プロジェクト: emildev35/processmaker
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $tasUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($tasUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(TaskPeer::PRO_UID);
             $criteria->addSelectColumn(TaskPeer::TAS_UID);
             $criteria->addSelectColumn(TaskPeer::TAS_TYPE);
             $criteria->addSelectColumn(TaskPeer::TAS_DURATION);
             $criteria->addSelectColumn(TaskPeer::TAS_DELAY_TYPE);
             $criteria->addSelectColumn(TaskPeer::TAS_TEMPORIZER);
             $criteria->addSelectColumn(TaskPeer::TAS_TYPE_DAY);
             $criteria->addSelectColumn(TaskPeer::TAS_TIMEUNIT);
             $criteria->addSelectColumn(TaskPeer::TAS_ALERT);
             $criteria->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE);
             $criteria->addSelectColumn(TaskPeer::TAS_ASSIGN_TYPE);
             $criteria->addSelectColumn(TaskPeer::TAS_ASSIGN_VARIABLE);
             $criteria->addSelectColumn(TaskPeer::TAS_GROUP_VARIABLE);
             $criteria->addSelectColumn(TaskPeer::TAS_MI_INSTANCE_VARIABLE);
             $criteria->addSelectColumn(TaskPeer::TAS_MI_COMPLETE_VARIABLE);
             $criteria->addSelectColumn(TaskPeer::TAS_ASSIGN_LOCATION);
             $criteria->addSelectColumn(TaskPeer::TAS_ASSIGN_LOCATION_ADHOC);
             $criteria->addSelectColumn(TaskPeer::TAS_TRANSFER_FLY);
             $criteria->addSelectColumn(TaskPeer::TAS_LAST_ASSIGNED);
             $criteria->addSelectColumn(TaskPeer::TAS_USER);
             $criteria->addSelectColumn(TaskPeer::TAS_CAN_UPLOAD);
             $criteria->addSelectColumn(TaskPeer::TAS_VIEW_UPLOAD);
             $criteria->addSelectColumn(TaskPeer::TAS_VIEW_ADDITIONAL_DOCUMENTATION);
             $criteria->addSelectColumn(TaskPeer::TAS_CAN_CANCEL);
             $criteria->addSelectColumn(TaskPeer::TAS_OWNER_APP);
             $criteria->addSelectColumn(TaskPeer::STG_UID);
             $criteria->addSelectColumn(TaskPeer::TAS_CAN_PAUSE);
             $criteria->addSelectColumn(TaskPeer::TAS_CAN_SEND_MESSAGE);
             $criteria->addSelectColumn(TaskPeer::TAS_CAN_DELETE_DOCS);
             $criteria->addSelectColumn(TaskPeer::TAS_SELF_SERVICE);
             $criteria->addSelectColumn(TaskPeer::TAS_START);
             $criteria->addSelectColumn(TaskPeer::TAS_TO_LAST_USER);
             $criteria->addSelectColumn(TaskPeer::TAS_SEND_LAST_EMAIL);
             $criteria->addSelectColumn(TaskPeer::TAS_DERIVATION);
             $criteria->addSelectColumn(TaskPeer::TAS_POSX);
             $criteria->addSelectColumn(TaskPeer::TAS_POSY);
             $criteria->addSelectColumn(TaskPeer::TAS_WIDTH);
             $criteria->addSelectColumn(TaskPeer::TAS_HEIGHT);
             $criteria->addSelectColumn(TaskPeer::TAS_COLOR);
             $criteria->addSelectColumn(TaskPeer::TAS_EVN_UID);
             $criteria->addSelectColumn(TaskPeer::TAS_BOUNDARY);
             $criteria->addSelectColumn(TaskPeer::TAS_DERIVATION_SCREEN_TPL);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = TaskPeer::retrieveByPK($tasUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table Task ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
コード例 #3
0
 public function getStartCasesPerType($sUIDUser = '', $typeView = null)
 {
     $rows[] = array('uid' => 'char', 'value' => 'char');
     $tasks = array();
     $c = new Criteria();
     $c->clearSelectColumns();
     $c->addSelectColumn(TaskPeer::TAS_UID);
     $c->addSelectColumn(TaskPeer::PRO_UID);
     $c->addJoin(TaskPeer::PRO_UID, ProcessPeer::PRO_UID, Criteria::LEFT_JOIN);
     $c->addJoin(TaskPeer::TAS_UID, TaskUserPeer::TAS_UID, Criteria::LEFT_JOIN);
     $c->add(ProcessPeer::PRO_STATUS, 'ACTIVE');
     $c->add(TaskPeer::TAS_START, 'TRUE');
     $c->add(TaskUserPeer::USR_UID, $sUIDUser);
     $rs = TaskPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $rs->next();
     $row = $rs->getRow();
     while (is_array($row)) {
         $tasks[] = $row['TAS_UID'];
         $rs->next();
         $row = $rs->getRow();
     }
     //check groups
     G::LoadClass('groups');
     $group = new Groups();
     $aGroups = $group->getActiveGroupsForAnUser($sUIDUser);
     $c = new Criteria();
     $c->clearSelectColumns();
     $c->addSelectColumn(TaskPeer::TAS_UID);
     $c->addSelectColumn(TaskPeer::PRO_UID);
     $c->addJoin(TaskPeer::PRO_UID, ProcessPeer::PRO_UID, Criteria::LEFT_JOIN);
     $c->addJoin(TaskPeer::TAS_UID, TaskUserPeer::TAS_UID, Criteria::LEFT_JOIN);
     $c->add(ProcessPeer::PRO_STATUS, 'ACTIVE');
     $c->add(TaskPeer::TAS_START, 'TRUE');
     $c->add(TaskUserPeer::USR_UID, $aGroups, Criteria::IN);
     $rs = TaskPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $rs->next();
     $row = $rs->getRow();
     while (is_array($row)) {
         $tasks[] = $row['TAS_UID'];
         $rs->next();
         $row = $rs->getRow();
     }
     $c = new Criteria();
     $c->addSelectColumn(TaskPeer::TAS_UID);
     $c->addSelectColumn(TaskPeer::PRO_UID);
     $c->addAsColumn('TAS_TITLE', 'C1.CON_VALUE');
     $c->addAsColumn('PRO_TITLE', 'C2.CON_VALUE');
     $c->addAlias('C1', 'CONTENT');
     $c->addAlias('C2', 'CONTENT');
     if ($typeView == 'category') {
         $c->addAsColumn('PRO_CATEGORY', 'PCS.PRO_CATEGORY');
         $c->addAsColumn('CATEGORY_NAME', 'PCSCAT.CATEGORY_NAME');
         $c->addAlias('PCS', 'PROCESS');
         $c->addAlias('PCSCAT', 'PROCESS_CATEGORY');
         $aConditions = array();
         $aConditions[] = array(TaskPeer::PRO_UID, 'PCS.PRO_UID');
         $c->addJoinMC($aConditions, Criteria::LEFT_JOIN);
         $aConditions = array();
         $aConditions[] = array('PCS.PRO_CATEGORY', 'PCSCAT.CATEGORY_UID');
         $c->addJoinMC($aConditions, Criteria::LEFT_JOIN);
     }
     $aConditions = array();
     $aConditions[] = array(TaskPeer::TAS_UID, 'C1.CON_ID');
     $aConditions[] = array('C1.CON_CATEGORY', DBAdapter::getStringDelimiter() . 'TAS_TITLE' . DBAdapter::getStringDelimiter());
     $aConditions[] = array('C1.CON_LANG', DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter());
     $c->addJoinMC($aConditions, Criteria::LEFT_JOIN);
     $aConditions = array();
     $aConditions[] = array(TaskPeer::PRO_UID, 'C2.CON_ID');
     $aConditions[] = array('C2.CON_CATEGORY', DBAdapter::getStringDelimiter() . 'PRO_TITLE' . DBAdapter::getStringDelimiter());
     $aConditions[] = array('C2.CON_LANG', DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter());
     $c->addJoinMC($aConditions, Criteria::LEFT_JOIN);
     $c->add(TaskPeer::TAS_UID, $tasks, Criteria::IN);
     if ($typeView == 'category') {
         $c->addDescendingOrderByColumn('PRO_CATEGORY');
     } else {
         $c->addAscendingOrderByColumn('PRO_TITLE');
         $c->addAscendingOrderByColumn('TAS_TITLE');
     }
     $rs = TaskPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $rs->next();
     while ($row = $rs->getRow()) {
         if ($typeView == 'category') {
             $taskTitle = TaskPeer::retrieveByPK($row['TAS_UID']);
             $row['TAS_TITLE'] = $taskTitle->getTasTitle();
             $row['CATEGORY_NAME'] = $row['CATEGORY_NAME'] == '' ? G::LoadTranslation('ID_PROCESS_NOCATEGORY') : $row['CATEGORY_NAME'];
             $rows[] = array('uid' => $row['TAS_UID'], 'value' => $row['PRO_TITLE'] . ' (' . $row['TAS_TITLE'] . ')', 'pro_uid' => $row['PRO_UID'], 'cat' => $row['PRO_CATEGORY'], 'catname' => $row['CATEGORY_NAME']);
         } else {
             $rows[] = array('uid' => $row['TAS_UID'], 'value' => $row['PRO_TITLE'] . ' (' . $row['TAS_TITLE'] . ')', 'pro_uid' => $row['PRO_UID']);
         }
         $rs->next();
         $row = $rs->getRow();
     }
     return $rows;
 }
コード例 #4
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

        );

    }
コード例 #5
0
 if (!in_array($filters['sort'], $columnsList)) {
     $filters['sort'] = '';
 }
 $filters['dir'] = G::toUpper($filters['dir']);
 if (!($filters['dir'] == 'DESC' || $filters['dir'] == 'ASC')) {
     $filters['dir'] = 'DESC';
 }
 $result = $list->loadList($userUid, $filters, function (array $record) {
     try {
         if (isset($record["DEL_PREVIOUS_USR_UID"])) {
             if ($record["DEL_PREVIOUS_USR_UID"] == "") {
                 $appDelegation = AppDelegationPeer::retrieveByPK($record["APP_UID"], $record["DEL_INDEX"]);
                 if (!is_null($appDelegation)) {
                     $appDelegationPrevious = AppDelegationPeer::retrieveByPK($record["APP_UID"], $appDelegation->getDelPrevious());
                     if (!is_null($appDelegationPrevious)) {
                         $taskPrevious = TaskPeer::retrieveByPK($appDelegationPrevious->getTasUid());
                         if (!is_null($taskPrevious)) {
                             switch ($taskPrevious->getTasType()) {
                                 case "SCRIPT-TASK":
                                     $record["DEL_PREVIOUS_USR_UID"] = $taskPrevious->getTasType();
                                     break;
                             }
                         }
                     }
                 }
             }
             $record["PREVIOUS_USR_UID"] = $record["DEL_PREVIOUS_USR_UID"];
             $record["PREVIOUS_USR_USERNAME"] = $record["DEL_PREVIOUS_USR_USERNAME"];
             $record["PREVIOUS_USR_FIRSTNAME"] = $record["DEL_PREVIOUS_USR_FIRSTNAME"];
             $record["PREVIOUS_USR_LASTNAME"] = $record["DEL_PREVIOUS_USR_LASTNAME"];
         }
コード例 #6
0
 /**
  * Configuration functions
  *
  * @param string $UsrUid
  * @param string $ProUid
  * @param string $TasUid
  * @return void
  */
 public function prepareInformation($UsrUid = null, $ProUid = null, $TasUid = null)
 {
     // setup calendarDays according the task
     if (isset($TasUid)) {
         $task = TaskPeer::retrieveByPK($TasUid);
         if (!is_null($task)) {
             $this->calendarDays = $task->getTasTypeDay() == 2;
         }
     }
     //get an array with all holidays.
     $aoHolidays = HolidayPeer::doSelect(new Criteria());
     $holidays = array();
     foreach ($aoHolidays as $holiday) {
         $holidays[] = strtotime($holiday->getHldDate());
     }
     // by default the weekdays are from monday to friday
     $this->weekends = array(0, 6);
     $this->holidays = $holidays;
     return;
 }
コード例 #7
0
ファイル: Triggers.php プロジェクト: bqevin/processmaker
 public function verifyDependecies($TRI_UID)
 {
     require_once "classes/model/Event.php";
     require_once "classes/model/StepTrigger.php";
     $oResult = new stdClass();
     $oResult->dependencies = array();
     $oCriteria = new Criteria();
     $oCriteria->addSelectColumn(EventPeer::EVN_UID);
     $oCriteria->addSelectColumn(EventPeer::TRI_UID);
     $oCriteria->add(EventPeer::EVN_ACTION, '', Criteria::NOT_EQUAL);
     $oCriteria->add(EventPeer::TRI_UID, $TRI_UID);
     $oDataset = EventPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aRows = array();
     while ($oDataset->next()) {
         array_push($aRows, $oDataset->getRow());
     }
     $oResult->dependencies['Events'] = array();
     if (count($aRows) == 0) {
         $oResult->code = 0;
     } else {
         $oResult->code = 1;
         foreach ($aRows as $row) {
             $oTrigger = TriggersPeer::retrieveByPK($row['TRI_UID']);
             array_push($oResult->dependencies['Events'], array('UID' => $oTrigger->getTriUid(), 'DESCRIPTION' => $oTrigger->getTriTitle()));
         }
     }
     //for tasks dependencies
     $oCriteria = new Criteria();
     $oCriteria->addSelectColumn(StepTriggerPeer::TAS_UID);
     $oCriteria->addSelectColumn(StepTriggerPeer::TRI_UID);
     $oCriteria->add(StepTriggerPeer::TRI_UID, $TRI_UID);
     $oDataset = StepTriggerPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aRows = array();
     while ($oDataset->next()) {
         array_push($aRows, $oDataset->getRow());
     }
     $oResult->dependencies['Tasks'] = array();
     if ($oResult->code == 0 && count($aRows) == 0) {
         $oResult->code = 0;
     } elseif (count($aRows) > 0) {
         $oResult->code = 1;
         foreach ($aRows as $row) {
             $oTask = TaskPeer::retrieveByPK($row['TAS_UID']);
             array_push($oResult->dependencies['Tasks'], array('UID' => $oTask->getTasUid(), 'DESCRIPTION' => $oTask->getTasTitle()));
         }
     }
     //Tasks, assignment rules dependencies
     $criteria = new Criteria();
     $criteria->addSelectColumn(TaskPeer::TAS_UID);
     $criteria->add(TaskPeer::TAS_SELFSERVICE_TIMEOUT, 1);
     $criteria->add(TaskPeer::TAS_SELFSERVICE_TRIGGER_UID, $TRI_UID);
     $rsCriteria = TaskPeer::doSelectRS($criteria);
     $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $arrayRow = array();
     while ($rsCriteria->next()) {
         array_push($arrayRow, $rsCriteria->getRow());
     }
     $oResult->dependencies["Assignment rules"] = array();
     if ($oResult->code == 0 && count($arrayRow) == 0) {
         $oResult->code = 0;
     } else {
         if (count($arrayRow) > 0) {
             foreach ($arrayRow as $row) {
                 $task = TaskPeer::retrieveByPK($row["TAS_UID"]);
                 array_push($oResult->dependencies["Assignment rules"], array("UID" => $task->getTasUid(), "DESCRIPTION" => $task->getTasTitle()));
             }
             $oResult->code = 1;
         }
     }
     return $oResult;
 }
コード例 #8
0
 public function getTaskUserSelfService($tas_uid, $appFields)
 {
     $oTask = new \Tasks();
     $oGroup = new \Groups();
     $taskNextDel = \TaskPeer::retrieveByPK($tas_uid);
     $arrayTaskUser = array();
     if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") {
         // Self Service Value Based Assignment
         $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#");
         if (isset($appFields["APP_DATA"][$nextTaskGroupVariable])) {
             $dataGroupVariable = $appFields["APP_DATA"][$nextTaskGroupVariable];
             $dataGroupVariable = is_array($dataGroupVariable) ? $dataGroupVariable : trim($dataGroupVariable);
             if (!empty($dataGroupVariable) && is_array($dataGroupVariable)) {
                 $arrayTaskUser[] = $dataGroupVariable;
             } elseif (!empty($dataGroupVariable)) {
                 $arrayUsersOfGroup = $oGroup->getUsersOfGroup($dataGroupVariable);
                 foreach ($arrayUsersOfGroup as $arrayUser) {
                     $arrayTaskUser[] = $arrayUser["USR_UID"];
                 }
             }
         }
     } else {
         // Self Service
         $arrayGroupsOfTask = $oTask->getGroupsOfTask($tas_uid, 1);
         foreach ($arrayGroupsOfTask as $arrayGroup) {
             $arrayUsersOfGroup = $oGroup->getUsersOfGroup($arrayGroup["GRP_UID"]);
             foreach ($arrayUsersOfGroup as $arrayUser) {
                 $arrayTaskUser[] = $arrayUser["USR_UID"];
             }
         }
         $arrayUsersOfTask = $oTask->getUsersOfTask($tas_uid, 1);
         foreach ($arrayUsersOfTask as $arrayUser) {
             $arrayTaskUser[] = $arrayUser["USR_UID"];
         }
     }
     return $arrayTaskUser;
 }
コード例 #9
0
ファイル: AppDelegation.php プロジェクト: rrsc/processmaker
    public function calculateRiskDate($dueDate, $risk)

    {

        try {



            $data = array();

            if (isset( $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] ) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {

                $data['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];

                $data['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];

            } else {

                $task = TaskPeer::retrieveByPK( $this->getTasUid() );

                $data['TAS_DURATION'] = $task->getTasDuration();

                $data['TAS_TIMEUNIT'] = $task->getTasTimeUnit();

            }



            $riskTime = $data['TAS_DURATION'] - ($data['TAS_DURATION'] * $risk);



            //Calendar - Use the dates class to calculate dates

            $calendar = new calendar();



            $arrayCalendarData = array();



            if ($calendar->pmCalendarUid == "") {

                $calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());



                $arrayCalendarData = $calendar->getCalendarData();

            }



            //Risk date

            $riskDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), $riskTime, $data['TAS_TIMEUNIT'], $arrayCalendarData);



            return $riskDate;

        } catch (Exception $e) {

            throw $e;

        }

    }
コード例 #10
0
ファイル: ScriptTask.php プロジェクト: emildev35/processmaker
 /**
  * Execute Script
  *
  * @param string $activityUid          Unique id of Event
  * @param array  $arrayApplicationData Case data
  *
  * return array
  */
 public function execScriptByActivityUid($activityUid, array $arrayApplicationData)
 {
     try {
         $task = \TaskPeer::retrieveByPK($activityUid);
         if (!is_null($task) && $task->getTasType() == "SCRIPT-TASK") {
             $criteria = new \Criteria("workflow");
             $criteria->addSelectColumn(\ScriptTaskPeer::SCRTAS_OBJ_UID);
             $criteria->add(\ScriptTaskPeer::ACT_UID, $activityUid, \Criteria::EQUAL);
             $rsCriteria = \ScriptTaskPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             if ($rsCriteria->next()) {
                 $row = $rsCriteria->getRow();
                 $scriptTasObjUid = $row["SCRTAS_OBJ_UID"];
                 $trigger = \TriggersPeer::retrieveByPK($scriptTasObjUid);
                 if (!is_null($trigger)) {
                     $pmScript = new \PMScript();
                     $pmScript->setFields($arrayApplicationData["APP_DATA"]);
                     $pmScript->setScript($trigger->getTriWebbot());
                     $result = $pmScript->execute();
                     if (isset($pmScript->aFields["__ERROR__"])) {
                         \G::log("Case Uid: " . $arrayApplicationData["APP_UID"] . ", Error: " . $pmScript->aFields["__ERROR__"], PATH_DATA . "log/ScriptTask.log");
                     }
                     $arrayApplicationData["APP_DATA"] = $pmScript->aFields;
                     $case = new \Cases();
                     $result = $case->updateCase($arrayApplicationData["APP_UID"], $arrayApplicationData);
                 }
             }
         }
         //Return
         return $arrayApplicationData["APP_DATA"];
     } catch (\Exception $e) {
         throw $e;
     }
 }
コード例 #11
0
ファイル: Task.php プロジェクト: nshong/processmaker
 public function remove($TasUid)
 {
     $oConnection = Propel::getConnection(TaskPeer::DATABASE_NAME);
     try {
         $oTask = TaskPeer::retrieveByPK($TasUid);
         if (!is_null($oTask)) {
             $oConnection->begin();
             Content::removeContent('TAS_TITLE', '', $oTask->getTasUid());
             Content::removeContent('TAS_DESCRIPTION', '', $oTask->getTasUid());
             Content::removeContent('TAS_DEF_TITLE', '', $oTask->getTasUid());
             Content::removeContent('TAS_DEF_DESCRIPTION', '', $oTask->getTasUid());
             Content::removeContent('TAS_DEF_PROC_CODE', '', $oTask->getTasUid());
             Content::removeContent('TAS_DEF_MESSAGE', '', $oTask->getTasUid());
             Content::removeContent('TAS_DEF_SUBJECT_MESSAGE', '', $oTask->getTasUid());
             $iResult = $oTask->delete();
             $oConnection->commit();
             return $iResult;
         } else {
             throw new Exception("The row '" . $TasUid . "' in table TASK doesn't exist!");
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
コード例 #12
0
ファイル: BaseTaskUser.php プロジェクト: sgrove/cothinker
 public function getTask($con = null)
 {
     if ($this->aTask === null && $this->task_id !== null) {
         include_once 'lib/model/om/BaseTaskPeer.php';
         $this->aTask = TaskPeer::retrieveByPK($this->task_id, $con);
     }
     return $this->aTask;
 }
コード例 #13
0
 /**
  * Delete WebEntry
  *
  * @param string $webEntryUid     Unique id of WebEntry
  * @param string $webEntryTaskUid WebEntry, unique id of Task
  *
  * return void
  */
 public function deleteWebEntry($webEntryUid, $webEntryTaskUid)
 {
     try {
         if ($webEntryTaskUid != "") {
             $obj = \TaskPeer::retrieveByPK($webEntryTaskUid);
             if (!is_null($obj)) {
                 $task = new \Tasks();
                 $task->deleteTask($webEntryTaskUid);
             }
         }
         if ($webEntryUid != "") {
             $obj = \WebEntryPeer::retrieveByPK($webEntryUid);
             if (!is_null($obj)) {
                 $this->webEntry->delete($webEntryUid);
             }
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
コード例 #14
0
    /**

     * new Case begins a new case under the name of the logged-in user.

     *

     * @param string $processId

     * @param string $userId

     * @param string $taskId

     * @param string $variables

     * @param int $executeTriggers : Optional parameter. The execution all triggers of the task, according to your steps, 1 yes 0 no.

     * @return $result will return an object

     */

    public function newCase($processId, $userId, $taskId, $variables, $executeTriggers = 0)

    {

        //$executeTriggers, this parameter is not important, it may be the last parameter in the method



        $g = new G();



        try {

            $g->sessionVarSave();



            $_SESSION["PROCESS"] = $processId;

            $_SESSION["TASK"] = $taskId;

            $_SESSION["USER_LOGGED"] = $userId;



            $Fields = array ();



            if (is_array( $variables ) && count( $variables ) > 0) {

                $Fields = $variables;

            }



            $oProcesses = new Processes();

            $pro = $oProcesses->processExists( $processId );



            if (! $pro) {

                $result = new wsResponse( 11, G::loadTranslation( 'ID_INVALID_PROCESS' ) . " " . $processId );



                $g->sessionVarRestore();



                return $result;

            }



            $oCase = new Cases();

            $startingTasks = $oCase->getStartCases( $userId );

            array_shift( $startingTasks ); //remove the first row, the header row

            $founded = '';

            $tasksInThisProcess = 0;

            $validTaskId = $taskId;



            foreach ($startingTasks as $key => $val) {

                if ($val['pro_uid'] == $processId) {

                    $tasksInThisProcess ++;

                    $validTaskId = $val['uid'];

                }



                if ($val['uid'] == $taskId) {

                    $founded = $val['value'];

                }

            }



            if ($taskId == '') {

                if ($tasksInThisProcess == 1) {

                    $founded = $validTaskId;

                    $taskId = $validTaskId;

                }



                if ($tasksInThisProcess > 1) {

                    $result = new wsResponse( 13, G::loadTranslation( 'ID_MULTIPLE_STARTING_TASKS' ) );



                    $g->sessionVarRestore();



                    return $result;

                }

            }



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



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



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

                $result = new wsResponse( 14, G::loadTranslation( 'ID_TASK_INVALID_USER_NOT_ASSIGNED_TASK' ) );



                $g->sessionVarRestore();



                return $result;

            }



            //Start case

            $case = $oCase->startCase( $taskId, $userId );



            $_SESSION['APPLICATION'] = $case['APPLICATION'];

            $_SESSION['PROCESS'] = $case['PROCESS'];

            $_SESSION['TASK'] = $taskId;

            $_SESSION['INDEX'] = $case['INDEX'];

            $_SESSION['USER_LOGGED'] = $userId;

            $_SESSION['USR_USERNAME'] = (isset($case['USR_USERNAME'])) ? $case['USR_USERNAME'] : '';

            $_SESSION['STEP_POSITION'] = 0;



            $caseId = $case['APPLICATION'];

            $caseNr = $case['CASE_NUMBER'];



            $oldFields = $oCase->loadCase( $caseId );



            $oldFields['APP_DATA'] = array_merge( $oldFields['APP_DATA'], $Fields );



            $oldFields['DEL_INDEX'] = $case['INDEX'];

            $oldFields['TAS_UID'] = $taskId;

            $up_case = $oCase->updateCase( $caseId, $oldFields );



            //Execute all triggers of the task, according to your steps

            if ($executeTriggers == 1) {

                $task = new Tasks();

                $arrayStep = $task->getStepsOfTask($taskId);



                foreach ($arrayStep as $step) {

                    $arrayField = $oCase->loadCase($caseId);



                    $arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "BEFORE", $arrayField["APP_DATA"]);

                    $arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "AFTER", $arrayField["APP_DATA"]);



                    unset($arrayField['APP_STATUS']);

                    unset($arrayField['APP_PROC_STATUS']);

                    unset($arrayField['APP_PROC_CODE']);

                    unset($arrayField['APP_PIN']);

                    $arrayField = $oCase->updateCase($caseId, $arrayField);

                }

            }



            //Response

            $result = new wsResponse( 0, G::loadTranslation( 'ID_STARTED_SUCCESSFULLY' ) );

            $result->caseId = $caseId;

            $result->caseNumber = $caseNr;



            $g->sessionVarRestore();



            return $result;

        } catch (Exception $e) {

            $result = new wsResponse( 100, $e->getMessage() );



            $g->sessionVarRestore();



            return $result;

        }

    }
コード例 #15
0
ファイル: Workflow.php プロジェクト: emildev35/processmaker
 /**
  * @param string $tasUid
  * @param bool $value
  */
 public function setStartTask($tasUid, $value = true)
 {
     $value = $value ? "TRUE" : "FALSE";
     self::log("Setting Start Task with Uid: {$tasUid}: {$value}");
     $task = \TaskPeer::retrieveByPK($tasUid);
     $task->setTasStart($value);
     $task->save();
     self::log("Setting Start Task -> {$value}, Success!");
 }
コード例 #16
0
    function doDerivation ($currentDelegation, $nextDel, $appFields, $aSP = null)

    {

        $iAppThreadIndex = $appFields['DEL_THREAD'];

        $delType = 'NORMAL';



        if (is_numeric( $nextDel['DEL_PRIORITY'] )) {

            $nextDel['DEL_PRIORITY'] = (isset( $nextDel['DEL_PRIORITY'] ) ? ($nextDel['DEL_PRIORITY'] >= 1 && $nextDel['DEL_PRIORITY'] <= 5 ? $nextDel['DEL_PRIORITY'] : '3') : '3');

        } else {

            $nextDel['DEL_PRIORITY'] = 3;

        }

        switch ($nextDel['TAS_ASSIGN_TYPE']) {

            case 'CANCEL_MI':

            case 'STATIC_MI':

                // Create new delegation depending on the no of users in the group

                $iNewAppThreadIndex = $appFields['DEL_THREAD'];

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



                foreach ($nextDel['NEXT_TASK']['USER_ASSIGNED'] as $key => $aValue) {

                    //Incrementing the Del_thread First so that new delegation has new del_thread

                    $iNewAppThreadIndex += 1;

                    //Creating new delegation according to users in group

                    $iMIDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'], $currentDelegation['APP_UID'], $nextDel['TAS_UID'], (isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''), $currentDelegation['DEL_INDEX'], $nextDel['DEL_PRIORITY'], $delType, $iNewAppThreadIndex, $nextDel );



                    $iNewThreadIndex = $this->case->newAppThread( $currentDelegation['APP_UID'], $iMIDelIndex, $iAppThreadIndex );



                    //Setting the del Index for Updating the AppThread delIndex

                    if ($key == 0) {

                        $iNewDelIndex = $iMIDelIndex - 1;

                    }

                } //end foreach

                break;

            case 'BALANCED':

                $this->setTasLastAssigned( $nextDel['TAS_UID'], $nextDel['USR_UID'] );

                //No Break, need no execute the default ones....

            default:

                // Create new delegation

                $iNewDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'], $currentDelegation['APP_UID'], $nextDel['TAS_UID'], (isset( $nextDel['USR_UID'] ) ? $nextDel['USR_UID'] : ''), $currentDelegation['DEL_INDEX'], $nextDel['DEL_PRIORITY'], $delType, $iAppThreadIndex, $nextDel );

                break;

        }



        $iAppThreadIndex = $appFields['DEL_THREAD'];



        switch ($currentDelegation['ROU_TYPE']) {

            case 'PARALLEL':

            case 'PARALLEL-BY-EVALUATION':

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

                $iNewThreadIndex = $this->case->newAppThread( $currentDelegation['APP_UID'], $iNewDelIndex, $iAppThreadIndex );

                $this->case->updateAppDelegation( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex );

                break;

            default:

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

                break;

        } //en switch



        //if there are subprocess to create

        if (isset( $aSP )) {

            //Create the new case in the sub-process

            // set the initial date to null the time its created

            $aNewCase = $this->case->startCase( $aSP['TAS_UID'], $aSP['USR_UID'], true, $appFields);



            $taskNextDel = TaskPeer::retrieveByPK($aSP["TAS_UID"]); //Sub-Process



            //Copy case variables to sub-process case

            $aFields = unserialize( $aSP['SP_VARIABLES_OUT'] );

            $aNewFields = array ();

            $aOldFields = $this->case->loadCase( $aNewCase['APPLICATION'] );



            foreach ($aFields as $sOriginField => $sTargetField) {

                $sOriginField = trim($sOriginField, " @#%?$=");

                $sTargetField = trim($sTargetField, " @#%?$=");



                $aNewFields[$sTargetField] = isset( $appFields['APP_DATA'][$sOriginField] ) ? $appFields['APP_DATA'][$sOriginField] : '';

            }



            $aOldFields['APP_DATA'] = array_merge( $aOldFields['APP_DATA'], $aNewFields );

            $aOldFields['APP_STATUS'] = 'TO_DO';



            $this->case->updateCase( $aNewCase['APPLICATION'], $aOldFields );



            //Create a registry in SUB_APPLICATION table

            $aSubApplication = array ('APP_UID' => $aNewCase['APPLICATION'],'APP_PARENT' => $currentDelegation['APP_UID'],'DEL_INDEX_PARENT' => $iNewDelIndex,'DEL_THREAD_PARENT' => $iAppThreadIndex,'SA_STATUS' => 'ACTIVE','SA_VALUES_OUT' => serialize( $aNewFields ),'SA_INIT_DATE' => date( 'Y-m-d H:i:s' )

            );



            if ($aSP['SP_SYNCHRONOUS'] == 0) {

                $aSubApplication['SA_STATUS'] = 'FINISHED';

                $aSubApplication['SA_FINISH_DATE'] = $aSubApplication['SA_INIT_DATE'];

            }



            $oSubApplication = new SubApplication();

            $oSubApplication->create( $aSubApplication );

            //Update the AppDelegation to execute the update trigger

            $AppDelegation = AppDelegationPeer::retrieveByPK( $aNewCase['APPLICATION'], $aNewCase['INDEX'] );



            // note added by krlos pacha carlos[at]colosa[dot]com

            // the following line of code was commented because it is related to the 6878 bug

            //$AppDelegation->setDelInitDate("+1 second");



            $AppDelegation->save();



            //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE

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

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



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

                    $appAssignSelfServiceValue = new AppAssignSelfServiceValue();



                    $appAssignSelfServiceValue->create($aNewCase["APPLICATION"], $aNewCase["INDEX"], array("PRO_UID" => $aNewCase["PROCESS"], "TAS_UID" => $aSP["TAS_UID"], "GRP_UID" => trim($aOldFields["APP_DATA"][$nextTaskGroupVariable])));

                }

            }



            //If not is SYNCHRONOUS derivate one more time

            if ($aSP['SP_SYNCHRONOUS'] == 0) {

                $this->case->setDelInitDate( $currentDelegation['APP_UID'], $iNewDelIndex );

                $aDeriveTasks = $this->prepareInformation( array ('USER_UID' => -1,'APP_UID' => $currentDelegation['APP_UID'],'DEL_INDEX' => $iNewDelIndex

                ) );



                if (isset( $aDeriveTasks[1] )) {

                    if ($aDeriveTasks[1]['ROU_TYPE'] != 'SELECT') {

                        $nextDelegations2 = array ();

                        foreach ($aDeriveTasks as $aDeriveTask) {

                            $nextDelegations2[] = array ('TAS_UID' => $aDeriveTask['NEXT_TASK']['TAS_UID'],'USR_UID' => $aDeriveTask['NEXT_TASK']['USER_ASSIGNED']['USR_UID'],'TAS_ASSIGN_TYPE' => $aDeriveTask['NEXT_TASK']['TAS_ASSIGN_TYPE'],'TAS_DEF_PROC_CODE' => $aDeriveTask['NEXT_TASK']['TAS_DEF_PROC_CODE'],'DEL_PRIORITY' => 3,'TAS_PARENT' => $aDeriveTask['NEXT_TASK']['TAS_PARENT']

                            );

                        }

                        $currentDelegation2 = array ('APP_UID' => $currentDelegation['APP_UID'],'DEL_INDEX' => $iNewDelIndex,'APP_STATUS' => 'TO_DO','TAS_UID' => $currentDelegation['TAS_UID'],'ROU_TYPE' => $aDeriveTasks[1]['ROU_TYPE']

                        );

                        $this->derivate( $currentDelegation2, $nextDelegations2 );

                    }

                }

            }

        } //end switch

        return $iNewDelIndex;

    }
コード例 #17
0
 public function updateActivity($actUid, $data)
 {
     //Update Activity
     $activityBefore = \BpmnActivityPeer::retrieveByPK($actUid);
     parent::updateActivity($actUid, $data);
     $activityCurrent = \BpmnActivityPeer::retrieveByPK($actUid);
     //Update Task
     $taskData = array();
     if (array_key_exists("ACT_NAME", $data)) {
         $taskData["TAS_TITLE"] = $data["ACT_NAME"];
     }
     if (array_key_exists("ACT_NAME", $data)) {
         $taskData["TAS_POSX"] = $data["BOU_X"];
     }
     if (array_key_exists("ACT_NAME", $data)) {
         $taskData["TAS_POSY"] = $data["BOU_Y"];
     }
     if ($activityBefore->getActTaskType() != "SCRIPTTASK" && $activityCurrent->getActTaskType() == "SCRIPTTASK") {
         $taskData["TAS_TYPE"] = "SCRIPT-TASK";
         $taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
     }
     if ($activityBefore->getActTaskType() == "SCRIPTTASK" && $activityCurrent->getActTaskType() != "SCRIPTTASK") {
         $taskData["TAS_TYPE"] = "NORMAL";
         $taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
         $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask();
         $scriptTask->deleteWhere(array(\ScriptTaskPeer::PRJ_UID => $activityCurrent->getPrjUid(), \ScriptTaskPeer::ACT_UID => $activityCurrent->getActUid()));
     }
     if ($activityCurrent->getActLoopType() == "PARALLEL") {
         $task = \TaskPeer::retrieveByPK($actUid);
         if ($task->getTasAssignType() == "BALANCED" || $task->getTasAssignType() == "MANUAL" || $task->getTasAssignType() == "EVALUATE" || $task->getTasAssignType() == "REPORT_TO" || $task->getTasAssignType() == "SELF_SERVICE") {
             $taskData["TAS_ASSIGN_TYPE"] = "MULTIPLE_INSTANCE";
         }
     }
     if ($activityCurrent->getActLoopType() == "EMPTY") {
         $task = \TaskPeer::retrieveByPK($actUid);
         if ($task->getTasAssignType() == "MULTIPLE_INSTANCE_VALUE_BASED" || $task->getTasAssignType() == "MULTIPLE_INSTANCE") {
             $taskData["TAS_ASSIGN_TYPE"] = "BALANCED";
         }
     }
     $this->wp->updateTask($actUid, $taskData);
 }