array( 'caption' => 'Hodina', 'period' => 3600, ), 'day' => array( 'caption' => 'Den', 'period' => 86400, // 3600 * 24, ), 'week' => array( 'caption' => 'Týden', 'period' => 604800, // 3600 * 24 * 7, ), 'month' => array( 'caption' => 'Měsíc', 'period' => 2592000, // 3600 * 24 * 30, ), 'year' => array( 'caption' => 'Rok', 'period' => 31536000, // 3600 * 24 * 365, ), 'years' => array( 'caption' => 'Desetiletí', 'period' => 315360000, // 3600 * 24 * 365 * 10, ), ); function EditTime($Time) { $Output = '
'; $TimeParts = getdate($_SESSION[$Time]); //print_r($TimeParts); // Day selection $Output .= '. '; // Month selection $Output .= '. '; // Day selection $Output .= '    '; // Hour selection $Output .= ' : '; // Minute selection $Output .= ' '; $Output .= ''; $Output .= '
'; $Output .= '
'; $Output .= ''; $Output .= '
'; return($Output); } function Show() { $Debug = 0; foreach($this->Config['Application']['DefaultVariables'] as $Index => $Variable) { if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable; if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index]; if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index]; //$$Index = $_SESSION[$Index]; } if($_SESSION['TimeSpecify'] == 0) { $_SESSION['TimeEnd'] = time() - 60; $_SESSION['TimeStart'] = $_SESSION['TimeEnd'] - $this->GraphTimeRanges[$_SESSION['Period']]['period']; } $Output = '
'; $Output .= '
Statistiky
'; if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = ''; switch($_GET['Operation']) { case 'SetTime': if(array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST)) { if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) { $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'], $_POST['Day'], $_POST['Year']); $$_GET['Time'] = $_SESSION[$_GET['Time']]; } } break; case 'SetTimeNow': if(array_key_exists('Time', $_GET)) { if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) { $_SESSION[$_GET['Time']] = time(); $$_GET['Time'] = $_SESSION[$_GET['Time']]; } } break; } $Output .= 'Časový úsek:
'; // Show graf time range menu if($_SESSION['TimeSpecify'] == 0) { $Output .= 'Délka úseku: '; foreach($this->GraphTimeRanges as $Index => $Item) $Output .= ''.$Item['caption'].' '; $Output .= '
'; $Output .= 'Přesnější nastavení...
'; } else { $Output .= ''; $Output .= ''; $Output .= ''; $Output .= '
Počátek:'.$this->EditTime('TimeStart').'
Konec:'.$this->EditTime('TimeEnd').'
'; $Output .= 'Jednoduché nastavení...
'; } $Output .= '
'.$this->Graph(); $Output .= '
'.$this->MeasureTable(); $Output .= '
'; return($Output); } function Graph() { $Output = 'Graf:
'; $Output .= 'Graf
'; $Output .= 'Odkaz na vybraný graf
'; //print_r(GetValues($Measure, $TimeStart, $TimeEnd)); return($Output); } function MeasureTable() { $Output = ''; $Output .= ''; if(array_key_exists('Debug', $_GET)) $Output .= ''; $Output .= ''; $PrefixMultiplier = new PrefixMultiplier(); $Result = $this->Database->select('Measure', '*', 'Enabled=1 ORDER BY Description'); while($Measure = $Result->fetch_array()) { $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure['Method']); $MeasureMethod = $DbResult2->fetch_assoc(); $StopWatchStart = $this->System->GetMicrotime(); if(array_key_exists('Debug', $_GET)) { $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', 'Measure='.$Measure['Id']); $RowCount = $DbResult->fetch_array(); $RowCount = $RowCount[0]; } $Result2 = $this->Database->select($Measure['DataTable'], 'Time, Avg', 'Measure='.$Measure['Id'].' AND Level=0 ORDER BY Time DESC LIMIT 1'); if($Result2->num_rows > 0) { $Row = $Result2->fetch_array(); $LastMeasureTime = date('j.n.Y G:i:s', $this->Database->MysqlDateTimeToTime($Row['Time'])); $LastMeasureValue = $PrefixMultiplier->Add($Row['Avg'], $MeasureMethod['Unit']); } else { $LastMeasureTime = ' '; $LastMeasureValue = ' '; } if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne'; if($Measure['Info'] == '') $Measure['Info'] = ' '; $GenerationTime = floor(($this->System->GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; $Output .= ''; if(array_key_exists('Debug', $_GET)) $Output .= ''; $Output .= ''; } $Output .= '
Měřená veličinaPoslední hodnotaČas posledního měřeníInterpolacePoznámkyPočet položekČas vykonání
'.$Measure['Name'].''.$LastMeasureValue.''.$LastMeasureTime.''.$Interpolate.''.$Measure['Description'].''.$RowCount.''.$GenerationTime.'
'; //echo(time()); //print_r(gd_info()); //print_r($_SESSION); //ShowPage($Output); return($Output); } }