<?
<dbconnect>
+ function display_components ($headline, $sth);
+ {
+ if (pg_NumRows ($sth) > 0) {
+ printf ("<h3>%s</h3>\n", $headline);
+ }
+
+ for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
+ $row = pg_fetch_array ($sth, $nr);
+ $start = explode (" ", $row['starttime']);
+ if ($row['endtime']) {
+ $end = explode (" ", $row['endtime']);
+ printf ("<br>%s <a href=\"component.php3?id=%d\">%s</a> %s — %s",
+ $row['type'], $row['component'], $row['name'], $start[0], $end[0]);
+ } else {
+ printf ("<br>%s <a href=\"component.php3?id=%d\">%s</a> since %s",
+ $row['type'], $row['component'], $row['name'], $start[0]);
+ }
+ if ($row['usage']) {
+ printf (" (%s)", $row['usage']);
+ }
+ }
+ }
+
if ($id) {
$fields = array ('compound.name',
'compound.hostname',
."AND types.id = hwtype "
."ORDER BY types.name,component.name,screw.starttime", $id);
$sth = pg_exec ($dbh, $query) or die_query("Cannot issue query!", $query);
+ display_components ("Components", $sth);
- if (pg_NumRows ($sth) > 0) {
- echo "<h3>Components</h3>\n";
- }
-
- for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
- $row = pg_fetch_array ($sth, $nr);
- $start = explode (" ", $row['starttime']);
- if ($row['endtime']) {
- $end = explode (" ", $row['endtime']);
- printf ("<br>%s <a href=\"component.php3?id=%d\">%s</a> %s — %s",
- $row['type'], $row['component'], $row['name'], $start[0], $end[0]);
- } else {
- printf ("<br>%s <a href=\"component.php3?id=%d\">%s</a> since %s",
- $row['type'], $row['component'], $row['name'], $start[0]);
- }
- if ($row['usage']) {
- printf (" (%s)", $row['usage']);
- }
- }
-
-
+ $query = sprintf ("SELECT component.name,component,screw.starttime,screw.endtime,types.name as type,usage "
+ ."FROM screw,component,types "
+ ."WHERE compound = %d AND component = component.id "
+ ."AND screw.endtime IS NOT NULL "
+ ."AND types.id = hwtype "
+ ."ORDER BY types.name,component.name,screw.starttime", $id);
+ $sth = pg_exec ($dbh, $query) or die_query("Cannot issue query!", $query);
+ display_components ("Outdated Components", $sth);
}
?>