include_once($path."php_inc/config.inc.php"); include_once($path."php_inc/module_set.inc.php"); class Report{ var $tmplName; /* Template-Id */ var $rptName; /* Report-Id */ var $rptArray; var $connection; /* Connection - Instanz */ var $parserInstance = NULL; /* Parser - Instanz */ var $connectionInstance = NULL; /* Connection - Instanz */ var $sensInstance = NULL; /* Sensor-Instanz */ /* Konstruktor */ function Report($tplName, &$parser, &$connection){ /* Klassenvariablen zuordnen */ $this->tmplName = $tplName; $this->rptName = $_REQUEST['rptName']; $this->rptArray = Config::getRptArray($this->rptName); $this->connInstance = &$connection; $this->parserInstance = &$parser; $parser->parseContent($this->_getRptFilename($tplName), & $this, "top"); /* Oberen Modulrahmen parsen */ $this->buildTable(); $parser->parseContent($this->_getRptFilename($tplName), & $this, "bottom"); /* unteren Modulrahmen Parsen */ } /* Dateinamen des Modul-Files zusammenbauen */ function _getRptFilename($modName){ global $path; return $path."content/reports/rpt_".$modName.".html"; } function buildTable(){ /* Tabelle des Sensors bestimmen */ $tableQuery = "SELECT tabelle FROM sensoren, typen WHERE sensoren.id=".$this->rptArray[2]." AND typen.typ = sensoren.typ"; $table = $this->connInstance->fetchQueryResultLine($tableQuery); if($this->rptArray[10]){ $div = "/count(".$this->rptArray[3].")"; } else { $div = ""; } $result = &$this->connInstance->getRawResult("SELECT to_char(date_trunc('".$this->rptArray[4]."', timestamp), '".$this->rptArray[11]."') as ts, sum(".$this->rptArray[3].")".$div." as val FROM ".$table['tabelle']." WHERE sens_id=".$this->rptArray[2]." AND timestamp > (current_timestamp - INTERVAL '".$this->rptArray[5]."') GROUP BY ts ORDER BY max(timestamp) DESC"); $buff = '
| Zeit | '.$this->rptArray[6].' |
|---|---|
| '; $buff .= $array['ts']; $buff .= ' | '; $buff .= ''; $buff .= round(($array['val'] * $this->rptArray[7]), 1).$this->rptArray[8]; $buff .= ' | '; $buff .= '