1 #include <infocon.style>
4 <script type="text/javascript">
5 function check(form, value)
7 var form = document.forms[form];
9 for (i=0; i< form.elements.length; i++) {
10 if (form.elements[i].name.substr(0,4) == 'oid_')
11 form.elements[i].checked = value;
17 document.write('<div class="jscode">');
18 document.write('<a href="javascript:check('+form+',true)">Check all</a>');
19 document.write(" / ");
20 document.write('<a href="javascript:check('+form+',false)">Uncheck all</a>');
21 document.write(" ");
22 document.write('</div>');
26 <style type="text/css">
40 for ($idx=0; $idx < $_POST["fields"]; $idx++) {
41 if (isset($_POST["oid_".$idx])) {
42 $query = sprintf('UPDATE stempel SET status=%d WHERE oid=%d',
43 $_POST["status"], $_POST["oid_".$idx]);
45 $sth = pg_exec ($dbh, $query);
48 return sprintf("<br>%d records updated.", $count);
52 function display_tables()
60 $table_head = '<h3 class="bar">Kunde: %s</h3><script type="text/javascript">plant(%d);</script>
61 <form action="status.php" method="POST">
62 <table class="smallfont border" width="100%%" cellpadding=0 cellspacing=1>
64 <th width=15%%>Datum</th>
65 <th width=5%%>Dauer</th>
66 <th width=5%%>St.</th>
67 <th width=75%% align=left>Verwendungszweck</th>
70 if (!is_array($stati))
71 $stati = find_status();
73 $table_foot = '</table><div align="center"><p>';
75 foreach ($stati as $k=>$v)
76 $table_foot .= sprintf('<input type="radio" name="status" value="%s"%s>%s ', $k, 0==$k?' checked':'', $v);
77 $table_foot .= '</p><p><input type="submit" class="button" value="Aktualisieren"></div>'.
78 '<input type="hidden" name="fields" value="%d"></p>'.
81 $table_row = '<tr class=t%d><td>%s</td><td align="center">%s</td><td align="center">%s</td><td>%s</td></tr>';
82 $table_sum = '<tr class="t%d"><td> </td><td align="center">%s</td><td> </td><td>Summe</td></tr>';
84 $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 ";
85 if (isset($month) && strlen($month))
86 $query .= "AND cast(start AS TEXT) LIKE '".$month."-%' ";
87 if (isset($cust) && strlen($cust))
88 $query .= "AND customer ='".$cust."' ";
92 $query .= "AND status = $status ";
94 $query .= "AND status = 0 ";
95 $query .= "ORDER BY customer,start";
97 $sth = pg_exec ($dbh, $query);
101 while ($row = pg_fetch_array ($sth)) {
103 if ($customer != $row['customer']) {
104 if (strlen($customer)) {
105 printf($table_sum, $color, min2hour($sum));
106 printf($table_foot, $fieldnr);
108 printf($table_head, ucfirst($row['customer']), $form++);
109 $customer = $row['customer'];
115 $sum += $row['time'];
116 $d = explode(' ', $row['start']);
118 $check = '<input type="checkbox" name="oid_'.$fieldnr++.'" value="'.$row['oid'].'">';
119 printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['kurz'], $row['task']);
122 if (pg_num_rows($sth) > 0) {
123 printf($table_sum, $color, min2hour($sum));
124 printf($table_foot, $fieldnr);
128 function find_customers()
133 $query = "SELECT DISTINCT customer FROM stempel ORDER BY customer";
134 $sth = pg_exec ($dbh, $query);
136 while ($row = pg_fetch_array ($sth))
142 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
143 or die("Unable to connect to SQL server");
145 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
147 if (isset($_POST["status"]) && isset($_POST["fields"])) {
150 if (isset($_GET['month']))
151 $month = $_GET['month'];
153 if (isset($_POST["filter"])) {
154 $month = $_POST["month"];
155 $cust = $_POST["customer"];
156 $status = $_POST["status"];
158 $month = date('Y-m');
162 <page func=InfoCon title="Stempeluhr">
171 <h3 class=bar>Display</h3>
173 <form action=status.php method=POST>
176 if (!is_array($months))
177 $months = find_months();
179 printf('<option value=""%s>alle</option>', !strlen($_POST['month'])?' selected':'');
180 foreach ($months as $m) {
181 printf('<option value="%s"%s>%s</option>', $m, $_POST['month']==$m?' selected':'', $m);
186 <select name=customer>
188 if (!is_array($customers))
189 $customers = find_customers();
191 printf('<option value=""%s>alle</option>', !strlen($_POST['month'])?' selected':'');
192 foreach ($customers as $c) {
193 printf('<option value="%s"%s>%s</option>', $c, $_POST['customer']==$c?' selected':'', $c);
199 if (!is_array($stati))
200 $stati = find_status();
202 printf('<input type="radio" name="status" value="all"%s>alle ', $status=='all'?' checked':'');
203 foreach ($stati as $k=>$v)
204 printf('<input type="radio" name="status" value="%s"%s>%s ', $k, $status==$k?' checked':'', $v);
207 <input type="hidden" name="filter" value="form">
208 <input class="button" type="submit" value="Display">