Esempio n. 1
0
 /**
  * @return Application
  */
 public function getLastApplication()
 {
     $c = new Criteria();
     $c->add(ApplicationPeer::PROCESSED_DATE, null, Criteria::ISNOTNULL);
     $c->add(ApplicationPeer::MEMBER_ID, $this->getId());
     $c->addDescendingOrderByColumn(ApplicationPeer::DATE);
     return ApplicationPeer::doSelectOne($c);
 }
Esempio n. 2
0
    /**
     * Get status info Case
     *
     * @param string $applicationUid Unique id of Case
     * @param int    $del_index      {@min 1}
     * @param string $userUid        Unique id of User
     *
     * return array Return an array with status info Case, array empty otherwise
     */
    public function getStatusInfo($applicationUid, $delIndex = 0, $userUid = "")
    {
        try {
            //Verify data
            $this->throwExceptionIfNotExistsCase($applicationUid, $delIndex, $this->getFieldNameByFormatFieldName("APP_UID"));

            //Get data
            //Status is PAUSED
            $delimiter = \DBAdapter::getStringDelimiter();

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

            $criteria->addSelectColumn($delimiter . "PAUSED" . $delimiter . " AS APP_STATUS");
            $criteria->addSelectColumn(\AppDelayPeer::APP_DEL_INDEX . " AS DEL_INDEX");

            $criteria->add(\AppDelayPeer::APP_UID, $applicationUid, \Criteria::EQUAL);
            $criteria->add(\AppDelayPeer::APP_TYPE, "PAUSE", \Criteria::EQUAL);
            $criteria->add(
                $criteria->getNewCriterion(\AppDelayPeer::APP_DISABLE_ACTION_USER, null, \Criteria::ISNULL)->addOr(
                $criteria->getNewCriterion(\AppDelayPeer::APP_DISABLE_ACTION_USER, 0, \Criteria::EQUAL))
            );

            if ($delIndex != 0) {
                $criteria->add(\AppDelayPeer::APP_DEL_INDEX, $delIndex, \Criteria::EQUAL);
            }

            if ($userUid != "") {
                $criteria->add(\AppDelayPeer::APP_DELEGATION_USER, $userUid, \Criteria::EQUAL);
            }

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

            if ($rsCriteria->next()) {
                $row = $rsCriteria->getRow();

                //Return
                return array("APP_STATUS" => $row["APP_STATUS"], "DEL_INDEX" => $row["DEL_INDEX"]);
            }

            //Status is TO_DO, DRAFT
            $criteria = new \Criteria("workflow");

            $criteria->addSelectColumn(\ApplicationPeer::APP_STATUS);
            $criteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);

            $arrayCondition = array();
            $arrayCondition[] = array(\ApplicationPeer::APP_UID, \AppDelegationPeer::APP_UID, \Criteria::EQUAL);
            $arrayCondition[] = array(\ApplicationPeer::APP_UID, \AppThreadPeer::APP_UID, \Criteria::EQUAL);
            $arrayCondition[] = array(\ApplicationPeer::APP_UID, $delimiter . $applicationUid . $delimiter, \Criteria::EQUAL);
            $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);

            $criteria->add(
                $criteria->getNewCriterion(\ApplicationPeer::APP_STATUS, "TO_DO", \Criteria::EQUAL)->addAnd(
                $criteria->getNewCriterion(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL))->addAnd(
                $criteria->getNewCriterion(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))->addAnd(
                $criteria->getNewCriterion(\AppThreadPeer::APP_THREAD_STATUS, "OPEN"))
            )->addOr(
                $criteria->getNewCriterion(\ApplicationPeer::APP_STATUS, "DRAFT", \Criteria::EQUAL)->addAnd(
                $criteria->getNewCriterion(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))->addAnd(
                $criteria->getNewCriterion(\AppThreadPeer::APP_THREAD_STATUS, "OPEN"))
            );

            if ($delIndex != 0) {
                $criteria->add(\AppDelegationPeer::DEL_INDEX, $delIndex, \Criteria::EQUAL);
            }

            if ($userUid != "") {
                $criteria->add(\AppDelegationPeer::USR_UID, $userUid, \Criteria::EQUAL);
            }

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

            if ($rsCriteria->next()) {
                $row = $rsCriteria->getRow();

                //Return
                return array("APP_STATUS" => $row["APP_STATUS"], "DEL_INDEX" => $row["DEL_INDEX"]);
            }

            //Status is CANCELLED, COMPLETED
            $criteria = new \Criteria("workflow");

            $criteria->addSelectColumn(\ApplicationPeer::APP_STATUS);
            $criteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);

            $arrayCondition = array();
            $arrayCondition[] = array(\ApplicationPeer::APP_UID, \AppDelegationPeer::APP_UID, \Criteria::EQUAL);
            $arrayCondition[] = array(\ApplicationPeer::APP_UID, $delimiter . $applicationUid . $delimiter, \Criteria::EQUAL);
            $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);

            $criteria->add(\ApplicationPeer::APP_STATUS, array("CANCELLED", "COMPLETED"), \Criteria::IN);
            $criteria->add(\AppDelegationPeer::DEL_LAST_INDEX, 1, \Criteria::EQUAL);

            if ($delIndex != 0) {
                $criteria->add(\AppDelegationPeer::DEL_INDEX, $delIndex, \Criteria::EQUAL);
            }

            if ($userUid != "") {
                $criteria->add(\AppDelegationPeer::USR_UID, $userUid, \Criteria::EQUAL);
            }

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

            if ($rsCriteria->next()) {
                $row = $rsCriteria->getRow();

                //Return
                return array("APP_STATUS" => $row["APP_STATUS"], "DEL_INDEX" => $row["DEL_INDEX"]);
            }

            //Return
            return array();
        } catch (\Exception $e) {
            throw $e;
        }
    }
Esempio n. 3
0
#end trigger debug session.......
//$oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List');
//Save data - Start
$oCase->updateCase($_SESSION['APPLICATION'], $Fields);
//Save data - End
//Obtain previous and next step - Start
try {
    $oCase = new Cases();
    $aNextStep = $oCase->getNextStep($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION']);
    $aPreviousStep = $oCase->getPreviousStep($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION']);
} catch (Exception $e) {
}
//Obtain previous and next step - End
try {
    //Add content content step - Start
    $oApp = ApplicationPeer::retrieveByPK($_SESSION['APPLICATION']);
    $array['APP_NUMBER'] = $APP_NUMBER;
    $sTitleCase = $oApp->getAppTitle();
    $array['APP_TITLE'] = $sTitleCase;
    $array['CASE'] = G::LoadTranslation('ID_CASE');
    $array['TITLE'] = G::LoadTranslation('ID_TITLE');
    $noShowTitle = 0;
    if (isset($oProcessFieds['PRO_SHOW_MESSAGE'])) {
        $noShowTitle = $oProcessFieds['PRO_SHOW_MESSAGE'];
    }
    switch ($_GET['TYPE']) {
        case 'DYNAFORM':
            if ($noShowTitle == 0) {
                $G_PUBLISH->AddContent('smarty', 'cases/cases_title', '', '', $array);
            }
            if (!$aPreviousStep) {
Esempio n. 4
0
    public function newRow ($data, $delPreviusUsrUid, $isInitSubprocess = false, $dataPreviusApplication = array(), $isSelfService = false)
    {
        $removeList = true;
        if (isset($data['REMOVED_LIST'])) {
            $removeList = $data['REMOVED_LIST'];
            unset($data['REMOVED_LIST']);
        }
        $data['DEL_PREVIOUS_USR_UID'] = $delPreviusUsrUid;
        if (isset($data['DEL_TASK_DUE_DATE'])) {
            $data['DEL_DUE_DATE'] = $data['DEL_TASK_DUE_DATE'];
        }

        $criteria = new Criteria();
        $criteria->addSelectColumn( ApplicationPeer::APP_NUMBER );
        $criteria->addSelectColumn( ApplicationPeer::APP_UPDATE_DATE );
        $criteria->add( ApplicationPeer::APP_UID, $data['APP_UID'], Criteria::EQUAL );
        $dataset = ApplicationPeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $dataset->next();
        $aRow = $dataset->getRow();
        $data = array_merge($data, $aRow);


        $criteria = new Criteria();
        $criteria->addSelectColumn(ContentPeer::CON_VALUE);
        $criteria->add( ContentPeer::CON_ID, $data['APP_UID'], Criteria::EQUAL );
        $criteria->add( ContentPeer::CON_CATEGORY, 'APP_TITLE', Criteria::EQUAL );
        $criteria->add( ContentPeer::CON_LANG, SYS_LANG, Criteria::EQUAL );
        $dataset = ContentPeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $dataset->next();
        $aRow = $dataset->getRow();
        $data['APP_TITLE'] = $aRow['CON_VALUE'];


        $criteria = new Criteria();
        $criteria->addSelectColumn(ContentPeer::CON_VALUE);
        $criteria->add( ContentPeer::CON_ID, $data['PRO_UID'], Criteria::EQUAL );
        $criteria->add( ContentPeer::CON_CATEGORY, 'PRO_TITLE', Criteria::EQUAL );
        $criteria->add( ContentPeer::CON_LANG, SYS_LANG, Criteria::EQUAL );
        $dataset = ContentPeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $dataset->next();
        $aRow = $dataset->getRow();
        $data['APP_PRO_TITLE'] = $aRow['CON_VALUE'];


        $criteria = new Criteria();
        $criteria->addSelectColumn(ContentPeer::CON_VALUE);
        $criteria->add( ContentPeer::CON_ID, $data['TAS_UID'], Criteria::EQUAL );
        $criteria->add( ContentPeer::CON_CATEGORY, 'TAS_TITLE', Criteria::EQUAL );
        $criteria->add( ContentPeer::CON_LANG, SYS_LANG, Criteria::EQUAL );
        $dataset = ContentPeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $dataset->next();
        $aRow = $dataset->getRow();
        $data['APP_TAS_TITLE'] = $aRow['CON_VALUE'];


        $data['APP_PREVIOUS_USER'] = '';
        if ($data['DEL_PREVIOUS_USR_UID'] != '') {
            $criteria = new Criteria();
            $criteria->addSelectColumn(UsersPeer::USR_USERNAME);
            $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
            $criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
            $criteria->add( UsersPeer::USR_UID, $data['DEL_PREVIOUS_USR_UID'], Criteria::EQUAL );
            $dataset = UsersPeer::doSelectRS($criteria);
            $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $dataset->next();
            $aRow = $dataset->getRow();
            $data['DEL_PREVIOUS_USR_USERNAME']  = $aRow['USR_USERNAME'];
            $data['DEL_PREVIOUS_USR_FIRSTNAME'] = $aRow['USR_FIRSTNAME'];
            $data['DEL_PREVIOUS_USR_LASTNAME']  = $aRow['USR_LASTNAME'];
        }

        $users = new Users();
        $criteria = new Criteria();
        $criteria->addSelectColumn(SubApplicationPeer::DEL_INDEX_PARENT);
        $criteria->add( SubApplicationPeer::APP_PARENT, $data['APP_UID'], Criteria::EQUAL );
        $dataset = SubApplicationPeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        if ($dataset->next()) {
            $aSub = $dataset->getRow();
            if ($aSub['DEL_INDEX_PARENT'] == $data['DEL_PREVIOUS'] && !$isSelfService) {
                $users->refreshTotal($data['USR_UID'], 'add', 'inbox');
                self::create($data, $isSelfService);
                return 1;
            }
        }

        if (!$isInitSubprocess) {
            if ($data['APP_STATUS'] == 'DRAFT') {
                $users->refreshTotal($data['USR_UID'], 'add', 'draft');
            } else {
                $oRow = ApplicationPeer::retrieveByPK($data['APP_UID']);
                $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
                if ($removeList) {
                    if ($data['DEL_INDEX'] == 2 || $aFields['APP_STATUS'] == 'DRAFT') {
                        $criteria = new Criteria();
                        $criteria->addSelectColumn(SubApplicationPeer::APP_UID);
                        $criteria->add( SubApplicationPeer::APP_UID, $data['APP_UID'], Criteria::EQUAL );
                        $dataset = SubApplicationPeer::doSelectRS($criteria);
                        if ($dataset->next()) {
                            $users->refreshTotal($delPreviusUsrUid, 'remove', 'inbox');
                        } else {
                            $users->refreshTotal($delPreviusUsrUid, 'remove', 'draft');
                        }
                    } else {
                        $users->refreshTotal($delPreviusUsrUid, 'remove', 'inbox');
                    }
                }
                if (!$isSelfService) {
                    $users->refreshTotal($data['USR_UID'], 'add', 'inbox');
                }
            }
        } else {
            if($data['USR_UID'] !=''){
                $users->refreshTotal($data['USR_UID'], 'add', 'inbox');
            }
            if ($dataPreviusApplication['APP_STATUS'] == 'DRAFT') {
                $users->refreshTotal($dataPreviusApplication['CURRENT_USER_UID'], 'remove', 'draft');
            } else {
                $users->refreshTotal($dataPreviusApplication['CURRENT_USER_UID'], 'remove', 'inbox');
            }
        }
        self::create($data, $isSelfService);
    }
Esempio n. 5
0
    /**
     * Remove List Paused
     *
     * @param type $seqName
     * @return type
     * @throws type
     *
     */
    public function remove ($app_uid, $del_index, $data_inbox)
    {
        $users = new Users();
        $users->refreshTotal($data_inbox['USR_UID'], 'removed', 'paused');

        $oRow = ApplicationPeer::retrieveByPK($app_uid);
        $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME );
        $data_inbox['APP_STATUS'] = $aFields['APP_STATUS'];
        if ($data_inbox['APP_STATUS'] == 'TO_DO') {
            $users->refreshTotal($data_inbox['USR_UID'], 'add', 'inbox');
        }
        $listInbox = new ListInbox();
        $listInbox->newRow($data_inbox, $data_inbox['USR_UID']);

        $con = Propel::getConnection( ListPausedPeer::DATABASE_NAME );
        try {
            $this->setAppUid($app_uid);
            $this->setDelIndex($del_index);
            $con->begin();
            $this->delete();
            $con->commit();
        } catch (Exception $e) {
            $con->rollback();
            throw ($e);
        }
    }
 /**
  * Function populateTable
  * This Function fills the table
  *
  * @access public
  * @param string $sTableName Table name
  * @param string $sConnection Connection name
  * @param string $sType
  * @param array $aFields
  * @param string $sProcessUid
  * @param string $sGrid
  * @return void
  */
 public function populateTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $sProcessUid = '', $sGrid = '')
 {
     $sTableName = $this->sPrefix . $sTableName;
     //we have to do the propel connection
     $PropelDatabase = $this->chooseDB($sConnection);
     $con = Propel::getConnection($PropelDatabase);
     $stmt = $con->createStatement();
     if ($sType == 'GRID') {
         $aAux = explode('-', $sGrid);
         $sGrid = $aAux[0];
     }
     try {
         switch (DB_ADAPTER) {
             case 'mysql':
                 //select cases for this Process, ordered by APP_NUMBER
                 $oCriteria = new Criteria('workflow');
                 $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUid);
                 $oCriteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER);
                 $oDataset = ApplicationPeer::doSelectRS($oCriteria);
                 $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $oDataset->next();
                 while ($aRow = $oDataset->getRow()) {
                     $aData = unserialize($aRow['APP_DATA']);
                     //delete previous record from this report table ( previous records in case this is a grid )
                     $deleteSql = 'DELETE FROM `' . $sTableName . "` WHERE APP_UID = '" . $aRow['APP_UID'] . "'";
                     $rsDel = $stmt->executeQuery($deleteSql);
                     if ($sType == 'NORMAL') {
                         $sQuery = 'INSERT INTO `' . $sTableName . '` (';
                         $sQuery .= '`APP_UID`,`APP_NUMBER`';
                         foreach ($aFields as $aField) {
                             $sQuery .= ',`' . $aField['sFieldName'] . '`';
                         }
                         $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'];
                         foreach ($aFields as $aField) {
                             switch ($aField['sType']) {
                                 case 'number':
                                     $sQuery .= ',' . (isset($aData[$aField['sFieldName']]) ? (double) str_replace(',', '', $aData[$aField['sFieldName']]) : '0');
                                     break;
                                 case 'char':
                                 case 'text':
                                     if (!isset($aData[$aField['sFieldName']])) {
                                         $aData[$aField['sFieldName']] = '';
                                     }
                                     $sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? mysql_real_escape_string($aData[$aField['sFieldName']]) : '') . "'";
                                     break;
                                 case 'date':
                                     $value = (isset($aData[$aField['sFieldName']]) && trim($aData[$aField['sFieldName']])) != '' ? "'" . $aData[$aField['sFieldName']] . "'" : 'NULL';
                                     $sQuery .= "," . $value;
                                     break;
                             }
                         }
                         $sQuery .= ')';
                         $rs = $stmt->executeQuery($sQuery);
                     } else {
                         if (isset($aData[$sGrid])) {
                             foreach ($aData[$sGrid] as $iRow => $aGridRow) {
                                 $sQuery = 'INSERT INTO `' . $sTableName . '` (';
                                 $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
                                 foreach ($aFields as $aField) {
                                     $sQuery .= ',`' . $aField['sFieldName'] . '`';
                                 }
                                 $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'] . ',' . $iRow;
                                 foreach ($aFields as $aField) {
                                     switch ($aField['sType']) {
                                         case 'number':
                                             $sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (double) str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
                                             break;
                                         case 'char':
                                         case 'text':
                                             if (!isset($aGridRow[$aField['sFieldName']])) {
                                                 $aGridRow[$aField['sFieldName']] = '';
                                             }
                                             $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
                                             break;
                                         case 'date':
                                             $value = (isset($aGridRow[$aField['sFieldName']]) && trim($aGridRow[$aField['sFieldName']])) != '' ? "'" . $aGridRow[$aField['sFieldName']] . "'" : 'NULL';
                                             $sQuery .= "," . $value;
                                             break;
                                     }
                                 }
                                 $sQuery .= ')';
                                 $rs = $stmt->executeQuery($sQuery);
                             }
                         }
                     }
                     $oDataset->next();
                 }
                 break;
                 /**
                  * For SQLServer code
                  */
             /**
              * For SQLServer code
              */
             case 'mssql':
                 $oCriteria = new Criteria('workflow');
                 $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUid);
                 $oCriteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER);
                 $oDataset = ApplicationPeer::doSelectRS($oCriteria);
                 $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $oDataset->next();
                 while ($aRow = $oDataset->getRow()) {
                     $aData = unserialize($aRow['APP_DATA']);
                     mysql_query('DELETE FROM [' . $sTableName . "] WHERE APP_UID = '" . $aRow['APP_UID'] . "'");
                     if ($sType == 'NORMAL') {
                         $sQuery = 'INSERT INTO [' . $sTableName . '] (';
                         $sQuery .= '[APP_UID],[APP_NUMBER]';
                         foreach ($aFields as $aField) {
                             $sQuery .= ',[' . $aField['sFieldName'] . ']';
                         }
                         $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'];
                         foreach ($aFields as $aField) {
                             switch ($aField['sType']) {
                                 case 'number':
                                     $sQuery .= ',' . (isset($aData[$aField['sFieldName']]) ? (double) str_replace(',', '', $aData[$aField['sFieldName']]) : '0');
                                     break;
                                 case 'char':
                                 case 'text':
                                     if (!isset($aData[$aField['sFieldName']])) {
                                         $aData[$aField['sFieldName']] = '';
                                     }
                                     $sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? mysql_real_escape_string($aData[$aField['sFieldName']]) : '') . "'";
                                     break;
                                 case 'date':
                                     $sQuery .= ",'" . (isset($aData[$aField['sFieldName']]) ? $aData[$aField['sFieldName']] : '') . "'";
                                     break;
                             }
                         }
                         $sQuery .= ')';
                         $rs = $stmt->executeQuery($sQuery);
                     } else {
                         if (isset($aData[$sGrid])) {
                             foreach ($aData[$sGrid] as $iRow => $aGridRow) {
                                 $sQuery = 'INSERT INTO [' . $sTableName . '] (';
                                 $sQuery .= '`APP_UID`,`APP_NUMBER`,`ROW`';
                                 foreach ($aFields as $aField) {
                                     $sQuery .= ',[' . $aField['sFieldName'] . ']';
                                 }
                                 $sQuery .= ") VALUES ('" . $aRow['APP_UID'] . "'," . (int) $aRow['APP_NUMBER'] . ',' . $iRow;
                                 foreach ($aFields as $aField) {
                                     switch ($aField['sType']) {
                                         case 'number':
                                             $sQuery .= ',' . (isset($aGridRow[$aField['sFieldName']]) ? (double) str_replace(',', '', $aGridRow[$aField['sFieldName']]) : '0');
                                             break;
                                         case 'char':
                                         case 'text':
                                             if (!isset($aGridRow[$aField['sFieldName']])) {
                                                 $aGridRow[$aField['sFieldName']] = '';
                                             }
                                             $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? mysql_real_escape_string($aGridRow[$aField['sFieldName']]) : '') . "'";
                                             break;
                                         case 'date':
                                             $sQuery .= ",'" . (isset($aGridRow[$aField['sFieldName']]) ? $aGridRow[$aField['sFieldName']] : '') . "'";
                                             break;
                                     }
                                 }
                                 $sQuery .= ')';
                                 $rs = $stmt->executeQuery($sQuery);
                             }
                         }
                     }
                     $oDataset->next();
                 }
                 break;
         }
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Esempio n. 7
0
    /**
     * Populate the report table with all case data
     * @param string $sType
     * @param string $sProcessUid
     * @param string $sGrid
     * @return number
     */
    public function populateReportTable($tableName, $sConnection = 'rp', $type = 'NORMAL', $processUid = '', $gridKey = '', $addTabUid = '')
    {
        require_once "classes/model/Application.php";

        $this->className = $this->getPHPName($tableName);
        $this->classPeerName = $this->className . 'Peer';

        if (!file_exists(PATH_WORKSPACE . 'classes/' . $this->className . '.php')) {
            throw new Exception( "ERROR: " . PATH_WORKSPACE . 'classes/' . $this->className . '.php'
                                . " class file doesn't exit!");
        }

        require_once PATH_WORKSPACE . 'classes/' . $this->className . '.php';

        //select cases for this Process, ordered by APP_NUMBER
        $con = Propel::getConnection($sConnection);
        $stmt = $con->createStatement();
        $criteria = new Criteria('workflow');
        $criteria->add(ApplicationPeer::PRO_UID, $processUid);
        $criteria->addAscendingOrderByColumn(ApplicationPeer::APP_NUMBER);
        $dataset = ApplicationPeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        while ($dataset->next()) {
            $row = $dataset->getRow();
            //remove old applications references
            $deleteSql = "DELETE FROM $tableName WHERE APP_UID = '" . $row['APP_UID'] . "'";
            $rs = $stmt->executeQuery($deleteSql);
            // getting the case data
            $caseData = unserialize($row['APP_DATA']);

            $fieldTypes = array();

            if ($addTabUid != '') {
                require_once 'classes/model/Fields.php';
                $criteriaField = new Criteria('workflow');
                $criteriaField->add(FieldsPeer::ADD_TAB_UID, $addTabUid);
                $datasetField = FieldsPeer::doSelectRS($criteriaField);
                $datasetField->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                while ($datasetField->next()) {
                    $rowfield = $datasetField->getRow();
                    switch ($rowfield['FLD_TYPE']) {
                        case 'FLOAT':
                        case 'DOUBLE':
                        case 'INTEGER':
                            $fieldTypes[] = array($rowfield['FLD_NAME']=>$rowfield['FLD_TYPE']);
                            break;
                        default:
                            break;
                    }
                }
            }

            // quick fix
            // map all empty values as NULL for Database
            foreach ($caseData as $dKey => $dValue) {
                if (!is_array($dValue)) {
                    foreach ($fieldTypes as $key => $fieldType) {
                        foreach ($fieldType as $name => $theType) {
                            if (strtoupper($dKey) == $name) {
                                $caseData[$dKey] = validateType ($dValue, $theType);
                                unset($name);
                            }
                        }
                    }
                    // normal fields
                    if (trim($dValue) === '') {
                        $caseData[$dKey] = null;
                    }
                } else {
                    // grids
                    foreach ($caseData[$dKey] as $dIndex => $dRow) {
                        if (!is_array($dRow)) {
                            foreach ($dRow as $k => $v) {
                                if (trim($v) === '') {
                                    $caseData[$dKey][$dIndex][$k] = null;
                                }
                            }
                        }
                    }
                }
            }

            if ($type == 'GRID') {
                list($gridName, $gridUid) = explode('-', $gridKey);
                $gridData = isset($caseData[$gridName]) ? $caseData[$gridName] : array();

                foreach ($gridData as $i => $gridRow) {
                    eval('$obj = new ' . $this->className . '();');
                    $obj->fromArray($caseData, BasePeer::TYPE_FIELDNAME);
                    $obj->setAppUid($row['APP_UID']);
                    $obj->setAppNumber($row['APP_NUMBER']);
                    if (method_exists($obj, 'setAppStatus')) {
                        $obj->setAppStatus($row['APP_STATUS']);
                    }
                    $obj->fromArray(array_change_key_case($gridRow, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
                    $obj->setRow($i);
                    $obj->save();
                    eval('$obj = new ' . $this->className . '();');
                }
            } else {
                eval('$obj = new ' . $this->className . '();');
                $obj->fromArray(array_change_key_case($caseData, CASE_UPPER), BasePeer::TYPE_FIELDNAME);
                $obj->setAppUid($row['APP_UID']);
                $obj->setAppNumber($row['APP_NUMBER']);
                if (method_exists($obj, 'setAppStatus')) {
                    $obj->setAppStatus($row['APP_STATUS']);
                }
                $obj->save();
                $obj = null;
            }
        }
    }
Esempio n. 8
0
 public function getSearchAllCount()
 {
     $criteriaCount = new Criteria('workflow');
     $totalCount = ApplicationPeer::doCount($criteriaCount);
     return $totalCount;
 }
        */
        case 'emptyFileOptions':
            global $G_PUBLISH;
            $G_PUBLISH = new Publisher();
            $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_FileEditCreateEmpty', '');
            G::RenderPage('publish', 'raw');
            break;
        case "taskCases":
            require_once "classes/model/Application.php";
            require_once "classes/model/AppDelegation.php";
            require_once "classes/model/AppDelay.php";
            $criteria = new Criteria("workflow");
            $criteria->addSelectColumn("COUNT(DISTINCT APPLICATION.APP_UID)");
            $criteria->addJoin(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN);
            $criteria->addJoin(ApplicationPeer::APP_UID, AppDelayPeer::APP_UID, Criteria::LEFT_JOIN);
            $criteria->add(AppDelegationPeer::TAS_UID, $oData->task_uid);
            $criteria->add($criteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL)->addOr($criteria->getNewCriterion(AppDelayPeer::APP_DELAY_UID, null, Criteria::ISNOTNULL)->addAnd($criteria->getNewCriterion(AppDelayPeer::APP_TYPE, array("REASSIGN", "ADHOC", "CANCEL"), Criteria::NOT_IN))->addAnd($criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->addOr($criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0)))));
            $rs = ApplicationPeer::doSelectRS($criteria);
            $rs->next();
            $row = $rs->getRow();
            $response->casesNumRec = intval($row[0]);
            $json = new Services_JSON();
            $sOutput = $json->encode($response);
            break;
    }
    if (isset($sOutput)) {
        die($sOutput);
    }
} catch (Exception $oException) {
    die($oException->getMessage() . "\n" . $oException->getTraceAsString());
}
Esempio n. 10
0
     echo G::json_encode($result);
     break;
 case 'canDeleteUser':
     G::LoadClass('case');
     $oProcessMap = new Cases();
     $USR_UID = $_POST['uUID'];
     $total = 0;
     $history = 0;
     $c = $oProcessMap->getCriteriaUsersCases('TO_DO', $USR_UID);
     $total += ApplicationPeer::doCount($c);
     $c = $oProcessMap->getCriteriaUsersCases('DRAFT', $USR_UID);
     $total += ApplicationPeer::doCount($c);
     $c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $USR_UID);
     $history += ApplicationPeer::doCount($c);
     $c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID);
     $history += ApplicationPeer::doCount($c);
     $response = '{success: true, candelete: ';
     $response .= $total > 0 ? 'false' : 'true';
     $response .= ', hashistory: ';
     $response .= $history > 0 ? 'true' : 'false';
     $response .= '}';
     echo $response;
     break;
 case 'deleteUser':
     $UID = $_POST['USR_UID'];
     G::LoadClass('tasks');
     $oTasks = new Tasks();
     $oTasks->ofToAssignUserOfAllTasks($UID);
     G::LoadClass('groups');
     $oGroups = new Groups();
     $oGroups->removeUserOfAllGroups($UID);
Esempio n. 11
0
 public function createApplication($aData)
 {
     $c = new Criteria();
     $c->clearSelectColumns();
     $c->addSelectColumn('MAX(' . ApplicationPeer::APP_NUMBER . ')');
     $c->add(ApplicationPeer::PRO_UID, $aData['PRO_UID']);
     $result = ApplicationPeer::doSelectRS($c);
     $result->next();
     $row = $result->getRow();
     $maxNumber = $row[0] + 1;
     $this->setAppUid(G::generateUniqueID());
     $this->setAppNumber($maxNumber);
     $this->setAppParent(isset($aData['APP_PARENT']) ? $aData['APP_PARENT'] : 0);
     $this->setAppStatus(isset($aData['APP_STATUS']) ? $aData['APP_STATUS'] : 'DRAFT');
     $this->setProUid($aData['PRO_UID']);
     $this->setAppProcStatus(isset($aData['APP_PROC_STATUS']) ? $aData['APP_PROC_STATUS'] : '');
     $this->setAppProcCode(isset($aData['APP_PROC_CODE']) ? $aData['APP_PROC_CODE'] : '');
     $this->setAppParallel(isset($aData['APP_PARALLEL']) ? $aData['APP_PARALLEL'] : 'N');
     $this->setAppInitUser($aData['USR_UID']);
     $this->setAppCurUser($aData['USR_UID']);
     $this->setAppCreateDate(isset($aData['APP_CREATE_DATE']) ? $aData['APP_CREATE_DATE'] : 'now');
     $this->setAppInitDate(isset($aData['APP_INIT_DATE']) ? $aData['APP_INIT_DATE'] : 'now');
     $this->setAppUpdateDate(isset($aData['APP_UPDATE_DATE']) ? $aData['APP_UPDATE_DATE'] : 'now');
     //$this->setAppData(serialize(array()));
     /** Start Comment : Sets the $this->Fields['APP_DATA']
         Merge between stored APP_DATA with new APP_DATA. **/
     if (!$this->getAppData()) {
         //        if (!$this->is_new)
         //        {
         //          $this->load($fields['APP_UID']);
         //        }
     }
     $this->Fields['APP_DATA'] = isset($this->Fields['APP_DATA']) ? $this->Fields['APP_DATA'] : array();
     if (isset($fields['APP_DATA']) && is_array($fields['APP_DATA'])) {
         foreach ($fields['APP_DATA'] as $k => $v) {
             $this->Fields['APP_DATA'][$k] = $v;
         }
     }
     /** End Comment **/
     /*
     Begin Comment : Replace APP_DATA in APP_TITLE (before to serialize)
       $pro = new process( $this->_dbc );
       $pro->load((isset($fields['PRO_UID']) ? $fields['PRO_UID'] : $this->Fields['PRO_UID']));
       $fields['APP_TITLE'] = G::replaceDataField( $pro->Fields['PRO_TITLE'], $this->Fields['APP_DATA']);
     End Comment
     */
     //    parent::save();
     //    $this->Fields['APP_DATA'] = unserialize($this->Fields['APP_DATA']);
     //    /** Start Comment: Save in the table CONTENT */
     //      $this->content->saveContent('APP_TITLE',$fields);
     //    /** End Comment */
     if ($this->validate()) {
         $res = $this->save();
         $this->setAppTitle('');
         $this->setAppDescription('');
         $this->setAppProcCode('');
     } else {
         // Something went wrong. We can now get the validationFailures and handle them.
         $msg = '';
         $validationFailuresArray = $this->getValidationFailures();
         foreach ($validationFailuresArray as $objValidationFailure) {
             $msg .= $objValidationFailure->getMessage() . "<br/>";
         }
         //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
     }
     return $this->getAppUid();
 }
Esempio n. 12
0
    /**

     * Delete User

     *

     * @param string $usrUid Unique id of User

     *

     * return void

     */

    public function delete($usrUid)

    {

        try {

            //Verify data

            $this->throwExceptionIfNotExistsUser($usrUid, $this->arrayFieldNameForException["usrUid"]);



            \G::LoadClass('case');

            $oProcessMap = new \Cases();

            $USR_UID = $usrUid;

            $total = 0;

            $history = 0;

            $c = $oProcessMap->getCriteriaUsersCases('TO_DO', $USR_UID);

            $total += \ApplicationPeer::doCount($c);

            $c = $oProcessMap->getCriteriaUsersCases('DRAFT', $USR_UID);

            $total += \ApplicationPeer::doCount($c);

            $c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $USR_UID);

            $history += \ApplicationPeer::doCount($c);

            $c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID);

            $history += \ApplicationPeer::doCount($c);

            if ($total > 0) {

                throw new \Exception(\G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", array($USR_UID)));

            } else {

                $UID = $usrUid;

                \G::LoadClass('tasks');

                $oTasks = new \Tasks();

                $oTasks->ofToAssignUserOfAllTasks($UID);

                \G::LoadClass('groups');

                $oGroups = new \Groups();

                $oGroups->removeUserOfAllGroups($UID);

                $this->changeUserStatus($UID, 'CLOSED');

                $_GET['USR_USERNAME'] = '';

                $this->updateUser(array('USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']), '');

                require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");

                $oUser = new \Users();

                $aFields = $oUser->load($UID);

                $aFields['USR_STATUS'] = 'CLOSED';

                $aFields['USR_USERNAME'] = '';

                $oUser->update($aFields);

                //Delete Dashboard

                require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "DashletInstance.php");

                $criteria = new \Criteria( 'workflow' );

                $criteria->add( \DashletInstancePeer::DAS_INS_OWNER_UID, $UID );

                $criteria->add( \DashletInstancePeer::DAS_INS_OWNER_TYPE , 'USER');

                \DashletInstancePeer::doDelete( $criteria );

            }

        } catch (\Exception $e) {

            throw $e;

        }

    }
Esempio n. 13
0
 /**
  * Get case list
  *
  * @param string $userId
  * @return $result will return an object
  */
 public function caseList($userId)
 {
     try {
         $result = array();
         $oCriteria = new Criteria('workflow');
         $del = DBAdapter::getStringDelimiter();
         $oCriteria->addSelectColumn(ApplicationPeer::APP_UID);
         $oCriteria->addSelectColumn(ApplicationPeer::APP_NUMBER);
         $oCriteria->addSelectColumn(ApplicationPeer::APP_STATUS);
         $oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
         $oCriteria->addSelectColumn(ApplicationPeer::PRO_UID);
         $oCriteria->addAsColumn('CASE_TITLE', 'C1.CON_VALUE');
         $oCriteria->addAlias("C1", 'CONTENT');
         $caseTitleConds = array();
         $caseTitleConds[] = array(ApplicationPeer::APP_UID, 'C1.CON_ID');
         $caseTitleConds[] = array('C1.CON_CATEGORY', $del . 'APP_TITLE' . $del);
         $caseTitleConds[] = array('C1.CON_LANG', $del . SYS_LANG . $del);
         $oCriteria->addJoinMC($caseTitleConds, Criteria::LEFT_JOIN);
         $oCriteria->addJoin(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN);
         $oCriteria->add(ApplicationPeer::APP_STATUS, array('TO_DO', 'DRAFT'), Criteria::IN);
         $oCriteria->add(AppDelegationPeer::USR_UID, $userId);
         $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
         $oCriteria->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
         $oDataset = ApplicationPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             /*
             $result[] = array(
                 'guid'     => $aRow['APP_UID'],
                 'name'     => $aRow['CASE_TITLE'],
                 'status'   => $aRow['APP_STATUS'],
                 'delIndex' => $aRow['DEL_INDEX']
             );
             */
             $result[] = array('guid' => $aRow['APP_UID'], 'name' => $aRow['APP_NUMBER'], 'status' => $aRow['APP_STATUS'], 'delIndex' => $aRow['DEL_INDEX'], 'processId' => $aRow['PRO_UID']);
             $oDataset->next();
         }
         return $result;
     } catch (Exception $e) {
         $result[] = array('guid' => $e->getMessage(), 'name' => $e->getMessage(), 'status' => $e->getMessage(), 'status' => $e->getMessage(), 'processId' => $e->getMessage());
         return $result;
     }
 }
Esempio n. 14
0
    public function refreshTotal ($userId, $type = 'add', $list = "inbox", $total = 1)
    {
        if ($userId == "") {
            return;
        }

        $nameList = self::getNameTotal($list);
        $criteria = new Criteria();
        $criteria->addSelectColumn( $nameList );
        $criteria->add( UsersPeer::USR_UID, $userId, Criteria::EQUAL );
        $dataset = ApplicationPeer::doSelectRS($criteria);
        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $dataset->next();
        $aRow = $dataset->getRow();

        $num = $aRow[$nameList];
        if ($type == 'add') {
            $num++;
        } else {
            $num--;
        }

        $data = array(
            'USR_UID' => $userId,
            $nameList => $num
        );
        self::update($data);
    }
Esempio n. 15
0
 public function executeEvents($sNow, $debug = false, &$log = array(), $cron = 0)
 {
     require_once 'classes/model/Configuration.php';
     require_once 'classes/model/Triggers.php';
     G::LoadClass('case');
     $debug = 1;
     $oCase = new Cases();
     try {
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(AppEventPeer::APP_UID);
         $oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
         $oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
         $oCriteria->addSelectColumn(EventPeer::PRO_UID);
         $oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
         $oCriteria->addSelectColumn(EventPeer::TRI_UID);
         $oCriteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
         $oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
         $oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
         $oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
         $oCriteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
         $oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
         $oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::JOIN);
         $aConditions = array();
         array_push($aConditions, array(AppEventPeer::APP_UID, AppDelegationPeer::APP_UID));
         array_push($aConditions, array(AppEventPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX));
         $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
         $oCriteria->addJoin(ApplicationPeer::APP_UID, AppEventPeer::APP_UID);
         $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
         //by me
         $oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
         $oCriteria->add(AppEventPeer::APP_EVN_ACTION_DATE, $sNow, Criteria::LESS_EQUAL);
         $oDataset = AppEventPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $c = 0;
         while ($oDataset->next()) {
             if ($cron == 1) {
                 $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
                 $arrayCron["processcTimeStart"] = time();
                 @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
             }
             $c++;
             $aRow = $oDataset->getRow();
             $oTrigger = new Triggers();
             $aFields = $oCase->loadCase($aRow['APP_UID']);
             $oAppEvent = AppEventPeer::retrieveByPK($aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID']);
             //g::pr($aRow); //die;
             if ($debug) {
                 require_once 'classes/model/Application.php';
                 $oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
                 $oEv = EventPeer::retrieveByPk($aRow['EVN_UID']);
                 $log[] = 'Event ' . $oEv->getEvnDescription() . ' with ID ' . $aRow['EVN_UID'];
                 println("\nOK+ event \"" . $oEv->getEvnDescription() . "\" with ID {} was found");
                 println(" - PROCESS................" . $aRow['PRO_UID']);
                 println(" - APPLICATION............" . $aRow['APP_UID'] . " CASE #" . $oApp->getAppNumber());
                 println(" - ACTION DATE............" . $aRow['APP_EVN_ACTION_DATE']);
                 println(" - ATTEMPTS..............." . $aRow['APP_EVN_ATTEMPTS']);
                 println(" - INTERVAL WITH TASKS...." . $aRow['EVN_RELATED_TO']);
             }
             if ($aRow['TRI_UID'] == '') {
                 //a rare case when the tri_uid is not set.
                 $log[] = " (!) Any trigger was set................................SKIPPED and will be CLOSED";
                 if ($debug) {
                     println(" (!) Any trigger was set................................SKIPPED and will be CLOSED");
                 }
                 $oAppEvent->setAppEvnStatus('CLOSE');
                 $oAppEvent->save();
                 continue;
             }
             $oTrigger = TriggersPeer::retrieveByPk($aRow['TRI_UID']);
             if (!is_object($oTrigger)) {
                 //the trigger record doesn't exist..
                 $log[] = ' (!) The trigger ' . $aRow['TRI_UID'] . ' ' . $oTrigger->getTriTitle() . " doesn't exist.......SKIPPED and will be CLOSED";
                 if ($debug) {
                     println(" (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED");
                 }
                 $oAppEvent->setAppEvnStatus('CLOSE');
                 $oAppEvent->save();
                 continue;
             }
             global $oPMScript;
             $oPMScript = new PMScript();
             $task = new Task();
             $taskFields = $task->Load($aRow['TAS_UID']);
             $aFields['APP_DATA']['APP_NUMBER'] = $aFields['APP_NUMBER'];
             $aFields['APP_DATA']['TAS_TITLE'] = $taskFields['TAS_TITLE'];
             $aFields['APP_DATA']['DEL_TASK_DUE_DATE'] = $aRow['DEL_TASK_DUE_DATE'];
             $oPMScript->setFields($aFields['APP_DATA']);
             $oPMScript->setScript($oTrigger->getTriWebbot());
             $oPMScript->execute();
             $oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
             if (sizeof($_SESSION['TRIGGER_DEBUG']['ERRORS']) == 0) {
                 $log[] = ' - The trigger ' . $oTrigger->getTriTitle() . ' was executed successfully!';
                 if ($debug) {
                     println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
                     //g::pr($aFields);
                 }
                 $aFields['APP_DATA'] = $oPMScript->aFields;
                 $oCase->updateCase($aRow['APP_UID'], $aFields);
                 $oAppEvent->setAppEvnStatus('CLOSE');
             } else {
                 if ($debug) {
                     $log[] = ' - The trigger ' . $aRow['TRI_UID'] . ' throw some errors!';
                     println(" - The trigger {$aRow['TRI_UID']} throw some errors!");
                     print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']);
                 }
                 if ($oAppEvent->getAppEvnAttempts() > 0) {
                     $oAppEvent->setAppEvnAttempts($oAppEvent->getAppEvnAttempts() - 1);
                 } else {
                     $oAppEvent->setAppEvnStatus('CLOSE');
                 }
             }
             $oAppEvent->save();
         }
         return $c;
     } catch (Exception $oError) {
         $log[] = ' Error execute event : ' . $oError->getMessage();
         die($oError->getMessage());
         return $oError->getMessage();
     }
 }
Esempio n. 16
0
    public function reportTableDeleteRecord($applicationUid)

    {

        $criteria1 = new Criteria("workflow");



        //SELECT

        $criteria1->addSelectColumn(ApplicationPeer::PRO_UID);



        //FROM



        //WHERE

        $criteria1->add(ApplicationPeer::APP_UID, $applicationUid);



        //QUERY

        $rsCriteria1 = ApplicationPeer::doSelectRS($criteria1);

        $rsCriteria1->setFetchmode(ResultSet::FETCHMODE_ASSOC);



        $rsCriteria1->next();

        $row1 = $rsCriteria1->getRow();



        $processUid = $row1["PRO_UID"];



        $criteria2 = new Criteria("workflow");



        //SELECT

        $criteria2->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME);



        //FROM



        //WHERE



        $criteria2->add(AdditionalTablesPeer::PRO_UID, $processUid);



        //QUERY

        $rsCriteria2 = AdditionalTablesPeer::doSelectRS($criteria2);

        $rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);



        G::LoadClass("pmTable");

        $pmTable = new PmTable();



        while ($rsCriteria2->next()) {

            try {

                $row2 = $rsCriteria2->getRow();

                $tableName = $row2["ADD_TAB_NAME"];

                $pmTableName = $pmTable->toCamelCase($tableName);



                //DELETE

                require_once (PATH_WORKSPACE . "classes" . PATH_SEP . "$pmTableName.php");



                $criteria3 = new Criteria("workflow");



                eval("\$criteria3->add(" . $pmTableName . "Peer::APP_UID, \$applicationUid);");

                eval($pmTableName . "Peer::doDelete(\$criteria3);");



            } catch (Exception $e) {

                throw $e;

            }

        }

    }
Esempio n. 17
0
    /**
     * Populates the object using an array.
     *
     * This is particularly useful when populating an object from one of the
     * request arrays (e.g. $_POST).  This method goes through the column
     * names, checking to see whether a matching key exists in populated
     * array. If so the setByName() method is called for that column.
     *
     * You can specify the key type of the array by additionally passing one
     * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
     * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
     *
     * @param      array  $arr     An array to populate the object from.
     * @param      string $keyType The type of keys the array uses.
     * @return     void
     */
    public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
    {
        $keys = ApplicationPeer::getFieldNames($keyType);

        if (array_key_exists($keys[0], $arr)) {
            $this->setAppUid($arr[$keys[0]]);
        }

        if (array_key_exists($keys[1], $arr)) {
            $this->setAppNumber($arr[$keys[1]]);
        }

        if (array_key_exists($keys[2], $arr)) {
            $this->setAppParent($arr[$keys[2]]);
        }

        if (array_key_exists($keys[3], $arr)) {
            $this->setAppStatus($arr[$keys[3]]);
        }

        if (array_key_exists($keys[4], $arr)) {
            $this->setProUid($arr[$keys[4]]);
        }

        if (array_key_exists($keys[5], $arr)) {
            $this->setAppProcStatus($arr[$keys[5]]);
        }

        if (array_key_exists($keys[6], $arr)) {
            $this->setAppProcCode($arr[$keys[6]]);
        }

        if (array_key_exists($keys[7], $arr)) {
            $this->setAppParallel($arr[$keys[7]]);
        }

        if (array_key_exists($keys[8], $arr)) {
            $this->setAppInitUser($arr[$keys[8]]);
        }

        if (array_key_exists($keys[9], $arr)) {
            $this->setAppCurUser($arr[$keys[9]]);
        }

        if (array_key_exists($keys[10], $arr)) {
            $this->setAppCreateDate($arr[$keys[10]]);
        }

        if (array_key_exists($keys[11], $arr)) {
            $this->setAppInitDate($arr[$keys[11]]);
        }

        if (array_key_exists($keys[12], $arr)) {
            $this->setAppFinishDate($arr[$keys[12]]);
        }

        if (array_key_exists($keys[13], $arr)) {
            $this->setAppUpdateDate($arr[$keys[13]]);
        }

        if (array_key_exists($keys[14], $arr)) {
            $this->setAppData($arr[$keys[14]]);
        }

        if (array_key_exists($keys[15], $arr)) {
            $this->setAppPin($arr[$keys[15]]);
        }

        if (array_key_exists($keys[16], $arr)) {
            $this->setAppDuration($arr[$keys[16]]);
        }

        if (array_key_exists($keys[17], $arr)) {
            $this->setAppDelayDuration($arr[$keys[17]]);
        }

    }
Esempio n. 18
0
 public function deleteProcess($sProcessUID, $flagRemoveCases = true)
 {
     try {
         //G::LoadClass('case');
         //G::LoadClass('reportTables');
         //Instance all classes necesaries
         $oProcess = new \Process();
         $oDynaform = new \Dynaform();
         $oInputDocument = new \InputDocument();
         $oOutputDocument = new \OutputDocument();
         $oTrigger = new \Triggers();
         $oRoute = new \Route();
         $oGateway = new \Gateway();
         $oEvent = new \Event();
         $oSwimlaneElement = new \SwimlanesElements();
         $oConfiguration = new \Configuration();
         $oDbSource = new \DbSource();
         $oReportTable = new \ReportTables();
         $oCaseTracker = new \CaseTracker();
         $oCaseTrackerObject = new \CaseTrackerObject();
         //Update PROCESS_FILES_CHECKED
         $configuration = \ConfigurationPeer::retrieveByPK("PROCESS_FILES_CHECKED", "", "", "", "");
         if (!is_null($configuration)) {
             $arrayProjectUid = unserialize($configuration->getCfgValue());
             unset($arrayProjectUid[$sProcessUID]);
             $conf = new \Configuration();
             $result = $conf->update(array("CFG_UID" => "PROCESS_FILES_CHECKED", "OBJ_UID" => "", "CFG_VALUE" => serialize($arrayProjectUid), "PRO_UID" => "", "USR_UID" => "", "APP_UID" => ""));
         }
         //Delete the applications of process
         if ($flagRemoveCases) {
             $case = new \Cases();
             $criteria = new \Criteria("workflow");
             $criteria->addSelectColumn(\ApplicationPeer::APP_UID);
             $criteria->add(\ApplicationPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
             $rsCriteria = \ApplicationPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             while ($rsCriteria->next()) {
                 $row = $rsCriteria->getRow();
                 $result = $case->removeCase($row["APP_UID"]);
             }
         }
         //Delete the tasks of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
         $oDataset = \TaskPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             //$this->deleteTask($aRow['TAS_UID']);
             $oTasks = new \Tasks();
             $oTasks->deleteTask($aRow['TAS_UID']);
             $oDataset->next();
         }
         //Delete the dynaforms of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\DynaformPeer::PRO_UID, $sProcessUID);
         $oDataset = \DynaformPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oDynaform->remove($aRow['DYN_UID']);
             $oDataset->next();
         }
         //Delete the input documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\InputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = \InputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oInputDocument->remove($aRow['INP_DOC_UID']);
             $oDataset->next();
         }
         //Delete the output documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oOutputDocument->remove($aRow['OUT_DOC_UID']);
             $oDataset->next();
         }
         //Delete the triggers of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\TriggersPeer::PRO_UID, $sProcessUID);
         $oDataset = \TriggersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oTrigger->remove($aRow['TRI_UID']);
             $oDataset->next();
         }
         //Delete the routes of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\RoutePeer::PRO_UID, $sProcessUID);
         $oDataset = \RoutePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oRoute->remove($aRow['ROU_UID']);
             $oDataset->next();
         }
         //Delete the gateways of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\GatewayPeer::PRO_UID, $sProcessUID);
         $oDataset = \GatewayPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oGateway->remove($aRow['GAT_UID']);
             $oDataset->next();
         }
         //Delete the Event of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\EventPeer::PRO_UID, $sProcessUID);
         $oDataset = \EventPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oEvent->remove($aRow['EVN_UID']);
             $oDataset->next();
         }
         //Delete the swimlanes elements of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\SwimlanesElementsPeer::PRO_UID, $sProcessUID);
         $oDataset = \SwimlanesElementsPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oSwimlaneElement->remove($aRow['SWI_UID']);
             $oDataset->next();
         }
         //Delete the configurations of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ConfigurationPeer::PRO_UID, $sProcessUID);
         $oDataset = \ConfigurationPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
             $oDataset->next();
         }
         //Delete the DB sources of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\DbSourcePeer::PRO_UID, $sProcessUID);
         $oDataset = \DbSourcePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             /**
              * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
              * in order to solve the bug 0004389, we use the validation function Exists
              * inside the remove function in order to verify if the DbSource record
              * exists in the Database, however there is a strange behavior within the
              * propel engine, when the first record is erased somehow the "_deleted"
              * attribute of the next row is set to true, so when propel tries to erase
              * it, obviously it can't and trows an error. With the "Exist" function
              * we ensure that if there is the record in the database, the _delete attribute must be false.
              *
              * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
              * I have just identified the source of the issue, when is created a $oDbSource DbSource object
              * it's used whenever a record is erased or removed in the db, however the problem
              * it's that the same object is used every time, and the delete method invoked
              * sets the _deleted attribute to true when its called, of course as we use
              * the same object, the first time works fine but trowns an error with the
              * next record, cos it's the same object and the delete method checks if the _deleted
              * attribute it's true or false, the attrib _deleted is setted to true the
              * first time and later is never changed, the issue seems to be part of
              * every remove function in the model classes, not only DbSource
              * i recommend that a more general solution must be achieved to resolve
              * this issue in every model class, to prevent future problems.
              */
             $oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
             $oDataset->next();
         }
         //Delete the supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
         \ProcessUserPeer::doDelete($oCriteria);
         //Delete the object permissions
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ObjectPermissionPeer::PRO_UID, $sProcessUID);
         \ObjectPermissionPeer::doDelete($oCriteria);
         //Delete the step supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\StepSupervisorPeer::PRO_UID, $sProcessUID);
         \StepSupervisorPeer::doDelete($oCriteria);
         //Delete the report tables
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ReportTablePeer::PRO_UID, $sProcessUID);
         $oDataset = \ReportTablePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oReportTable->deleteReportTable($aRow['REP_TAB_UID']);
             $oDataset->next();
         }
         //Delete case tracker configuration
         $oCaseTracker->remove($sProcessUID);
         //Delete case tracker objects
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
         \ProcessUserPeer::doDelete($oCriteria);
         //Delete SubProcess
         $criteria = new \Criteria("workflow");
         $criteria->add(\SubProcessPeer::PRO_PARENT, $sProcessUID, \Criteria::EQUAL);
         $result = \SubProcessPeer::doDelete($criteria);
         //Delete WebEntries
         $webEntry = new \ProcessMaker\BusinessModel\WebEntry();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\WebEntryPeer::WE_UID);
         $criteria->add(\WebEntryPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \WebEntryPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $webEntry->delete($row["WE_UID"]);
         }
         //Delete WebEntry-Events
         $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\WebEntryEventPeer::WEE_UID);
         $criteria->add(\WebEntryEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \WebEntryEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $webEntryEvent->delete($row["WEE_UID"]);
         }
         //Delete MessageTypes
         $messageType = new \ProcessMaker\BusinessModel\MessageType();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\MessageTypePeer::MSGT_UID);
         $criteria->add(\MessageTypePeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \MessageTypePeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $messageType->delete($row["MSGT_UID"]);
         }
         //Delete Message-Event-Relation
         $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
         $messageEventRelation->deleteWhere(array(\MessageEventRelationPeer::PRJ_UID => $sProcessUID));
         //Delete Message-Event-Task-Relation
         $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
         $elementTaskRelation->deleteWhere(array(\ElementTaskRelationPeer::PRJ_UID => $sProcessUID));
         //Delete Message-Event-Definition
         $messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_UID);
         $criteria->add(\MessageEventDefinitionPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $messageEventDefinition->delete($row["MSGED_UID"]);
         }
         //Delete Script-Task
         $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask();
         $scriptTask->deleteWhere(array(\ScriptTaskPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL)));
         //Delete Timer-Event
         $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
         $timerEvent->deleteWhere(array(\TimerEventPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL)));
         //Delete Email-Event
         $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_UID);
         $criteria->add(\EmailEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \EmailEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $emailEvent->delete($sProcessUID, $row["EMAIL_EVENT_UID"], false);
         }
         //Delete files Manager
         $filesManager = new \ProcessMaker\BusinessModel\FilesManager();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID);
         $criteria->add(\ProcessFilesPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $filesManager->deleteProcessFilesManager($sProcessUID, $row["PRF_UID"]);
         }
         //Delete the actions by email
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\AbeConfigurationPeer::PRO_UID, $sProcessUID);
         \AbeConfigurationPeer::doDelete($oCriteria);
         //Delete the process
         try {
             $oProcess->remove($sProcessUID);
         } catch (\Exception $oError) {
             throw $oError;
         }
         return true;
     } catch (\Exception $oError) {
         throw $oError;
     }
 }
Esempio n. 19
0
 /** 
  * This function does a sql statment to a report wiht a condition
  * or maybe when you're looking for some specials cases
  * 
  * @name generatedReport1_filter
  *
  * @param string $from
  * @param string $to
  * @param string $startedby
  * @return object
  */
 function generatedReport1_filter($from, $to, $startedby)
 {
     $this->reportsPatch();
     require_once 'classes/model/AppDelegation.php';
     require_once 'classes/model/Application.php';
     require_once 'classes/model/Users.php';
     $oCriteria = new Criteria('workflow');
     $del = DBAdapter::getStringDelimiter();
     $oCriteria->addSelectColumn(UsersPeer::USR_UID);
     $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
     $oCriteria->addAsColumn("MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")");
     $oCriteria->addAsColumn("MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")");
     $oCriteria->addAsColumn("TOTALDUR", "SUM(" . AppDelegationPeer::DEL_DURATION . ")");
     $oCriteria->addAsColumn("PROMEDIO", "AVG(" . AppDelegationPeer::DEL_DURATION . ")");
     $oCriteria->addAsColumn('PRO_TITLE', 'C1.CON_VALUE');
     $oCriteria->addAlias("C1", 'CONTENT');
     $proTitleConds = array();
     $proTitleConds[] = array(AppDelegationPeer::PRO_UID, 'C1.CON_ID');
     $proTitleConds[] = array('C1.CON_CATEGORY', $del . 'PRO_TITLE' . $del);
     $proTitleConds[] = array('C1.CON_LANG', $del . SYS_LANG . $del);
     $oCriteria->addJoinMC($proTitleConds, Criteria::LEFT_JOIN);
     $oCriteria->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
     //$oCriteria->add(AppDelegationPeer::DEL_DURATION,  $from, Criteria::GREATER_EQUAL);
     //$oCriteria->add(AppDelegationPeer::DEL_DURATION,  $to, Criteria::LESS_EQUAL);
     //$aAux1 = explode('-', $from);  date('Y-m-d H:i:s', mktime(0, 0, 0, $aAux1[1], $aAux1[2], $aAux1[0]))
     $oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $from . ' 00:00:00', Criteria::GREATER_EQUAL)->addAnd($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $to . ' 23:59:59', Criteria::LESS_EQUAL)));
     if ($startedby != '') {
         $oCriteria->add(ApplicationPeer::APP_INIT_USER, $startedby);
     }
     $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID);
     $oCriteria->addGroupByColumn('C1.CON_VALUE');
     $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aProcess[] = array('PRO_UID' => 'char', 'PRO_TITLE' => 'char', 'CANTCASES' => 'integer', 'MIN' => 'float', 'MAX' => 'float', 'TOTALDUR' => 'float', 'PROMEDIO' => 'float');
     while ($aRow = $oDataset->getRow()) {
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(ApplicationPeer::PRO_UID);
         $oCriteria->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']);
         if ($startedby != '') {
             $oCriteria->add(ApplicationPeer::APP_INIT_USER, $startedby);
         }
         $aProcess[] = array('PRO_UID' => $aRow['PRO_UID'], 'PRO_TITLE' => $aRow['PRO_TITLE'], 'CANTCASES' => ApplicationPeer::doCount($oCriteria), 'MIN' => number_format($aRow['MIN'], 2), 'MAX' => number_format($aRow['MAX'], 2), 'TOTALDUR' => number_format($aRow['TOTALDUR'], 2), 'PROMEDIO' => number_format($aRow['PROMEDIO'], 2));
         $oDataset->next();
     }
     global $_DBArray;
     $_DBArray['reports'] = $aProcess;
     $_SESSION['_DBArray'] = $_DBArray;
     G::LoadClass('ArrayPeer');
     $oCriteria = new Criteria('dbarray');
     $oCriteria->setDBArrayTable('reports');
     return $oCriteria;
 }
Esempio n. 20
0
 /**
  * Get a paginated list of application uids from database.
  *
  * @param integer $skip
  *          the offset from where to return the application records
  * @param integer $pagesize
  *          the size of the page
  * @return array of application id's in the specified page.
  */
 public function getPagedApplicationUids($skip, $pagesize)
 {
     $c = new Criteria();
     $c->addSelectColumn(ApplicationPeer::APP_UID);
     $c->setOffset($skip);
     $c->setLimit($pagesize);
     $rs = ApplicationPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $rs->next();
     $row = $rs->getRow();
     $appUIds = array();
     while (is_array($row)) {
         $appUIds[] = $row;
         $rs->next();
         $row = $rs->getRow();
     }
     return $appUIds;
 }
Esempio n. 21
0
 public function getCasesCountForProcess($pro_uid)
 {
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn('COUNT(*) AS TOTAL_CASES');
     $oCriteria->add(ApplicationPeer::PRO_UID, $pro_uid);
     $oDataset = ApplicationPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $cases = $oDataset->getRow();
     return (int) $cases['TOTAL_CASES'];
 }
Esempio n. 22
0
    /**
     * Check if the user has permissions
     *
     * @param string $applicationUid Unique id of Case
     * @param string $delIndex       Delegation index
     * @param string $userUid        Unique id of User
     * @param string $appDocumentUid
     *
     * return void Throw exception the user does not have permission to delete
     */
    public function throwExceptionIfHaventPermissionToDelete($applicationUid, $delIndex, $userUid, $appDocumentUid)
    {
        try {
            //Verify data inbox
            $case = new \ProcessMaker\BusinessModel\Cases();
            $arrayResult = $case->getStatusInfo($applicationUid, $delIndex, $userUid);

            $flagInbox = 1;

            if (empty($arrayResult) || !preg_match("/^(?:TO_DO|DRAFT)$/", $arrayResult["APP_STATUS"])) {
                $flagInbox = 0;
            }

            //Verify data permission
            $flagPermission = 0;

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

            $criteria->addSelectColumn(\AppDocumentPeer::DOC_UID);

            $criteria->add(\AppDocumentPeer::APP_DOC_UID, $appDocumentUid, \Criteria::EQUAL);
            $criteria->add(\AppDocumentPeer::APP_UID, $applicationUid, \Criteria::EQUAL);
            $criteria->add(\AppDocumentPeer::APP_DOC_TYPE, "OUTPUT", \Criteria::EQUAL);

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

            if ($rsCriteria->next()) {
                $row = $rsCriteria->getRow();

                $outputDocumentUid = $row["DOC_UID"];

                $application = \ApplicationPeer::retrieveByPK($applicationUid);

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

                $criteria2->addSelectColumn(\ObjectPermissionPeer::OP_UID);

                $criteria2->add(\ObjectPermissionPeer::PRO_UID, $application->getProUid(), \Criteria::EQUAL);
                $criteria2->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "OUTPUT", \Criteria::EQUAL);
                $criteria2->add(
                    $criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, $outputDocumentUid, \Criteria::EQUAL)->addOr(
                    $criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "0", \Criteria::EQUAL))->addOr(
                    $criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "", \Criteria::EQUAL))
                );
                $criteria2->add(\ObjectPermissionPeer::OP_ACTION, "DELETE", \Criteria::EQUAL);

                //User
                $criteriaU = clone $criteria2;

                $criteriaU->add(\ObjectPermissionPeer::OP_USER_RELATION, 1, \Criteria::EQUAL);
                $criteriaU->add(\ObjectPermissionPeer::USR_UID, $userUid, \Criteria::EQUAL);

                $rsCriteriaU = \ObjectPermissionPeer::doSelectRS($criteriaU);
                $rsCriteriaU->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

                if ($rsCriteriaU->next()) {
                    $flagPermission = 1;
                }

                //Group
                if ($flagPermission == 0) {
                    $criteriaG = clone $criteria2;

                    $criteriaG->add(\ObjectPermissionPeer::OP_USER_RELATION, 2, \Criteria::EQUAL);

                    $criteriaG->addJoin(\ObjectPermissionPeer::USR_UID, \GroupUserPeer::GRP_UID, \Criteria::LEFT_JOIN);
                    $criteriaG->add(\GroupUserPeer::USR_UID, $userUid, \Criteria::EQUAL);

                    $rsCriteriaG = \ObjectPermissionPeer::doSelectRS($criteriaG);
                    $rsCriteriaG->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

                    if ($rsCriteriaG->next()) {
                        $flagPermission = 1;
                    }
                }
            }

            if ($flagInbox == 1) {
                if ($flagPermission == 0) {
                    throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_OUTPUT_DOCUMENT", array($userUid)));
                }
            } else {
                if ($flagPermission == 0) {
                    throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_OUTPUT_DOCUMENT", array($userUid)));
                }
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
Esempio n. 23
0
 function getDatasetCasesByProcess()
 {
     $dataSet = new XYDataSet();
     $processObj = new Process();
     $c = new Criteria('workflow');
     $c->clearSelectColumns();
     $c->addSelectColumn(ApplicationPeer::PRO_UID);
     $c->addSelectColumn('COUNT(*) AS CANT');
     //$c->addJoin( ProcessPeer::PRO_UID, ProcessPeer::PRO_UID, Criteria::LEFT_JOIN);
     $c->addGroupByColumn(ApplicationPeer::PRO_UID);
     $rs = ApplicationPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $rs->next();
     $row = $rs->getRow();
     while (is_array($row)) {
         $processObj->load($row['PRO_UID']);
         $label = $processObj->getProTitle();
         $value = $row['CANT'];
         $dataSet->addPoint(new Point($label, (int) $value));
         $rs->next();
         $row = $rs->getRow();
     }
     return $dataSet;
 }
Esempio n. 24
0
 public function userParticipatedInCase($sAppUid, $sUIDUserLogged)
 {
     $c = new Criteria('workflow');
     $c->addSelectColumn(AppDelegationPeer::APP_UID);
     $c->add(AppDelegationPeer::APP_UID, $sAppUid);
     $c->add(AppDelegationPeer::USR_UID, $sUIDUserLogged);
     $rs = ApplicationPeer::doSelectRS($c);
     $count = 0;
     while ($rs->next()) {
         $count++;
     }
     return $count;
 }
Esempio n. 25
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *     rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ApplicationPeer::APP_UID, $pks, Criteria::IN);
         $objs = ApplicationPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 public function deleteProcess($sProcessUID)
 {
     try {
         G::LoadClass('case');
         G::LoadClass('reportTables');
         //Instance all classes necesaries
         $oProcess = new Process();
         $oDynaform = new Dynaform();
         $oInputDocument = new InputDocument();
         $oOutputDocument = new OutputDocument();
         $oTrigger = new Triggers();
         $oRoute = new Route();
         $oGateway = new Gateway();
         $oEvent = new Event();
         $oSwimlaneElement = new SwimlanesElements();
         $oConfiguration = new Configuration();
         $oDbSource = new DbSource();
         $oReportTable = new ReportTables();
         $oCaseTracker = new CaseTracker();
         $oCaseTrackerObject = new CaseTrackerObject();
         //Delete the applications of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID);
         $oDataset = ApplicationPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $oCase = new Cases();
         while ($aRow = $oDataset->getRow()) {
             $oCase->removeCase($aRow['APP_UID']);
             $oDataset->next();
         }
         //Delete the tasks of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
         $oDataset = TaskPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $this->deleteTask($aRow['TAS_UID']);
             $oDataset->next();
         }
         //Delete the dynaforms of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
         $oDataset = DynaformPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oDynaform->remove($aRow['DYN_UID']);
             $oDataset->next();
         }
         //Delete the input documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oInputDocument->remove($aRow['INP_DOC_UID']);
             $oDataset->next();
         }
         //Delete the output documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oOutputDocument->remove($aRow['OUT_DOC_UID']);
             $oDataset->next();
         }
         //Delete the triggers of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
         $oDataset = TriggersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oTrigger->remove($aRow['TRI_UID']);
             $oDataset->next();
         }
         //Delete the routes of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
         $oDataset = RoutePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oRoute->remove($aRow['ROU_UID']);
             $oDataset->next();
         }
         //Delete the gateways of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
         $oDataset = GatewayPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oGateway->remove($aRow['GAT_UID']);
             $oDataset->next();
         }
         //Delete the Event of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(EventPeer::PRO_UID, $sProcessUID);
         $oDataset = EventPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oEvent->remove($aRow['EVN_UID']);
             $oDataset->next();
         }
         //Delete the swimlanes elements of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
         $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oSwimlaneElement->remove($aRow['SWI_UID']);
             $oDataset->next();
         }
         //Delete the configurations of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::PRO_UID, $sProcessUID);
         $oDataset = ConfigurationPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
             $oDataset->next();
         }
         //Delete the DB sources of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID);
         $oDataset = DbSourcePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             /**
              * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
              * in order to solve the bug 0004389, we use the validation function Exists
              * inside the remove function in order to verify if the DbSource record
              * exists in the Database, however there is a strange behavior within the
              * propel engine, when the first record is erased somehow the "_deleted"
              * attribute of the next row is set to true, so when propel tries to erase
              * it, obviously it can't and trows an error. With the "Exist" function
              * we ensure that if there is the record in the database, the _delete attribute must be false.
              *
              * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
              * I have just identified the source of the issue, when is created a $oDbSource DbSource object
              * it's used whenever a record is erased or removed in the db, however the problem
              * it's that the same object is used every time, and the delete method invoked
              * sets the _deleted attribute to true when its called, of course as we use
              * the same object, the first time works fine but trowns an error with the
              * next record, cos it's the same object and the delete method checks if the _deleted
              * attribute it's true or false, the attrib _deleted is setted to true the
              * first time and later is never changed, the issue seems to be part of
              * every remove function in the model classes, not only DbSource
              * i recommend that a more general solution must be achieved to resolve
              * this issue in every model class, to prevent future problems.
              */
             $oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
             $oDataset->next();
         }
         //Delete the supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
         ProcessUserPeer::doDelete($oCriteria);
         //Delete the object permissions
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
         ObjectPermissionPeer::doDelete($oCriteria);
         //Delete the step supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
         StepSupervisorPeer::doDelete($oCriteria);
         //Delete the report tables
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
         $oDataset = ReportTablePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oReportTable->deleteReportTable($aRow['REP_TAB_UID']);
             $oDataset->next();
         }
         //Delete case tracker configuration
         $oCaseTracker->remove($sProcessUID);
         //Delete case tracker objects
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
         ProcessUserPeer::doDelete($oCriteria);
         //Delete the process
         try {
             $oProcess->remove($sProcessUID);
         } catch (Exception $oError) {
             //nada
         }
         return true;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Esempio n. 27
0
        $aTypes = array('to_do', 'draft', 'cancelled', 'sent', 'paused', 'completed', 'selfservice', 'to_revise', 'to_reassign');
        $aTypesID = array('to_do' => 'CASES_INBOX', 'draft' => 'CASES_DRAFT', 'cancelled' => 'CASES_CANCELLED', 'sent' => 'CASES_SENT', 'paused' => 'CASES_PAUSED', 'completed' => 'CASES_COMPLETED', 'selfservice' => 'CASES_SELFSERVICE', 'to_revise' => 'CASES_TO_REVISE', 'to_reassign' => 'CASES_TO_REASSIGN');
        if (!isset($_POST['A'])) {
            $oCases = new Cases();
            $aCount = $oCases->getAllConditionCasesCount($aTypes, true);
            echo Bootstrap::json_encode($aCount);
        } else {
            echo Bootstrap::json_encode($aTypesID);
        }
        break;
    case "previusJump":
        //require_once 'classes/model/Application.php';
        $oCriteria = new Criteria('workflow');
        $response = array("success" => true);
        $oCriteria->add(ApplicationPeer::APP_NUMBER, $_POST['appNumber']);
        $oDataset = ApplicationPeer::doSelectRS($oCriteria);
        $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $oDataset->next();
        $aApplication = $oDataset->getRow();
        if (is_array($aApplication)) {
            $response['exists'] = true;
        } else {
            $response['exists'] = false;
        }
        echo Bootstrap::json_encode($response);
        break;
    default:
        echo 'default';
}
function getCasesTypeIds()
{
 /**
  * Will return all the information of a WS.
  * - Status
  * - # of cases
  * - # of processes
  * - # of users
  * @param string $wsName
  * @return array
  */
 function getWorkspaceInfo($wsName)
 {
     $aResult = array('num_processes' => '0', 'num_cases' => '0');
     $result = array();
     require_once 'classes/model/Process.php';
     require_once 'classes/model/Application.php';
     require_once 'classes/model/Users.php';
     $Criteria = new Criteria('workflow');
     $Criteria->add(ProcessPeer::PRO_STATUS, 'ACTIVE', CRITERIA::EQUAL);
     $aResult['num_processes'] = ProcessPeer::doCount($Criteria);
     $Criteria = new Criteria('workflow');
     $Criteria->add(ApplicationPeer::APP_STATUS, 'COMPLETED', CRITERIA::NOT_EQUAL);
     $aResult['num_cases'] = ApplicationPeer::doCount($Criteria);
     $Criteria = new Criteria('workflow');
     $Criteria->add(UsersPeer::USR_STATUS, array('DELETED', 'DISABLED'), CRITERIA::NOT_IN);
     $aResult['num_users'] = UsersPeer::doCount($Criteria);
     return $aResult;
 }
Esempio n. 29
0
 function getStatusArray($action, $userUid)
 {
     global $oAppCache;
     $status = array();
     $status[] = array('', G::LoadTranslation('ID_ALL_STATUS'));
     //get the list based in the action provided
     switch ($action) {
         case 'sent':
             $cStatus = $oAppCache->getSentListProcessCriteria($userUid);
             // a little slow
             break;
         case 'simple_search':
         case 'search':
             $cStatus = new Criteria('workflow');
             $cStatus->clearSelectColumns();
             $cStatus->setDistinct();
             $cStatus->addSelectColumn(ApplicationPeer::APP_STATUS);
             $oDataset = ApplicationPeer::doSelectRS($cStatus);
             $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             $oDataset->next();
             while ($aRow = $oDataset->getRow()) {
                 $status[] = array($aRow['APP_STATUS'], G::LoadTranslation('ID_CASES_STATUS_' . $aRow['APP_STATUS']));
                 //here we can have a translation for the status ( the second param)
                 $oDataset->next();
             }
             return $status;
             break;
         case 'selfservice':
             $cStatus = $oAppCache->getUnassignedListCriteria($userUid);
             break;
         case 'paused':
             $cStatus = $oAppCache->getPausedListCriteria($userUid);
             break;
         case 'to_revise':
             $cStatus = $oAppCache->getToReviseListCriteria($userUid);
             //           $cStatus       = $oAppCache->getPausedListCriteria($userUid);
             break;
         case 'to_reassign':
             $cStatus = $oAppCache->getToReassignListCriteria($userUid);
             break;
         case 'todo':
         case 'draft':
         case 'gral':
             //      case 'to_revise' :
         //      case 'to_revise' :
         default:
             return $status;
             break;
     }
     //get the status for this user in this action only for participated, unassigned, paused
     //    if ( $action != 'todo' && $action != 'draft' && $action != 'to_revise') {
     if ($action != 'todo' && $action != 'draft') {
         //$cStatus = new Criteria('workflow');
         $cStatus->clearSelectColumns();
         $cStatus->setDistinct();
         $cStatus->addSelectColumn(AppCacheViewPeer::APP_STATUS);
         $oDataset = AppCacheViewPeer::doSelectRS($cStatus);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $status[] = array($aRow['APP_STATUS'], G::LoadTranslation('ID_CASES_STATUS_' . $aRow['APP_STATUS']));
             //here we can have a translation for the status ( the second param)
             $oDataset->next();
         }
     }
     return $status;
 }
Esempio n. 30
0
 /**
  * Check if the user is Supervisor
  *
  * @param string $applicationUid Unique id of Case
  * @param string $userUid        Unique id of User
  *
  * return array Return data of input documents
  */
 public function getCasesInputDocumentsBySupervisor($applicationUid, $userUid)
 {
     try {
         //Verify data Supervisor
         $application = \ApplicationPeer::retrieveByPK($applicationUid);
         $flagSupervisor = 0;
         $supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
         $processSupervisor = $supervisor->getProcessSupervisors($application->getProUid(), "ASSIGNED");
         $arraySupervisor = $processSupervisor["data"];
         foreach ($arraySupervisor as $value) {
             if (!empty($value["usr_uid"]) && $value["usr_uid"] == $userUid) {
                 $flagSupervisor = 1;
                 break;
             }
         }
         $user = new \Users();
         $appDocument = new \AppDocument();
         $configuraction = new \Configurations();
         $confEnvSetting = $configuraction->getFormats();
         $arrayInputDocument = array();
         //Query
         $criteria = $this->getAppDocumentCriteriaByData($applicationUid);
         $rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         /*----------------------------------********---------------------------------*/
         $licensedFeatures =& \PMLicensedFeatures::getSingleton();
         $enablePMGmail = false;
         if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
             \G::LoadClass("pmDrive");
             $pmDrive = new \PMDrive();
             $enablePMGmail = $pmDrive->getStatusService();
         }
         /*----------------------------------********---------------------------------*/
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $arrayUserData = $user->load($row["USR_UID"]);
             $arrayAppDocument = $appDocument->load($row["APP_DOC_UID"], $row["DOC_VERSION"]);
             $row["APP_DOC_FILENAME"] = $arrayAppDocument["APP_DOC_FILENAME"];
             $row["APP_DOC_CREATE_USER"] = $configuraction->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
             $row["APP_DOC_LINK"] = "cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
             /*----------------------------------********---------------------------------*/
             //change donwload link - drive
             $driveDownload = @unserialize($arrayAppDocument['APP_DOC_DRIVE_DOWNLOAD']);
             if ($driveDownload !== false && is_array($driveDownload) && $enablePMGmail) {
                 if (array_key_exists('INPUT', $driveDownload)) {
                     $row['APP_DOC_LINK'] = $driveDownload['INPUT'];
                 } else {
                     if (array_key_exists('ATTACHED', $driveDownload)) {
                         $row['APP_DOC_LINK'] = $driveDownload['ATTACHED'];
                     }
                 }
             }
             /*----------------------------------********---------------------------------*/
             $arrayInputDocument[] = $this->getAppDocumentDataFromRecord($row);
         }
         if (!empty($arrayInputDocument) && $flagSupervisor == 0) {
             throw new \Exception(\G::LoadTranslation("ID_USER_IS_NOT_SUPERVISOR"));
         }
         //Return
         return $arrayInputDocument;
     } catch (\Exception $e) {
         throw $e;
     }
 }