1 #include <infocon.style>
4 function min2hour($minutes)
6 return sprintf('%02d:%02d', $minutes/60, $minutes%60);
14 for ($idx=0; $idx < $_POST["fields"]; $idx++) {
15 if (isset($_POST["oid_".$idx])) {
16 $query = sprintf('UPDATE stempel SET status=%d WHERE oid=%d',
17 $_POST["status"], $_POST["oid_".$idx]);
19 $sth = pg_exec ($dbh, $query);
23 return sprintf("<br>%d records updated.", $count);
26 function display_tables()
32 $table_head = '<h3 class="bar">Kunde: %s</h3><form action="status.php" method="POST">
33 <table class="font" width="100%%" border=0 cellpadding=2 cellspacing=0>
35 <th width=15%%>Datum</th>
36 <th width=10%%>Dauer</th>
37 <th width=75%%>Verwendungszweck</th>
39 $table_foot = '</table><center>'.
40 '<input type="radio" name="status" value="0" checked>unbekannt'.
41 '<input type="radio" name="status" value="1">ignoriert'.
42 '<input type="radio" name="status" value="2">wartung'.
43 '<input type="radio" name="status" value="3">berechnet'.
45 '<center><input type="submit" value="Aktualisieren"></center>'.
46 '<input type="hidden" name="fields" value="%d">'.
48 $table_row = '<tr bgcolor=#%s><td>%s</td><td align="center">%s</td><td>%s</td></tr>';
50 $query = "SELECT oid,start,customer,time,task FROM stempel WHERE time IS NOT NULL ";
51 if (isset($month) && $month !== 'all')
52 $query .= "AND start LIKE '".$month."-%' ";
55 $query .= "AND status = $status ";
57 $query .= "AND status = 0 ";
58 $query .= "ORDER BY customer,start";
60 $sth = pg_exec ($dbh, $query);
63 while ($row = pg_fetch_array ($sth)) {
65 if ($customer != $row['customer']) {
66 if (strlen($customer))
67 printf($table_foot, $fieldnr);
68 printf($table_head, $row['customer']);
69 $customer = $row['customer'];
76 $d = explode(' ', $row['start']);
78 $check = '<input type="checkbox" name="oid_'.$fieldnr++.'" value="'.$row['oid'].'">';
79 printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['task']);
80 $color = $color=="<cold>"?"<coln>":"<cold>";
82 printf($table_foot, $fieldnr);
85 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
86 or die("Unable to connect to SQL server");
88 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
90 if (isset($_POST["status"]) && isset($_POST["fields"])) {
93 if (isset($_GET['month']))
94 $month = $_GET['month'];
96 if (isset($_POST["filter"])) {
97 $month = $_POST["month"];
98 $status = $_POST["status"];
100 $month = date('Y-m');
104 <page func=InfoCon title="Stempeluhr">
113 <h3 class=bar>Display</h3>
115 <form action=status.php method=POST>
117 <option value="all">alle</option>
119 foreach ($months as $m) {
120 printf('<option value="%s">%s</option>', $m, $m);
125 <input type="radio" name="status" value="all">alle
126 <input type="radio" name="status" value="0">unbekannt
127 <input type="radio" name="status" value="1">ignoriert
128 <input type="radio" name="status" value="2">wartung
129 <input type="radio" name="status" value="3">berechnet
131 <input type="hidden" name="filter" value="form">
132 <input type="submit" value="Display">