2010-12-02 16:45:32 +00:00
< ? php
2011-05-16 12:48:50 +00:00
$sensors = dbFetchRows ( " SELECT * FROM `sensors` WHERE `sensor_class` = ? AND device_id = ? ORDER BY `sensor_index` " , array ( $sensor_class , $device [ 'device_id' ]));
2010-12-02 16:45:32 +00:00
2011-05-16 12:48:50 +00:00
if ( count ( $sensors ))
2010-12-02 16:45:32 +00:00
{
echo ( '<div style="background-color: #eeeeee; margin: 5px; padding: 5px;">' );
2011-03-18 14:36:52 +00:00
echo ( '<p style="padding: 0px 5px 5px;" class="sectionhead"><a class="sectionhead" href="device/' . $device [ 'device_id' ] . '/health/' . strtolower ( $sensor_type ) . '/"><img align="absmiddle" src="' . $config [ 'base_url' ] . '/images/icons/' . strtolower ( $sensor_type ) . '.png"> ' . $sensor_type . '</a></p>' );
2010-12-02 16:45:32 +00:00
$i = '1' ;
echo ( '<table width="100%" valign="top">' );
2011-05-16 12:48:50 +00:00
foreach ( $sensors as $sensor )
2010-12-02 16:45:32 +00:00
{
2011-03-16 23:10:10 +00:00
if ( is_integer ( $i / 2 )) { $row_colour = $list_colour_a ; } else { $row_colour = $list_colour_b ; }
2010-12-02 16:45:32 +00:00
2011-05-17 19:21:20 +00:00
### FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
2010-12-02 16:45:32 +00:00
$graph_colour = str_replace ( " # " , " " , $row_colour );
2011-05-17 19:21:20 +00:00
$sensor_day = " graph.php?id= " . $sensor [ 'sensor_id' ] . " &type= " . $graph_type . " &from= " . $config [ 'time' ][ 'day' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=210&height=100 " ;
$sensor_week = " graph.php?id= " . $sensor [ 'sensor_id' ] . " &type= " . $graph_type . " &from= " . $config [ 'time' ][ 'week' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=210&height=100 " ;
$sensor_month = " graph.php?id= " . $sensor [ 'sensor_id' ] . " &type= " . $graph_type . " &from= " . $config [ 'time' ][ 'month' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=210&height=100 " ;
$sensor_year = " graph.php?id= " . $sensor [ 'sensor_id' ] . " &type= " . $graph_type . " &from= " . $config [ 'time' ][ 'year' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=210&height=100 " ;
$sensor_minigraph = " <img src='graph.php?id= " . $sensor [ 'sensor_id' ] . " &type= " . $graph_type . " &from= " . $config [ 'time' ][ 'day' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=80&height=20&bg= $graph_colour ' align='absmiddle'> " ;
2010-12-02 16:45:32 +00:00
$sensor_link = " <a href='graphs/ " . $sensor [ 'sensor_id' ] . " / " . $graph_type . " /' onmouseover= \" return " ;
$sensor_link .= " overlib('<div class=list-large> " . $device [ 'hostname' ] . " - " . $sensor [ 'sensor_descr' ];
2011-05-17 19:21:20 +00:00
$sensor_link .= " </div><div style= \ 'width: 570px \ '><img src= \ ' $sensor_day\ '><img src= \ ' $sensor_week\ '><img src= \ ' $sensor_month\ '><img src= \ ' $sensor_year\ '></div>', RIGHT " . $config [ 'overlib_defaults' ] . " ); \" onmouseout= \" return nd(); \" > " ;
2010-12-02 16:45:32 +00:00
$sensor_link_c = $sensor_link . " <span " . ( $sensor [ 'sensor_current' ] < $sensor [ 'sensor_limit_low' ] || $sensor [ 'sensor_current' ] > $sensor [ 'sensor_limit' ] ? " style='color: red' " : '' ) . '>' . $sensor [ 'sensor_current' ] . $sensor_unit . " </span></a> " ;
$sensor_link_b = $sensor_link . $sensor_minigraph . " </a> " ;
$sensor_link_a = $sensor_link . $sensor [ 'sensor_descr' ] . " </a> " ;
$sensor [ 'sensor_descr' ] = truncate ( $sensor [ 'sensor_descr' ], 25 , '' );
echo ( " <tr bgcolor=' $row_colour '><td class=tablehead><strong> $sensor_link_a </strong></td><td width=80 align=right class=tablehead> $sensor_link_b <td width=80 align=right class=tablehead> $sensor_link_c </td></tr> " );
$i ++ ;
}
2011-03-16 23:10:10 +00:00
2010-12-02 16:45:32 +00:00
echo ( " </table> " );
echo ( " </div> " );
}
2011-05-16 12:48:50 +00:00
?>