- Added alternate timetable version, which collapses all events
of the same node into one line. - Fixed bug with urlencode() in page navigation.
This commit is contained in:
parent
7bd1b0356c
commit
96975133c0
|
@ -39,7 +39,7 @@
|
||||||
if ($tsmmonitor->configarray["queryarray"][$tsmmonitor->GETVars['qq']]["timetablefields"] != "") {
|
if ($tsmmonitor->configarray["queryarray"][$tsmmonitor->GETVars['qq']]["timetablefields"] != "") {
|
||||||
|
|
||||||
echo "<select name='tabletype' size=1 onChange='submit();' class='button topnavbutton'>";
|
echo "<select name='tabletype' size=1 onChange='submit();' class='button topnavbutton'>";
|
||||||
$types = array('normal view', 'timetable');
|
$types = array('normal view', 'timetable', 'timetable2');
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
echo '<option value="'.$type.'"';
|
echo '<option value="'.$type.'"';
|
||||||
if ($_SESSION['tabletype'] == $type){echo "SELECTED";}
|
if ($_SESSION['tabletype'] == $type){echo "SELECTED";}
|
||||||
|
|
|
@ -232,7 +232,7 @@ class TSMMonitor {
|
||||||
$sortcol = urlencode($_GET['sort']);
|
$sortcol = urlencode($_GET['sort']);
|
||||||
|
|
||||||
$getvars = 'q='.$_GET['q'].'&m='.$_GET['m'].'&s='.$this->GETVars['server'].'&sort='.$sortcol."&so=".$so;
|
$getvars = 'q='.$_GET['q'].'&m='.$_GET['m'].'&s='.$this->GETVars['server'].'&sort='.$sortcol."&so=".$so;
|
||||||
$self = urlencode($_SERVER['PHP_SELF']);
|
$self = $_SERVER['PHP_SELF'];
|
||||||
$navelement = '<a class="tablefooter" href="'.$self.'?'.$getvars.'&page=';
|
$navelement = '<a class="tablefooter" href="'.$self.'?'.$getvars.'&page=';
|
||||||
|
|
||||||
$fp = "First";
|
$fp = "First";
|
||||||
|
@ -837,7 +837,7 @@ class TSMMonitor {
|
||||||
$wc= " ";
|
$wc= " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == "timetable") {
|
if ($type == "timetable" || $type == "timetable2") {
|
||||||
$columnnames = $this->configarray["queryarray"][$this->GETVars['qq']]["timetablefields"];
|
$columnnames = $this->configarray["queryarray"][$this->GETVars['qq']]["timetablefields"];
|
||||||
} else {
|
} else {
|
||||||
$columnnames = $this->getTableFields("res_".$qtable."_".$server);
|
$columnnames = $this->getTableFields("res_".$qtable."_".$server);
|
||||||
|
@ -896,6 +896,27 @@ class TSMMonitor {
|
||||||
array_push($outp, $rowarray2);
|
array_push($outp, $rowarray2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($type == "timetable2") {
|
||||||
|
$sqlres = $this->adodb->fetchArrayDB($sql);
|
||||||
|
$outp = array();
|
||||||
|
foreach ($sqlres as $row) {
|
||||||
|
$rowarray2 = array();
|
||||||
|
while (list($keycell, $valcell) = each($row)) {
|
||||||
|
if ($keycell == "Start Time" || $keycell == "Actual Start" || $keycell == "End Time") {
|
||||||
|
$date = $row[$keycell];
|
||||||
|
$rowarray2[] = mktime(substr($date,11,2),substr($date,14,2),substr($date,17,2),substr($date,5,2),substr($date,8,2),substr($date,0,4));
|
||||||
|
} else if ($keycell == "Node Name") {
|
||||||
|
$nodename = $valcell;
|
||||||
|
if ($outp[$nodename] == "") {
|
||||||
|
$outp[$nodename] = array();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$rowarray2[] = $valcell;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array_push($outp[$nodename], $rowarray2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $outp;
|
return $outp;
|
||||||
|
@ -1174,15 +1195,16 @@ class TSMMonitor {
|
||||||
*
|
*
|
||||||
* @param string $startpunkt I forgot that one
|
* @param string $startpunkt I forgot that one
|
||||||
* @param string $FirstCol first field of result table
|
* @param string $FirstCol first field of result table
|
||||||
|
* @param integer $pxperHour Width of a on hour field in pixels
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function generateTimetableHeader($startpunkt = '', $FirstCol = '') {
|
function generateTimetableHeader($startpunkt = '', $FirstCol = '', $pxperHour = 30) {
|
||||||
|
|
||||||
$header = $FirstCol["label"];
|
$header = $FirstCol["label"];
|
||||||
$out= "<tr align='left'><th>".$header."</th><th>";
|
$out= "<tr align='left'><th>".$header."</th><th>";
|
||||||
for ($count = 0; $count <= 24; $count++) {
|
for ($count = 0; $count <= 24; $count++) {
|
||||||
$imagename = strftime("%H", $startpunkt + ($count * 3600));
|
$imagename = strftime("%H", $startpunkt + ($count * 3600));
|
||||||
$out .= "<img src='images/".$imagename.".gif' height=20px width=30px title='".strftime("%H:00 (%D)", $startpunkt+($count*$hour))."' />";
|
$out .= "<img src='images/".$imagename.".gif' height=20px width=".$pxperHour."px title='".strftime("%H:00 (%D)", $startpunkt+($count*$hour))."' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= "</th></tr>";
|
$out .= "</th></tr>";
|
||||||
|
@ -1243,7 +1265,7 @@ class TSMMonitor {
|
||||||
$now = time();
|
$now = time();
|
||||||
$out = '';
|
$out = '';
|
||||||
$height = 8;
|
$height = 8;
|
||||||
$faktor = 120;
|
$factor = 120;
|
||||||
$oneday = 86400;
|
$oneday = 86400;
|
||||||
$onehour = 3600;
|
$onehour = 3600;
|
||||||
$tolerance = 1200;
|
$tolerance = 1200;
|
||||||
|
@ -1252,7 +1274,7 @@ class TSMMonitor {
|
||||||
|
|
||||||
$startpunkt = ((ceil($now / $onehour) * $onehour) - $onehour - $oneday) - (($this->timetablestarttime - 24) * $onehour);
|
$startpunkt = ((ceil($now / $onehour) * $onehour) - $onehour - $oneday) - (($this->timetablestarttime - 24) * $onehour);
|
||||||
$endpunkt = $startpunkt + $oneday + $onehour;
|
$endpunkt = $startpunkt + $oneday + $onehour;
|
||||||
$lastpoint = ($endpunkt - $startpunkt)/$faktor;
|
$lastpoint = ($endpunkt - $startpunkt) / $factor;
|
||||||
|
|
||||||
$out .= "<table class='timetable' width='".$lastpoint."'>";
|
$out .= "<table class='timetable' width='".$lastpoint."'>";
|
||||||
$out .= $this->generateTimetableNavigation();
|
$out .= $this->generateTimetableNavigation();
|
||||||
|
@ -1275,12 +1297,14 @@ class TSMMonitor {
|
||||||
// cut the bar at the left side to fit into table
|
// cut the bar at the left side to fit into table
|
||||||
$start = 0;
|
$start = 0;
|
||||||
} else {
|
} else {
|
||||||
$start = ($valrow[1]-$startpunkt)/$faktor;
|
$start = ($valrow[1] - $startpunkt) / $factor;
|
||||||
}
|
}
|
||||||
$end = ($valrow[2]-$startpunkt)/$faktor;
|
$end = ($valrow[2] - $startpunkt) / $factor;
|
||||||
$duration = $end - $start;
|
$duration = $end - $start;
|
||||||
// fake a longer time for better visibility
|
// fake a longer time for better visibility
|
||||||
if ($duration < 2) {$duration=2;}
|
if ($duration < 2) {
|
||||||
|
$duration = 2;
|
||||||
|
}
|
||||||
// cut the bar at the right side to fit into table
|
// cut the bar at the right side to fit into table
|
||||||
if (($start + $duration) > $lastpoint) {
|
if (($start + $duration) > $lastpoint) {
|
||||||
$duration = $lastpoint - $start;
|
$duration = $lastpoint - $start;
|
||||||
|
@ -1314,7 +1338,7 @@ class TSMMonitor {
|
||||||
} else {
|
} else {
|
||||||
$out .= "<td>".$valrow[0]."</td>";
|
$out .= "<td>".$valrow[0]."</td>";
|
||||||
}
|
}
|
||||||
if ($valrow[3] != 'Missed') {
|
if ($status != 'Missed') {
|
||||||
$out .= "<td class='content'>";
|
$out .= "<td class='content'>";
|
||||||
$out .= "<img src='images/trans.gif' height=1px width=".$start."px />";
|
$out .= "<img src='images/trans.gif' height=1px width=".$start."px />";
|
||||||
$out .= "<img src='images/".$barcol.".gif' height=".$height."px width=".$duration."px title='".strftime("%H:%M", $valrow[1])." - ".strftime("%H:%M", $valrow[2])." (".$name.", ".$dur."h".$statusmsg.")' />";
|
$out .= "<img src='images/".$barcol.".gif' height=".$height."px width=".$duration."px title='".strftime("%H:%M", $valrow[1])." - ".strftime("%H:%M", $valrow[2])." (".$name.", ".$dur."h".$statusmsg.")' />";
|
||||||
|
@ -1330,7 +1354,145 @@ class TSMMonitor {
|
||||||
$out .= "</table>";
|
$out .= "</table>";
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generateTimetable2 - generates HTML code for graphical timetables (version 2)
|
||||||
|
*
|
||||||
|
* @param array $tablearray Array containing an SQL query result
|
||||||
|
* @param string $FirstCol first field of result table
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function generateTimetable2($tablearray = '', $FirstCol = '') {
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$out = '';
|
||||||
|
$height = 8;
|
||||||
|
$pxperhour = 30;
|
||||||
|
$oneday = 86400;
|
||||||
|
$onehour = 3600;
|
||||||
|
$resolution = ($onehour / $pxperhour);
|
||||||
|
$tolerance = 1200;
|
||||||
|
|
||||||
|
$this->timetablestarttime = 24 + $_SESSION['timeshift'];
|
||||||
|
|
||||||
|
$startpoint = ((ceil($now / $onehour) * $onehour) - $onehour - $oneday) - (($this->timetablestarttime - 24) * $onehour);
|
||||||
|
$endpoint = $startpoint + $oneday + $onehour;
|
||||||
|
$lastpoint = ($oneday + $onehour) / $resolution;
|
||||||
|
|
||||||
|
$out .= "<table class='timetable' width='".$lastpoint."'>";
|
||||||
|
$out .= $this->generateTimetableNavigation();
|
||||||
|
$out .= $this->generateTimetableHeader($startpoint, $FirstCol, $pxperhour);
|
||||||
|
$out .= "</td></tr>";
|
||||||
|
|
||||||
|
$lasttimepoint = $now - ($this->timetablestarttime * $onehour) - $tolerance;
|
||||||
|
|
||||||
|
$ii = 1;
|
||||||
|
|
||||||
|
// every node with events
|
||||||
|
while (list($nodename, $keyrow) = each($tablearray)) {
|
||||||
|
$egroup = array();
|
||||||
|
end($keyrow);
|
||||||
|
$last = key($keyrow);
|
||||||
|
reset($keyrow);
|
||||||
|
|
||||||
|
if ($ii == 1) {
|
||||||
|
$out .= "<tr class='d0' width=".$lastpoint.">";
|
||||||
|
} else {
|
||||||
|
$out .= "<tr class='d1' width=".$lastpoint.">";
|
||||||
|
$ii = 0;
|
||||||
|
}
|
||||||
|
$out .= "<td style='color:#000000;'>".$nodename."</td>";
|
||||||
|
$out .= "<td class='content'>";
|
||||||
|
|
||||||
|
$pend = 0;
|
||||||
|
$line = "";
|
||||||
|
$lstartpx = 0;
|
||||||
|
$ldurpx = 0;
|
||||||
|
// every event for the current backup
|
||||||
|
while (list($key, $valrow) = each($keyrow)) {
|
||||||
|
$ebegin = $valrow[0];
|
||||||
|
$eend = $valrow[1];
|
||||||
|
// event within display range
|
||||||
|
if ($ebegin <= $endpoint && $eend > $lasttimepoint) {
|
||||||
|
if (empty($egroup)) {
|
||||||
|
array_push($egroup, $valrow);
|
||||||
|
} else {
|
||||||
|
$pendround = (ceil($pend / $resolution) * $resolution);
|
||||||
|
if ($ebegin <= $pendround) {
|
||||||
|
array_push($egroup, $valrow);
|
||||||
|
} else if ($ebegin > $pendround || $key == $last) {
|
||||||
|
$cbegin = (floor($egroup[0][0] / $resolution) * $resolution);
|
||||||
|
$cend = (ceil($egroup[(count($egroup) - 1)][1] / $resolution) * $resolution);
|
||||||
|
$cstatus = array();
|
||||||
|
$cstatusmsg = array();
|
||||||
|
$cshade = "";
|
||||||
|
|
||||||
|
if ($cbegin < $lasttimepoint) {
|
||||||
|
// cut the bar at the left side to fit into table
|
||||||
|
$startpx = 0;
|
||||||
|
} else {
|
||||||
|
$startpx = ($cbegin - $startpoint) / $resolution;
|
||||||
|
}
|
||||||
|
$endpx = ($cend - $startpoint) / $resolution;
|
||||||
|
$durpx = ceil($endpx - $startpx);
|
||||||
|
// cut the bar at the right side to fit into table
|
||||||
|
if (($startpx + $durpx) > $lastpoint) {
|
||||||
|
$durpx = ceil($lastpoint - $startpx);
|
||||||
|
$cshade = "light";
|
||||||
|
}
|
||||||
|
if ($cbegin < $lasttimepoint) {
|
||||||
|
$cshade = "light";
|
||||||
|
}
|
||||||
|
$barcol = $cshade."green";
|
||||||
|
while (list($ckey, $cvalrow) = each($egroup)) {
|
||||||
|
$cestatus = $cvalrow[2];
|
||||||
|
$cedur = strftime("%H:%M", ($cvalrow[1] - $cvalrow[0]) - $onehour);
|
||||||
|
if (isset($cestatus)) {
|
||||||
|
if ($cestatus == "YES" || $cestatus == "Completed") {
|
||||||
|
array_push($cstatusmsg, $cedur."h, Status was OK");
|
||||||
|
} else {
|
||||||
|
$barcol = $cshade."red";
|
||||||
|
array_push($cstatusmsg, $cedur."h, Status was UNSUCCESSFUL");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$barcol = $cshade."grey";
|
||||||
|
array_push($cstatusmsg, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($line == "") {
|
||||||
|
$line .= "<img src='images/trans.gif' height=1px width=".$startpx."px />";
|
||||||
|
} else {
|
||||||
|
$line .= "<img src='images/trans.gif' height=1px width=".($startpx - $lstartpx - $ldurpx)."px />";
|
||||||
|
}
|
||||||
|
$line .= "<img src='images/".$barcol.".gif' height=".$height."px width=".$durpx."px title='".$nodename." ".strftime("%H:%M", $cbegin)." - ".strftime("%H:%M", $cend)." (".(join('; ', $cstatusmsg)).")' />";
|
||||||
|
|
||||||
|
// clearup for next event
|
||||||
|
unset($egroup);
|
||||||
|
$egroup = array();
|
||||||
|
array_push($egroup, $valrow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$pend = $valrow[1];
|
||||||
|
$lstartpx = $startpx;
|
||||||
|
$ldurpx = $durpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$out .= $line;
|
||||||
|
$out .= "</td></tr>\n";
|
||||||
|
$ii++;
|
||||||
|
unset($egroup);
|
||||||
|
unset($line);
|
||||||
|
}
|
||||||
|
$out .= $this->generateTimetableHeader($startpoint);
|
||||||
|
$out .= $this->generateTimetableNavigation();
|
||||||
|
$out .= "</table>";
|
||||||
|
|
||||||
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
15
index.php
15
index.php
|
@ -149,6 +149,21 @@ include_once "includes/page_head.php";
|
||||||
$headerarray = $queryarray[$tsmmonitor->GETVars['qq']]["header"]["column"];
|
$headerarray = $queryarray[$tsmmonitor->GETVars['qq']]["header"]["column"];
|
||||||
echo $tsmmonitor->generateTimetable($tablearray, $headerarray[0]);
|
echo $tsmmonitor->generateTimetable($tablearray, $headerarray[0]);
|
||||||
|
|
||||||
|
} else if ($_SESSION["tabletype"] != "" && $_SESSION["tabletype"] == "timetable2") {
|
||||||
|
|
||||||
|
if ($_POST["back"] != "") {
|
||||||
|
$_SESSION['timeshift'] += $_SESSION['selectedtimestep'];
|
||||||
|
}
|
||||||
|
if ($_POST["forward"] != "") {
|
||||||
|
$_SESSION['timeshift'] -= $_SESSION['selectedtimestep'];
|
||||||
|
}
|
||||||
|
if ($_SESSION['timeshift'] < 0) {
|
||||||
|
$_SESSION['timeshift'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tablearray = $tsmmonitor->execute('timetable2');
|
||||||
|
$headerarray = $queryarray[$tsmmonitor->GETVars['qq']]["header"]["column"];
|
||||||
|
echo $tsmmonitor->generateTimetable2($tablearray, $headerarray[0]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue