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>';
49 $table_sum = '<tr bgcolor="#%s"><td> </td><td align="center">%s</td><td>Summe</td></tr>';
51 $query = "SELECT oid,start,customer,time,task FROM stempel WHERE time IS NOT NULL ";
52 if (isset($month) && $month !== 'all')
53 $query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
56 $query .= "AND status = $status ";
58 $query .= "AND status = 0 ";
59 $query .= "ORDER BY customer,start";
61 $sth = pg_exec ($dbh, $query);
64 while ($row = pg_fetch_array ($sth)) {
66 if ($customer != $row['customer']) {
67 if (strlen($customer)) {
68 printf($table_sum, $color, min2hour($sum));
69 printf($table_foot, $fieldnr);
71 printf($table_head, $row['customer']);
72 $customer = $row['customer'];
79 $d = explode(' ', $row['start']);
81 $check = '<input type="checkbox" name="oid_'.$fieldnr++.'" value="'.$row['oid'].'">';
82 printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['task']);
83 $color = $color=="<cold>"?"<coln>":"<cold>";
85 printf($table_sum, $color, min2hour($sum));
86 printf($table_foot, $fieldnr);
89 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
90 or die("Unable to connect to SQL server");
92 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
94 if (isset($_POST["status"]) && isset($_POST["fields"])) {
97 if (isset($_GET['month']))
98 $month = $_GET['month'];
100 if (isset($_POST["filter"])) {
101 $month = $_POST["month"];
102 $status = $_POST["status"];
104 $month = date('Y-m');
108 <page func=InfoCon title="Stempeluhr">
117 <h3 class=bar>Display</h3>
119 <form action=status.php method=POST>
121 <option value="all">alle</option>
123 if (!is_array($months))
124 $months = find_months();
126 foreach ($months as $m) {
127 printf('<option value="%s">%s</option>', $m, $m);
132 <input type="radio" name="status" value="all">alle
133 <input type="radio" name="status" value="0">unbekannt
134 <input type="radio" name="status" value="1">ignoriert
135 <input type="radio" name="status" value="2">wartung
136 <input type="radio" name="status" value="3">berechnet
138 <input type="hidden" name="filter" value="form">
139 <input type="submit" value="Display">