1 #include <infocon.style>
4 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
5 or die("Unable to connect to SQL server");
7 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
9 if (isset($_GET['month']))
10 $month = $_GET['month'];
15 <page func=InfoCon title="Stempeluhr">
18 function min2hour($minutes)
20 return sprintf('%02d:%02d', $minutes/60, $minutes%60);
23 $table_head = '<h3 class="bar">%s</h3>
24 <table class="font" width="100%%" border=0 cellpadding=2 cellspacing=0>
26 <th width=15%%>Datum</th>
27 <th width=10%%>Dauer</th>
28 <th width=75%%>Verwendungszweck</th>
30 $table_foot = '</table>';
31 $table_row = '<tr bgcolor=#%s><td>%s</td><td align="center">%s</td><td><a href="edit.php?id=%d">%s</a></td></tr>';
32 $table_sum = '<tr bgcolor=#%s><td> </td><td align="center">%s</td><td>Summe</td></tr>';
34 $query = "SELECT oid,start,customer,time,task FROM stempel WHERE time IS NOT NULL ";
35 if (isset($month) && $month !== 'all')
36 $query .= "AND start LIKE '".$month."-%' ";
37 $query .= "ORDER BY customer,start";
39 $sth = pg_exec ($dbh, $query);
42 while ($row = pg_fetch_array ($sth)) {
44 if ($customer != $row['customer']) {
45 if (strlen($customer)) {
46 printf($table_sum, $color, min2hour($sum));
49 printf($table_head, $row['customer']);
50 $customer = $row['customer'];
56 $d = explode(' ', $row['start']);
58 printf($table_row, $color, $d[0], min2hour($row['time']), $row['oid'], $row['task']);
59 $color = $color=="<cold>"?"<coln>":"<cold>";
61 printf($table_sum, $color, min2hour($sum));
64 <div style="padding-top: 0.5em"></div>