コード例 #1
0
    /**
     * Get Data Generate
     *
     * @access public
     * @param string $pro_uid, Process Uid
     * @param string $tas_uid, Task Uid
     * @param string $dyn_uid, Dynaform Uid
     * @return string
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    public function getDataGrid ($pro_uid, $tas_uid, $dyn_uid, $usr_uid, $start = '', $limit = '', $search = '')
    {
        $start    = !empty($start)      ?   $start      : "0";
        $limit    = !empty($limit)      ?   $limit      : "20";
        $search   = !empty($search)     ?   $search     : "";

        $callback = isset($_REQUEST["callback"])? $_REQUEST["callback"] : "stcCallback1001";
        $dir      = isset($_REQUEST["dir"])?      $_REQUEST["dir"]    : "DESC";
        $sort     = isset($_REQUEST["sort"])?     $_REQUEST["sort"]   : "";
        $filter   = isset($_REQUEST["filter"])?   $_REQUEST["filter"] : "";
        $user     = isset($_REQUEST["user"])?     $_REQUEST["user"]   : "";
        $status   = isset($_REQUEST["status"])?   strtoupper($_REQUEST["status"]) : "";
        $action   = isset($_GET["action"])?    $_GET["action"] : (isset($_REQUEST["action"])? $_REQUEST["action"] : "todo");
        $type     = isset($_GET["type"])?      $_GET["type"] : (isset($_REQUEST["type"])? $_REQUEST["type"] : "extjs");
        $user     = isset($_REQUEST["user"])?     $_REQUEST["user"] : "";
        $dateFrom = isset($_REQUEST["dateFrom"])? substr($_REQUEST["dateFrom"], 0, 10) : "";
        $dateTo   = isset($_REQUEST["dateTo"])?   substr($_REQUEST["dateTo"], 0, 10) : "";

        $rowUid = isset($_REQUEST["rowUid"])? $_REQUEST["rowUid"] : "";
        $dropdownList = isset($_REQUEST ["dropList"])? G::json_decode($_REQUEST ["dropList"]) : array();

        try {
            G::LoadClass("pmFunctions");
            G::LoadClass("BasePeer");
            G::LoadClass("configuration");
            G::LoadClass("case");
            G::LoadClass("reportTables");

            $response = array();
            $searchFields = array();
            //
            $query = "SELECT REP_TAB_UID
                      FROM   CASE_CONSOLIDATED
                      WHERE  TAS_UID = '" . $tas_uid . "'";
            $caseConsolidated = executeQuery($query);

            $tableUid  = null;
            $tableName = null;

            foreach ($caseConsolidated as $item) {
                $criteria = new Criteria();
                $criteria->addSelectColumn(ReportTablePeer::REP_TAB_NAME);
                $criteria->add(ReportTablePeer::REP_TAB_UID,$item["REP_TAB_UID"]);

                $result = ReportTablePeer::doSelectRS($criteria);
                $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);

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

                    $tableUid  = $item["REP_TAB_UID"];
                    $tableName = $row["REP_TAB_NAME"];
                } else {
                    throw (new Exception("Not found the report table"));
                }
            }

            $className = $tableName;

            if (!class_exists($className)) {
                require_once (PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $className . ".php");
            }

            $oCriteria = new Criteria("workflow");
            
            $oCriteria->addSelectColumn("*");
            $oCriteria->addSelectColumn($tableName . ".APP_UID");
            
            $oCriteria->addJoin($tableName . ".APP_UID", AppCacheViewPeer::APP_UID, Criteria::LEFT_JOIN);
            
            $oCriteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
            $oCriteria->add(AppCacheViewPeer::TAS_UID, $tas_uid);
            $oCriteria->add(AppCacheViewPeer::USR_UID, $usr_uid);
            $oCriteria->add(AppCacheViewPeer::APP_STATUS, "TO_DO");
            
            if ($search != "") {
                $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml";

                if (!class_exists('Smarty')) {
                    require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php');  
                }
                $G_FORM = new \xmlform();
                $G_FORM->home = PATH_DYNAFORM;
                $G_FORM->parseFile($filename, SYS_LANG, true);

                foreach ($G_FORM->fields as $key => $val) {
                    switch ($val->type) {
                        case "text":
                        case "textarea":
                        case "currency":
                        case "percentage":
                            $searchFields[] = $val->name;
                            $dataType[] = $val->type;
                            break;
                    }
                }

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

                foreach ($searchFields as $index => $value) {
                    $value = strtoupper($value);
                    eval("\$field = " . $tableName . "Peer::" . $value . ";");

                    if ($sw == 0) {
                        if ($dataType[$index] == 'currency' || $dataType[$index] == 'percentage') {
                            if ( is_numeric($search) || is_float($search) ) {
                                $oTmpCriteria = $oNewCriteria->getNewCriterion($field, $search);
                            }
                        } else {
                            $oTmpCriteria = $oNewCriteria->getNewCriterion($field, "%" . $search . "%", Criteria::LIKE);
                        }
                    } else {
                        if ($dataType[$index] == 'currency' || $dataType[$index] == 'percentage') {
                            if ( is_numeric($search) || is_float($search) ) {
                                $oTmpCriteria = $oNewCriteria->getNewCriterion($field, $search)->addOr($oTmpCriteria);
                            }
                        } else {
                            $oTmpCriteria = $oNewCriteria->getNewCriterion($field, "%" . $search . "%", Criteria::LIKE)->addOr($oTmpCriteria);
                        }
                    }

                    $sw = 1;
                }

                if ($oTmpCriteria != null) {
                    $oCriteria->add(
                        $oCriteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE)->addOr($oTmpCriteria)
                    );
                } else {
                    $oCriteria->add($oCriteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE));
                }
            }
            
            G::LoadSystem('inputfilter');
            $filter = new \InputFilter();

            if ($sort != "") {
                $reportTable = new ReportTables();
                $arrayReportTableVar = $reportTable->getTableVars($tableUid);
                $tableName = $filter->validateInput($tableName);
                $sort = $filter->validateInput($sort);
                if (in_array($sort, $arrayReportTableVar)) {
                    $sort = strtoupper($sort);
                    eval('$field = ' . $tableName . 'Peer::' . $sort . ';');
                } else {
                    eval('$field = AppCacheViewPeer::' . $sort . ';');
                }

                if ($dir == "ASC") {
                    $oCriteria->addAscendingOrderByColumn($field);
                } else {
                    $oCriteria->addDescendingOrderByColumn($field);
                }
            } else {
                $oCriteria->addDescendingOrderByColumn(AppCacheViewPeer::APP_NUMBER);
            }

            //pagination pagination attributes
            $oCriteria->setLimit($limit);
            $oCriteria->setOffset($start);
            //end of pagination attributes

            $oDataset = AppCacheViewPeer::doSelectRS($oCriteria);
            //eval('$oDataset = '.$className.'Peer::doSelectRS($oCriteria);');

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

            $aTaskConsolidated = array();

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

                foreach ($aRow as $datakey => $dataField) {
                    foreach ($dropdownList as $tmpField) {
                        if ($tmpField == $datakey) {
                            $appUid = $aRow["APP_UID"];
                            $fieldVal = $aRow[$tmpField];
                            $aRow[$tmpField] = self::getDropdownLabel($appUid, $pro_uid, $dyn_uid, $tmpField, $fieldVal);
                        }
                    }
                }

                $aTaskConsolidated[] = $aRow;
            }

            foreach ($aTaskConsolidated as $key => $val) {
                foreach ($val as $iKey => $iVal) {
                    if (self::checkValidDate($iVal)) {
                        $val[$iKey] = str_replace("-", "/", $val[$iKey]);
                    }
                }
                $response["data"][] = $val;
            }

            $query = "SELECT COUNT(APP_CACHE_VIEW.TAS_UID) AS QTY
                      FROM   CASE_CONSOLIDATED
                             LEFT JOIN CONTENT ON (CASE_CONSOLIDATED.TAS_UID = CONTENT.CON_ID)
                             LEFT JOIN APP_CACHE_VIEW ON (CASE_CONSOLIDATED.TAS_UID = APP_CACHE_VIEW.TAS_UID)
                             LEFT JOIN TASK ON (CASE_CONSOLIDATED.TAS_UID = TASK.TAS_UID)
                      WHERE  CONTENT.CON_CATEGORY = 'TAS_TITLE' AND
                             CONTENT.CON_LANG = 'en' AND
                             APP_CACHE_VIEW.DEL_THREAD_STATUS = 'OPEN' AND
                             USR_UID = '" . $usr_uid . "' AND
                             APP_CACHE_VIEW.TAS_UID = '" . $tas_uid . "'";
            $count = executeQuery($query);

            $totalCount = 0;
            foreach ($count as $item) {
                $totalCount = $totalCount + $item["QTY"];
            }

            $response["totalCount"] = $totalCount;
            echo G::json_encode($response);
        } catch (Exception $e) {
            $msg = array("error" => $e->getMessage());
            echo G::json_encode($msg);
        }
    }
コード例 #2
0
ファイル: class.processes.php プロジェクト: rrsc/processmaker
    /**

     * Create Report Tables from an array of data

     *

     * @param array $aReportTables

     * @param array $aReportTablesVars

     * @return void

     */

    public function createReportTables ($aReportTables, $aReportTablesVars)

    {

        $this->createReportTablesVars( $aReportTablesVars );

        $oReportTables = new ReportTables();

        foreach ($aReportTables as $sKey => $aRow) {

            $bExists = true;

            $sTable = $aRow['REP_TAB_NAME'];

            $iCounter = 1;

            while ($bExists) {

                $oCriteria = new Criteria( 'workflow' );

                $oCriteria->add( ReportTablePeer::REP_TAB_NAME, $sTable );

                $oDataset = ReportTablePeer::doSelectRS( $oCriteria );

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

                $oDataset->next();

                $bExists = ($aRow2 = $oDataset->getRow());

                if ($bExists) {

                    $sTable = $aRow['REP_TAB_NAME'] . '_' . $iCounter;

                    $iCounter ++;

                } else {

                    $aRow['REP_TAB_NAME'] = $sTable;

                }

            }

            $aFields = $oReportTables->getTableVars( $aRow['REP_TAB_UID'], true );

            $oReportTables->createTable( $aRow['REP_TAB_NAME'], $aRow['REP_TAB_CONNECTION'], $aRow['REP_TAB_TYPE'], $aFields );

            $oReportTables->populateTable( $aRow['REP_TAB_NAME'], $aRow['REP_TAB_CONNECTION'], $aRow['REP_TAB_TYPE'], $aFields, $aRow['PRO_UID'], $aRow['REP_TAB_GRID'] );

            $aReportTables[$sKey]['REP_TAB_NAME'] = $aRow['REP_TAB_NAME'];

            $oRep = new ReportTable();

            if ($oRep->reportTableExists( $aRow['REP_TAB_UID'] )) {

                $oRep->remove( $aRow['REP_TAB_UID'] );

            }

            $oRep->create( $aRow );

        }

    }
コード例 #3
0
         foreach ($dynFields as $dfield) {
             $aProcessFields[] = array('FIELD_UID' => $dfield['name'] . '-' . $dfield['type'], 'FIELD_NAME' => $dfield['name']);
         }
         $resultList['processFields'] = $aProcessFields;
     }
     echo G::json_encode($resultList);
     break;
 case 'fieldsList':
     G::LoadClass('reportTables');
     G::LoadClass('xmlfield_InputPM');
     $aFields['FIELDS'] = array();
     $oReportTable = new ReportTable();
     $aFields = $oReportTable->load($_POST['REP_TAB_UID']);
     $aTheFields = getDynaformsVars($aFields['PRO_UID'], false);
     $oReportTables = new ReportTables();
     $aVars = $oReportTables->getTableVars($_POST['REP_TAB_UID']);
     $aFields['FIELDS'] = array();
     foreach ($aTheFields as $aField) {
         if (in_array($aField['sName'], $aVars)) {
             $aResultFields[] = array('FIELD_UID' => $aField['sName'] . '-' . $aField['sType'], 'FIELD_NAME' => $aField['sName'], 'FIELD_DYNAFORM' => $aField['sName']);
         }
     }
     $result->success = true;
     $result->data = $aResultFields;
     echo G::json_encode($result);
     break;
 case 'getDbConnectionsList':
     G::LoadClass('dbConnections');
     $proUid = $_POST['PRO_UID'];
     $dbConn = new DbConnections();
     $dbConnections = $dbConn->getConnectionsProUid($proUid);