+
#include <infocon.style>
<?
return sprintf("<br>%d records updated.", $count);
}
+ function find_status()
+ {
+ global $dbh;
+
+ $a = array();
+ $query = "SELECT id,name FROM stempel_status ORDER BY id";
+ $sth = pg_exec ($dbh, $query);
+
+ while ($row = pg_fetch_array ($sth)) {
+ $a[$row['id']] = $row['name'];
+ }
+ return $a;
+ }
+
+ $stati = false;
function display_tables()
{
global $month;
global $status;
global $dbh;
+ global $stati;
$table_head = '<h3 class="bar">Kunde: %s</h3><form action="status.php" method="POST">
- <table class="font" width="100%%" border=0 cellpadding=2 cellspacing=0>
- <tr bgcolor=#<colh>>
+ <table class="smallfont border" width="100%%" cellpadding=0 cellspacing=1>
+ <tr class="head">
<th width=15%%>Datum</th>
- <th width=10%%>Dauer</th>
+ <th width=5%%>Dauer</th>
+ <th width=5%%>St.</th>
<th width=75%%>Verwendungszweck</th>
</tr>';
- $table_foot = '</table><center>'.
- '<input type="radio" name="status" value="0" checked>unbekannt'.
- '<input type="radio" name="status" value="1">ignoriert'.
- '<input type="radio" name="status" value="2">wartung'.
- '<input type="radio" name="status" value="3">berechnet'.
- '</center>'.
- '<center><input type="submit" value="Aktualisieren"></center>'.
- '<input type="hidden" name="fields" value="%d">'.
+
+ if (!is_array($stati))
+ $stati = find_status();
+
+ $table_foot = '</table><div align="center"><p>';
+
+ foreach ($stati as $k=>$v)
+ $table_foot .= sprintf('<input type="radio" name="status" value="%s"%s>%s ', $k, 0==$k?' checked':'', $v);
+ $table_foot .= '</p><p><input type="submit" value="Aktualisieren"></div>'.
+ '<input type="hidden" name="fields" value="%d"></p>'.
'</form>';
- $table_row = '<tr bgcolor=#%s><td>%s</td><td align="center">%s</td><td>%s</td></tr>';
- $table_sum = '<tr bgcolor="#%s"><td> </td><td align="center">%s</td><td>Summe</td></tr>';
- $query = "SELECT oid,start,customer,time,task FROM stempel WHERE time IS NOT NULL ";
+ $table_row = '<tr class=t%d><td>%s</td><td align="center">%s</td><td align="center">%s</td><td>%s</td></tr>';
+ $table_sum = '<tr class="t%d"><td> </td><td align="center">%s</td><td> </td><td>Summe</td></tr>';
+
+ $query = "SELECT stempel.oid,start,customer,time,task,kurz FROM stempel JOIN stempel_status ON (stempel.status = stempel_status.id) WHERE time IS NOT NULL ";
if (isset($month) && $month !== 'all')
$query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
if (isset($status)) {
$customer = $row['customer'];
$fieldnr = 0;
$sum = 0;
- $color = "<cold>";
+ $color = 0;
}
$sum += $row['time'];
$d = explode(' ', $row['start']);
$check = '<input type="checkbox" name="oid_'.$fieldnr++.'" value="'.$row['oid'].'">';
- printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['task']);
- $color = $color=="<cold>"?"<coln>":"<cold>";
+ printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['kurz'], $row['task']);
+ $color = !$color;
}
printf($table_sum, $color, min2hour($sum));
printf($table_foot, $fieldnr);
<form action=status.php method=POST>
<select name=month>
-<option value="all">alle</option>
<?
if (!is_array($months))
$months = find_months();
+ printf('<option value="all"%s>alle</option>', $_POST['month']=='alle'?' selected':'');
foreach ($months as $m) {
- printf('<option value="%s">%s</option>', $m, $m);
+ printf('<option value="%s"%s>%s</option>', $m, $_POST['month']==$m?' selected':'', $m);
}
?>
</select>
-<input type="radio" name="status" value="all">alle
-<input type="radio" name="status" value="0">unbekannt
-<input type="radio" name="status" value="1">ignoriert
-<input type="radio" name="status" value="2">wartung
-<input type="radio" name="status" value="3">berechnet
+<?
+ if (!is_array($stati))
+ $stati = find_status();
+
+ printf('<input type="radio" name="status" value="all"%s>alle ', $status=='all'?' checked':'');
+ foreach ($stati as $k=>$v)
+ printf('<input type="radio" name="status" value="%s"%s>%s ', $k, $status==$k?' checked':'', $v);
+?>
<input type="hidden" name="filter" value="form">
-<input type="submit" value="Display">
+<input class="button" type="submit" value="Display">
</form>
<? } ?>