1 #include <infocon.style>
5 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
6 or die("Unable to connect to SQL server");
8 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
10 if (isset($_GET['month']))
11 $month = $_GET['month'];
16 <page func=InfoCon title="Stempeluhr">
19 $table_head = '<h3 class="bar">Kunde: %s</h3>
20 <table class="smallfont border" width="100%%" cellpadding=0 cellspacing=1>
22 <th width=10%%>Datum</th>
23 <th width=5%%>Dauer</th>
24 <th width=5%%>St.</th>
25 <th width=80%%>Arbeitsbeschreibung</th>
27 $table_foot = '</table>';
28 $table_row = '<tr class="t%d"><td>%s</td><td align="center">%s</td><td align="center">%s</td><td><a href="edit.php?id=%d">%s</a></td></tr>';
29 $table_sum = '<tr class="t%d"><td> </td><td align="center"><strong>%s</strong></td><td> </td><td><strong>Summe</strong></td></tr>';
31 $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 ";
32 if (isset($month) && $month !== 'all')
33 $query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
34 $query .= "ORDER BY customer,start";
36 $sth = pg_exec ($dbh, $query);
39 while ($row = pg_fetch_array ($sth)) {
41 if ($customer != $row['customer']) {
42 if (strlen($customer)) {
43 printf($table_sum, $color, min2hour($sum));
46 printf($table_head, $row['customer']);
47 $customer = $row['customer'];
53 $d = explode(' ', $row['start']);
55 printf($table_row, $color, $d[0], min2hour($row['time']), $row['kurz'], $row['oid'], $row['task']);
58 printf($table_sum, $color, min2hour($sum));
61 <div style="padding-top: 0.5em"></div>
63 <form action=<?=$_SERVER["SCRIPT_NAME"]?> method=get>
64 <b>Select month</b>: <select name=month>
66 $months = find_months();
68 foreach ($months as $m) {
74 printf('<option value="%s"%s>%s</option>', $m, $sel, $m);
76 printf('<option value="all"%s>All</option>', $month == 'all'?' selected':'');
79 <input class=button type=submit value="Select">
81 <div style="padding-top: 0.5em"></div>