Exemple #1
0
 /**
  * Get available Steps of a Task
  *
  * @param string $taskUid Unique id of Task
  *
  * return array Return an array with the Steps available of a Task
  */
 public function getAvailableSteps($taskUid)
 {
     try {
         $arrayAvailableStep = array();
         //Verify data
         $this->throwExceptionIfNotExistsTask("", $taskUid, $this->arrayParamException["taskUid"]);
         //Load Task
         $task = new \Task();
         $arrayTaskData = $task->load($taskUid);
         $processUid = $arrayTaskData["PRO_UID"];
         //Get data
         //Get Uids
         $arrayUid = array();
         $task = new \Tasks();
         $arrayStep = $task->getStepsOfTask($taskUid);
         foreach ($arrayStep as $step) {
             $arrayUid[] = $step["STEP_UID_OBJ"];
         }
         //Array DB
         $arraydbStep = array();
         $delimiter = \DBAdapter::getStringDelimiter();
         //DynaForms
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\DynaformPeer::DYN_UID);
         $criteria->addAsColumn("DYN_TITLE", "CT.CON_VALUE");
         $criteria->addAsColumn("DYN_DESCRIPTION", "CD.CON_VALUE");
         $criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
         $criteria->addAlias("CD", \ContentPeer::TABLE_NAME);
         $arrayCondition = array();
         $arrayCondition[] = array(\DynaformPeer::DYN_UID, "CT.CON_ID", \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "DYN_TITLE" . $delimiter, \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
         $arrayCondition = array();
         $arrayCondition[] = array(\DynaformPeer::DYN_UID, "CD.CON_ID", \Criteria::EQUAL);
         $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "DYN_DESCRIPTION" . $delimiter, \Criteria::EQUAL);
         $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
         $criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
         $criteria->add(\DynaformPeer::DYN_UID, $arrayUid, \Criteria::NOT_IN);
         $criteria->add(\DynaformPeer::DYN_TYPE, "xmlform", \Criteria::EQUAL);
         $rsCriteria = \DynaformPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             if ($row["DYN_TITLE"] . "" == "") {
                 //There is no transaltion for this Document name, try to get/regenerate the label
                 $row["DYN_TITLE"] = \Content::Load("DYN_TITLE", "", $row["DYN_UID"], SYS_LANG);
             }
             $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $row["DYN_UID"], $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $row["DYN_TITLE"], $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => $row["DYN_DESCRIPTION"], $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "DYNAFORM");
         }
         //InputDocuments
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID);
         $criteria->addAsColumn("INP_DOC_TITLE", "CT.CON_VALUE");
         $criteria->addAsColumn("INP_DOC_DESCRIPTION", "CD.CON_VALUE");
         $criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
         $criteria->addAlias("CD", \ContentPeer::TABLE_NAME);
         $arrayCondition = array();
         $arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CT.CON_ID", \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "INP_DOC_TITLE" . $delimiter, \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
         $arrayCondition = array();
         $arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CD.CON_ID", \Criteria::EQUAL);
         $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "INP_DOC_DESCRIPTION" . $delimiter, \Criteria::EQUAL);
         $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
         $criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
         $criteria->add(\InputDocumentPeer::INP_DOC_UID, $arrayUid, \Criteria::NOT_IN);
         $rsCriteria = \InputDocumentPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             if ($row["INP_DOC_TITLE"] . "" == "") {
                 //There is no transaltion for this Document name, try to get/regenerate the label
                 $row["INP_DOC_TITLE"] = \Content::Load("INP_DOC_TITLE", "", $row["INP_DOC_UID"], SYS_LANG);
             }
             $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $row["INP_DOC_UID"], $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $row["INP_DOC_TITLE"], $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => $row["INP_DOC_DESCRIPTION"], $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "INPUT_DOCUMENT");
         }
         //OutputDocuments
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
         $criteria->addAsColumn("OUT_DOC_TITLE", "CT.CON_VALUE");
         $criteria->addAsColumn("OUT_DOC_DESCRIPTION", "CD.CON_VALUE");
         $criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
         $criteria->addAlias("CD", \ContentPeer::TABLE_NAME);
         $arrayCondition = array();
         $arrayCondition[] = array(\OutputDocumentPeer::OUT_DOC_UID, "CT.CON_ID", \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "OUT_DOC_TITLE" . $delimiter, \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
         $arrayCondition = array();
         $arrayCondition[] = array(\OutputDocumentPeer::OUT_DOC_UID, "CD.CON_ID", \Criteria::EQUAL);
         $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "OUT_DOC_DESCRIPTION" . $delimiter, \Criteria::EQUAL);
         $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
         $criteria->add(\OutputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
         $criteria->add(\OutputDocumentPeer::OUT_DOC_UID, $arrayUid, \Criteria::NOT_IN);
         $rsCriteria = \OutputDocumentPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             if ($row["OUT_DOC_TITLE"] . "" == "") {
                 //There is no transaltion for this Document name, try to get/regenerate the label
                 $row["OUT_DOC_TITLE"] = \Content::Load("OUT_DOC_TITLE", "", $row["OUT_DOC_UID"], SYS_LANG);
             }
             $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $row["OUT_DOC_UID"], $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $row["OUT_DOC_TITLE"], $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => $row["OUT_DOC_DESCRIPTION"], $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "OUTPUT_DOCUMENT");
         }
         //Call plugin
         $pluginRegistry =& \PMPluginRegistry::getSingleton();
         $externalSteps = $pluginRegistry->getSteps();
         if (is_array($externalSteps) && count($externalSteps) > 0) {
             foreach ($externalSteps as $key => $value) {
                 $arraydbStep[] = array($this->getFieldNameByFormatFieldName("OBJ_UID") => $value->sStepId, $this->getFieldNameByFormatFieldName("OBJ_TITLE") => $value->sStepTitle, $this->getFieldNameByFormatFieldName("OBJ_DESCRIPTION") => "", $this->getFieldNameByFormatFieldName("OBJ_TYPE") => "EXTERNAL");
             }
         }
         if (!empty($arraydbStep)) {
             $arraydbStep = Util\ArrayUtil::sort($arraydbStep, array($this->getFieldNameByFormatFieldName("OBJ_TYPE"), $this->getFieldNameByFormatFieldName("OBJ_TITLE")), SORT_ASC);
         }
         return $arraydbStep;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Exemple #2
0
    /**
     * lista de usuarios a reasignar
     */
    public function getUsersToReassign($usr_uid, $task_uid)
    {
        //G::LoadClass( 'tasks' );
        G::LoadSystem( 'rbac' );
        G::LoadClass( 'memcached' );
        $memcache = \PMmemcached::getSingleton( SYS_SYS );
        $RBAC = \RBAC::getSingleton( PATH_DATA, session_id() );
        $RBAC->sSystem = 'PROCESSMAKER';
        $RBAC->initRBAC();
        $memKey = 'rbacSession' . session_id();
        if (($RBAC->aUserInfo = $memcache->get( $memKey )) === false) {
            $RBAC->loadUserRolePermission( $RBAC->sSystem, $usr_uid );
            $memcache->set( $memKey, $RBAC->aUserInfo, \PMmemcached::EIGHT_HOURS );
        }
        $GLOBALS['RBAC'] = $RBAC;

        $task = new \Task();
        $tasks = $task->load($task_uid);
        $case = new \Cases();
        $result = new \stdclass();
        $result->data = $case->getUsersToReassign($task_uid, $usr_uid, $tasks['PRO_UID']);
        return $result;
    }
 /**
  * Get list for Process Permissions
  *
  * @var string $pro_uid. Uid for Process
  * @var string $op_uid. Uid for Process Permission
  *
  * @access public
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @return array
  */
 public function getProcessPermissions($pro_uid, $op_uid = '')
 {
     $pro_uid = $this->validateProUid($pro_uid);
     if ($op_uid != '') {
         $op_uid = $this->validateOpUid($op_uid);
     }
     G::LoadClass('case');
     Cases::verifyTable();
     $aObjectsPermissions = array();
     $oCriteria = new \Criteria('workflow');
     $oCriteria->add(ObjectPermissionPeer::PRO_UID, $pro_uid);
     if ($op_uid != '') {
         $oCriteria->add(ObjectPermissionPeer::OP_UID, $op_uid);
     }
     $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         //Obtain task target
         if ($aRow['TAS_UID'] != '' && $aRow['TAS_UID'] != '0') {
             try {
                 $oTask = new \Task();
                 $aFields = $oTask->load($aRow['TAS_UID']);
                 $sTaskTarget = $aFields['TAS_TITLE'];
             } catch (\Exception $oError) {
                 $sTaskTarget = 'All Tasks';
             }
         } else {
             $sTaskTarget = G::LoadTranslation('ID_ANY_TASK');
         }
         //Obtain user or group
         if ($aRow['OP_USER_RELATION'] == 1) {
             $oUser = new \Users();
             $aFields = $oUser->load($aRow['USR_UID']);
             $sUserGroup = $aFields['USR_FIRSTNAME'] . ' ' . $aFields['USR_LASTNAME'] . ' (' . $aFields['USR_USERNAME'] . ')';
         } else {
             $oGroup = new \Groupwf();
             if ($aRow['USR_UID'] != '') {
                 try {
                     $aFields = $oGroup->load($aRow['USR_UID']);
                     $sUserGroup = $aFields['GRP_TITLE'];
                 } catch (\Exception $oError) {
                     $sUserGroup = '(GROUP DELETED)';
                 }
             } else {
                 $sUserGroup = G::LoadTranslation('ID_ANY');
             }
         }
         //Obtain task source
         if ($aRow['OP_TASK_SOURCE'] != '' && $aRow['OP_TASK_SOURCE'] != '0') {
             try {
                 $oTask = new \Task();
                 $aFields = $oTask->load($aRow['OP_TASK_SOURCE']);
                 $sTaskSource = $aFields['TAS_TITLE'];
             } catch (\Exception $oError) {
                 $sTaskSource = 'All Tasks';
             }
         } else {
             $sTaskSource = G::LoadTranslation('ID_ANY_TASK');
         }
         //Obtain object and type
         switch ($aRow['OP_OBJ_TYPE']) {
             case 'ALL':
                 $sObjectType = G::LoadTranslation('ID_ALL');
                 $sObject = G::LoadTranslation('ID_ALL');
                 break;
             case 'ANY':
                 //For backward compatibility (some process with ANY instead of ALL
                 $sObjectType = G::LoadTranslation('ID_ALL');
                 $sObject = G::LoadTranslation('ID_ALL');
                 break;
                 /* case 'ANY_DYNAFORM':
                    $sObjectType = G::LoadTranslation('ID_ANY_DYNAFORM');
                    $sObject     = G::LoadTranslation('ID_ALL');
                    break;
                    case 'ANY_INPUT':
                    $sObjectType = G::LoadTranslation('ID_ANY_INPUT');
                    $sObject     = G::LoadTranslation('ID_ALL');
                    break;
                    case 'ANY_OUTPUT':
                    $sObjectType = G::LoadTranslation('ID_ANY_OUTPUT');
                    $sObject     = G::LoadTranslation('ID_ALL');
                    break; */
             /* case 'ANY_DYNAFORM':
                $sObjectType = G::LoadTranslation('ID_ANY_DYNAFORM');
                $sObject     = G::LoadTranslation('ID_ALL');
                break;
                case 'ANY_INPUT':
                $sObjectType = G::LoadTranslation('ID_ANY_INPUT');
                $sObject     = G::LoadTranslation('ID_ALL');
                break;
                case 'ANY_OUTPUT':
                $sObjectType = G::LoadTranslation('ID_ANY_OUTPUT');
                $sObject     = G::LoadTranslation('ID_ALL');
                break; */
             case 'DYNAFORM':
                 $sObjectType = G::LoadTranslation('ID_DYNAFORM');
                 if ($aRow['OP_OBJ_UID'] != '' && $aRow['OP_OBJ_UID'] != '0') {
                     $oDynaform = new \Dynaform();
                     $aFields = $oDynaform->load($aRow['OP_OBJ_UID']);
                     $sObject = $aFields['DYN_TITLE'];
                 } else {
                     $sObject = G::LoadTranslation('ID_ALL');
                 }
                 break;
             case 'INPUT':
                 $sObjectType = G::LoadTranslation('ID_INPUT_DOCUMENT');
                 if ($aRow['OP_OBJ_UID'] != '' && $aRow['OP_OBJ_UID'] != '0') {
                     $oInputDocument = new \InputDocument();
                     $aFields = $oInputDocument->load($aRow['OP_OBJ_UID']);
                     $sObject = $aFields['INP_DOC_TITLE'];
                 } else {
                     $sObject = G::LoadTranslation('ID_ALL');
                 }
                 break;
             case 'OUTPUT':
                 $sObjectType = G::LoadTranslation('ID_OUTPUT_DOCUMENT');
                 if ($aRow['OP_OBJ_UID'] != '' && $aRow['OP_OBJ_UID'] != '0') {
                     $oOutputDocument = new \OutputDocument();
                     $aFields = $oOutputDocument->load($aRow['OP_OBJ_UID']);
                     $sObject = $aFields['OUT_DOC_TITLE'];
                 } else {
                     $sObject = G::LoadTranslation('ID_ALL');
                 }
                 break;
             case 'CASES_NOTES':
                 $sObjectType = G::LoadTranslation('ID_CASES_NOTES');
                 $sObject = 'N/A';
                 break;
             case 'MSGS_HISTORY':
                 $sObjectType = G::LoadTranslation('MSGS_HISTORY');
                 $sObject = G::LoadTranslation('ID_ALL');
                 break;
             default:
                 $sObjectType = G::LoadTranslation('ID_ALL');
                 $sObject = G::LoadTranslation('ID_ALL');
                 break;
         }
         //Participated
         if ($aRow['OP_PARTICIPATE'] == 0) {
             $sParticipated = G::LoadTranslation('ID_NO');
         } else {
             $sParticipated = G::LoadTranslation('ID_YES');
         }
         //Obtain action (permission)
         $sAction = G::LoadTranslation('ID_' . $aRow['OP_ACTION']);
         //Add to array
         $arrayTemp = array();
         $arrayTemp = array_merge($aRow, array('OP_UID' => $aRow['OP_UID'], 'TASK_TARGET' => $sTaskTarget, 'GROUP_USER' => $sUserGroup, 'TASK_SOURCE' => $sTaskSource, 'OBJECT_TYPE' => $sObjectType, 'OBJECT' => $sObject, 'PARTICIPATED' => $sParticipated, 'ACTION' => $sAction, 'OP_CASE_STATUS' => $aRow['OP_CASE_STATUS']));
         $aObjectsPermissions[] = array_change_key_case($arrayTemp, CASE_LOWER);
         $oDataset->next();
     }
     if ($op_uid != '' && empty($aObjectsPermissions)) {
         throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST"));
     } elseif ($op_uid != '' && !empty($aObjectsPermissions)) {
         $aObjectsPermissions = array_change_key_case($aObjectsPermissions, CASE_LOWER);
         return current($aObjectsPermissions);
     }
     $aObjectsPermissions = array_change_key_case($aObjectsPermissions, CASE_LOWER);
     return $aObjectsPermissions;
 }
Exemple #4
0
    public function getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID)
    {
        \G::LoadClass("configuration");
        $conf = new \Configurations();
        $confEnvSetting = $conf->getFormats();
        //verifica si la tabla OBJECT_PERMISSION
        $cases = new \cases();
        $cases->verifyTable();
        $listing = false;
        $oPluginRegistry = & \PMPluginRegistry::getSingleton();
        if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) {
            $folderData = new \folderData(null, null, $sApplicationUID, null, $sUserUID);
            $folderData->PMType = "OUTPUT";
            $folderData->returnList = true;
            //$oPluginRegistry = & PMPluginRegistry::getSingleton();
            $listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
        }
        $aObjectPermissions = $cases->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID);
        if (!is_array($aObjectPermissions)) {
            $aObjectPermissions = array('DYNAFORMS' => array(-1),'INPUT_DOCUMENTS' => array(-1),'OUTPUT_DOCUMENTS' => array(-1));
        }
        if (!isset($aObjectPermissions['DYNAFORMS'])) {
            $aObjectPermissions['DYNAFORMS'] = array(-1);
        } else {
            if (!is_array($aObjectPermissions['DYNAFORMS'])) {
                $aObjectPermissions['DYNAFORMS'] = array(-1);
            }
        }
        if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) {
            $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
        } else {
            if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) {
                $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
            }
        }
        if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
            $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
        } else {
            if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
                $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
            }
        }
        $aDelete = $cases->getAllObjectsFrom($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID, 'DELETE');
        $oAppDocument = new \AppDocument();
        $oCriteria = new \Criteria('workflow');
        $oCriteria->add(\AppDocumentPeer::APP_UID, $sApplicationUID);
        $oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
        $oCriteria->add(\AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), \Criteria::IN);
        //$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['OUTPUT_DOCUMENTS'], Criteria::IN);
        $oCriteria->add(
            $oCriteria->getNewCriterion(
                \AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['OUTPUT_DOCUMENTS'], \Criteria::IN)->addOr($oCriteria->getNewCriterion(\AppDocumentPeer::USR_UID, $sUserUID, \Criteria::EQUAL))
        );
        $aConditions = array();
        $aConditions[] = array(\AppDocumentPeer::APP_UID, \AppDelegationPeer::APP_UID);
        $aConditions[] = array(\AppDocumentPeer::DEL_INDEX, \AppDelegationPeer::DEL_INDEX);
        $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
        $oCriteria->add(\AppDelegationPeer::PRO_UID, $sProcessUID);
        $oCriteria->addAscendingOrderByColumn(\AppDocumentPeer::APP_DOC_INDEX);
        $oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
        $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
        $oDataset->next();
        $aOutputDocuments = array();
        $aOutputDocuments[] = array(
            'APP_DOC_UID' => 'char',
            'DOC_UID' => 'char',
            'APP_DOC_COMMENT' => 'char',
            'APP_DOC_FILENAME' => 'char',
            'APP_DOC_INDEX' => 'integer'
        );
        $oUser = new \Users();
        while ($aRow = $oDataset->getRow()) {
            $oCriteria2 = new \Criteria('workflow');
            $oCriteria2->add(\AppDelegationPeer::APP_UID, $sApplicationUID);
            $oCriteria2->add(\AppDelegationPeer::DEL_INDEX, $aRow['DEL_INDEX']);
            $oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria2);
            $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
            $oDataset2->next();
            $aRow2 = $oDataset2->getRow();
            $oTask = new \Task();
            if ($oTask->taskExists($aRow2['TAS_UID'])) {
                $aTask = $oTask->load($aRow2['TAS_UID']);
            } else {
                $aTask = array('TAS_TITLE' => '(TASK DELETED)');
            }
            $lastVersion = $oAppDocument->getLastDocVersion($aRow['DOC_UID'], $sApplicationUID);
            if ($lastVersion == $aRow['DOC_VERSION']) {
                //Only show last document Version
                $aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']);
                //Get output Document information
                $oOutputDocument = new \OutputDocument();
                $aGields = $oOutputDocument->load($aRow['DOC_UID']);
                //OUTPUTDOCUMENT
                $outDocTitle = $aGields['OUT_DOC_TITLE'];
                switch ($aGields['OUT_DOC_GENERATE']) {
                    //G::LoadTranslation(ID_DOWNLOAD)
                    case "PDF":
                        $fileDoc = 'javascript:alert("NO DOC")';
                        $fileDocLabel = " ";
                        $filePdf = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand();
                        $filePdfLabel = ".pdf";
                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "PDF")) {
                                    $filePdfLabel = \G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .pdf";
                                    $filePdf = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        break;
                    case "DOC":
                        $fileDoc = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand();
                        $fileDocLabel = ".doc";
                        $filePdf = 'javascript:alert("NO PDF")';
                        $filePdfLabel = " ";
                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "DOC")) {
                                    $fileDocLabel = \G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .doc";
                                    $fileDoc = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        break;
                    case "BOTH":
                        $fileDoc = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand();
                        $fileDocLabel = ".doc";
                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "DOC")) {
                                    $fileDocLabel = G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .doc";
                                    $fileDoc = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        $filePdf = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand();
                        $filePdfLabel = ".pdf";

                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "PDF")) {
                                    $filePdfLabel = \G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .pdf";
                                    $filePdf = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        break;
                }
                try {
                    $aAux1 = $oUser->load($aAux['USR_UID']);
                    $sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
                } catch (\Exception $oException) {
                    $sUser = '******';
                }
                //if both documents were generated, we choose the pdf one, only if doc was
                //generate then choose the doc file.
                $firstDocLink = $filePdf;
                $firstDocLabel = $filePdfLabel;
                if ($aGields['OUT_DOC_GENERATE'] == 'DOC') {
                    $firstDocLink = $fileDoc;
                    $firstDocLabel = $fileDocLabel;
                }
                $aFields = array(
                    'APP_DOC_UID' => $aAux['APP_DOC_UID'],
                    'DOC_UID' => $aAux['DOC_UID'],
                    'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'],
                    'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'],
                    'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'],
                    'ORIGIN' => $aTask['TAS_TITLE'],
                    'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'],
                    'CREATED_BY' => $sUser,
                    'FILEDOC' => $fileDoc,
                    'FILEPDF' => $filePdf,
                    'OUTDOCTITLE' => $outDocTitle,
                    'DOC_VERSION' => $aAux['DOC_VERSION'],
                    'TYPE' => $aAux['APP_DOC_TYPE'] . ' ' . $aGields['OUT_DOC_GENERATE'],
                    'DOWNLOAD_LINK' => $firstDocLink,
                    'DOWNLOAD_FILE' => $aAux['APP_DOC_FILENAME'] . $firstDocLabel
                );
                if (trim($fileDocLabel) != '') {
                    $aFields['FILEDOCLABEL'] = $fileDocLabel;
                }
                if (trim($filePdfLabel) != '') {
                    $aFields['FILEPDFLABEL'] = $filePdfLabel;
                }
                if ($aFields['APP_DOC_FILENAME'] != '') {
                    $aFields['TITLE'] = $aFields['APP_DOC_FILENAME'];
                } else {
                    $aFields['TITLE'] = $aFields['APP_DOC_COMMENT'];
                }
                //$aFields['POSITION'] = $_SESSION['STEP_POSITION'];
                $aFields['CONFIRM'] = \G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT');
                if (in_array($aRow['APP_DOC_UID'], $aObjectPermissions['OUTPUT_DOCUMENTS'])) {
                    if (in_array($aRow['APP_DOC_UID'], $aDelete['OUTPUT_DOCUMENTS'])) {
                        $aFields['ID_DELETE'] = \G::LoadTranslation('ID_DELETE');
                    }
                }
                $aOutputDocuments[] = $aFields;
            }
            $oDataset->next();
        }
        global $_DBArray;
        $_DBArray['outputDocuments'] = $aOutputDocuments;
        \G::LoadClass('ArrayPeer');
        $oCriteria = new \Criteria('dbarray');
        $oCriteria->setDBArrayTable('outputDocuments');
        $oCriteria->addDescendingOrderByColumn('CREATE_DATE');
        return $oCriteria;
    }
Exemple #5
0
    /**
     * Load data of the Process
     *
     * @param string $processUid
     *
     * return array  Return data array with data of the Process (attributes of the process, tasks and routes)
     *
     * @access public
     */
    public function loadProcess($processUid)
    {
        $arrayDefineProcessData = array();

        //Process
        $process = new \Process();

        $arrayProcessData = $process->load($processUid);

        $arrayDefineProcessData["process"] = array(
            "PRO_UID"   => $processUid,
            "PRO_TITLE" => $arrayProcessData["PRO_TITLE"],
            "PRO_DESCRIPTION" => $arrayProcessData["PRO_DESCRIPTION"],
            "PRO_CATEGORY"    => $arrayProcessData["PRO_CATEGORY"]
        );

        //Load data
        $processMap = new \processMap();

        $arrayData = (array)(\Bootstrap::json_decode($processMap->load($processUid)));

        //Tasks & Routes
        $arrayDefineProcessData["process"]["tasks"]  = array();
        $arrayDefineProcessData["process"]["routes"] = array();

        if (isset($arrayData["task"]) && count($arrayData["task"]) > 0) {
            foreach ($arrayData["task"] as $indext => $valuet) {
                $t = (array)($valuet);

                $taskUid = $t["uid"];

                //Load task data
                $task = new \Task();

                $arrayTaskData = $task->load($taskUid);

                //Set task
                $arrayDefineProcessData["process"]["tasks"][] = array(
                    "TAS_UID"   => $taskUid,
                    "TAS_TITLE" => $arrayTaskData["TAS_TITLE"],
                    "TAS_DESCRIPTION" => $arrayTaskData["TAS_DESCRIPTION"],
                    "TAS_POSX"  => $arrayTaskData["TAS_POSX"],
                    "TAS_POSY"  => $arrayTaskData["TAS_POSY"],
                    "TAS_START" => $arrayTaskData["TAS_START"]
                );

                //Routes
                if (isset($t["derivation"])) {
                    $t["derivation"] = (array)($t["derivation"]);

                    $type = "";

                    switch ($t["derivation"]["type"]) {
                        case 0:
                            $type = "SEQUENTIAL";
                            break;
                        case 1:
                            $type = "SELECT";
                            break;
                        case 2:
                            $type = "EVALUATE";
                            break;
                        case 3:
                            $type = "PARALLEL";
                            break;
                        case 4:
                            $type = "PARALLEL-BY-EVALUATION";
                            break;
                        case 5:
                            $type = "SEC-JOIN";
                            break;
                        case 8:
                            $type = "DISCRIMINATOR";
                            break;
                    }

                    foreach ($t["derivation"]["to"] as $indexr => $valuer) {
                        $r = (array)($valuer);

                        //Criteria
                        $criteria = new \Criteria("workflow");

                        $criteria->addSelectColumn(\RoutePeer::ROU_UID);
                        $criteria->add(\RoutePeer::PRO_UID, $processUid, \Criteria::EQUAL);
                        $criteria->add(\RoutePeer::TAS_UID, $taskUid, \Criteria::EQUAL);
                        $criteria->add(\RoutePeer::ROU_NEXT_TASK, $r["task"], \Criteria::EQUAL);

                        $rsCriteria = \RoutePeer::doSelectRS($criteria);
                        $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

                        $rsCriteria->next();

                        $row = $rsCriteria->getRow();

                        $routeUid = $row["ROU_UID"];

                        //Set route
                        $arrayDefineProcessData["process"]["routes"][] = array(
                            "ROU_UID" => $routeUid,
                            "TAS_UID" => $taskUid,
                            "ROU_NEXT_TASK" => $r["task"],
                            "ROU_TYPE" => $type
                        );
                    }
                }
            }
        }

        return $arrayDefineProcessData;
    }