Esempio n. 1
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. 2
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. 3
0
 /**
  * Method to do selects.
  *
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param      Connection $con
  * @return     array Array of selected Objects
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function doSelect(Criteria $criteria, $con = null)
 {
     return ApplicationPeer::populateObjects(ApplicationPeer::doSelectRS($criteria, $con));
 }
Esempio n. 4
0
 /**
  * Get new sequece number
  *
  * @param type $seqName
  * @return type
  * @throws type
  */
 public function getSequeceNumber($seqName)
 {
     $c = new Criteria();
     $c->clearSelectColumns();
     try {
         if ($this->nameExists("APP_NUMBER")) {
             $aSequence = $this->load($seqName);
             $nSeqValue = $aSequence['SEQ_VALUE'] + 1;
         } else {
             $c->addSelectColumn('MAX(' . ApplicationPeer::APP_NUMBER . ')');
             //the appnumber is based in all processes
             //active, not only in the specified
             //process guid
             $result = ApplicationPeer::doSelectRS($c);
             $result->next();
             $row = $result->getRow();
             $nSeqValue = $row[0] + 1;
         }
         return $nSeqValue;
     } catch (Exception $e) {
         throw $e;
     }
 }
 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. 6
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. 7
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()
{
Esempio n. 8
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();
 }
        */
        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
    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. 11
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. 12
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. 13
0
 /** to show the cases grouped by Process */
 function getCasesByProcess()
 {
     $dataSet = array();
     $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();
         $labelPie[] = substr($processObj->getProTitle(), 0, 16);
         $data[] = (int) $row['CANT'];
         $rs->next();
         $row = $rs->getRow();
     }
     $dataSet['data'] = $data;
     $dataSet['label'] = $label;
     $dataSet['labelPie'] = $labelPie;
     $max = 1;
     foreach ($dataSet['data'] as $k => $val) {
         if ($val > $max) {
             $max = $val;
         }
     }
     $aux = intval($max / 6) * 6 + 6;
     $dataSet['max'] = $aux;
     return $dataSet;
 }
Esempio n. 14
0
 public function newRow($data, $delPreviusUsrUid)
 {
     $data['UNA_UID'] = isset($data['UNA_UID']) ? $data['UNA_UID'] : G::GenerateUniqueId();
     $data['DEL_PREVIOUS_USR_UID'] = $delPreviusUsrUid;
     $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['APP_PREVIOUS_USR_USERNAME'] = $aRow['USR_USERNAME'];
         $data['APP_PREVIOUS_USR_FIRSTNAME'] = $aRow['USR_FIRSTNAME'];
         $data['APP_PREVIOUS_USR_LASTNAME'] = $aRow['USR_LASTNAME'];
     }
     self::create($data);
     return $data['UNA_UID'];
 }
Esempio n. 15
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. 16
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;
     }
 }
 /**
  * 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. 18
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. 19
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. 20
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. 21
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. 22
0
 /**
  * Get data of Cases OutputDocument
  *
  * @param string $applicationUid
  * @param string $outputDocumentUid
  * @param string $userUid
  *
  * return object Return an object with data of an OutputDocument
  */
 public function addCasesOutputDocument($applicationUid, $outputDocumentUid, $userUid)
 {
     try {
         $sApplication = $applicationUid;
         $index = \AppDelegation::getCurrentIndex($applicationUid);
         $sUserLogged = $userUid;
         $outputID = $outputDocumentUid;
         $g = new \G();
         $g->sessionVarSave();
         \G::LoadClass('case');
         $oCase = new \Cases();
         $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs');
         //require_once 'classes/model/OutputDocument.php';
         $oOutputDocument = new \OutputDocument();
         $aOD = $oOutputDocument->load($outputID);
         $Fields = $oCase->loadCase($sApplication);
         $sFilename = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
         require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php";
         require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php";
         //Get the Custom Folder ID (create if necessary)
         $oFolder = new \AppFolder();
         $folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication);
         //Tags
         $fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication);
         //Get last Document Version and apply versioning if is enabled
         $oAppDocument = new \AppDocument();
         $lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication);
         $oCriteria = new \Criteria('workflow');
         $oCriteria->add(\AppDocumentPeer::APP_UID, $sApplication);
         $oCriteria->add(\AppDocumentPeer::DOC_UID, $outputID);
         $oCriteria->add(\AppDocumentPeer::DOC_VERSION, $lastDocVersion);
         $oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
         $oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         if ($aOD['OUT_DOC_VERSIONING'] && $lastDocVersion != 0) {
             //Create new Version of current output
             $lastDocVersion++;
             if ($aRow = $oDataset->getRow()) {
                 $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion + 1, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags);
                 $oAppDocument = new \AppDocument();
                 $oAppDocument->create($aFields);
                 $sDocUID = $aRow['APP_DOC_UID'];
             }
         } else {
             ////No versioning so Update a current Output or Create new if no exist
             if ($aRow = $oDataset->getRow()) {
                 //Update
                 $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags);
                 $oAppDocument = new \AppDocument();
                 $oAppDocument->update($aFields);
                 $sDocUID = $aRow['APP_DOC_UID'];
             } else {
                 //we are creating the appdocument row
                 //create
                 if ($lastDocVersion == 0) {
                     $lastDocVersion++;
                 }
                 $aFields = array('APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags);
                 $oAppDocument = new \AppDocument();
                 $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields);
             }
         }
         $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
         $pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP;
         //G::pr($sFilename);die;
         \G::mk_dir($pathOutput);
         $aProperties = array();
         if (!isset($aOD['OUT_DOC_MEDIA'])) {
             $aOD['OUT_DOC_MEDIA'] = 'Letter';
         }
         if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) {
             $aOD['OUT_DOC_LEFT_MARGIN'] = '15';
         }
         if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) {
             $aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
         }
         if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) {
             $aOD['OUT_DOC_TOP_MARGIN'] = '15';
         }
         if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) {
             $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
         }
         $aProperties['media'] = $aOD['OUT_DOC_MEDIA'];
         $aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']);
         if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) {
             $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR'];
         }
         $this->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (bool) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties, $applicationUid);
         /*----------------------------------********---------------------------------*/
         $licensedFeatures =& \PMLicensedFeatures::getSingleton();
         if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
             \G::LoadClass("pmDrive");
             $pmDrive = new \PMDrive();
             if ($pmDrive->getStatusService()) {
                 $app = new \Application();
                 $user = new \Users();
                 $dataUser = $user->load($userUid);
                 $pmDrive->setDriveUser($dataUser['USR_EMAIL']);
                 $appData = $app->Load($applicationUid);
                 if ($appData['APP_DRIVE_FOLDER_UID'] == null) {
                     $process = new \Process();
                     $process->setProUid($appData['PRO_UID']);
                     $result = $pmDrive->createFolder($process->getProTitle() . ' - ' . G::LoadTranslation("ID_CASE") . ' #' . $appData['APP_NUMBER'], $pmDrive->getFolderIdPMDrive($userUid));
                     $appData['APP_DRIVE_FOLDER_UID'] = $result->id;
                     $app->update($appData);
                 }
                 $fileIdDriveDoc = '';
                 $fileIdDrivePdf = '';
                 $sFilenameOriginal = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
                 switch ($aOD['OUT_DOC_GENERATE']) {
                     case "BOTH":
                         $result = $pmDrive->uploadFile('application/pdf', $pathOutput . $sFilename . '.pdf', $sFilenameOriginal . '.pdf', $appData['APP_DRIVE_FOLDER_UID']);
                         $oAppDocument->setDriveDownload('OUTPUT_PDF', $result->webContentLink);
                         $fileIdDrivePdf = $result->id;
                         $result = $pmDrive->uploadFile('application/doc', $pathOutput . $sFilename . '.doc', $sFilenameOriginal . '.doc', $appData['APP_DRIVE_FOLDER_UID']);
                         $oAppDocument->setDriveDownload('OUTPUT_DOC', $result->webContentLink);
                         $fileIdDriveDoc = $result->id;
                         break;
                     case "PDF":
                         $result = $pmDrive->uploadFile('application/pdf', $pathOutput . $sFilename . '.pdf', $sFilenameOriginal . '.pdf', $appData['APP_DRIVE_FOLDER_UID']);
                         $oAppDocument->setDriveDownload('OUTPUT_PDF', $result->webContentLink);
                         $fileIdDrivePdf = $result->id;
                         break;
                     case "DOC":
                         $result = $pmDrive->uploadFile('application/doc', $pathOutput . $sFilename . '.doc', $sFilenameOriginal . '.doc', $appData['APP_DRIVE_FOLDER_UID']);
                         $oAppDocument->setDriveDownload('OUTPUT_DOC', $result->webContentLink);
                         $fileIdDriveDoc = $result->id;
                         break;
                 }
                 $aFields['DOC_VERSION'] = $oAppDocument->getDocVersion();
                 // $docVersion;
                 $aFields['APP_DOC_UID'] = $oAppDocument->getAppDocUid();
                 //$appDocUid;
                 $appDocUid = $aFields['APP_DOC_UID'];
                 $oAppDocument->update($aFields);
                 //$option = 'pmDrive';
                 //add permissions
                 $criteria = new \Criteria('workflow');
                 $criteria->addSelectColumn(\ApplicationPeer::PRO_UID);
                 $criteria->addSelectColumn(\TaskUserPeer::TAS_UID);
                 $criteria->addSelectColumn(\TaskUserPeer::USR_UID);
                 $criteria->addSelectColumn(\TaskUserPeer::TU_RELATION);
                 $criteria->add(\ApplicationPeer::APP_UID, $applicationUid);
                 $criteria->addJoin(\ApplicationPeer::PRO_UID, \TaskPeer::PRO_UID, \Criteria::LEFT_JOIN);
                 $criteria->addJoin(\TaskPeer::TAS_UID, \TaskUserPeer::TAS_UID, \Criteria::LEFT_JOIN);
                 $dataset = \ApplicationPeer::doSelectRS($criteria);
                 $dataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                 $userPermission = array();
                 $case = new \Cases();
                 while ($dataset->next()) {
                     $row = $dataset->getRow();
                     if ($row['TU_RELATION'] == 1) {
                         //users
                         $dataUser = $user->load($row['USR_UID']);
                         if (array_search($dataUser['USR_EMAIL'], $userPermission) === false) {
                             $objectPermissions = $case->getAllObjects($row['PRO_UID'], $applicationUid, $row['TAS_UID'], $row['USR_UID']);
                             if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) {
                                 $userPermission[] = $dataUser['USR_EMAIL'];
                             }
                         }
                     } else {
                         //Groups
                         $criteria = new \Criteria('workflow');
                         $criteria->addSelectColumn(\UsersPeer::USR_EMAIL);
                         $criteria->addSelectColumn(\UsersPeer::USR_UID);
                         $criteria->add(\GroupUserPeer::GRP_UID, $row['USR_UID']);
                         $criteria->addJoin(\GroupUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
                         $oDataset = \AppDelegationPeer::doSelectRS($criteria);
                         $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                         while ($oDataset->next()) {
                             $aRow = $oDataset->getRow();
                             if (array_search($aRow['USR_EMAIL'], $userPermission) === false) {
                                 $objectPermissions = $case->getAllObjects($row['PRO_UID'], $applicationUid, $row['TAS_UID'], $aRow['USR_UID']);
                                 if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) {
                                     $userPermission[] = $aRow['USR_EMAIL'];
                                 }
                             }
                         }
                     }
                 }
                 $userPermission = array_unique($userPermission);
                 foreach ($userPermission as $key => $val) {
                     $pmDrive->setPermission($appData['APP_DRIVE_FOLDER_UID'], $val, 'user', 'writer');
                     $pmDrive->setPermission($fileIdDrivePdf, $val);
                     $pmDrive->setPermission($fileIdDriveDoc, $val);
                 }
             }
         }
         /*----------------------------------********---------------------------------*/
         //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
         //G::LoadClass('plugin');
         $oPluginRegistry =& \PMPluginRegistry::getSingleton();
         if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
             $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
             $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace;
             $oAppDocument1 = new \AppDocument();
             $oAppDocument1->update($aFields);
             $sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP;
             $oData['APP_UID'] = $sApplication;
             $oData['ATTACHMENT_FOLDER'] = true;
             switch ($aOD['OUT_DOC_GENERATE']) {
                 case "BOTH":
                     $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
                     $documentData->sFileType = "PDF";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink($pathOutput . $sFilename . '.pdf');
                     }
                     $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
                     $documentData->sFileType = "DOC";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink($pathOutput . $sFilename . '.doc');
                     }
                     break;
                 case "PDF":
                     $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion());
                     $documentData->sFileType = "PDF";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink($pathOutput . $sFilename . '.pdf');
                     }
                     break;
                 case "DOC":
                     $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion());
                     $documentData->sFileType = "DOC";
                     $documentData->bUseOutputFolder = true;
                     $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
                     if ($uploadReturn) {
                         //Only delete if the file was saved correctly
                         unlink($pathOutput . $sFilename . '.doc');
                     }
                     break;
             }
         }
         $g->sessionVarRestore();
         $oAppDocument = \AppDocumentPeer::retrieveByPK($aFields['APP_DOC_UID'], $lastDocVersion);
         if ($oAppDocument->getAppDocStatus() == 'DELETED') {
             $oAppDocument->setAppDocStatus('ACTIVE');
             $oAppDocument->save();
         }
         $response = $this->getCasesOutputDocument($applicationUid, $userUid, $aFields['APP_DOC_UID']);
         return $response;
     } catch (\Exception $e) {
         throw $e;
     }
 }