<?php

$ttl = new Title("Sensor Logs");
$cboSensorSelect = new ComboBoxBySql($_SESSION['config']->DBCONNECT, "SELECT id, concat(name ,' (', id  ,')') descr FROM homecontrol_sensor", "sensorSelectCob", $_REQUEST['sensorSelectCob']);
$cboSensorSelect->setDirectSelect(true);
$cboSensorSelect->setNullValue(" ");
$cobStartTime = new ComboBoxBySql($_SESSION['config']->DBCONNECT, "SELECT distinct from_unixtime(update_time, '%d.%m.%Y') as zeit, from_unixtime(update_time, '%d.%m.%Y') as zeit2 FROM homecontrol_sensor_log", "startTimeCob", $_REQUEST['startTimeCob']);
$cobStartTime->setDirectSelect(true);
$cobStartTime->setNullValue(" ");
$sqlEndCob = "SELECT distinct from_unixtime(update_time, '%d.%m.%Y') as zeit, from_unixtime(update_time, '%d.%m.%Y') as zeit2 FROM homecontrol_sensor_log";
if (isset($_REQUEST['startTimeCob']) && strlen($_REQUEST['startTimeCob']) > 0) {
    $sqlEndCob .= " WHERE update_time >= " . strtotime(substr($_REQUEST['startTimeCob'], 8, 2) . "-" . substr($_REQUEST['startTimeCob'], 3, 2) . "-" . substr($_REQUEST['startTimeCob'], 0, 2));
}
$cobEndTime = new ComboBoxBySql($_SESSION['config']->DBCONNECT, $sqlEndCob, "endTimeCob", $_REQUEST['endTimeCob']);
$cobEndTime->setDirectSelect(true);
$cobEndTime->setNullValue(" ");
$txtSelect = new Text("Sensor Auswahl:");
$frmSelect = new Form();
$timeSelect = new Table(array("", "", "", ""));
$rT = $timeSelect->createRow();
$rT->setColSizes(array(130, 100, 63));
$rT->setAlignments(array("left", "left", "center"));
$rT->setAttribute(0, new Text("Zeitraum von: "));
$rT->setAttribute(1, $cobStartTime);
$rT->setAttribute(2, new Text("bis: "));
$rT->setAttribute(3, $cobEndTime);
$timeSelect->addRow($rT);
// -------------------------
// Show
// -------------------------
$tbl = new Table(array("", ""));