Esempio n. 1
0
 function Chart(&$ch_array, $param)
 {
     global $field_labels;
     if ($this->webchart) {
         $this->chrt_array = Convert_Old_Chart($ch_array);
     } else {
         $this->chrt_array = $ch_array;
     }
     $this->setConnection();
     $this->pSet = new ProjectSettings($this->chrt_array['tables'][0]);
     $this->showDetails = $param['showDetails'];
     if ($this->showDetails) {
         $this->detailTablesData = $this->pSet->getDetailTablesArr();
     }
     $this->hasFlash = $param["hasFlash"];
     $this->pageId = $param["pageId"];
     $this->chrt_array["appearance"]["autoupdate"] = false;
     $this->numRecordsToShow = $this->chrt_array['appearance']['maxbarscroll'];
     if ($this->numRecordsToShow < 1) {
         $this->numRecordsToShow = 1;
     }
     $this->table_type = $this->chrt_array["table_type"];
     if (!$this->table_type) {
         $this->table_type = "project";
     }
     $this->webchart = $param["webchart"];
     $this->cname = $param["cname"];
     $this->chartPreview = $param["chartPreview"];
     $this->dashChart = $param["dashChart"];
     $this->sessionPrefix = $this->chrt_array['tables'][0];
     if ($this->dashChart) {
         $this->dashTName = $param["dashTName"];
         $this->dashElementName = $param["dashElementName"];
         $this->sessionPrefix = $this->dashTName . "_" . $this->sessionPrefix;
     }
     $this->gstrOrderBy = $param["gstrOrderBy"];
     $TableName = GoodFieldName($this->chrt_array['tables'][0]);
     // #10461, $this->setConnection(); needs to be called after value is assigned to $this->webchart
     $this->setConnection();
     if ($this->isProjectDB()) {
         $this->cipherer = new RunnerCipherer($this->chrt_array['tables'][0]);
     }
     $this->header = $this->chrt_array['appearance']['head'];
     $this->footer = $this->chrt_array['appearance']['foot'];
     $this->y_axis_label = $this->chrt_array['appearance']['y_axis_label'];
     for ($i = 0; $i < count($this->chrt_array['parameters']) - 1; $i++) {
         if (isset($this->chrt_array['parameters'][$i]['currencyFormat'])) {
             $this->arrFormatCurrency[] = $this->chrt_array['parameters'][$i]['currencyFormat'];
         } else {
             if ($this->chrt_array['appearance']['scur'] == "false") {
                 $this->arrFormatCurrency[] = "";
             } else {
                 $this->arrFormatCurrency[] = $this->chrt_array['appearance']['scur'];
             }
         }
         if (isset($this->chrt_array['parameters'][$i]['decimalFormat'])) {
             $this->arrFormatDecimal[] = $this->chrt_array['parameters'][$i]['decimalFormat'];
         } else {
             $this->arrFormatDecimal[] = $this->chrt_array['appearance']['dec'];
         }
         $this->arrFormatCustomer[] = $this->chrt_array['parameters'][$i]['customFormat'];
         $this->arrFormatCustomerStr[] = $this->chrt_array['parameters'][$i]['customFormatStr'];
         if ($this->chrt_array["chart_type"]["type"] == "ohlc" || $this->chrt_array["chart_type"]["type"] == "candlestick") {
             $this->arrOHLC_color[] = "#" . $this->chrt_array['parameters'][$i]['ohlcColor'];
             if ($this->table_type != "db") {
                 $this->arrOHLC_open[] = $this->chrt_array['parameters'][$i]['ohlcOpen'];
                 $this->arrOHLC_high[] = $this->chrt_array['parameters'][$i]['ohlcHigh'];
                 $this->arrOHLC_low[] = $this->chrt_array['parameters'][$i]['ohlcLow'];
                 $this->arrOHLC_close[] = $this->chrt_array['parameters'][$i]['ohlcClose'];
             } else {
                 if ($this->chrt_array['parameters'][$i]['agr_func']) {
                     $this->arrOHLC_open[] = $this->chrt_array['parameters'][$i]['agr_func'] . "_" . $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcOpen'];
                     $this->arrOHLC_high[] = $this->chrt_array['parameters'][$i]['agr_func'] . "_" . $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcHigh'];
                     $this->arrOHLC_low[] = $this->chrt_array['parameters'][$i]['agr_func'] . "_" . $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcLow'];
                     $this->arrOHLC_close[] = $this->chrt_array['parameters'][$i]['agr_func'] . "_" . $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcClose'];
                 } else {
                     $this->arrOHLC_open[] = $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcOpen'];
                     $this->arrOHLC_high[] = $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcHigh'];
                     $this->arrOHLC_low[] = $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcLow'];
                     $this->arrOHLC_close[] = $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['ohlcClose'];
                 }
             }
             if ($this->chrt_array["chart_type"]["type"] == "candlestick") {
                 $this->arrOHLC_candle[] = "#" . $this->chrt_array['parameters'][$i]['ohlcCandleColor'];
             }
         } elseif ($this->chrt_array['parameters'][$i]['name'] != "") {
             if ($this->table_type != "db") {
                 $this->arrDataSeries[] = $this->chrt_array['parameters'][$i]['agr_func'] ? $this->chrt_array['parameters'][$i]['label'] : $this->chrt_array['parameters'][$i]['name'];
                 if ($this->chrt_array["chart_type"]["type"] == "bubble") {
                     $this->arrDataSize[] = $this->chrt_array['parameters'][$i]['size'];
                 }
             } else {
                 $this->arrDataSeries[] = $this->chrt_array['parameters'][$i]['agr_func'] ? $this->chrt_array['parameters'][$i]['agr_func'] . "_" . $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['name'] : $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['name'];
                 if ($this->chrt_array["chart_type"]["type"] == "bubble") {
                     $this->arrDataSize[] = $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['size'];
                 }
             }
             if (isset($this->chrt_array['appearance']['scolor' . ($i + 1) . '1'])) {
                 $this->arrDataColor[] = $this->chrt_array['appearance']['scolor' . ($i + 1) . '1'];
             } else {
                 $this->arrDataColor[] = $this->chrt_array['parameters'][$i]['series_color'];
             }
             if ($this->chrt_array["chart_type"]["type"] == "gauge") {
                 for ($k = 0; is_array($this->chrt_array["parameters"][$i]["gaugeColorZone"]) && $k < count($this->chrt_array["parameters"][$i]["gaugeColorZone"]); $k++) {
                     $beginColor = (double) @$this->chrt_array["parameters"][$i]["gaugeColorZone"][$k]["gaugeBeginColor"];
                     $endColor = (double) @$this->chrt_array["parameters"][$i]["gaugeColorZone"][$k]["gaugeEndColor"];
                     $gColor = "#" . @$this->chrt_array["parameters"][$i]["gaugeColorZone"][$k]["gaugeColor"];
                     $this->arrGaugeColor[count($this->arrDataSeries) - 1][] = array($beginColor, $endColor, $gColor);
                 }
             }
         }
         if ($this->table_type == "project" && !$this->webchart) {
             if ($this->chrt_array["chart_type"]["type"] != "candlestick" && $this->chrt_array["chart_type"]["type"] != "ohlc") {
                 $this->arrDataLabels[] = $this->chart_xmlencode(GetFieldLabel(GoodFieldName($TableName), GoodFieldName($this->chrt_array['parameters'][$i]['name'])));
             } else {
                 $this->arrDataLabels[] = $this->chart_xmlencode(GetFieldLabel(GoodFieldName($TableName), GoodFieldName($this->chrt_array['parameters'][$i]['ohlcOpen'])));
             }
         } else {
             if (!$this->chart_xmlencode($this->chrt_array['parameters'][$i]['label'])) {
                 if ($this->chrt_array["chart_type"]["type"] != "candlestick" && $this->chrt_array["chart_type"]["type"] != "ohlc") {
                     $this->arrDataLabels[] = $this->chart_xmlencode($this->chrt_array['parameters'][$i]['name']);
                 } else {
                     $this->arrDataLabels[] = $this->chart_xmlencode($this->chrt_array['parameters'][$i]['ohlcOpen']);
                 }
             } else {
                 $this->arrDataLabels[] = $this->chart_xmlencode($this->chrt_array['parameters'][$i]['label']);
             }
         }
     }
     if ($this->chrt_array["chart_type"]["type"] != "gauge") {
         if ($this->table_type != "db") {
             $this->strLabel = $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'];
         } else {
             $this->strLabel = $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['agr_func'] ? $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['agr_func'] . "_" . $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['table'] . "_" . $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'] : $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['table'] . "_" . $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'];
         }
         for ($j = 0; $j < count($this->chrt_array['fields']); $j++) {
             if ($this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'] == $this->chrt_array['fields'][$j]['name']) {
                 if ($this->table_type == "project") {
                     $this->label2 = $this->chart_xmlencode(GetFieldLabel($TableName, GoodFieldName($this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'])));
                 } else {
                     $this->label2 = $this->chart_xmlencode($this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name']);
                 }
             }
         }
     }
     if ($this->chrt_array["chart_type"]["type"] != "ohlc" && $this->chrt_array["chart_type"]["type"] != "candlestick") {
         foreach ($this->arrDataColor as $ind => $val) {
             if ($ind == 0) {
                 $this->arrAxesColor = "#000000";
             } else {
                 $this->arrAxesColor = "#" . $this->arrDataColor[$ind];
             }
         }
     } else {
         foreach ($this->arrOHLC_color as $ind => $val) {
             if ($ind == 0) {
                 $this->arrAxesColor = "#000000";
             } else {
                 $this->arrAxesColor = "#" . $this->arrOHLC_color[$ind];
             }
         }
     }
     // prepare search params
     $gQuery = $this->pSet->getSQLQuery();
     $masterWhere = "";
     if (!$this->dashChart) {
         $masterTable = $_SESSION[$this->sessionPrefix . "_mastertable"];
         $detailKeysByM = $this->pSet->getDetailKeysByMasterTable($masterTable);
         if (count($detailKeysByM)) {
             for ($i = 0; $i < count($detailKeysByM); $i++) {
                 if ($i != 0) {
                     $masterWhere .= " and ";
                 }
                 if ($this->cipherer && isEncryptionByPHPEnabled()) {
                     $mValue = $this->cipherer->MakeDBValue($detailKeysByM[$i], $_SESSION[$this->sessionPrefix . "_masterkey" . ($i + 1)]);
                 } else {
                     $mValue = make_db_value($detailKeysByM[$i], $_SESSION[$this->sessionPrefix . "_masterkey" . ($i + 1)]);
                 }
                 if (strlen($mValue) != 0) {
                     $masterWhere .= RunnerPage::_getFieldSQLDecrypt($detailKeysByM[$i], $this->connection, $this->pSet, $this->cipherer) . "=" . $mValue;
                 } else {
                     $masterWhere .= "1=0";
                 }
             }
         }
     }
     $strWhereClause = "";
     $searchHavingClause = "";
     $strSearchCriteria = "and";
     global $strTableName;
     // search where for basic charts
     if (!$this->webchart) {
         if (!$this->chartPreview && isset($_SESSION[$this->sessionPrefix . '_advsearch'])) {
             $searchClauseObj = SearchClause::UnserializeObject($_SESSION[$this->sessionPrefix . '_advsearch']);
             include_once getabspath('classes/controls/EditControlsContainer.php');
             $editControls = new EditControlsContainer(null, $this->pSet, PAGE_SEARCH, $this->cipherer);
             $whereComponents = RunnerPage::sGetWhereComponents($gQuery, $this->pSet, $searchClauseObj, $editControls, $this->connection);
             $strWhereClause = $whereComponents["searchWhere"];
             foreach ($whereComponents["filterWhere"] as $fWhere) {
                 $strWhereClause = whereAdd($strWhereClause, $fWhere);
             }
             $searchHavingClause = $whereComponents["searchHaving"];
             foreach ($whereComponents["filterHaving"] as $fHaving) {
                 $searchHavingClause = whereAdd($searchHavingClause, $fHaving);
             }
             $strSearchCriteria = $whereComponents["searchUnionRequired"] ? "or" : "and";
         }
     } else {
         if ($this->table_type != "project") {
             $strTableName = "webchart" . $this->cname;
         }
         $strWhereClause = CalcSearchParam($this->table_type != "project");
     }
     if ($strWhereClause) {
         $this->chrt_array['where'] .= $this->chrt_array['where'] ? " AND (" . $strWhereClause . ")" : " WHERE (" . $strWhereClause . ")";
     }
     if ($this->table_type == "project") {
         if (SecuritySQL("Search", $this->chrt_array['tables'][0])) {
             $strWhereClause = whereAdd($strWhereClause, SecuritySQL("Search", $strTableName));
         }
         $this->strSQL = $gQuery->gSQLWhere($strWhereClause, $searchHavingClause, $strSearchCriteria);
         $strOrderBy = $this->gstrOrderBy;
         $this->strSQL .= " " . $strOrderBy;
         if ($masterWhere) {
             $strWhereClause = whereAdd($strWhereClause, $masterWhere);
         }
         $strSQLbak = $this->strSQL;
         if (tableEventExists("BeforeQueryChart", $strTableName)) {
             $tstrSQL = $this->strSQL;
             $eventObj = getEventObject($strTableName);
             $eventObj->BeforeQueryChart($tstrSQL, $strWhereClause, $strOrderBy);
             $this->strSQL = $tstrSQL;
         }
         if ($strSQLbak == $this->strSQL) {
             $this->strSQL = $gQuery->gSQLWhere($strWhereClause, $searchHavingClause, $strSearchCriteria);
             $this->strSQL .= " " . $strOrderBy;
         }
     }
     if ($this->cname && $this->table_type == "db") {
         $this->strSQL = $this->chrt_array['sql'] . $this->chrt_array['where'] . $this->chrt_array['group_by'] . $this->chrt_array['order_by'];
     } elseif ($this->cname && $this->table_type == "custom") {
         if (!IsStoredProcedure($this->chrt_array['sql'])) {
             $sql_query = $this->chrt_array['sql'];
             if ($this->connection->dbType == nDATABASE_MSSQLServer) {
                 $pos = strrpos(strtoupper($sql_query), "ORDER BY");
                 if ($pos) {
                     $sql_query = substr($sql_query, 0, $pos);
                 }
             }
             if ($this->connection->dbType != nDATABASE_Oracle) {
                 $this->strSQL = "select * from (" . $sql_query . ") as " . $this->connection->addFieldWrappers("custom_query") . $this->chrt_array['where'];
             } else {
                 $this->strSQL = "select * from (" . $sql_query . ")" . $this->chrt_array['where'];
             }
         } else {
             $this->strSQL = $this->chrt_array['sql'];
         }
     }
     if (tableEventExists("UpdateChartSettings", $strTableName)) {
         $eventObj = getEventObject($strTableName);
         $eventObj->UpdateChartSettings($this);
     }
 }
function DisplayMasterTableInfo_BranchMaster($params)
{
    global $cman;
    $detailtable = $params["detailtable"];
    $keys = $params["keys"];
    $xt = new Xtempl();
    $tName = "BranchMaster";
    $xt->eventsObject = getEventObject($tName);
    $settings = new ProjectSettings($tName, PAGE_LIST);
    $cipherer = new RunnerCipherer($tName);
    $connection = $cman->byTable($tName);
    $masterQuery = $settings->getSQLQuery();
    $viewControls = new ViewControlsContainer($settings, PAGE_LIST);
    $where = "";
    $keysAssoc = array();
    $showKeys = "";
    if ($detailtable == "Fact_SalesTransaction") {
        $keysAssoc["GroupID"] = $keys[1 - 1];
        $keysAssoc["CompanyID"] = $keys[2 - 1];
        $where .= RunnerPage::_getFieldSQLDecrypt("GroupID", $connection, $settings, $cipherer) . "=" . $cipherer->MakeDBValue("GroupID", $keys[1 - 1], "", true);
        $keyValue = $viewControls->showDBValue("GroupID", $keysAssoc);
        $showKeys .= " " . GetFieldLabel("BranchMaster", "GroupID") . ": " . $keyValue;
        $where .= " and ";
        $showKeys .= " , ";
        $where .= RunnerPage::_getFieldSQLDecrypt("CompanyID", $connection, $settings, $cipherer) . "=" . $cipherer->MakeDBValue("CompanyID", $keys[2 - 1], "", true);
        $keyValue = $viewControls->showDBValue("CompanyID", $keysAssoc);
        $showKeys .= " " . GetFieldLabel("BranchMaster", "CompanyID") . ": " . $keyValue;
        $xt->assign('showKeys', $showKeys);
    }
    if (!$where) {
        return;
    }
    $str = SecuritySQL("Search", $tName);
    if (strlen($str)) {
        $where .= " and " . $str;
    }
    $strWhere = whereAdd($masterQuery->WhereToSql(), $where);
    if (strlen($strWhere)) {
        $strWhere = " where " . $strWhere . " ";
    }
    $strSQL = $masterQuery->HeadToSql() . ' ' . $masterQuery->FromToSql() . $strWhere . $masterQuery->TailToSql();
    LogInfo($strSQL);
    $data = $cipherer->DecryptFetchedArray($connection->query($strSQL)->fetchAssoc());
    if (!$data) {
        return;
    }
    // reassign pagetitlelabel function adding extra params
    $xt->assign_function("pagetitlelabel", "xt_pagetitlelabel", array("record" => $data, "settings" => $settings));
    $keylink = "";
    $xt->assign("BranchCloudFolder_mastervalue", $viewControls->showDBValue("BranchCloudFolder", $data, $keylink));
    $format = $settings->getViewFormat("BranchCloudFolder");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("BranchCloudFolder"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("BranchCloudFolder_class", $class);
    // add class for field header as field value
    $xt->assign("BranchLastSyncDate_mastervalue", $viewControls->showDBValue("BranchLastSyncDate", $data, $keylink));
    $format = $settings->getViewFormat("BranchLastSyncDate");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("BranchLastSyncDate"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("BranchLastSyncDate_class", $class);
    // add class for field header as field value
    $xt->assign("l_mastervalue", $viewControls->showDBValue("l", $data, $keylink));
    $format = $settings->getViewFormat("l");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("l"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("l_class", $class);
    // add class for field header as field value
    $layout = GetPageLayout("BranchMaster", 'masterlist');
    if ($layout) {
        $xt->assign("pageattrs", 'class="' . $layout->style . " page-" . $layout->name . '"');
    }
    $xt->displayPartial(GetTemplateName("BranchMaster", "masterlist"));
}
Esempio n. 3
0
 function xt_doevent($params)
 {
     if (isset($this->xt_events[@$params["custom1"]])) {
         $eventArr = $this->xt_events[@$params["custom1"]];
         if (isset($eventArr["method"])) {
             $params = array();
             if (isset($eventArr["params"])) {
                 $params = $eventArr["params"];
             }
             $method = $eventArr["method"];
             //			if(method_exists($eventArr["object"],$method))
             $eventArr["object"]->{$method}($params);
             return;
         }
     }
     global $strTableName, $globalEvents;
     if ($this->eventsObject) {
         $eventObj =& $this->eventsObject;
     } elseif (strlen($strTableName)) {
         $eventObj = getEventObject($strTableName);
     } else {
         $eventObj =& $globalEvents;
     }
     if (!$eventObj) {
         return;
     }
     $eventName = $params["custom1"];
     if (!$eventObj->exists($eventName)) {
         return;
     }
     $eventObj->{$eventName}($params);
 }
Esempio n. 4
0
 function getReport($from = 0)
 {
     global $bSubqueriesSupported;
     $this->init($from);
     // include all records in report with pagination
     $this->_doPaging = $from == -1;
     $isExistTimeFormatField = false;
     for ($i = 0; $i < count($this->fieldsArr); $i++) {
         if ($this->fieldsArr[$i]['viewFormat'] == "Time") {
             $isExistTimeFormatField = true;
             break;
         }
     }
     // retrieve ALL records from table
     $this->_fullRequest = $this->_doPaging || $this->repGlobalSummary && $isExistTimeFormatField;
     // MYSQL version < 5.0
     // a very bad thing to do, but we need this for global summary and pagination
     if (!$bSubqueriesSupported) {
         $this->_fullRequest = true;
     }
     // use non-optimized algorithm
     $this->_recordBasedRequest = $this->_fullRequest;
     // request records if there is no grouping
     if (!$this->repGroupFieldsCount) {
         $this->_recordBasedRequest = true;
     }
     //////////////////////////////// start building report
     $this->_sql->setRecordBasedRequest($this->_recordBasedRequest);
     if ($this->_doPaging || $this->_fullRequest) {
         $this->_sql->_limitLevel = 0;
         // no limits
     } else {
         if (!$this->repGroupFieldsCount) {
             $this->_sql->_limitLevel = 2;
         } else {
             $this->_sql->_limitLevel = 1;
         }
         // limit groups
     }
     $page = -1;
     $nRow = 0;
     if (!$this->_recordBasedRequest) {
         // get groups to show
         $groups = $this->_groups->getDisplayGroups($from);
         // iterate through records in these groups
         $hsql = $this->_sql->sql2($groups);
         if (tableEventExists('BeforeQueryReport', $this->tName)) {
             $hwhere = $hsql['where'];
             $eventsObj = getEventObject($this->tName);
             $eventsObj->BeforeQueryReport($hwhere);
             $hsql['where'] = $hwhere;
         }
         $sql = $this->_sql->buildsql($hsql);
         $cursor = db_query($sql, $this->_connection);
         while ($data = $this->cipherer->DecryptFetchedArray($cursor)) {
             $this->pageObject->recId = $nRow;
             $this->setSummary($this->repShowDet, $data, $this->recordVisible($nRow) ? $this->getFormattedRow($data) : null);
             $nRow++;
         }
     } else {
         $this->_groups->init($from);
         $this->_sql->setOldAlgorithm();
         $hsql = $this->_sql->sql2(null);
         $sql = $this->_sql->buildsql($hsql);
         $cursor = db_query($sql, $this->_connection);
         while ($data = $this->cipherer->DecryptFetchedArray($cursor)) {
             if ($this->repGroupFieldsCount) {
                 // take a record group into account
                 $this->_groups->setGroup($data);
             }
             if ($this->_fullRequest) {
                 $this->_groups->setGlobalSummary(true, $data);
             }
             if ($this->repGroupFieldsCount) {
                 $visible = $this->_doPaging || $this->_groups->isVisibleGroup() || $this->_pagesize == -1;
             } else {
                 $visible = $this->recordVisible($nRow);
             }
             if ($visible) {
                 $this->pageObject->recId = $nRow;
                 $this->setSummary(true, $data, $this->getFormattedRow($data));
             } else {
                 if (!$this->_fullRequest && count($this->_list) > 0) {
                     // exit loop at the end of visible recordset
                     break;
                 }
             }
             $nRow++;
         }
         $this->_sql->setOldAlgorithm(false);
     }
     $this->setFinish();
     $this->makeSummary();
     $global_totals = $this->getTotals();
     $this->writePageSummary();
     $globals = $this->writeGlobalSummary($global_totals);
     if ($this->repGroupFieldsCount) {
         $countrows = $this->_groups->getCountGroups($this->_fullRequest);
         $countGroups = $countrows;
     } else {
         $countrows = $global_totals['count'];
         $countGroups = 1;
     }
     $maxpages = 1;
     if ($this->_pagesize > 0) {
         $maxpages = ceil($countrows / $this->_pagesize);
     }
     $returnthis = array('list' => $this->_list, 'global' => $globals, 'page' => $this->_summary, 'maxpages' => $maxpages, 'countRows' => $countrows, 'countGroups' => $countGroups);
     return $returnthis;
 }
Esempio n. 5
0
 function RunnerPage(&$params)
 {
     global $locale_info, $cCharset, $page_layouts;
     // copy properties to object
     RunnerApply($this, $params);
     $this->setTableConnection();
     $this->pSet = new ProjectSettings($this->tName, $this->pageType);
     $this->pSetEdit = $this->pSet;
     $this->pSetSearch = new ProjectSettings($this->tName, PAGE_SEARCH);
     $this->searchTableName = $this->tName;
     $this->assignCipherer();
     include_once getabspath("classes/controls/EditControlsContainer.php");
     $this->controls = new EditControlsContainer($this, $this->pSetEdit, $this->pageType);
     include_once getabspath("classes/controls/ViewControlsContainer.php");
     $this->viewControls = new ViewControlsContainer($this->pSet, $this->pageType, $this);
     $this->gQuery = $this->pSet->getSQLQuery();
     //set google map configuration
     $this->googleMapCfg = array('isUseMainMaps' => false, 'isUseFieldsMaps' => false, 'isUseGoogleMap' => false, 'APIcode' => GetGlobalData("apiGoogleMapsCode", ""), 'mainMapIds' => array(), 'fieldMapsIds' => array(), 'mapsData' => array());
     $this->debugJSMode = false;
     if ($this->flyId < $this->id + 1) {
         $this->flyId = $this->id + 1;
     }
     // get permissions
     if ($this->tName) {
         $this->permis[$this->tName] = $this->getPermissions();
         $this->eventsObject =& getEventObject($this->tName);
     }
     if (!$this->sessionPrefix) {
         $this->assignSessionPrefix();
     }
     $this->isDisplayLoading = $this->pSet->displayLoading();
     //init settingMap globalSettings
     $this->settingsMap["globalSettings"] = array();
     $this->settingsMap["globalSettings"]["shortTNames"] = array();
     $this->searchPanelActivated = $this->checkIfSearchPanelActivated(isMobile());
     //global settings including "shortTNames" might be updated
     $this->setParamsForSearchPanel();
     $this->searchSavingEnabled = $this->isSearchSavingEnabled() && $this->needSearchClauseObj;
     $this->setSessionVariables();
     //	get locking object
     $this->lockingObj = GetLockingObject($this->tName);
     $this->warnLeavingPages = $this->pSet->warnLeavingPages();
     $this->is508 = isEnableSection508();
     $this->isUseVideo = $this->pSet->isUseVideo();
     $this->strCaption = GetTableCaption(GoodFieldName($this->tName));
     $this->tableType = $this->pSet->getTableType();
     $this->isAddWebRep = GetGlobalData("isAddWebRep", false);
     //	get details keys by master table
     $this->detailKeysByM = $this->getDetailKeysByMasterTable();
     $this->isDynamicPerm = GetGlobalData("isDynamicPerm", false);
     $this->shortTableName = $this->pSet->getShortTableName();
     $this->isResizeColumns = $this->pSet->isResizeColumns();
     $this->isUseAjaxSuggest = $this->pSetSearch->isUseAjaxSuggest();
     $this->useDetailsPreview = $this->pSet->isUseDetailsPreview();
     $this->isShowDetailTables = displayDetailsOn($this->tName, $this->pageType);
     //	get all details table for current table
     $this->allDetailsTablesArr = $this->pSet->getDetailTablesArr();
     //	set template file
     $this->setTemplateFile();
     //	init jsSettings
     $this->jsSettings = array();
     $this->jsSettings["tableSettings"] = array();
     $this->jsSettings["tableSettings"][$this->tName] = array();
     $this->jsSettings["tableSettings"][$this->tName]["proxy"] = array("proxy" => "");
     $this->jsSettings["tableSettings"][$this->tName]['fieldSettings'] = array();
     $this->settingsMap["globalSettings"]["webRootPath"] = GetWebRootPath();
     $this->settingsMap["globalSettings"]["ext"] = "php";
     $this->settingsMap["globalSettings"]["charSet"] = $cCharset;
     $this->settingsMap["globalSettings"]["debugMode"] = $this->debugJSMode;
     $this->settingsMap["globalSettings"]["googleMapsApiCode"] = $this->googleMapCfg['APIcode'];
     $this->settingsMap["globalSettings"]["shortTNames"][$this->tName] = $this->shortTableName;
     $globalPopupPagesLayoutNames = GetGlobalData("popupPagesLayoutNames", array());
     if (count($globalPopupPagesLayoutNames)) {
         $this->settingsMap["globalSettings"]["popupPagesLayoutNames"] = $globalPopupPagesLayoutNames;
     }
     //isMobile
     $this->settingsMap["globalSettings"]["isMobile"] = isMobile();
     $this->settingsMap["globalSettings"]["mobileDeteced"] = detectMobileDevice();
     // s508 must be in global settings
     $this->settingsMap['globalSettings']['s508'] = $this->is508;
     $this->settingsMap["globalSettings"]["locale"] = array();
     $this->settingsMap["globalSettings"]["locale"]["dateFormat"] = $locale_info["LOCALE_IDATE"];
     $this->settingsMap["globalSettings"]["locale"]["startWeekDay"] = $locale_info["LOCALE_IFIRSTDAYOFWEEK"];
     $this->settingsMap["globalSettings"]["locale"]["dateDelimiter"] = $locale_info["LOCALE_SDATE"];
     $this->settingsMap["tableSettings"] = array();
     $this->settingsMap['tableSettings']['hasEvents'] = array("default" => false, "jsName" => "hasEvents");
     $this->settingsMap["tableSettings"]["strCaption"] = array("default" => "", "jsName" => "strCaption");
     $this->settingsMap["tableSettings"]["isUseAudio"] = array("default" => false, "jsName" => "isUseAudio");
     //fix it
     $this->settingsMap["tableSettings"]["isUseVideo"] = array("default" => false, "jsName" => "isUseVideo");
     $this->settingsMap['tableSettings']['listGridLayout'] = array("default" => gltHORIZONTAL, "jsName" => "listGridLayout");
     $this->settingsMap["tableSettings"]["rowHighlite"] = array("default" => false, "jsName" => "isUseHighlite");
     $this->settingsMap["tableSettings"]["isUseToolTips"] = array("default" => false, "jsName" => "isUseToolTips");
     $this->settingsMap['tableSettings']['recsPerRowList'] = array("default" => 1, "jsName" => "recsPerRowList");
     $this->settingsMap["tableSettings"]["showAddInPopup"] = array("default" => false, "jsName" => "showAddInPopup");
     $this->settingsMap["tableSettings"]["showEditInPopup"] = array("default" => false, "jsName" => "showEditInPopup");
     $this->settingsMap["tableSettings"]["showViewInPopup"] = array("default" => false, "jsName" => "showViewInPopup");
     $this->settingsMap["tableSettings"]["isResizeColumns"] = array("default" => false, "jsName" => "isUseResize");
     $this->settingsMap["tableSettings"]["useDetailsPreview"] = array("default" => false, "jsName" => "isUseDP");
     $this->settingsMap['tableSettings']['isUsebuttonHandlers'] = array("default" => false, "jsName" => "isUseButtons");
     //if the Search panel added to the non table based page ajax suggests should be configured according to the search table's settings
     $ajaxSuggestDefault = $this->tableBasedSearchPanelAdded ? !$this->isUseAjaxSuggest : true;
     $this->settingsMap["tableSettings"]["isUseAjaxSuggest"] = array("default" => $ajaxSuggestDefault, "jsName" => "ajaxSuggest");
     if ($this->pageType == PAGE_REGISTER || $this->pageType == PAGE_CHANGEPASS) {
         $this->pageLayout = GetPageLayout('', $this->pageType);
     } else {
         $this->pageLayout = GetPageLayout($this->shortTableName, $this->pageType);
     }
     if ($this->pageLayout) {
         $this->jsSettings['tableSettings'][$this->tName]['pageSkinStyle'] = array();
         $this->jsSettings['tableSettings'][$this->tName]['pageSkinStyle'][$this->pageType] = $this->pageLayout->style . " page-" . $this->pageLayout->name;
         $this->AddCSSFile($this->pageLayout->getCSSFiles(isRTL(), isPageLayoutMobile($this->templatefile)));
     }
     $this->controlsMap["oldLayout"] = $this->isOldLayout();
     $this->controlsMap["layoutName"] = $this->getLayoutName();
     $this->settingsMap["fieldSettings"] = array();
     $this->settingsMap["fieldSettings"]["UseTimestamp"] = array("default" => false, "jsName" => "isUseTimeStamp");
     $this->settingsMap["fieldSettings"]["strName"] = array("default" => "", "jsName" => "strName");
     $this->settingsMap["fieldSettings"]["ShowTime"] = array("default" => false, "jsName" => "showTime");
     $this->settingsMap["fieldSettings"]["EditFormat"] = array("default" => "", "jsName" => "editFormat");
     $this->settingsMap["fieldSettings"]["DateEditType"] = array("default" => EDIT_DATE_SIMPLE, "jsName" => "dateEditType");
     $this->settingsMap["fieldSettings"]["RTEType"] = array("default" => "", "jsName" => "RTEType");
     $this->settingsMap["fieldSettings"]["ViewFormat"] = array("default" => "", "jsName" => "viewFormat");
     $this->settingsMap["fieldSettings"]["validateAs"] = array("default" => null, "jsName" => "validation");
     $this->settingsMap["fieldSettings"]["strEditMask"] = array("default" => null, "jsName" => "mask");
     $this->settingsMap["fieldSettings"]["LastYearFactor"] = array("default" => 10, "jsName" => "lastYear");
     $this->settingsMap["fieldSettings"]["InitialYearFactor"] = array("default" => 100, "jsName" => "initialYear");
     $this->settingsMap["fieldSettings"]["ShowListOfThumbnails"] = array("default" => false, "jsName" => "showListOfThumbnails");
     $this->settingsMap["fieldSettings"]["ImageWidth"] = array("default" => 0, "jsName" => "imageWidth");
     $this->settingsMap["fieldSettings"]["ImageHeight"] = array("default" => 0, "jsName" => "imageHeight");
     $this->jsSettings["tableSettings"][$this->tName]["strCaption"] = $this->strCaption;
     $this->jsSettings["tableSettings"][$this->tName]["pageMode"] = $this->mode;
     if ($this->listAjax) {
         $this->jsSettings['tableSettings'][$this->tName]['pageMode'] = LIST_AJAX;
     }
     if ($this->lockingObj) {
         $this->jsSettings['tableSettings'][$this->tName]['locking'] = true;
     }
     if ($this->warnLeavingPages && ($this->pageType == PAGE_REGISTER || $this->pageType == PAGE_ADD || $this->pageType == PAGE_EDIT)) {
         $this->jsSettings['tableSettings'][$this->tName]['warnOnLeaving'] = true;
     }
     //If current table has detail tables
     if (count($this->allDetailsTablesArr)) {
         if ($this->pageType == PAGE_LIST) {
             $this->jsSettings['tableSettings'][$this->tName]['detailTables'] = array();
         }
         $this->jsSettings['tableSettings'][$this->tName]['isShowDetails'] = $this->isShowDetailTables;
         for ($i = 0; $i < count($this->allDetailsTablesArr); $i++) {
             $this->settingsMap["globalSettings"]['shortTNames'][$this->allDetailsTablesArr[$i]['dDataSourceTable']] = $this->allDetailsTablesArr[$i]['dShortTable'];
             if ($this->pageType == PAGE_LIST || $this->pageType == PAGE_REPORT || $this->pageType == PAGE_CHART) {
                 unset($_SESSION[$this->allDetailsTablesArr[$i]['dDataSourceTable'] . '_advsearch']);
                 $dPermission = $this->getPermissions($this->allDetailsTablesArr[$i]['dDataSourceTable']);
                 if ($dPermission["search"]) {
                     $this->jsSettings['tableSettings'][$this->tName]['detailTables'][$this->allDetailsTablesArr[$i]['dDataSourceTable']] = array('pageType' => $this->allDetailsTablesArr[$i]['dType'], 'dispChildCount' => $this->allDetailsTablesArr[$i]['dispChildCount'], 'hideChild' => $this->allDetailsTablesArr[$i]['hideChild'], 'listShowType' => $this->allDetailsTablesArr[$i]['previewOnList'], 'addShowType' => $this->allDetailsTablesArr[$i]['previewOnAdd'], 'editShowType' => $this->allDetailsTablesArr[$i]['previewOnEdit'], 'viewShowType' => $this->allDetailsTablesArr[$i]['previewOnView']);
                 }
                 if ($this->allDetailsTablesArr[$i]['previewOnList'] == DP_POPUP) {
                     $this->jsSettings['tableSettings'][$this->tName]['isUsePopUp'] = true;
                 }
                 // field names of master keys of current table for passed details table name
                 $this->masterKeysByD[$i] = $this->allDetailsTablesArr[$i]['masterKeys'];
             }
         }
         if (($this->pageType == PAGE_ADD || $this->pageType == PAGE_EDIT) && $this->isShowDetailTables) {
             $this->controlsMap["dControlsMap"] = array();
         }
     }
     $this->controlsMap["video"] = array();
     $this->controlsMap['toolTips'] = array();
     $this->addLookupSettings();
     $this->addMultiUploadSettings();
     $this->controlsMap["searchPanelActivated"] = $this->searchPanelActivated;
     if ($this->pageType != PAGE_LIST || $this->mode != LIST_DETAILS) {
         $this->controlsMap["controls"] = array();
         if (!($this->pageType == PAGE_ADD && $this->mode == ADD_INLINE) && !($this->pageType == PAGE_EDIT && $this->mode == EDIT_INLINE)) {
             $allSearchFields = $this->pSetSearch->getAllSearchFields();
             $this->controlsMap["search"] = array();
             $this->controlsMap["search"]["searchBlocks"] = array();
             $this->controlsMap["search"]["allSearchFields"] = $allSearchFields;
             $this->controlsMap["search"]["allSearchFieldsLabels"] = $this->getSearchFieldsLabels($allSearchFields);
             $this->controlsMap["search"]["panelSearchFields"] = $this->pSetSearch->GetPanelSearchFields();
             $this->controlsMap["search"]["googleLikeFields"] = $this->pSetSearch->getGoogleLikeFields();
             $this->controlsMap["search"]["inflexSearchPanel"] = !$this->pSetSearch->isFlexibleSearch();
             $this->controlsMap["search"]["requiredSearchFields"] = $this->pSetSearch->getSearchRequiredFields();
             $this->controlsMap["search"]["isSearchRequired"] = $this->pSetSearch->noRecordsOnFirstPage();
             $this->controlsMap["search"]["searchTableName"] = $this->searchTableName;
             $this->controlsMap["search"]["shortSearchTableName"] = $this->pSetSearch->getShortTableName();
             if ($this->pageType != PAGE_SEARCH) {
                 $this->controlsMap["search"]["submitPageType"] = $this->pageType;
             } else {
                 if (postvalue("rname")) {
                     $this->controlsMap["search"]["submitPageType"] = "dreport";
                     $this->controlsMap["search"]["baseParams"]["rname"] = postvalue("rname");
                     if ($_SESSION["crossLink"]) {
                         if (substr($_SESSION["crossLink"], 0, 1) == "&") {
                             $_SESSION["crossLink"] = substr($_SESSION["crossLink"], 1);
                         }
                         $alink = explode("&", $_SESSION["crossLink"]);
                         foreach ($alink as $param) {
                             $arrtmp = explode("=", $param);
                             $this->controlsMap["search"]["baseParams"][$arrtmp[0]] = $arrtmp[1];
                         }
                     }
                 } elseif (postvalue("cname")) {
                     $this->controlsMap["search"]["submitPageType"] = "dchart";
                     $this->controlsMap["search"]["baseParams"]["cname"] = postvalue("cname");
                 } else {
                     $this->controlsMap["search"]["submitPageType"] = $this->tableType;
                 }
             }
         }
     }
     $this->isUseToolTips = $this->isUseToolTips || $this->pSet->isUseToolTips();
     $this->googleMapCfg["APIcode"] = "";
     $this->processMasterKeyValue();
     $this->assignSearchLogger();
 }
Esempio n. 6
0
 /**
  * Get a report's SQL query string
  * @param String strSQL		The report table's SQL query
  * @return String	
  */
 protected function getstrSQL($strSQL)
 {
     global $strTableName;
     $group_x = $this->getIntervalType($this->index_field_x);
     $group_y = $this->getIntervalType($this->index_field_y);
     $fName = $this->CrossGoodFieldName($this->dataField);
     $select_field = "' ', ";
     $avg_func = "";
     if ($fName != " ") {
         $select_field = $this->dataGroupFunction . "(" . $this->connection->addFieldWrappers($fName) . "), ";
         $this->is_value_empty = false;
         $ftype = $this->getFieldType($field);
         if ($this->dataGroupFunction == "avg" && !IsDateFieldType($ftype)) {
             $avg_func = ", sum(" . $this->connection->addFieldWrappers($fName) . ") as " . $this->connection->addFieldWrappers("avg_sum") . ", count(" . $this->connection->addFieldWrappers($fName) . ") as " . $this->connection->addFieldWrappers("avg_count");
         } else {
             $avg_func = ", 1 as " . $this->connection->addFieldWrappers("avg_sum") . ", 1 as " . $this->connection->addFieldWrappers("avg_count");
         }
     }
     $whereClause = "";
     if (tableEventExists("BeforeQueryReport", $strTableName)) {
         $eventObj = getEventObject($strTableName);
         $eventObj->BeforeQueryReport($whereClause);
         if ($whereClause) {
             $whereClause = " where " . $whereClause;
         }
     }
     $selectClause = "select " . $select_field . $group_y[0] . ", " . $group_x[0] . $avg_func;
     $groupByClause = "group by " . $group_x[1] . ", " . $group_y[1];
     $orderByClause = "order by " . $group_x[1] . "," . $group_y[1];
     if ($this->connection->dbType != nDATABASE_Oracle) {
         if ($this->connection->dbType == nDATABASE_MSSQLServer) {
             $pos = strrpos(strtoupper($strSQL), "ORDER BY");
             if ($pos) {
                 $strSQL = substr($strSQL, 0, $pos);
             }
         }
         return $selectClause . " from (" . $strSQL . ") as cross_table" . $whereClause . " " . $groupByClause . " " . $orderByClause;
     }
     return $selectClause . " from (" . $strSQL . ")" . $whereClause . " " . $groupByClause . " " . $orderByClause;
 }
Esempio n. 7
0
	function xt_doevent($params)
	{
		if (isset($this->xt_events[@$params["custom1"]]))
		{
			$eventArr = $this->xt_events[@$params["custom1"]];
			
			if(isset($eventArr["method"]))
			{
				$params=array();
				if(isset($eventArr["params"]))
					$params=$eventArr["params"];
				$method=$eventArr["method"];
				$eventArr["object"]->$method($params);
				return;
			}
		}
		global $strTableName, $globalEvents;
		if($this->eventsObject)
			$eventObj = &$this->eventsObject;
		elseif(strlen($strTableName))
			$eventObj = getEventObject($strTableName);
		else
			$eventObj = &$globalEvents;
		if(!$eventObj)
			return;
		$eventName = $params["custom1"];
		if(!$eventObj->exists($eventName))
			return;
		$eventObj->$eventName($params);
	}
Esempio n. 8
0
 function RunnerPage(&$params)
 {
     global $locale_info, $cCharset, $page_layouts;
     // copy properties to object
     RunnerApply($this, $params);
     $this->pSet = new ProjectSettings($this->tName, $this->pageType);
     $this->pSetEdit = $this->pSet;
     $this->cipherer = new RunnerCipherer($this->tName, $this->pSet);
     include_once getabspath("classes/controls/EditControlsContainer.php");
     $this->controls = new EditControlsContainer($this);
     include_once getabspath("classes/controls/ViewControlsContainer.php");
     $this->viewControls = new ViewControlsContainer($this->pSet, $this->pageType, $this);
     $this->gQuery = $this->pSet->getSQLQuery();
     //set google map configuration
     $this->googleMapCfg = array('markerAsLinkToView' => true, 'isUseMainMaps' => false, 'isUseFieldsMaps' => false, 'isUseGoogleMap' => false, 'APIcode' => GetGlobalData("apiGoogleMapsCode", ""), 'mainMapIds' => array(), 'fieldMapsIds' => array(), 'mapsData' => array());
     $this->debugJSMode = false;
     if ($this->flyId < $this->id + 1) {
         $this->flyId = $this->id + 1;
     }
     // get permissions
     if ($this->tName) {
         $this->permis[$this->tName] = $this->getPermissions();
         $this->eventsObject =& getEventObject($this->tName);
     }
     if (!$this->sessionPrefix) {
         $this->sessionPrefix = $this->tName;
     }
     $this->setSessionVariables();
     //	get locking object
     $this->lockingObj = GetLockingObject($this->tName);
     $this->is508 = isEnableSection508();
     $this->isEncryptionEnabled = isEncryptionEnabled();
     $this->isEncryptionByPHPEnabled = isEncryptionByPHPEnabled();
     $this->isUseVideo = $this->pSet->isUseVideo();
     $this->isUseAudio = $this->pSet->isUseAudio();
     $this->strCaption = GetTableCaption(GoodFieldName($this->tName));
     $this->isTableType = $this->pSet->isTableType();
     $this->isAddWebRep = GetGlobalData("isAddWebRep", false);
     //	get details keys by master table
     $this->detailKeysByM = $this->pSet->getDetailKeysByMasterTable($this->masterTable);
     $this->isDynamicPerm = GetGlobalData("isDynamicPerm", false);
     $this->shortTableName = $this->pSet->getShortTableName();
     $this->showAddInPopup = $this->pSet->isShowAddInPopup();
     $this->showEditInPopup = $this->pSet->isShowEditInPopup();
     $this->showViewInPopup = $this->pSet->isShowViewInPopup();
     $this->isResizeColumns = $this->pSet->isResizeColumns();
     $this->isUseAjaxSuggest = $this->pSet->isUseAjaxSuggest();
     $this->useDetailsPreview = $this->pSet->isUseDetailsPreview();
     $this->isShowDetailTables = displayDetailsOn($this->tName, $this->pageType);
     //	get all details table for current table
     $this->allDetailsTablesArr = $this->pSet->getDetailTablesArr();
     //	set template file
     $this->setTemplateFile();
     //	init jsSettings
     $this->jsSettings["tableSettings"][$this->tName] = array();
     $this->jsSettings["tableSettings"][$this->tName]["proxy"] = array("proxy" => "");
     $this->jsSettings["tableSettings"][$this->tName]['fieldSettings'] = array();
     $this->settingsMap["globalSettings"] = array();
     $this->settingsMap["globalSettings"]["ext"] = "php";
     $this->settingsMap["globalSettings"]["charSet"] = $cCharset;
     $this->settingsMap["globalSettings"]["debugMode"] = $this->debugJSMode;
     $this->settingsMap["globalSettings"]["googleMapsApiCode"] = $this->googleMapCfg['APIcode'];
     $this->settingsMap["globalSettings"]["shortTNames"][$this->tName] = $this->shortTableName;
     //isMobile
     $this->settingsMap["globalSettings"]["isMobile"] = isMobile();
     // s508 must be in global settings
     $this->settingsMap['globalSettings']['s508'] = $this->is508;
     $this->settingsMap["globalSettings"]["locale"]["dateFormat"] = $locale_info["LOCALE_IDATE"];
     $this->settingsMap["globalSettings"]["locale"]["startWeekDay"] = $locale_info["LOCALE_IFIRSTDAYOFWEEK"];
     $this->settingsMap["globalSettings"]["locale"]["dateDelimiter"] = $locale_info["LOCALE_SDATE"];
     $this->settingsMap["tableSettings"] = array();
     $this->settingsMap['tableSettings']['hasEvents'] = array("default" => false, "jsName" => "hasEvents");
     $this->settingsMap["tableSettings"]["listIcons"] = array("default" => false, "jsName" => "listIcons");
     $this->settingsMap["tableSettings"]["strCaption"] = array("default" => "", "jsName" => "strCaption");
     $this->settingsMap["tableSettings"]["isUseAudio"] = array("default" => false, "jsName" => "isUseAudio");
     $this->settingsMap["tableSettings"]["isUseVideo"] = array("default" => false, "jsName" => "isUseVideo");
     $this->settingsMap['tableSettings']['isVerLayout'] = array("default" => false, "jsName" => "isVertLayout");
     $this->settingsMap["tableSettings"]["rowHighlite"] = array("default" => false, "jsName" => "isUseHighlite");
     $this->settingsMap["tableSettings"]["isUseToolTips"] = array("default" => false, "jsName" => "isUseToolTips");
     $this->settingsMap['tableSettings']['recsPerRowList'] = array("default" => 1, "jsName" => "recsPerRowList");
     $this->settingsMap["tableSettings"]["showAddInPopup"] = array("default" => false, "jsName" => "showAddInPopup");
     $this->settingsMap["tableSettings"]["showEditInPopup"] = array("default" => false, "jsName" => "showEditInPopup");
     $this->settingsMap["tableSettings"]["showViewInPopup"] = array("default" => false, "jsName" => "showViewInPopup");
     $this->settingsMap["tableSettings"]["isResizeColumns"] = array("default" => false, "jsName" => "isUseResize");
     $this->settingsMap["tableSettings"]["isUseAjaxSuggest"] = array("default" => true, "jsName" => "ajaxSuggest");
     $this->settingsMap["tableSettings"]["useDetailsPreview"] = array("default" => false, "jsName" => "isUseDP");
     $this->settingsMap['tableSettings']['isUsebuttonHandlers'] = array("default" => false, "jsName" => "isUseButtons");
     if ($this->pageType == PAGE_REGISTER || $this->pageType == PAGE_CHANGEPASS) {
         $layout = GetPageLayout('', $this->pageType);
     } else {
         $layout = GetPageLayout($this->shortTableName, $this->pageType);
     }
     if ($layout) {
         $rtl = $this->xt->getReadingOrder() == 'RTL' ? 'RTL' : '';
         $this->jsSettings['tableSettings'][$this->tName]['pageCSS'] = "styles/" . $layout->style . '/style' . $rtl . ".css";
         $this->jsSettings['tableSettings'][$this->tName]['pageLayout'] = "pagestyles/" . $layout->name . $rtl . ".css";
         $this->jsSettings['tableSettings'][$this->tName]['pageSkinStyle'] = $layout->style . " page-" . $layout->name;
     }
     $this->settingsMap["fieldSettings"]["UseTimestamp"] = array("default" => false, "jsName" => "isUseTimeStamp");
     $this->settingsMap["fieldSettings"]["strName"] = array("default" => "", "jsName" => "strName");
     $this->settingsMap["fieldSettings"]["ShowTime"] = array("default" => false, "jsName" => "showTime");
     $this->settingsMap["fieldSettings"]["EditFormat"] = array("default" => "", "jsName" => "editFormat");
     $this->settingsMap["fieldSettings"]["DateEditType"] = array("default" => EDIT_DATE_SIMPLE, "jsName" => "dateEditType");
     $this->settingsMap["fieldSettings"]["RTEType"] = array("default" => "", "jsName" => "RTEType");
     $this->settingsMap["fieldSettings"]["ViewFormat"] = array("default" => "", "jsName" => "viewFormat");
     $this->settingsMap["fieldSettings"]["validateAs"] = array("default" => null, "jsName" => "validation");
     $this->settingsMap["fieldSettings"]["strEditMask"] = array("default" => null, "jsName" => "mask");
     $this->settingsMap["fieldSettings"]["LastYearFactor"] = array("default" => 10, "jsName" => "lastYear");
     $this->settingsMap["fieldSettings"]["InitialYearFactor"] = array("default" => 100, "jsName" => "initialYear");
     $this->jsSettings["tableSettings"][$this->tName]["strCaption"] = $this->strCaption;
     $this->jsSettings["tableSettings"][$this->tName]["pageMode"] = $this->mode;
     if ($this->listAjax) {
         $this->jsSettings['tableSettings'][$this->tName]['pageMode'] = LIST_AJAX;
     }
     if ($this->lockingObj) {
         $this->jsSettings['tableSettings'][$this->tName]['locking'] = true;
     }
     //If current table has detail tables
     if (count($this->allDetailsTablesArr)) {
         if ($this->pageType == PAGE_LIST) {
             $this->jsSettings['tableSettings'][$this->tName]['detailTables'] = array();
         }
         $this->jsSettings['tableSettings'][$this->tName]['isShowDetails'] = $this->isShowDetailTables;
         for ($i = 0; $i < count($this->allDetailsTablesArr); $i++) {
             $this->settingsMap["globalSettings"]['shortTNames'][$this->allDetailsTablesArr[$i]['dDataSourceTable']] = $this->allDetailsTablesArr[$i]['dShortTable'];
             if ($this->pageType == PAGE_LIST) {
                 $this->jsSettings['tableSettings'][$this->tName]['detailTables'][$this->allDetailsTablesArr[$i]['dDataSourceTable']] = array('dispChildCount' => $this->allDetailsTablesArr[$i]['dispChildCount'], 'hideChild' => $this->allDetailsTablesArr[$i]['hideChild'], 'listShowType' => $this->allDetailsTablesArr[$i]['previewOnList'], 'addShowType' => $this->allDetailsTablesArr[$i]['previewOnAdd'], 'editShowType' => $this->allDetailsTablesArr[$i]['previewOnEdit'], 'viewShowType' => $this->allDetailsTablesArr[$i]['previewOnView']);
                 if ($this->allDetailsTablesArr[$i]['previewOnList'] == DP_POPUP) {
                     $this->jsSettings['tableSettings'][$this->tName]['isUsePopUp'] = true;
                 }
                 // field names of master keys of current table for passed details table name
                 $this->masterKeysByD[$i] = $this->pSet->getMasterKeysByDetailTable($this->allDetailsTablesArr[$i]['dDataSourceTable']);
             }
         }
         if (($this->pageType == PAGE_ADD || $this->pageType == PAGE_EDIT) && $this->isShowDetailTables) {
             $this->controlsMap["dControlsMap"] = array();
         }
     }
     $this->controlsMap["video"] = array();
     $this->controlsMap['toolTips'] = array();
     $this->addLookupSettings();
     $this->addMultiUploadSettings();
     if ($this->mode != LIST_DETAILS) {
         $this->controlsMap["controls"] = array();
         if (!$this->pageAddLikeInline && !$this->pageEditLikeInline) {
             $this->controlsMap["search"] = array();
             $this->controlsMap["search"]["searchBlocks"] = array();
             $this->controlsMap["search"]["panelSearchFields"] = $this->pSet->GetPanelSearchFields();
             $this->controlsMap["search"]["allSearchFields"] = $this->pSet->getAllSearchFields();
             $this->controlsMap["search"]["googleLikeFields"] = $this->pSet->getGoogleLikeFields();
             if ($this->pageType != PAGE_SEARCH) {
                 $this->controlsMap["search"]["submitPageType"] = $this->pageType;
             } else {
                 if (postvalue("rname")) {
                     $this->controlsMap["search"]["submitPageType"] = "dreport";
                     $this->controlsMap["search"]["baseParams"]["rname"] = postvalue("rname");
                     if ($_SESSION["crossLink"]) {
                         if (substr($_SESSION["crossLink"], 0, 1) == "&") {
                             $_SESSION["crossLink"] = substr($_SESSION["crossLink"], 1);
                         }
                         $alink = explode("&", $_SESSION["crossLink"]);
                         foreach ($alink as $param) {
                             $arrtmp = explode("=", $param);
                             $this->controlsMap["search"]["baseParams"][$arrtmp[0]] = $arrtmp[1];
                         }
                     }
                 } elseif (postvalue("cname")) {
                     $this->controlsMap["search"]["submitPageType"] = "dchart";
                     $this->controlsMap["search"]["baseParams"]["cname"] = postvalue("cname");
                 } else {
                     $this->controlsMap["search"]["submitPageType"] = $this->isTableType;
                 }
             }
         }
     }
     $this->timepicker = $this->timepicker || $this->pSet->isUseTimeForSearch();
     $this->isUseToolTips = $this->isUseToolTips || $this->pSet->isUseToolTips();
     $this->googleMapCfg["APIcode"] = "";
     if ($this->xt) {
         $this->xt->assign("pagetitle", $this->getPageTitle());
     }
 }
Esempio n. 9
0
 function getstrSQL()
 {
     global $strSQL;
     $gr_x = $_SESSION[$this->TableName . "_gr_x"];
     $gr_y = $_SESSION[$this->TableName . "_gr_y"];
     $index_field = $_SESSION[$this->TableName . "_field"];
     $group_func = $_SESSION[$this->TableName . "_group_func"];
     $group_x = array();
     $group_y = array();
     $arr_value = array();
     if ($gr_x == "") {
         $this->index_field_x = $this->getFirstGroupField("x");
         $group_x = $this->getIntervalType($this->index_field_x);
     } else {
         $group_x = $this->getIntervalType($gr_x);
         $this->index_field_x = $gr_x;
     }
     if ($gr_y == "") {
         $this->index_field_y = $this->getFirstGroupField("y");
         $group_y = $this->getIntervalType($this->index_field_y);
     } else {
         $group_y = $this->getIntervalType($gr_y);
         $this->index_field_y = $gr_y;
     }
     $arr_value = $this->getSelectedValue();
     if ($index_field == "") {
         if (!empty($arr_value)) {
             $field = $arr_value[0];
             $val = AddFieldWrappers($this->CrossGoodFieldName($field));
         } else {
             $field = $_SESSION['webreports']['group_fields'][0]["name"];
             $val = AddFieldWrappers($this->CrossGoodFieldName($field));
         }
     } else {
         $val = AddFieldWrappers($this->CrossGoodFieldName($arr_value[$index_field]));
         $field = $arr_value[$index_field];
     }
     if ($group_func == "") {
         $group_func = "sum";
     }
     $gr_func = $this->getGroupFunction($field, $group_func);
     $select_field = "' ', ";
     $avg_func = "";
     if ($val != " ") {
         $select_field = $gr_func . "(" . AddFieldWrappers($val) . "), ";
         $this->is_value_empty = false;
         $ftype = $this->getFieldType($field);
         if ($group_func == "avg" && !IsDateFieldType($ftype)) {
             $avg_func = ", sum(" . AddFieldWrappers($val) . ") as " . AddFieldWrappers("avg_sum") . ", count(" . AddFieldWrappers($val) . ") as " . AddFieldWrappers("avg_count");
         } else {
             $avg_func = ", 1 as " . AddFieldWrappers("avg_sum") . ", 1 as " . AddFieldWrappers("avg_count");
         }
     }
     global $strTableName;
     $hwhere = "";
     if (tableEventExists("BeforeQueryReport", $strTableName)) {
         $eventObj = getEventObject($strTableName);
         $eventObj->BeforeQueryReport($hwhere);
         if ($hwhere) {
             $hwhere = " where " . $hwhere;
         }
     }
     $crtableSQL = "select " . $select_field . $group_y[0] . ", " . $group_x[0] . $avg_func . " from (" . $strSQL . ") as cross_table" . $hwhere . " group by " . $group_x[1] . ", " . $group_y[1] . " Order by " . $group_x[1];
     //echo $crtableSQL;
     return $crtableSQL;
 }
function DisplayMasterTableInfoForPrint_calendar_table($params)
{
    global $cman;
    $detailtable = $params["detailtable"];
    $keys = $params["keys"];
    $xt = new Xtempl();
    $tName = "calendar_table";
    $xt->eventsObject = getEventObject($tName);
    $cipherer = new RunnerCipherer($tName);
    $settings = new ProjectSettings($tName, PAGE_PRINT);
    $connection = $cman->byTable($tName);
    $masterQuery = $settings->getSQLQuery();
    $viewControls = new ViewControlsContainer($settings, PAGE_PRINT);
    $where = "";
    $keysAssoc = array();
    $showKeys = "";
    if ($detailtable == "Fact_SalesTransaction") {
        $keysAssoc["dt"] = $keys[1 - 1];
        $where .= RunnerPage::_getFieldSQLDecrypt("dt", $connection, $settings, $cipherer) . "=" . $cipherer->MakeDBValue("dt", $keys[1 - 1], "", true);
        $keyValue = $viewControls->showDBValue("dt", $keysAssoc);
        $showKeys .= " " . GetFieldLabel("calendar_table", "dt") . ": " . $keyValue;
        $xt->assign('showKeys', $showKeys);
    }
    if ($detailtable == "Current Year Sales") {
        $keysAssoc["dt"] = $keys[1 - 1];
        $where .= RunnerPage::_getFieldSQLDecrypt("dt", $connection, $settings, $cipherer) . "=" . $cipherer->MakeDBValue("dt", $keys[1 - 1], "", true);
        $keyValue = $viewControls->showDBValue("dt", $keysAssoc);
        $showKeys .= " " . GetFieldLabel("calendar_table", "dt") . ": " . $keyValue;
        $xt->assign('showKeys', $showKeys);
    }
    if (!$where) {
        return;
    }
    $str = SecuritySQL("Export", $tName);
    if (strlen($str)) {
        $where .= " and " . $str;
    }
    $strWhere = whereAdd($masterQuery->m_where->toSql($masterQuery), $where);
    if (strlen($strWhere)) {
        $strWhere = " where " . $strWhere . " ";
    }
    $strSQL = $masterQuery->HeadToSql() . ' ' . $masterQuery->FromToSql() . $strWhere . $masterQuery->TailToSql();
    LogInfo($strSQL);
    $data = $cipherer->DecryptFetchedArray($connection->query($strSQL)->fetchAssoc());
    if (!$data) {
        return;
    }
    // reassign pagetitlelabel function adding extra params
    $xt->assign_function("pagetitlelabel", "xt_pagetitlelabel", array("record" => $data, "settings" => $settings));
    $keylink = "";
    $keylink .= "&key1=" . runner_htmlspecialchars(rawurlencode(@$data["dt"]));
    $xt->assign("dt_mastervalue", $viewControls->showDBValue("dt", $data, $keylink));
    $format = $settings->getViewFormat("dt");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("dt"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("dt_class", $class);
    // add class for field header as field value
    $xt->assign("y_mastervalue", $viewControls->showDBValue("y", $data, $keylink));
    $format = $settings->getViewFormat("y");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("y"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("y_class", $class);
    // add class for field header as field value
    $xt->assign("q_mastervalue", $viewControls->showDBValue("q", $data, $keylink));
    $format = $settings->getViewFormat("q");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("q"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("q_class", $class);
    // add class for field header as field value
    $xt->assign("m_mastervalue", $viewControls->showDBValue("m", $data, $keylink));
    $format = $settings->getViewFormat("m");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("m"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("m_class", $class);
    // add class for field header as field value
    $xt->assign("d_mastervalue", $viewControls->showDBValue("d", $data, $keylink));
    $format = $settings->getViewFormat("d");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("d"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("d_class", $class);
    // add class for field header as field value
    $xt->assign("dw_mastervalue", $viewControls->showDBValue("dw", $data, $keylink));
    $format = $settings->getViewFormat("dw");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("dw"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("dw_class", $class);
    // add class for field header as field value
    $xt->assign("monthName_mastervalue", $viewControls->showDBValue("monthName", $data, $keylink));
    $format = $settings->getViewFormat("monthName");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("monthName"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("monthName_class", $class);
    // add class for field header as field value
    $xt->assign("dayName_mastervalue", $viewControls->showDBValue("dayName", $data, $keylink));
    $format = $settings->getViewFormat("dayName");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("dayName"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("dayName_class", $class);
    // add class for field header as field value
    $xt->assign("w_mastervalue", $viewControls->showDBValue("w", $data, $keylink));
    $format = $settings->getViewFormat("w");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("w"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("w_class", $class);
    // add class for field header as field value
    $xt->assign("isWeekday_mastervalue", $viewControls->showDBValue("isWeekday", $data, $keylink));
    $format = $settings->getViewFormat("isWeekday");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("isWeekday"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("isWeekday_class", $class);
    // add class for field header as field value
    $xt->assign("isHoliday_mastervalue", $viewControls->showDBValue("isHoliday", $data, $keylink));
    $format = $settings->getViewFormat("isHoliday");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("isHoliday"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("isHoliday_class", $class);
    // add class for field header as field value
    $xt->assign("holidayDescr_mastervalue", $viewControls->showDBValue("holidayDescr", $data, $keylink));
    $format = $settings->getViewFormat("holidayDescr");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("holidayDescr"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("holidayDescr_class", $class);
    // add class for field header as field value
    $xt->assign("isPayday_mastervalue", $viewControls->showDBValue("isPayday", $data, $keylink));
    $format = $settings->getViewFormat("isPayday");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("isPayday"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("isPayday_class", $class);
    // add class for field header as field value
    $xt->assign("yearQuarterText_mastervalue", $viewControls->showDBValue("yearQuarterText", $data, $keylink));
    $format = $settings->getViewFormat("yearQuarterText");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("yearQuarterText"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("yearQuarterText_class", $class);
    // add class for field header as field value
    $xt->assign("yearMonthInt_mastervalue", $viewControls->showDBValue("yearMonthInt", $data, $keylink));
    $format = $settings->getViewFormat("yearMonthInt");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("yearMonthInt"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("yearMonthInt_class", $class);
    // add class for field header as field value
    $xt->assign("yearMonthText_mastervalue", $viewControls->showDBValue("yearMonthText", $data, $keylink));
    $format = $settings->getViewFormat("yearMonthText");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("yearMonthText"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("yearMonthText_class", $class);
    // add class for field header as field value
    $xt->assign("yearWeekInt_mastervalue", $viewControls->showDBValue("yearWeekInt", $data, $keylink));
    $format = $settings->getViewFormat("yearWeekInt");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("yearWeekInt"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("yearWeekInt_class", $class);
    // add class for field header as field value
    $xt->assign("yearWeekText_mastervalue", $viewControls->showDBValue("yearWeekText", $data, $keylink));
    $format = $settings->getViewFormat("yearWeekText");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("yearWeekText"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("yearWeekText_class", $class);
    // add class for field header as field value
    $xt->assign("monthWeekInt_mastervalue", $viewControls->showDBValue("monthWeekInt", $data, $keylink));
    $format = $settings->getViewFormat("monthWeekInt");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("monthWeekInt"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("monthWeekInt_class", $class);
    // add class for field header as field value
    $xt->assign("monthWeekText_mastervalue", $viewControls->showDBValue("monthWeekText", $data, $keylink));
    $format = $settings->getViewFormat("monthWeekText");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("monthWeekText"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("monthWeekText_class", $class);
    // add class for field header as field value
    $xt->assign("fiscalYear_mastervalue", $viewControls->showDBValue("fiscalYear", $data, $keylink));
    $format = $settings->getViewFormat("fiscalYear");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("fiscalYear"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("fiscalYear_class", $class);
    // add class for field header as field value
    $xt->assign("fiscalMonth_mastervalue", $viewControls->showDBValue("fiscalMonth", $data, $keylink));
    $format = $settings->getViewFormat("fiscalMonth");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("fiscalMonth"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("fiscalMonth_class", $class);
    // add class for field header as field value
    $xt->assign("fiscalQuarter_mastervalue", $viewControls->showDBValue("fiscalQuarter", $data, $keylink));
    $format = $settings->getViewFormat("fiscalQuarter");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("fiscalQuarter"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("fiscalQuarter_class", $class);
    // add class for field header as field value
    $xt->assign("fiscalYearMonthText_mastervalue", $viewControls->showDBValue("fiscalYearMonthText", $data, $keylink));
    $format = $settings->getViewFormat("fiscalYearMonthText");
    $class = " rnr-field-text";
    if ($format == FORMAT_FILE) {
        $class = ' rnr-field-file';
    }
    if ($format == FORMAT_AUDIO) {
        $class = ' rnr-field-audio';
    }
    if ($format == FORMAT_CHECKBOX) {
        $class = ' rnr-field-checkbox';
    }
    if ($format == FORMAT_NUMBER || IsNumberType($settings->getFieldType("fiscalYearMonthText"))) {
        $class = ' rnr-field-number';
    }
    $xt->assign("fiscalYearMonthText_class", $class);
    // add class for field header as field value
    $layout = GetPageLayout("calendar_table", 'masterprint');
    if ($layout) {
        $xt->assign("pageattrs", 'class="' . $layout->style . " page-" . $layout->name . '"');
    }
    $xt->displayPartial(GetTemplateName("calendar_table", "masterprint"));
}
Esempio n. 11
0
 function Chart(&$ch_array, $param)
 {
     global $field_labels;
     if ($this->webchart) {
         $this->chrt_array = Convert_Old_Chart($ch_array);
     } else {
         $this->chrt_array = $ch_array;
     }
     $this->pSet = new ProjectSettings($this->chrt_array['tables'][0]);
     $this->chrt_array["appearance"]["autoupdate"] = false;
     $this->numRecordsToShow = $this->chrt_array['appearance']['maxbarscroll'];
     if ($this->numRecordsToShow < 1) {
         $this->numRecordsToShow = 1;
     }
     $this->table_type = $this->chrt_array["table_type"];
     if (!$this->table_type) {
         $this->table_type = "project";
     }
     $this->webchart = $param["webchart"];
     $this->cname = $param["cname"];
     $this->sessionPrefix = $this->chrt_array['tables'][0];
     $this->gstrOrderBy = $param["gstrOrderBy"];
     $TableName = GoodFieldName($this->chrt_array['tables'][0]);
     $this->cipherer = new RunnerCipherer($this->chrt_array['tables'][0]);
     $this->header = $this->chrt_array['appearance']['head'];
     $this->footer = $this->chrt_array['appearance']['foot'];
     $this->y_axis_label = $this->chrt_array['appearance']['y_axis_label'];
     for ($i = 0; $i < count($this->chrt_array['parameters']) - 1; $i++) {
         if (isset($this->chrt_array['parameters'][$i]['currencyFormat'])) {
             $this->arrFormatCurrency[] = $this->chrt_array['parameters'][$i]['currencyFormat'];
         } else {
             if ($this->chrt_array['appearance']['scur'] == "false") {
                 $this->arrFormatCurrency[] = "";
             } else {
                 $this->arrFormatCurrency[] = $this->chrt_array['appearance']['scur'];
             }
         }
         if (isset($this->chrt_array['parameters'][$i]['decimalFormat'])) {
             $this->arrFormatDecimal[] = $this->chrt_array['parameters'][$i]['decimalFormat'];
         } else {
             $this->arrFormatDecimal[] = $this->chrt_array['appearance']['dec'];
         }
         $this->arrFormatCustomer[] = $this->chrt_array['parameters'][$i]['customFormat'];
         $this->arrFormatCustomerStr[] = $this->chrt_array['parameters'][$i]['customFormatStr'];
         if ($this->chrt_array["chart_type"]["type"] == "ohlc" || $this->chrt_array["chart_type"]["type"] == "candlestick") {
             $this->arrOHLC_open[] = $this->chrt_array['parameters'][$i]['ohlcOpen'];
             $this->arrOHLC_high[] = $this->chrt_array['parameters'][$i]['ohlcHigh'];
             $this->arrOHLC_low[] = $this->chrt_array['parameters'][$i]['ohlcLow'];
             $this->arrOHLC_close[] = $this->chrt_array['parameters'][$i]['ohlcClose'];
             $this->arrOHLC_color[] = "#" . $this->chrt_array['parameters'][$i]['ohlcColor'];
             if ($this->chrt_array["chart_type"]["type"] == "candlestick") {
                 $this->arrOHLC_candle[] = "#" . $this->chrt_array['parameters'][$i]['ohlcCandleColor'];
             }
         } elseif ($this->chrt_array['parameters'][$i]['name'] != "") {
             if ($this->table_type != "db") {
                 $this->arrDataSeries[] = $this->chrt_array['parameters'][$i]['agr_func'] ? $this->chrt_array['parameters'][$i]['label'] : $this->chrt_array['parameters'][$i]['name'];
             } else {
                 $this->arrDataSeries[] = $this->chrt_array['parameters'][$i]['agr_func'] ? $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['label'] : $this->chrt_array['parameters'][$i]['table'] . "_" . $this->chrt_array['parameters'][$i]['name'];
             }
             if (isset($this->chrt_array['appearance']['scolor' . ($i + 1) . '1'])) {
                 $this->arrDataColor[] = $this->chrt_array['appearance']['scolor' . ($i + 1) . '1'];
             } else {
                 $this->arrDataColor[] = $this->chrt_array['parameters'][$i]['series_color'];
             }
             if ($this->chrt_array["chart_type"]["type"] == "bubble") {
                 $this->arrDataSize[] = $this->chrt_array['parameters'][$i]['size'];
             }
             if ($this->chrt_array["chart_type"]["type"] == "gauge") {
                 for ($k = 0; is_array($this->chrt_array["parameters"][$i]["gaugeColorZone"]) && $k < count($this->chrt_array["parameters"][$i]["gaugeColorZone"]); $k++) {
                     $beginColor = (double) @$this->chrt_array["parameters"][$i]["gaugeColorZone"][$k]["gaugeBeginColor"];
                     $endColor = (double) @$this->chrt_array["parameters"][$i]["gaugeColorZone"][$k]["gaugeEndColor"];
                     $gColor = "#" . @$this->chrt_array["parameters"][$i]["gaugeColorZone"][$k]["gaugeColor"];
                     $this->arrGaugeColor[count($this->arrDataSeries) - 1][] = array($beginColor, $endColor, $gColor);
                 }
             }
         }
         if ($this->table_type == "project" && !$this->webchart) {
             $this->arrDataLabels[] = $this->chart_xmlencode(GetFieldLabel(GoodFieldName($TableName), GoodFieldName($this->chrt_array['parameters'][$i]['name'])));
         } else {
             if (!$this->chart_xmlencode($this->chrt_array['parameters'][$i]['label'])) {
                 $this->arrDataLabels[] = $this->chart_xmlencode($this->chrt_array['parameters'][$i]['name']);
             } else {
                 $this->arrDataLabels[] = $this->chart_xmlencode($this->chrt_array['parameters'][$i]['label']);
             }
         }
     }
     if ($this->chrt_array["chart_type"]["type"] != "gauge") {
         if ($this->table_type != "db") {
             $this->strLabel = $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'];
         } else {
             $this->strLabel = $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['table'] . "_" . $this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'];
         }
         for ($j = 0; $j < count($this->chrt_array['fields']); $j++) {
             if ($this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'] == $this->chrt_array['fields'][$j]['name']) {
                 if ($this->table_type == "project") {
                     $this->label2 = $this->chart_xmlencode(GetFieldLabel($TableName, GoodFieldName($this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name'])));
                 } else {
                     $this->label2 = $this->chart_xmlencode($this->chrt_array['parameters'][count($this->chrt_array['parameters']) - 1]['name']);
                 }
             }
         }
     }
     if ($this->chrt_array["chart_type"]["type"] != "ohlc" && $this->chrt_array["chart_type"]["type"] != "candlestick") {
         foreach ($this->arrDataColor as $ind => $val) {
             if ($ind == 0) {
                 $this->arrAxesColor = "#000000";
             } else {
                 $this->arrAxesColor = "#" . $this->arrDataColor[$ind];
             }
         }
     } else {
         foreach ($this->arrOHLC_color as $ind => $val) {
             if ($ind == 0) {
                 $this->arrAxesColor = "#000000";
             } else {
                 $this->arrAxesColor = "#" . $this->arrOHLC_color[$ind];
             }
         }
     }
     // prepare search params
     $gQuery = $this->pSet->getSQLQuery();
     $strWhereClause = "";
     $searchHavingClause = "";
     $strSearchCriteria = "and";
     global $strTableName;
     // search where for basic charts
     if (!$this->webchart) {
         if (isset($_SESSION[$this->sessionPrefix . '_advsearch'])) {
             $searchClauseObj = unserialize($_SESSION[$this->sessionPrefix . '_advsearch']);
             include_once getabspath('classes/controls/EditControlsContainer.php');
             $editControls = new EditControlsContainer(null, $this->pSet, PAGE_REPORT, $this->cipherer);
             $strWhereClause = $searchClauseObj->getWhere($this->pSet->getListOfFieldsByExprType(false), $editControls);
             $searchHavingClause = $searchClauseObj->getWhere($this->pSet->getListOfFieldsByExprType(true), $editControls);
             $strSearchCriteria = @$_SESSION[$strTableName . "_criteria"];
             if ($searchClauseObj->isUsedSearchFor && !$searchClauseObj->isUsedFieldsForSearch) {
                 $strSearchCriteria = "or";
             }
         }
     } else {
         if ($this->table_type != "project") {
             $strTableName = "webchart" . $this->cname;
         }
         $strWhereClause = CalcSearchParam($this->table_type != "project");
     }
     if ($strWhereClause) {
         $this->chrt_array['where'] .= $this->chrt_array['where'] ? " AND (" . $strWhereClause . ")" : " WHERE (" . $strWhereClause . ")";
     }
     if ($this->table_type == "project") {
         if (SecuritySQL("Search")) {
             $strWhereClause = whereAdd($strWhereClause, SecuritySQL("Search"));
         }
         $this->strSQL = $gQuery->gSQLWhere($strWhereClause, $searchHavingClause, $strSearchCriteria);
         $strOrderBy = $this->gstrOrderBy;
         $this->strSQL .= " " . $strOrderBy;
         $strSQLbak = $this->strSQL;
         if (tableEventExists("BeforeQueryChart", $strTableName)) {
             $tstrSQL = $this->strSQL;
             $eventObj = getEventObject($strTableName);
             $eventObj->BeforeQueryChart($tstrSQL, $strWhereClause, $strOrderBy);
             $this->strSQL = $tstrSQL;
         }
         if ($strSQLbak == $this->strSQL) {
             $this->strSQL = $gQuery->gSQLWhere($strWhereClause, $searchHavingClause, $strSearchCriteria);
             $this->strSQL .= " " . $strOrderBy;
         }
     }
     if ($this->cname && $this->table_type == "db") {
         $this->strSQL = $this->chrt_array['sql'] . $this->chrt_array['where'] . $this->chrt_array['group_by'] . $this->chrt_array['order_by'];
     } elseif ($this->cname && $this->table_type == "custom") {
         if (!IsStoredProcedure($this->chrt_array['sql'])) {
             $sql_query = $this->chrt_array['sql'];
             if (GetDatabaseType() == 2) {
                 $pos = strrpos(strtoupper($sql_query), "ORDER BY");
                 if ($pos) {
                     $sql_query = substr($sql_query, 0, $pos);
                 }
             }
             if (GetDatabaseType() != 1) {
                 //Oracle
                 $this->strSQL = "select * from (" . $sql_query . ") as " . AddFieldWrappers("custom_query") . $this->chrt_array['where'];
             } else {
                 $this->strSQL = "select * from (" . $sql_query . ")" . $this->chrt_array['where'];
             }
         } else {
             $this->strSQL = $this->chrt_array['sql'];
         }
     }
     if (tableEventExists("UpdateChartSettings", $strTableName)) {
         $eventObj = getEventObject($strTableName);
         $eventObj->UpdateChartSettings($this);
     }
 }