<?php
+$details = <<<EOC
+<div style="margin-top: -10px;">
+<div id="detail_use"></div>
+<span id="detail_usage"></span>
+<span id="detail_defunct"></span>
+</div>
+EOC;
+
$mask = array(
'table' => 'hw_component',
'title' => 'Komponenten',
'type' => 'textarea',
),
),
+ 'details' => array(
+ 'title' => 'Bisherige Verwendung',
+ 'html' => $details,
+ 'list' => array(
+ 'use' => array('fetch' => fetch_use),
+ 'usage' => array('fetch' => fetch_usage),
+ 'defunct' => array('fetch' => fetch_defunct),
+ ),
+ ),
);
+function fetch_use()
+{
+ $sql = sprintf('SELECT starttime,endtime,name,usage FROM hw_screw ' .
+ 'JOIN hw_compound ON compound = hw_compound.id ' .
+ 'WHERE component = %d ORDER BY starttime', $_POST['id']);
+
+ $res = query_db($sql);
+ if ($res === false) return '';
+
+ $ret = '<table cellpadding=0 cellspacing=1>';
+ foreach ($res as $row) {
+ $ret .= sprintf ('<tr><td>%s - %s</td><td>%s</td></tr>', $row['starttime'], $row['endtime'], $row['name']);
+# if (!empty($row['usage'])) $ret .= sprintf(' (%s)', $row['usage']);
+ }
+ $ret .= '</table>';
+
+ return $ret;
+}
+
+function fetch_usage()
+{
+ $sql = sprintf('SELECT usage FROM hw_screw ' .
+ 'JOIN hw_compound ON compound = hw_compound.id ' .
+ 'WHERE component = %d ORDER BY starttime DESC LIMIT 1', $_POST['id']);
+
+ $res = query_db($sql);
+ if ($res === false || empty($res[0]['usage'])) return '';
+
+ return 'Verwendung: ' . $res[0]['usage'];
+}
+
+function fetch_defunct()
+{
+ $sql = sprintf("SELECT status FROM hw_component WHERE id = %d AND status = 'defunct'", $_POST['id']);
+
+ $res = query_db($sql);
+ if ($res === false || !count($res)) return '';
+
+ error_log('defu');
+ return '<br>defekt';
+}
+
?>