コード例 #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->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->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'] != "") {
             $this->arrDataSeries[] = $this->chrt_array['parameters'][$i]['agr_func'] ? $this->chrt_array['parameters'][$i]['label'] : $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") {
         $this->strLabel = $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
     global $gsqlFrom, $gsqlWhereExpr;
     $gQuery = GetTableData($this->sessionPrefix, ".sqlquery", null);
     $strWhereClause = "";
     $searchHavingClause = "";
     // search where for basic charts
     if (!$this->webchart) {
         global $strTableName;
         if (isset($_SESSION[$this->sessionPrefix . '_advsearch'])) {
             $searchClauseObj = unserialize($_SESSION[$this->sessionPrefix . '_advsearch']);
             $strWhereClause = $searchClauseObj->getWhere(GetListOfFieldsByExprType(false));
             $searchHavingClause = $searchClauseObj->getWhere(GetListOfFieldsByExprType(true));
         }
     } else {
         if ($this->table_type != "project") {
             $strTableName = "webchart" . $this->cname;
         } else {
             $strTableName = $TableName;
         }
         $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 = gSQLWhere($strWhereClause, $searchHavingClause);
         $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 = gSQLWhere($strWhereClause, $searchHavingClause);
             $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 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);
     }
 }
コード例 #2
0
 /**
  * Builds SQL query, for retrieve data from DB
  *
  */
 function buildSQL()
 {
     global $gQuery;
     $searchWhereClause = $this->searchClauseObj->getWhere(GetListOfFieldsByExprType(false, $this->tName));
     $searchHavingClause = $this->searchClauseObj->getWhere(GetListOfFieldsByExprType(true, $this->tName));
     $this->strWhereClause = whereAdd($this->strWhereClause, $searchWhereClause);
     $this->strHavingClause = whereAdd($this->strHavingClause, $searchHavingClause);
     $strSecuritySql = SecuritySQL("Search", $this->tName);
     $this->strWhereClause = whereAdd($this->strWhereClause, $strSecuritySql);
     if ($this->noRecordsFirstPage && !count($_GET) && !count($_POST)) {
         $this->strWhereClause = whereAdd($this->strWhereClause, "1=0");
     }
     //add where clause with foreign keys of current table and it's master table master keys
     $where = $this->addWhereWithMasterTable();
     $this->strWhereClause = whereAdd($this->strWhereClause, $where);
     if ($this->dbType == nDATABASE_DB2) {
         $this->gsqlHead .= ", ROW_NUMBER() over () as DB2_ROW_NUMBER  ";
     }
     $strSQL = gSQLWhere_having($this->gsqlHead, $this->gsqlFrom, $this->gsqlWhereExpr, $this->gsqlGroupBy, $this->gsqlHaving, $this->strWhereClause, $this->strHavingClause);
     //	order by
     $strSQL .= " " . trim($this->strOrderBy);
     //	save SQL for use in "Export" and "Printer-friendly" pages
     $_SESSION[$this->sessionPrefix . "_sql"] = $strSQL;
     $_SESSION[$this->sessionPrefix . "_where"] = $this->strWhereClause;
     $_SESSION[$this->sessionPrefix . "_having"] = $this->strHavingClause;
     $_SESSION[$this->sessionPrefix . "_order"] = $this->strOrderBy;
     $_SESSION[$this->sessionPrefix . "_arrFieldForSort"] = $this->arrFieldForSort;
     $_SESSION[$this->sessionPrefix . "_arrHowFieldSort"] = $this->arrHowFieldSort;
     //	select and display records
     $this->addMasterDetailSubQuery();
     $strSQLbak = $strSQL;
     if ($this->eventExists("BeforeQueryList")) {
         $tstrWhereClause = $this->strWhereClause;
         $tstrOrderBy = $this->strOrderBy;
         $this->eventsObject->BeforeQueryList($strSQL, $tstrWhereClause, $tstrOrderBy);
         $this->strWhereClause = $tstrWhereClause;
         $this->strOrderBy = $tstrOrderBy;
     }
     //	Rebuild SQL if needed
     if ($strSQL != $strSQLbak) {
         //	changed $strSQL - old style
         $this->numRowsFromSQL = GetRowCount($strSQL);
     } else {
         $strSQL = gSQLWhere_having($this->gsqlHead, $this->gsqlFrom, $this->gsqlWhereExpr, $this->gsqlGroupBy, $this->gsqlHaving, $this->strWhereClause, $this->strHavingClause);
         $strSQL .= " " . trim($this->strOrderBy);
         $rowcount = false;
         if ($this->eventExists("ListGetRowCount")) {
             $rowcount = $this->eventsObject->ListGetRowCount($this->searchClauseObj, $this->masterTable, $this->masterKeysReq, null);
         }
         if ($rowcount !== false) {
             $this->numRowsFromSQL = $rowcount;
         } else {
             $this->numRowsFromSQL = gSQLRowCount_int($this->gsqlHead, $this->gsqlFrom, $this->gsqlWhereExpr, $this->gsqlGroupBy, $this->gsqlHaving, $this->strWhereClause, $this->strHavingClause);
         }
     }
     LogInfo($strSQL);
     $this->querySQL = $strSQL;
 }
コード例 #3
0
 function applyWhere(&$sql)
 {
     global $gQuery;
     return $this->searchClauseObj->applyWhere($sql, GetListOfFieldsByExprType(false, $this->tName), GetListOfFieldsByExprType(true, $this->tName));
 }