Пример #1
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $addTabUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($addTabUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_NAME);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_CLASS_NAME);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_INSERT);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_UPDATE);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_DELETE);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_LOG_SELECT);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_MAX_LENGTH);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_SDW_AUTO_DELETE);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_PLG_UID);
             $criteria->addSelectColumn(AdditionalTablesPeer::DBS_UID);
             $criteria->addSelectColumn(AdditionalTablesPeer::PRO_UID);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TYPE);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_GRID);
             $criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TAG);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = AdditionalTablesPeer::retrieveByPK($addTabUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table AdditionalTables ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
Пример #2
0
 /**
  *
  *
  * Creates a Dynaform based on a PMTable
  *
  * @name createFromPMTable
  * @author gustavo cruz gustavo[at]colosa[dot]com
  * @param array $aData Fields with :
  * $aData['DYN_UID'] the dynaform id
  * $aData['USR_UID'] the userid
  * string $pmTableUid uid of the PMTable
  *
  */
 public function createFromPMTable($aData, $pmTableUid)
 {
     $this->create($aData);
     $aData['DYN_UID'] = $this->getDynUid();
     //krumo(BasePeer::getFieldnames('Content'));
     $fields = array();
     //$oCriteria = new Criteria('workflow');
     $pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
     $addTabName = $pmTable->getAddTabName();
     $keys = '';
     if (isset($aData['FIELDS'])) {
         foreach ($aData['FIELDS'] as $iRow => $row) {
             if ($keys != '') {
                 $keys = $keys . '|' . $row['PRO_VARIABLE'];
             } else {
                 $keys = $row['PRO_VARIABLE'];
             }
         }
     } else {
         $keys = ' ';
     }
     //      $addTabKeys = $pmTable->getAddTabDynavars();
     //      $addTabKeys = unserialize($addTabKeys);
     //      $keys = '';
     //      foreach ( $addTabKeys as $addTabKey ){
     //        if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
     //            $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
     //        } else {
     //            $keys = $addTabKey['CASE_VARIABLE'];
     //        }
     //
     //      }
     // Determines the engine to use
     // For a description of a table
     $sDataBase = 'database_' . strtolower(DB_ADAPTER);
     if (G::LoadSystemExist($sDataBase)) {
         G::LoadSystem($sDataBase);
         $oDataBase = new database();
         $sql = $oDataBase->getTableDescription($addTabName);
     } else {
         $sql = 'DESC ' . $addTabName;
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $file = $aData['PRO_UID'] . '/' . $aData['DYN_UID'];
     $dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
     $ses = new DBSession($dbc);
     $fieldXML = new DynaFormField($dbc);
     $pmConnectionName = $addTabName . '_CONNECTION';
     if ($aData['DYN_TYPE'] == 'xmlform') {
         $labels = array();
         $options = array();
         $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS' => $keys);
         $fieldXML->Save($attributes, $labels, $options);
     }
     $keyRequered = '';
     $countKeys = 0;
     while ($res->next()) {
         if ($res->get('Key') != '') {
             $countKeys++;
         }
         if ($res->get('Extra') == 'auto_increment') {
             $keyRequered .= $res->get('Field');
         }
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     while ($res->next()) {
         // if(strtoupper($res->get('Null'))=='NO') {
         if (strtoupper($res->get($oDataBase->getFieldNull())) == 'NO') {
             if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
                 $required = '0';
             } else {
                 $required = '1';
             }
         } else {
             $required = '0';
         }
         $fieldName = $res->get('Field');
         $defaultValue = $res->get('Default');
         $labels = array(SYS_LANG => $fieldName);
         $options = array();
         $type = explode('(', $res->get('Type'));
         switch ($type[0]) {
             case 'text':
                 $type = 'textarea';
                 break;
             case 'date':
                 $type = 'date';
                 break;
             default:
                 $type = 'text';
                 break;
         }
         if ($aData['DYN_TYPE'] == 'xmlform') {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'PMCONNECTION' => $pmConnectionName, 'PMFIELD' => $fieldName, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         } else {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         }
         $fieldXML->Save($attributes, $labels, $options);
     }
     $labels = array(SYS_LANG => 'Submit');
     $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => 'SUBMIT', 'TYPE' => 'submit');
     $fieldXML->Save($attributes, $labels, $options);
 }
Пример #3
0
    public function remove($sUID)
    {
        $oConnection = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
        try {
            $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
            if (!is_null($oAdditionalTables)) {
                $aAdditionalTables = $oAdditionalTables->toArray(BasePeer::TYPE_FIELDNAME);
                $oConnection->begin();
                $iResult = $oAdditionalTables->delete();
                $oConnection->commit();

                return $iResult;
            } else {
                throw(new Exception('This row doesn\'t exist!'));
            }
        } catch (Exception $oError) {
            $oConnection->rollback();
            throw($oError);
        }
    }
Пример #4
0
 /**
  * loads the configuration fields from the database based in an action parameter
  * then assemble the Criteria object with these data.
  * @param  String $action
  * @return Criteria object $Criteria
  */
 public function addPMFieldsToCriteria($action)
 {
     $caseColumns = array();
     if (!class_exists('AdditionalTables')) {
         require_once "classes/model/AdditionalTables.php";
     }
     $caseReaderFields = array();
     $oCriteria = new Criteria('workflow');
     $oCriteria->clearSelectColumns();
     //default configuration fields array
     $defaultFields = $this->getDefaultFields();
     //if there is PMTABLE for this case list:
     if (!empty($this->confCasesList) && isset($this->confCasesList['PMTable']) && trim($this->confCasesList['PMTable']) != '') {
         //getting the table name
         $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($this->confCasesList['PMTable']);
         $tableName = $oAdditionalTables->getAddTabName();
         foreach ($this->confCasesList['second']['data'] as $fieldData) {
             if (!in_array($fieldData['name'], $defaultFields)) {
                 $fieldName = $tableName . '.' . $fieldData['name'];
                 $oCriteria->addSelectColumn($fieldName);
             } else {
                 switch ($fieldData['fieldType']) {
                     case 'case field':
                         $configTable = 'APP_CACHE_VIEW';
                         break;
                     case 'delay field':
                         $configTable = 'APP_DELAY';
                         break;
                     default:
                         $configTable = 'APP_CACHE_VIEW';
                         break;
                 }
                 $fieldName = $configTable . '.' . $fieldData['name'];
                 $oCriteria->addSelectColumn($fieldName);
             }
         }
         //add the default and hidden DEL_INIT_DATE
         $oCriteria->addSelectColumn('APP_CACHE_VIEW.DEL_INIT_DATE');
         //$oCriteria->addAlias("PM_TABLE", $tableName);
         //Add the JOIN
         $oCriteria->addJoin(AppCacheViewPeer::APP_UID, $tableName . '.APP_UID', Criteria::LEFT_JOIN);
         return $oCriteria;
     } else {
         //else this list do not have a PM Table
         if (is_array($this->confCasesList) && !empty($this->confCasesList['second']['data'])) {
             foreach ($this->confCasesList['second']['data'] as $fieldData) {
                 switch ($fieldData['fieldType']) {
                     case 'case field':
                         $configTable = 'APP_CACHE_VIEW';
                         break;
                     case 'delay field':
                         $configTable = 'APP_DELAY';
                         break;
                     default:
                         $configTable = 'APP_CACHE_VIEW';
                         break;
                 }
                 $fieldName = $configTable . '.' . $fieldData['name'];
                 $oCriteria->addSelectColumn($fieldName);
             }
         } else {
             //foreach ($defaultFields as $field) {
             $oCriteria->addSelectColumn('*');
             //}
         }
         //add the default and hidden DEL_INIT_DATE
         $oCriteria->addSelectColumn('APP_CACHE_VIEW.DEL_INIT_DATE');
         return $oCriteria;
     }
 }
Пример #5
0
 /**
  *
  *
  * Creates a Dynaform based on a PMTable
  *
  * @name createFromPMTable
  * @author gustavo cruz gustavo[at]colosa[dot]com
  * @param array $aData Fields with :
  * $aData['DYN_UID'] the dynaform id
  * $aData['USR_UID'] the userid
  * string $pmTableUid uid of the PMTable
  *
  */
 public function createFromPMTable($aData, $pmTableUid)
 {
     $this->create($aData, $pmTableUid);
     $aData['DYN_UID'] = $this->getDynUid();
     //krumo(BasePeer::getFieldnames('Content'));
     $fields = array();
     //$oCriteria = new Criteria('workflow');
     $pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
     $addTabName = $pmTable->getAddTabName();
     $keys = '';
     if (isset($aData['FIELDS'])) {
         foreach ($aData['FIELDS'] as $iRow => $row) {
             if ($keys != '') {
                 $keys = $keys . '|' . $row['PRO_VARIABLE'];
             } else {
                 $keys = $row['PRO_VARIABLE'];
             }
         }
     } else {
         $keys = ' ';
     }
     //      $addTabKeys = $pmTable->getAddTabDynavars();
     //      $addTabKeys = unserialize($addTabKeys);
     //      $keys = '';
     //      foreach ( $addTabKeys as $addTabKey ){
     //        if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
     //            $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
     //        } else {
     //            $keys = $addTabKey['CASE_VARIABLE'];
     //        }
     //
     //      }
     // Determines the engine to use
     // For a description of a table
     $sDataBase = 'database_' . strtolower(DB_ADAPTER);
     if (G::LoadSystemExist($sDataBase)) {
         G::LoadSystem($sDataBase);
         $oDataBase = new database();
         $sql = $oDataBase->getTableDescription($addTabName);
     } else {
         $sql = 'DESC ' . $addTabName;
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $file = $aData['PRO_UID'] . '/' . $aData['DYN_UID'];
     $dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
     $ses = new DBSession($dbc);
     $fieldXML = new DynaFormField($dbc);
     $pmConnectionName = $addTabName . '_CONNECTION';
     if ($aData['DYN_TYPE'] == 'xmlform') {
         $labels = array();
         $options = array();
         $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS' => $keys);
         $fieldXML->Save($attributes, $labels, $options);
     }
     $keyRequered = '';
     $countKeys = 0;
     while ($res->next()) {
         if ($res->get('Key') != '') {
             $countKeys++;
         }
         if ($res->get('Extra') == 'auto_increment') {
             $keyRequered .= $res->get('Field');
         }
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     while ($res->next()) {
         // if(strtoupper($res->get('Null'))=='NO') {
         if (strtoupper($res->get($oDataBase->getFieldNull())) == 'NO') {
             if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
                 $required = '0';
             } else {
                 $required = '1';
             }
         } else {
             $required = '0';
         }
         $fieldName = $res->get('Field');
         $defaultValue = $res->get('Default');
         $labels = array(SYS_LANG => $fieldName);
         $options = array();
         $type = explode('(', $res->get('Type'));
         switch ($type[0]) {
             case 'text':
                 $type = 'textarea';
                 break;
             case 'date':
                 $type = 'date';
                 break;
             default:
                 $type = 'text';
                 break;
         }
         if ($aData['DYN_TYPE'] == 'xmlform') {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'PMCONNECTION' => $pmConnectionName, 'PMFIELD' => $fieldName, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         } else {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         }
         $fieldXML->Save($attributes, $labels, $options);
     }
     $labels = array(SYS_LANG => 'Submit');
     $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => 'SUBMIT', 'TYPE' => 'submit');
     $fieldXML->Save($attributes, $labels, $options);
     //update content if version is 2
     if ($this->getDynVersion() === 2) {
         $items = array();
         $variables = array();
         $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
         while ($res->next()) {
             //data type
             $type = "text";
             $dataType = explode('(', $res->get('Type'));
             error_log(print_r($dataType, true));
             switch ($dataType[0]) {
                 case 'bigint':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'int':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'smallint':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'tinyint':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'decimal':
                     $type = 'text';
                     $dataType = 'float';
                     break;
                 case 'double':
                     $type = 'text';
                     $dataType = 'float';
                     break;
                 case 'float':
                     $type = 'text';
                     $dataType = 'float';
                     break;
                 case 'datetime':
                     $type = 'datetime';
                     $dataType = 'datetime';
                     break;
                 case 'date':
                     $type = 'datetime';
                     $dataType = 'datetime';
                     break;
                 case 'time':
                     $type = 'datetime';
                     $dataType = 'datetime';
                     break;
                 case 'char':
                     $type = 'text';
                     $dataType = 'string';
                     break;
                 case 'varchar':
                     $type = 'text';
                     $dataType = 'string';
                     break;
                 case 'mediumtext':
                     $type = 'textarea';
                     $dataType = 'string';
                     break;
                 default:
                     $type = "text";
                     $dataType = 'string';
                     break;
             }
             //variables
             $arrayData = array("var_name" => $res->get('Field'), "var_label" => $res->get('Field'), "var_field_type" => $dataType, "var_field_size" => 10, "var_null" => 1, "var_dbconnection" => "none", "var_sql" => "", "var_options_control" => "", "var_default" => "", "var_accepted_values" => array());
             $objVariable = new \ProcessMaker\BusinessModel\Variable();
             try {
                 $objVariable->existsName($this->getProUid(), $res->get('Field'));
                 $variable = $objVariable->create($this->getProUid(), $arrayData);
             } catch (\Exception $e) {
                 $data = $objVariable->getVariables($this->getProUid());
                 foreach ($data as $datavariable) {
                     if ($datavariable["var_name"] === $res->get('Field')) {
                         $variable = $datavariable;
                         break;
                     }
                 }
             }
             array_push($variables, $variable);
             array_push($items, array(array("type" => $type, "dataType" => $dataType, "id" => $res->get('Field'), "name" => $res->get('Field'), "label" => $res->get('Field'), "hint" => "", "required" => false, "defaultValue" => "", "dependentFields" => array(), "textTransform" => "none", "validate" => "any", "mask" => "", "maxLength" => 1000, "formula" => "", "mode" => "parent", "var_uid" => $variable["var_uid"], "var_name" => $variable["var_name"], "colSpan" => 12)));
         }
         //submit button
         array_push($items, array(array("type" => "submit", "id" => "FormDesigner-" . \ProcessMaker\Util\Common::generateUID(), "name" => "submit", "label" => "submit", "colSpan" => 12)));
         $json = array("name" => $this->getDynTitle(), "description" => $this->getDynDescription(), "items" => array(array("type" => "form", "id" => $this->getDynUid(), "name" => $this->getDynTitle(), "description" => $this->getDynDescription(), "mode" => "edit", "script" => "", "items" => $items, "variables" => $variables)));
         $aData = $this->Load($this->getDynUid());
         $aData["DYN_CONTENT"] = G::json_encode($json);
         $this->update($aData);
     }
 }
Пример #6
0
    /**

     * loads the configuration fields from the database based in an action parameter

     * then assemble the Criteria object with these data.

     * @param  String $action

     * @return Criteria object $Criteria

     */

    public function addPMFieldsToCriteria($action)

    {

        $caseColumns = array();



        if (!class_exists('AdditionalTables')) {

            require_once ("classes/model/AdditionalTables.php");

        }



        $caseReaderFields = array();

        $oCriteria = new Criteria('workflow');

        $oCriteria->clearSelectColumns();



        //Default configuration fields array

        $defaultFields = $this->getDefaultFields();



        //If there is PMTable for this case list

        if (is_array($this->confCasesList) && count($this->confCasesList) > 0 && isset($this->confCasesList["PMTable"]) && trim($this->confCasesList["PMTable"]) != "") {

            //Getting the table name

            $additionalTableUid = $this->confCasesList["PMTable"];



            $additionalTable = AdditionalTablesPeer::retrieveByPK($additionalTableUid);

            $tableName = $additionalTable->getAddTabName();



            $additionalTable = new AdditionalTables();

            $tableData = $additionalTable->load($additionalTableUid, true);



            $tableField = array();



            foreach ($tableData["FIELDS"] as $arrayField) {

                $tableField[] = $arrayField["FLD_NAME"];

            }



            foreach ($this->confCasesList["second"]["data"] as $fieldData) {

                if (in_array($fieldData["name"], $defaultFields)) {

                    switch ($fieldData["fieldType"]) {

                        case "case field":

                            $configTable = "APP_CACHE_VIEW";

                            break;

                        case "delay field":

                            $configTable = "APP_DELAY";

                            break;

                        default:

                            $configTable = "APP_CACHE_VIEW";

                            break;

                    }



                    $fieldName = $configTable . "." . $fieldData["name"];

                    $oCriteria->addSelectColumn($fieldName);

                } else {

                    if (in_array($fieldData["name"], $tableField)) {

                        $fieldName = $tableName . "." . $fieldData["name"];

                        $oCriteria->addSelectColumn($fieldName);

                    }

                }

            }



            //add the default and hidden DEL_INIT_DATE

            $oCriteria->addSelectColumn('APP_CACHE_VIEW.DEL_INIT_DATE');

            //$oCriteria->addAlias("PM_TABLE", $tableName);



            //Add the JOIN

            $oCriteria->addJoin(AppCacheViewPeer::APP_UID, $tableName.'.APP_UID', Criteria::LEFT_JOIN);



            return $oCriteria;

        } else {

            //This list do not have a PMTable

            if (is_array($this->confCasesList) && isset($this->confCasesList["second"]) && count($this->confCasesList["second"]["data"]) > 0) {

                foreach ($this->confCasesList["second"]["data"] as $fieldData) {

                    if (in_array($fieldData["name"], $defaultFields)) {

                        switch ($fieldData["fieldType"]) {

                            case "case field":

                                $configTable = "APP_CACHE_VIEW";

                                break;

                            case "delay field":

                                $configTable = "APP_DELAY";

                                break;

                            default:

                                $configTable = "APP_CACHE_VIEW";

                                break;

                        }



                        $fieldName = $configTable . "." . $fieldData["name"];

                        $oCriteria->addSelectColumn($fieldName);

                    }

                }

            } else {

                foreach (AppCacheViewPeer::getFieldNames(BasePeer::TYPE_FIELDNAME) as $field) {

                    $oCriteria->addSelectColumn("APP_CACHE_VIEW.$field");

                }

            }



            //add the default and hidden DEL_INIT_DATE

            $oCriteria->addSelectColumn('APP_CACHE_VIEW.DEL_INIT_DATE');



            return $oCriteria;

        }

    }
Пример #7
0
    public function getAll(
        $userUid,
        $start = null,
        $limit = null,
        $action = null,
        $filter = null,
        $search = null,
        $process = null,
        $status = null,
        $type = null,
        $dateFrom = null,
        $dateTo = null,
        $callback = null,
        $dir = null,
        $sort = "APP_CACHE_VIEW.APP_NUMBER",
        $category = null,
        $configuration = true,
        $paged = true
    ) {
        $callback = isset($callback)? $callback : "stcCallback1001";
        $dir = isset($dir)? $dir : "DESC";

        if (isset($sort)) {
            G::LoadClass('phpSqlParser');
            $parser = new PHPSQLParser($sort);
            $sort = $parser->parsed;
            $sort = $sort[''][0];
        }

        $sort = isset($sort)? $sort : "";
        $start = isset($start)? $start : "0";
        $limit = isset($limit)? $limit : "25";
        $filter = isset($filter)? $filter : "";
        $search = isset($search)? $search : "";
        $process = isset($process)? $process : "";
        $category = isset($category)? $category : "";
        $status = isset($status)? $status : "";
        $action = isset($action)? $action : "todo";
        $type = isset($type)? $type : "extjs";
        $dateFrom = isset($dateFrom)? $dateFrom : "";
        $dateTo = isset($dateTo)? $dateTo : "";

        G::LoadClass("BasePeer");
        G::LoadClass("configuration");
        //require_once ("classes/model/AppCacheView.php");
        //require_once ("classes/model/AppDelegation.php");
        //require_once ("classes/model/AdditionalTables.php");
        //require_once ("classes/model/AppDelay.php");
        //require_once ("classes/model/Fields.php");
        //require_once ("classes/model/Users.php");
        //require_once ("classes/model/Process.php");

        $oAppCache = new AppCacheView();

        if ($configuration == true) {
            //get data configuration
            $conf = new Configurations();
            $confCasesList = $conf->getConfiguration("casesList", ($action == "search" || $action == "simple_search")? "search" : $action);
            $oAppCache->confCasesList = $confCasesList;
        }

        $delimiter = DBAdapter::getStringDelimiter();

        // get the action based list
        switch ($action) {
            case "draft":
                $Criteria = $oAppCache->getDraftListCriteria($userUid);
                $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
                break;
            case "sent":
                $Criteria = $oAppCache->getSentListCriteria($userUid);
                $CriteriaCount = $oAppCache->getSentCountCriteria($userUid);

                if (!empty($status)) {
                    $Criteria->add(AppCacheViewPeer::APP_STATUS, $status);
                    $CriteriaCount->add(AppCacheViewPeer::APP_STATUS, $status);
                }
                break;
            case "selfservice":
            case "unassigned":
                //$userUid can't be empty or null
                $Criteria = $oAppCache->getUnassignedListCriteria($userUid);
                $CriteriaCount = $oAppCache->getUnassignedCountCriteria($userUid);
                break;
            case "paused":
                $Criteria = $oAppCache->getPausedListCriteria($userUid);
                $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
                break;
            case "completed":
                $Criteria = $oAppCache->getCompletedListCriteria($userUid);
                $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
                break;
            case "cancelled":
                $Criteria = $oAppCache->getCancelledListCriteria($userUid);
                $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
                break;
            case "search":
                //$Criteria = $oAppCache->getSearchListCriteria();
                //$CriteriaCount = $oAppCache->getSearchCountCriteria();

                switch ($status) {
                    case "TO_DO":
                        $Criteria = $oAppCache->getToDoListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
                        break;
                    case "DRAFT":
                        $Criteria = $oAppCache->getDraftListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
                        break;
                    case "PAUSED":
                        $Criteria = $oAppCache->getPausedListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
                        break;
                    case "CANCELLED":
                        $Criteria = $oAppCache->getCancelledListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
                        break;
                    case "COMPLETED":
                        $Criteria = $oAppCache->getCompletedListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);

                        $Criteria->add (AppCacheViewPeer::DEL_LAST_INDEX,"1");
                        $CriteriaCount->add (AppCacheViewPeer::DEL_LAST_INDEX,"1");
                        break;
                    default:
                        //All status
                        $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
                        $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
                        break;
                }
                break;
            case "simple_search":
                $Criteria = $oAppCache->getSimpleSearchListCriteria();
                $CriteriaCount = $oAppCache->getSimpleSearchCountCriteria();
                break;
            case "to_revise":
                $Criteria = $oAppCache->getToReviseListCriteria($userUid);
                $CriteriaCount = $oAppCache->getToReviseCountCriteria($userUid);
                break;
            case "to_reassign":
                $Criteria = $oAppCache->getToReassignListCriteria($userUid);
                $CriteriaCount = $oAppCache->getToReassignCountCriteria($userUid);
                break;
            case "all":
                $Criteria = $oAppCache->getAllCasesListCriteria($userUid);
                $CriteriaCount = $oAppCache->getAllCasesCountCriteria($userUid);
                break;
            case "gral":
                //General criteria probably will be deprecated
                $Criteria = $oAppCache->getGeneralListCriteria();
                $CriteriaCount = $oAppCache->getGeneralCountCriteria();
                break;
            case "todo":
                $Criteria = $oAppCache->getToDoListCriteria($userUid);
                $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
                break;
            default:
                //All status
                $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
                $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
                break;
        }

        $arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT");

        $Criteria->addJoin(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
        $Criteria->add(TaskPeer::TAS_TYPE, $arrayTaskTypeToExclude, Criteria::NOT_IN);

        $CriteriaCount->addJoin(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
        $CriteriaCount->add(TaskPeer::TAS_TYPE, $arrayTaskTypeToExclude, Criteria::NOT_IN);

        $Criteria->addAlias( 'CU', 'USERS' );
        $Criteria->addJoin( AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN );
        $Criteria->addAsColumn( 'USR_UID', 'CU.USR_UID' );
        $Criteria->addAsColumn( 'USR_FIRSTNAME', 'CU.USR_FIRSTNAME' );
        $Criteria->addAsColumn( 'USR_LASTNAME', 'CU.USR_LASTNAME' );
        $Criteria->addAsColumn( 'USR_USERNAME', 'CU.USR_USERNAME' );

        $CriteriaCount->addAlias( 'CU', 'USERS' );
        $CriteriaCount->addJoin( AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN );
        $CriteriaCount->addAsColumn( 'USR_UID', 'CU.USR_UID' );
        $CriteriaCount->addAsColumn( 'USR_FIRSTNAME', 'CU.USR_FIRSTNAME' );
        $CriteriaCount->addAsColumn( 'USR_LASTNAME', 'CU.USR_LASTNAME' );
        $CriteriaCount->addAsColumn( 'USR_USERNAME', 'CU.USR_USERNAME' );

        //Current delegation
        $appdelcrTableName = AppCacheViewPeer::TABLE_NAME;
        $appdelcrAppTasTitle = "APPDELCR.APP_TAS_TITLE";
        $appdelcrAppTasTitleCount = $appdelcrAppTasTitle;

        switch ($action) {
            case "sent":
                $appdelcrTableName = AppDelegationPeer::TABLE_NAME;
                $appdelcrAppTasTitle = "(SELECT CON_VALUE FROM CONTENT WHERE CON_ID = APPDELCR.TAS_UID AND CON_LANG = " . $delimiter . SYS_LANG . $delimiter . " AND CON_CATEGORY = " . $delimiter . "TAS_TITLE" . $delimiter . ")";
                $appdelcrAppTasTitleCount = "APPDELCR.TAS_UID";
                break;
            case "to_reassign":
                $appdelcrAppTasTitle = "APP_CACHE_VIEW.APP_TAS_TITLE";
                $appdelcrAppTasTitleCount = $appdelcrAppTasTitle;
                break;
        }

        $Criteria->addAsColumn("APPDELCR_APP_TAS_TITLE", $appdelcrAppTasTitle);
        $CriteriaCount->addAsColumn("APPDELCR_APP_TAS_TITLE", $appdelcrAppTasTitleCount);

        $Criteria->addAsColumn("USRCR_USR_UID", "USRCR.USR_UID");
        $Criteria->addAsColumn("USRCR_USR_FIRSTNAME", "USRCR.USR_FIRSTNAME");
        $Criteria->addAsColumn("USRCR_USR_LASTNAME", "USRCR.USR_LASTNAME");
        $Criteria->addAsColumn("USRCR_USR_USERNAME", "USRCR.USR_USERNAME");

        $CriteriaCount->addAsColumn("USRCR_USR_UID", "USRCR.USR_UID");
        $CriteriaCount->addAsColumn("USRCR_USR_FIRSTNAME", "USRCR.USR_FIRSTNAME");
        $CriteriaCount->addAsColumn("USRCR_USR_LASTNAME", "USRCR.USR_LASTNAME");
        $CriteriaCount->addAsColumn("USRCR_USR_USERNAME", "USRCR.USR_USERNAME");

        $Criteria->addAlias("APPDELCR", $appdelcrTableName);
        $Criteria->addAlias("USRCR", UsersPeer::TABLE_NAME);

        $CriteriaCount->addAlias("APPDELCR", $appdelcrTableName);
        $CriteriaCount->addAlias("USRCR", UsersPeer::TABLE_NAME);

        $arrayCondition = array();
        $arrayCondition[] = array(AppCacheViewPeer::APP_UID, "APPDELCR.APP_UID");
        $arrayCondition[] = array("APPDELCR.DEL_LAST_INDEX", 1);
        $Criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
        $CriteriaCount->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);

        $arrayCondition = array();
        $arrayCondition[] = array("APPDELCR.USR_UID", "USRCR.USR_UID");
        $Criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
        $CriteriaCount->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);

        //Previous user

        if (($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "paused" || $action == "to_revise" || $action == "sent") || ($status == "TO_DO" || $status == "DRAFT" || $status == "PAUSED" || $status == "CANCELLED" || $status == "COMPLETED")) {
            $Criteria->addAlias( 'PU', 'USERS' );
            $Criteria->addJoin( AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN );
            $Criteria->addAsColumn( 'PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME' );
            $Criteria->addAsColumn( 'PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME' );
            $Criteria->addAsColumn( 'PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME' );

            $CriteriaCount->addAlias( 'PU', 'USERS' );
            $CriteriaCount->addJoin( AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN );
            $CriteriaCount->addAsColumn( 'PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME' );
            $CriteriaCount->addAsColumn( 'PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME' );
            $CriteriaCount->addAsColumn( 'PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME' );
        }

        /*
        if (! is_array( $confCasesList )) {
            $rows = $this->getDefaultFields( $action );
            $result = $this->genericJsonResponse( '', array (), $rows, 20, '' );
            //$conf->saveObject($result,'casesList',$action,'','','');
        }
        */

        //Add the process filter
        if (!empty($process)) {
            $Criteria->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
            $CriteriaCount->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
        }

        //Add the category filter
        if (!empty($category)) {
            require_once 'classes/model/Process.php';
            $Criteria->addAlias("CP", "PROCESS");
            $Criteria->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
            $Criteria->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
            $Criteria->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");

            $CriteriaCount->addAlias("CP", "PROCESS");
            $CriteriaCount->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
            $CriteriaCount->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
            $CriteriaCount->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");
        }

        // add the user filter
        /*
        if ($user != '') {
            $Criteria->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
            $CriteriaCount->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
        }
        if ($status != '') {
            $Criteria->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
            $CriteriaCount->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
        }
        */

        if ($dateFrom != "") {
            if ($dateTo != "") {
                if ($dateFrom == $dateTo) {
                    $dateSame = $dateFrom;
                    $dateFrom = $dateSame . " 00:00:00";
                    $dateTo = $dateSame . " 23:59:59";
                } else {
                    $dateFrom = $dateFrom . " 00:00:00";
                    $dateTo = $dateTo . " 23:59:59";
                }

                $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) );
                $CriteriaCount->add( $CriteriaCount->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) );
            } else {
                $dateFrom = $dateFrom . " 00:00:00";

                $Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
                $CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
            }
        } elseif ($dateTo != "") {
            $dateTo = $dateTo . " 23:59:59";

            $Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL );
            $CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL );
        }

        //add the filter
        if ($filter != '') {
            switch ($filter) {
                case 'read':
                    $Criteria->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL );
                    $CriteriaCount->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL );
                    break;
                case 'unread':
                    $Criteria->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL );
                    $CriteriaCount->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL );
                    break;
                case 'started':
                    $Criteria->add( AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL );
                    $CriteriaCount->add( AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL );
                    break;
                case 'completed':
                    $Criteria->add( AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL );
                    $CriteriaCount->add( AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL );
                    break;
            }
        }

        //Add the search filter
        if ($search != '') {
            $oTmpCriteria = '';

            //If there is PMTable for this case list
            if (is_array($oAppCache->confCasesList) && count($oAppCache->confCasesList) > 0 && isset($oAppCache->confCasesList["PMTable"]) && trim($oAppCache->confCasesList["PMTable"]) != "") {
                //Default configuration fields array
                $defaultFields = $oAppCache->getDefaultFields();

                //Getting the table name
                $additionalTableUid = $oAppCache->confCasesList["PMTable"];

                $additionalTable = AdditionalTablesPeer::retrieveByPK($additionalTableUid);
                $tableName = $additionalTable->getAddTabName();

                $additionalTable = new AdditionalTables();
                $tableData = $additionalTable->load($additionalTableUid, true);

                $tableField = array();

                foreach ($tableData["FIELDS"] as $arrayField) {
                    $tableField[] = $arrayField["FLD_NAME"];
                }

                $oNewCriteria = new Criteria("workflow");
                $sw = 0;

                foreach ($oAppCache->confCasesList["second"]["data"] as $fieldData) {
                    if (!in_array($fieldData["name"], $defaultFields)) {
                        if (in_array($fieldData["name"], $tableField)) {
                            $fieldName = $tableName . "." . $fieldData["name"];

                            if ($sw == 0) {
                                $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, "%" . $search . "%", Criteria::LIKE);
                            } else {
                                $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, "%" . $search . "%", Criteria::LIKE)->addOr($oTmpCriteria);
                            }

                            $sw = 1;
                        }
                    }
                }

                //add the default and hidden DEL_INIT_DATE
            }

            // the criteria adds new fields if there are defined PM Table Fields in the cases list
            if ($oTmpCriteria != '') {
                $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE )->addOr( $oTmpCriteria ) ) ) );
            } else {
                $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE ) ) ) );
            }

            // the count query needs to be the normal criteria query if there are defined PM Table Fields in the cases list
            if ($oTmpCriteria != '') {
                $CriteriaCount = $Criteria;
            } else {
                $CriteriaCount->add( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE ) ) ) );
            }
        }

        // this is the optimal way or query to render the cases search list
        // fixing the bug related to the wrong data displayed in the list
        /*
        if ($action == 'search') {
            $oDatasetIndex = AppCacheViewPeer::doSelectRS( $Criteria );
            $oDatasetIndex->setFetchmode( ResultSet::FETCHMODE_ASSOC );
            $oDatasetIndex->next();
            $maxDelIndexList = array ();
            // a list of MAX_DEL_INDEXES is required in order to validate the right row
            while ($aRow = $oDatasetIndex->getRow()) {
                $maxDelIndexList[] = $aRow['MAX_DEL_INDEX'];
                $oDatasetIndex->next();
            }
            // adding the validation condition in order to get the right row using the group by sentence
            $Criteria->add( AppCacheViewPeer::DEL_INDEX, $maxDelIndexList, Criteria::IN );
            //
            //$params = array($maxDelIndexList);
        }
        */

        //here we count how many records exists for this criteria.
        //BUT there are some special cases, and if we dont optimize them the server will crash.
        $doCountAlreadyExecuted = $paged;
        //case 1. when the SEARCH action is selected and none filter, search criteria is defined,
        //we need to count using the table APPLICATION, because APP_CACHE_VIEW takes 3 seconds

        /*
        if ($action == 'search' && $filter == '' && $search == '' && $process == '' && $status == '' && $dateFrom == '' && $dateTo == '' && $category == '') {
            $totalCount = $oAppCache->getSearchAllCount();
            $doCountAlreadyExecuted = true;
        }
        if ($category != '') {
            $totalCount = $oAppCache->getSearchCountCriteria();
            $doCountAlreadyExecuted = true;
        }
        */
        $tableNameAux = '';
        $totalCount = 0;
        if ($doCountAlreadyExecuted == true) {
            // in the case of reassign the distinct attribute shows a diferent count result comparing to the
            // original list
            //Check also $distinct in the method getListCounters(), this in AppCacheView.php
            $distinct = true;

            if ($action != "sent" && (($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "to_reassign" || $action == "to_revise") || ($status == "TO_DO"))) {
                $distinct = false;
            }

            // first check if there is a PMTable defined within the list,
            // the issue that brokes the normal criteria query seems to be fixed
            if (isset( $oAppCache->confCasesList['PMTable'] ) && ! empty( $oAppCache->confCasesList['PMTable'] )) {
                // then
                $oAdditionalTables = AdditionalTablesPeer::retrieveByPK( $oAppCache->confCasesList['PMTable'] );
                $tableName = $oAdditionalTables->getAddTabName();
                $tableNameAux = $tableName;
                $tableName = strtolower( $tableName );
                $tableNameArray = explode( '_', $tableName );
                foreach ($tableNameArray as $item) {
                    $newTableName[] = ucfirst( $item );
                }
                $tableName = implode( '', $newTableName );
                // so the pm table class can be invoqued from the pm table model clases
                if (! class_exists( $tableName )) {
                    require_once (PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $tableName . ".php");
                }
            }
            $totalCount = AppCacheViewPeer::doCount($CriteriaCount, $distinct);
        }

        //Add sortable options
        $sortBk = $sort;

        if ($sortBk != "") {
            $sort = "";

            //Current delegation (*)
            if (($action == "sent" || $action == "search" || $action == "simple_search" || $action == "to_revise" || $action == "to_reassign") && ($status != "TO_DO")) {
                switch ($sortBk) {
                    case "APP_CACHE_VIEW.APP_CURRENT_USER":
                        $sort = "USRCR_" . $conf->userNameFormatGetFirstFieldByUsersTable();
                        break;
                    case "APP_CACHE_VIEW.APP_TAS_TITLE":
                        $sort = "APPDELCR_APP_TAS_TITLE";
                        break;
                }
            }

            if (isset( $oAppCache->confCasesList['PMTable'] ) && ! empty( $oAppCache->confCasesList['PMTable'] ) && $tableNameAux != '') {
                $sortTable = explode(".", $sortBk);

                $additionalTableUid = $oAppCache->confCasesList["PMTable"];

                require_once 'classes/model/Fields.php';
                $oCriteria = new Criteria('workflow');

                $oCriteria->addSelectColumn(FieldsPeer::FLD_UID);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_INDEX);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_NAME);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_DESCRIPTION);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_TYPE);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_SIZE);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_NULL);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_AUTO_INCREMENT);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_KEY);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_FOREIGN_KEY);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_FOREIGN_KEY_TABLE);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_DYN_NAME);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_DYN_UID);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_FILTER);
                $oCriteria->add(FieldsPeer::ADD_TAB_UID, $additionalTableUid);
                $oCriteria->add(FieldsPeer::FLD_NAME, $sortTable[1]);
                $oCriteria->addAscendingOrderByColumn(FieldsPeer::FLD_INDEX);

                $oDataset = FieldsPeer::doSelectRS($oCriteria);
                $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                $oDataset->next();
                $row = $oDataset->getRow();
                if (is_array($row)) {
                    $sort = $tableNameAux . "." . $sortTable[1];
                }
            }

            if ($sort == "") {
                $sort = $sortBk;
            }

            if (!in_array($sort, $Criteria->getSelectColumns())) {
                $sort = AppCacheViewPeer::APP_NUMBER; //DEFAULT VALUE
            }

            if ($dir == "DESC") {
                $Criteria->addDescendingOrderByColumn($sort);
            } else {
                $Criteria->addAscendingOrderByColumn($sort);
            }
        }

        //limit the results according the interface
        $Criteria->setLimit( $limit );
        $Criteria->setOffset( $start );

        //execute the query
        $oDataset = AppCacheViewPeer::doSelectRS( $Criteria, Propel::getDbConnection('workflow_ro') );

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

        $result = array ();
        $result['totalCount'] = $totalCount;
        $rows = array ();
        $aPriorities = array ('1' => 'VL','2' => 'L','3' => 'N','4' => 'H','5' => 'VH');
        $index = $start;

        while ($oDataset->next()) {
            $aRow = $oDataset->getRow();

            //$aRow = $oAppCache->replaceRowUserData($aRow);

            /*
             * For participated cases, we want the last step in the case, not only the last step this user participated. To do that we get every case information again for the last step. (This could be solved by a subquery, but Propel might not support it and subqueries can be slower for larger
             * datasets).
             */
             /*if ($action == 'sent' || $action == 'search') {
             $maxCriteria = new Criteria('workflow');
             $maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL);
             $maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX);
             $maxCriteria->setLimit(1);

             $maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria );
             $maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
             $maxDataset->next();

             $newData = $maxDataset->getRow();
             foreach ($aRow as $col => $value) {
             if (array_key_exists($col, $newData))
             $aRow[$col] = $newData[$col];
             }

             $maxDataset->close();
              }*/

            //Current delegation (*) || $action == "search" || $action == "to_revise"
            if (($action == "sent" || $action == "simple_search" || $action == "to_reassign") && ($status != "TO_DO")) {
                //Current task
                $aRow["APP_TAS_TITLE"] = $aRow["APPDELCR_APP_TAS_TITLE"];

                //Current user
                //if ($action != "to_reassign" ) {
                if (($action != "to_reassign") && ($action != "search") && ($action != "to revise")) {
                    $aRow["USR_UID"] = $aRow["USRCR_USR_UID"];
                    $aRow["USR_FIRSTNAME"] = $aRow["USRCR_USR_FIRSTNAME"];
                    $aRow["USR_LASTNAME"] = $aRow["USRCR_USR_LASTNAME"];
                    $aRow["USR_USERNAME"] = $aRow["USRCR_USR_USERNAME"];
                }
            }

            //Unassigned user
            if (! isset( $aRow['APP_CURRENT_USER'] )) {
                $aRow['APP_CURRENT_USER'] = "******" . strtoupper(G::LoadTranslation("ID_UNASSIGNED")) . "]";
            }

            // replacing the status data with their respective translation
            if (isset( $aRow['APP_STATUS'] )) {
                $aRow['APP_STATUS_LABEL'] = G::LoadTranslation( "ID_{$aRow['APP_STATUS']}" );
            }

            // replacing the priority data with their respective translation
            if (isset( $aRow['DEL_PRIORITY'] )) {
                $aRow['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}" );
            }

            $rows[] = $aRow;
        }

        $result['data'] = $rows;

        return $result;
    }
 public function getAll($userUid, $start = null, $limit = null, $action = null, $filter = null, $search = null, $process = null, $status = null, $type = null, $dateFrom = null, $dateTo = null, $callback = null, $dir = null, $sort = "APP_CACHE_VIEW.APP_NUMBER", $category = null)
 {
     $callback = isset($callback) ? $callback : "stcCallback1001";
     $dir = isset($dir) ? $dir : "DESC";
     $sort = isset($sort) ? $sort : "";
     $start = isset($start) ? $start : "0";
     $limit = isset($limit) ? $limit : "25";
     $filter = isset($filter) ? $filter : "";
     $search = isset($search) ? $search : "";
     $process = isset($process) ? $process : "";
     $category = isset($category) ? $category : "";
     $status = isset($status) ? $status : "";
     $action = isset($action) ? $action : "todo";
     $type = isset($type) ? $type : "extjs";
     $dateFrom = isset($dateFrom) ? $dateFrom : "";
     $dateTo = isset($dateTo) ? $dateTo : "";
     G::LoadClass("BasePeer");
     G::LoadClass("configuration");
     //require_once ("classes/model/AppCacheView.php");
     //require_once ("classes/model/AppDelegation.php");
     //require_once ("classes/model/AdditionalTables.php");
     //require_once ("classes/model/AppDelay.php");
     //require_once ("classes/model/Fields.php");
     //require_once ("classes/model/Users.php");
     //require_once ("classes/model/Process.php");
     $oAppCache = new AppCacheView();
     //get data configuration
     $conf = new Configurations();
     $confCasesList = $conf->getConfiguration('casesList', $action == 'search' || $action == 'simple_search' ? 'sent' : $action);
     $oAppCache->confCasesList = $confCasesList;
     // get the action based list
     switch ($action) {
         case "draft":
             $Criteria = $oAppCache->getDraftListCriteria($userUid);
             $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
             break;
         case "sent":
             $Criteria = $oAppCache->getSentListCriteria($userUid);
             $CriteriaCount = $oAppCache->getSentCountCriteria($userUid);
             if (!empty($status)) {
                 $Criteria->add(AppCacheViewPeer::APP_STATUS, $status);
                 $CriteriaCount->add(AppCacheViewPeer::APP_STATUS, $status);
             }
             break;
         case "selfservice":
         case "unassigned":
             //$userUid can't be empty or null
             $Criteria = $oAppCache->getUnassignedListCriteria($userUid);
             $CriteriaCount = $oAppCache->getUnassignedCountCriteria($userUid);
             break;
         case "paused":
             $Criteria = $oAppCache->getPausedListCriteria($userUid);
             $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
             break;
         case "completed":
             $Criteria = $oAppCache->getCompletedListCriteria($userUid);
             $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
             break;
         case "cancelled":
             $Criteria = $oAppCache->getCancelledListCriteria($userUid);
             $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
             break;
         case "search":
             //$Criteria = $oAppCache->getSearchListCriteria();
             //$CriteriaCount = $oAppCache->getSearchCountCriteria();
             switch ($status) {
                 case "TO_DO":
                     $Criteria = $oAppCache->getToDoListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
                     break;
                 case "DRAFT":
                     $Criteria = $oAppCache->getDraftListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
                     break;
                 case "PAUSED":
                     $Criteria = $oAppCache->getPausedListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
                     break;
                 case "CANCELLED":
                     $Criteria = $oAppCache->getCancelledListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
                     break;
                 case "COMPLETED":
                     $Criteria = $oAppCache->getCompletedListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
                     break;
                 default:
                     //All status
                     $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
                     $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
                     break;
             }
             break;
         case "simple_search":
             $Criteria = $oAppCache->getSimpleSearchListCriteria();
             $CriteriaCount = $oAppCache->getSimpleSearchCountCriteria();
             break;
         case "to_revise":
             $Criteria = $oAppCache->getToReviseListCriteria($userUid);
             $CriteriaCount = $oAppCache->getToReviseCountCriteria($userUid);
             break;
         case "to_reassign":
             $Criteria = $oAppCache->getToReassignListCriteria($userUid);
             $CriteriaCount = $oAppCache->getToReassignCountCriteria($userUid);
             break;
         case "all":
             $Criteria = $oAppCache->getAllCasesListCriteria($userUid);
             $CriteriaCount = $oAppCache->getAllCasesCountCriteria($userUid);
             break;
         case "gral":
             //General criteria probably will be deprecated
             $Criteria = $oAppCache->getGeneralListCriteria();
             $CriteriaCount = $oAppCache->getGeneralCountCriteria();
             break;
         case "todo":
             $Criteria = $oAppCache->getToDoListCriteria($userUid);
             $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
             break;
         default:
             //All status
             $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
             $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
             break;
     }
     $Criteria->addAlias('CU', 'USERS');
     $Criteria->addJoin(AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN);
     $Criteria->addAsColumn('USR_UID', 'CU.USR_UID');
     $Criteria->addAsColumn('USR_FIRSTNAME', 'CU.USR_FIRSTNAME');
     $Criteria->addAsColumn('USR_LASTNAME', 'CU.USR_LASTNAME');
     $Criteria->addAsColumn('USR_USERNAME', 'CU.USR_USERNAME');
     // Fix for previous user
     if ($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "paused" || $action == "to_revise" || $action == "sent" || ($status == "TO_DO" || $status == "DRAFT" || $status == "PAUSED" || $status == "CANCELLED" || $status == "COMPLETED")) {
         $Criteria->addAlias('PU', 'USERS');
         $Criteria->addJoin(AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN);
         $Criteria->addAsColumn('PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME');
         $Criteria->addAsColumn('PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME');
         $Criteria->addAsColumn('PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME');
     }
     /*
     if (! is_array( $confCasesList )) {
         $rows = $this->getDefaultFields( $action );
         $result = $this->genericJsonResponse( '', array (), $rows, 20, '' );
         //$conf->saveObject($result,'casesList',$action,'','','');
     }
     */
     //Add the process filter
     if (!empty($process)) {
         $Criteria->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
         $CriteriaCount->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
     }
     //Add the category filter
     if (!empty($category)) {
         $Criteria->addAlias("CP", "PROCESS");
         $Criteria->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
         $Criteria->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
         $Criteria->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");
         $CriteriaCount->addAlias("CP", "PROCESS");
         $CriteriaCount->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
         $CriteriaCount->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
         $CriteriaCount->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");
     }
     // add the user filter
     /*
     if ($user != '') {
         $Criteria->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
         $CriteriaCount->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
     }
     */
     /*
     if ($status != '') {
         $Criteria->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
         $CriteriaCount->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
     }
     */
     if ($dateFrom != '') {
         if ($dateTo != '') {
             $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL)->addAnd($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL)));
             $CriteriaCount->add($CriteriaCount->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL)->addAnd($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL)));
         } else {
             $Criteria->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL);
             $CriteriaCount->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL);
         }
     } elseif ($dateTo != '') {
         $Criteria->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL);
         $CriteriaCount->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL);
     }
     //add the filter
     if ($filter != '') {
         switch ($filter) {
             case 'read':
                 $Criteria->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL);
                 $CriteriaCount->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL);
                 break;
             case 'unread':
                 $Criteria->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
                 $CriteriaCount->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
                 break;
             case 'started':
                 $Criteria->add(AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL);
                 $CriteriaCount->add(AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL);
                 break;
             case 'completed':
                 $Criteria->add(AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL);
                 $CriteriaCount->add(AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL);
                 break;
         }
     }
     //add the search filter
     if ($search != '') {
         $defaultFields = $oAppCache->getDefaultFields();
         $oTmpCriteria = '';
         // if there is PMTABLE for this case list:
         if (!empty($oAppCache->confCasesList) && isset($oAppCache->confCasesList['PMTable']) && trim($oAppCache->confCasesList['PMTable']) != '') {
             // getting the table name
             $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($oAppCache->confCasesList['PMTable']);
             $tableName = $oAdditionalTables->getAddTabName();
             $oNewCriteria = new Criteria('workflow');
             $counter = 0;
             foreach ($oAppCache->confCasesList['second']['data'] as $fieldData) {
                 if (!in_array($fieldData['name'], $defaultFields)) {
                     $fieldName = $tableName . '.' . $fieldData['name'];
                     if ($counter == 0) {
                         $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, '%' . $search . '%', Criteria::LIKE);
                     } else {
                         $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, '%' . $search . '%', Criteria::LIKE)->addOr($oTmpCriteria);
                     }
                     $counter++;
                 }
             }
             //add the default and hidden DEL_INIT_DATE
         }
         // the criteria adds new fields if there are defined PM Table Fields in the cases list
         if ($oTmpCriteria != '') {
             $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE)->addOr($oTmpCriteria))));
         } else {
             $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE))));
         }
         // the count query needs to be the normal criteria query if there are defined PM Table Fields in the cases list
         if ($oTmpCriteria != '') {
             $CriteriaCount = $Criteria;
         } else {
             $CriteriaCount->add($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE))));
         }
     }
     // this is the optimal way or query to render the cases search list
     // fixing the bug related to the wrong data displayed in the list
     /*
     if ($action == 'search') {
         $oDatasetIndex = AppCacheViewPeer::doSelectRS( $Criteria );
         $oDatasetIndex->setFetchmode( ResultSet::FETCHMODE_ASSOC );
         $oDatasetIndex->next();
         $maxDelIndexList = array ();
         // a list of MAX_DEL_INDEXES is required in order to validate the right row
         while ($aRow = $oDatasetIndex->getRow()) {
             $maxDelIndexList[] = $aRow['MAX_DEL_INDEX'];
             $oDatasetIndex->next();
         }
         // adding the validation condition in order to get the right row using the group by sentence
         $Criteria->add( AppCacheViewPeer::DEL_INDEX, $maxDelIndexList, Criteria::IN );
         //
         //$params = array($maxDelIndexList);
     }
     */
     //here we count how many records exists for this criteria.
     //BUT there are some special cases, and if we dont optimize them the server will crash.
     $doCountAlreadyExecuted = false;
     //case 1. when the SEARCH action is selected and none filter, search criteria is defined,
     //we need to count using the table APPLICATION, because APP_CACHE_VIEW takes 3 seconds
     /*
     if ($action == 'search' && $filter == '' && $search == '' && $process == '' && $status == '' && $dateFrom == '' && $dateTo == '' && $category == '') {
         $totalCount = $oAppCache->getSearchAllCount();
         $doCountAlreadyExecuted = true;
     }
     if ($category != '') {
         $totalCount = $oAppCache->getSearchCountCriteria();
         $doCountAlreadyExecuted = true;
     }
     */
     if ($doCountAlreadyExecuted == false) {
         // in the case of reassign the distinct attribute shows a diferent count result comparing to the
         // original list
         //Check also $distinct in the method getListCounters(), this in AppCacheView.php
         $distinct = true;
         if ($action == "todo" || $action == "to_reassign" || $status == "TO_DO") {
             $distinct = false;
         }
         // first check if there is a PMTable defined within the list,
         // the issue that brokes the normal criteria query seems to be fixed
         if (isset($oAppCache->confCasesList['PMTable']) && !empty($oAppCache->confCasesList['PMTable'])) {
             // then
             $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($oAppCache->confCasesList['PMTable']);
             $tableName = $oAdditionalTables->getAddTabName();
             $tableName = strtolower($tableName);
             $tableNameArray = explode('_', $tableName);
             foreach ($tableNameArray as $item) {
                 $newTableName[] = ucfirst($item);
             }
             $tableName = implode('', $newTableName);
             // so the pm table class can be invoqued from the pm table model clases
             if (!class_exists($tableName)) {
                 require_once PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $tableName . ".php";
             }
         }
         $totalCount = AppCacheViewPeer::doCount($CriteriaCount, $distinct);
     }
     //add sortable options
     if ($sort != '') {
         if ($dir == 'DESC') {
             $Criteria->addDescendingOrderByColumn($sort);
         } else {
             $Criteria->addAscendingOrderByColumn($sort);
         }
     }
     //limit the results according the interface
     $Criteria->setLimit($limit);
     $Criteria->setOffset($start);
     //execute the query
     $oDataset = AppCacheViewPeer::doSelectRS($Criteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $result = array();
     $result['totalCount'] = $totalCount;
     $rows = array();
     $aPriorities = array('1' => 'VL', '2' => 'L', '3' => 'N', '4' => 'H', '5' => 'VH');
     $index = $start;
     while ($aRow = $oDataset->getRow()) {
         //$aRow = $oAppCache->replaceRowUserData($aRow);
         /*
          * For participated cases, we want the last step in the case, not only the last step this user participated. To do that we get every case information again for the last step. (This could be solved by a subquery, but Propel might not support it and subqueries can be slower for larger
          * datasets).
          */
         /*if ($action == 'sent' || $action == 'search') {
                      $maxCriteria = new Criteria('workflow');
                      $maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL);
                      $maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX);
                      $maxCriteria->setLimit(1);
         
                      $maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria );
                      $maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
                      $maxDataset->next();
         
                      $newData = $maxDataset->getRow();
                      foreach ($aRow as $col => $value) {
                      if (array_key_exists($col, $newData))
                      $aRow[$col] = $newData[$col];
                      }
         
                      $maxDataset->close();
                       }*/
         if (!isset($aRow['APP_CURRENT_USER'])) {
             $aRow['APP_CURRENT_USER'] = "******";
         }
         // replacing the status data with their respective translation
         if (isset($aRow['APP_STATUS'])) {
             $aRow['APP_STATUS'] = G::LoadTranslation("ID_{$aRow['APP_STATUS']}");
         }
         // replacing the priority data with their respective translation
         if (isset($aRow['DEL_PRIORITY'])) {
             $aRow['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}");
         }
         $rows[] = $aRow;
         $oDataset->next();
     }
     $result['data'] = $rows;
     return $result;
 }
Пример #9
0
    /**
     * Verify if doesn't exists the PM Table in table ADDITIONAL_TABLES
     *
     * @param string $additionalTableUid    Unique id of PM Table
     * @param string $fieldNameForException Field name for the exception
     *
     * return void Throw exception if doesn't exists the PM Table in table ADDITIONAL_TABLES
     */
    public function throwExceptionIfNotExistsPmTable($additionalTableUid, $fieldNameForException)
    {
        try {
            $obj = \AdditionalTablesPeer::retrieveByPK($additionalTableUid);

            if (!(is_object($obj) && get_class($obj) == "AdditionalTables")) {
                throw new \Exception(\G::LoadTranslation("ID_PMTABLE_DOES_NOT_EXIST", array($fieldNameForException, $additionalTableUid)));
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }