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 ($_POST['func'] == 'save') {
11 $sql = sprintf("UPDATE stempel SET task = '%s' WHERE oid = %d",
12 pg_escape_string(utf8_decode($_POST['task'])),
16 header('Content-type: application/json; charset="UTF-8"');
17 echo json_encode(true);
21 if (isset($_GET['month']))
22 $month = $_GET['month'];
27 <page func=InfoCon title="Stempeluhr">
30 $table_head = '<h3 class="bar">Kunde: %s</h3>
31 <table class="smallfont border" width="100%%" cellpadding=0 cellspacing=1>
33 <th width=10%%>Datum</th>
34 <th width=5%%>Dauer</th>
35 <th width=5%%>St.</th>
36 <th width=80%%>Arbeitsbeschreibung</th>
38 $table_foot = '</table>';
39 $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>';
40 $table_sum = '<tr class="t%d"><td> </td><td align="center"><strong>%s</strong></td><td> </td><td><strong>Summe</strong></td></tr>';
42 $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 ";
43 if (isset($month) && $month !== 'all')
44 $query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
45 $query .= "ORDER BY customer,start";
47 $sth = pg_exec ($dbh, $query);
50 while ($row = pg_fetch_array ($sth)) {
52 if ($customer != $row['customer']) {
53 if (strlen($customer)) {
54 printf($table_sum, $color, min2hour($sum));
57 printf($table_head, $row['customer']);
58 $customer = $row['customer'];
64 $d = explode(' ', $row['start']);
66 printf($table_row, $color, $d[0], min2hour($row['time']), $row['kurz'], $row['oid'], htmlspecialchars($row['task']));
69 printf($table_sum, $color, min2hour($sum));
72 <div style="padding-top: 0.5em"></div>
74 <form action=<?=$_SERVER["SCRIPT_NAME"]?> method=get>
75 <b>Select month</b>: <select name=month>
77 $months = find_months();
79 foreach ($months as $m) {
85 printf('<option value="%s"%s>%s</option>', $m, $sel, $m);
87 printf('<option value="all"%s>All</option>', $month == 'all'?' selected':'');
90 <input class=button type=submit value="Select">
92 <div style="padding-top: 0.5em"></div>