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 $name = load_customers();
32 $table_head = '<h3 class="bar">Kunde: %s</h3>
33 <table class="smallfont border" width="100%%" cellpadding=0 cellspacing=1>
35 <th width=10%%>Datum</th>
36 <th width=5%%>Dauer</th>
37 <th width=5%%>St.</th>
38 <th width=80%%>Arbeitsbeschreibung</th>
40 $table_foot = '</table>';
41 $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>';
42 $table_sum = '<tr class="t%d"><td> </td><td align="center"><strong>%s</strong></td><td> </td><td><strong>Summe</strong></td></tr>';
45 SELECT stempel.oid,start,stempel_customer.name AS customer,time,task,kurz
47 JOIN stempel_customer ON (stempel.customer = stempel_customer.short)
48 JOIN stempel_status ON (stempel.status = stempel_status.id)
49 WHERE time IS NOT NULL
51 if (isset($month) && $month !== 'all')
52 $query .= " AND cast(start AS TEXT) LIKE '".$month."-%'";
53 $query .= " ORDER BY customer,start";
55 $sth = pg_exec ($dbh, $query);
58 while ($row = pg_fetch_array ($sth)) {
60 if ($customer != $row['customer']) {
61 if (strlen($customer)) {
62 printf($table_sum, $color, min2hour($sum));
65 $cname = $name[$row['customer']];
66 if (!strlen($cname)) $cname = $row['customer'];
67 printf($table_head, $cname);
68 $customer = $row['customer'];
74 $d = explode(' ', $row['start']);
76 printf($table_row, $color, $d[0], min2hour($row['time']), $row['kurz'], $row['oid'], htmlspecialchars($row['task'], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'));
79 printf($table_sum, $color, min2hour($sum));
82 <div style="padding-top: 0.5em"></div>
84 <form action=<?=$_SERVER["SCRIPT_NAME"]?> method=get>
85 <b>Select month</b>: <select name=month>
87 $months = find_months();
89 foreach ($months as $m) {
95 printf('<option value="%s"%s>%s</option>', $m, $sel, $m);
97 printf('<option value="all"%s>All</option>', $month == 'all'?' selected':'');
100 <input class=button type=submit value="Select">
102 <div style="padding-top: 0.5em"></div>