2 #include <infocon.style>
5 function min2hour($minutes)
7 return sprintf('%02d:%02d', $minutes/60, $minutes%60);
15 for ($idx=0; $idx < $_POST["fields"]; $idx++) {
16 if (isset($_POST["oid_".$idx])) {
17 $query = sprintf('UPDATE stempel SET status=%d WHERE oid=%d',
18 $_POST["status"], $_POST["oid_".$idx]);
20 $sth = pg_exec ($dbh, $query);
24 return sprintf("<br>%d records updated.", $count);
28 function display_tables()
35 $table_head = '<h3 class="bar">Kunde: %s</h3><form action="status.php" method="POST">
36 <table class="smallfont border" width="100%%" cellpadding=0 cellspacing=1>
38 <th width=15%%>Datum</th>
39 <th width=5%%>Dauer</th>
40 <th width=5%%>St.</th>
41 <th width=75%%>Verwendungszweck</th>
44 if (!is_array($stati))
45 $stati = find_status();
47 $table_foot = '</table><div align="center"><p>';
49 foreach ($stati as $k=>$v)
50 $table_foot .= sprintf('<input type="radio" name="status" value="%s"%s>%s ', $k, 0==$k?' checked':'', $v);
51 $table_foot .= '</p><p><input type="submit" value="Aktualisieren"></div>'.
52 '<input type="hidden" name="fields" value="%d"></p>'.
55 $table_row = '<tr class=t%d><td>%s</td><td align="center">%s</td><td align="center">%s</td><td>%s</td></tr>';
56 $table_sum = '<tr class="t%d"><td> </td><td align="center">%s</td><td> </td><td>Summe</td></tr>';
58 $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 ";
59 if (isset($month) && $month !== 'all')
60 $query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
63 $query .= "AND status = $status ";
65 $query .= "AND status = 0 ";
66 $query .= "ORDER BY customer,start";
68 $sth = pg_exec ($dbh, $query);
71 while ($row = pg_fetch_array ($sth)) {
73 if ($customer != $row['customer']) {
74 if (strlen($customer)) {
75 printf($table_sum, $color, min2hour($sum));
76 printf($table_foot, $fieldnr);
78 printf($table_head, $row['customer']);
79 $customer = $row['customer'];
86 $d = explode(' ', $row['start']);
88 $check = '<input type="checkbox" name="oid_'.$fieldnr++.'" value="'.$row['oid'].'">';
89 printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['kurz'], $row['task']);
92 printf($table_sum, $color, min2hour($sum));
93 printf($table_foot, $fieldnr);
96 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
97 or die("Unable to connect to SQL server");
99 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
101 if (isset($_POST["status"]) && isset($_POST["fields"])) {
104 if (isset($_GET['month']))
105 $month = $_GET['month'];
107 if (isset($_POST["filter"])) {
108 $month = $_POST["month"];
109 $status = $_POST["status"];
111 $month = date('Y-m');
115 <page func=InfoCon title="Stempeluhr">
124 <h3 class=bar>Display</h3>
126 <form action=status.php method=POST>
129 if (!is_array($months))
130 $months = find_months();
132 printf('<option value="all"%s>alle</option>', $_POST['month']=='alle'?' selected':'');
133 foreach ($months as $m) {
134 printf('<option value="%s"%s>%s</option>', $m, $_POST['month']==$m?' selected':'', $m);
140 if (!is_array($stati))
141 $stati = find_status();
143 printf('<input type="radio" name="status" value="all"%s>alle ', $status=='all'?' checked':'');
144 foreach ($stati as $k=>$v)
145 printf('<input type="radio" name="status" value="%s"%s>%s ', $k, $status==$k?' checked':'', $v);
148 <input type="hidden" name="filter" value="form">
149 <input class="button" type="submit" value="Display">