Widen input element
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / index.wml
1 #include <infocon.style>
2
3 <page func=InfoCon title="Buchhaltung">
4 <calendar_init -5>
5
6 <style type="text/css">
7 span.in { color: green; }
8 span.out { color: red; }
9 span.in:hover, span.out:hover { background: yellow; border: 1px solid #ccc; }
10 input[id^=date_] { width: 6.1em; }
11 </style>
12
13 <h3>Übersichten</h3>
14
15 <?
16   $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
17          or die("Unable to connect to SQL server");
18 ?>
19 <form method=POST action=list.php>
20 <input type=hidden name=blzkto value="<? echo $blzkto; ?>">
21 <b>Jahr:</b> <select name=year>
22 <option>
23 <?
24   $query = "SELECT DISTINCT substr(date,0,5) AS year FROM sales ORDER BY substr(date,0,5) DESC";
25   $sth = pg_exec ($dbh, $query);
26
27   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
28     $cat = pg_fetch_array ($sth, $nr);
29     printf ("<option value=\"%s\">%s", $cat["year"], $cat["year"]);
30   }
31 ?></select><br>
32 <b>Kategorie:</b> <select name=category>
33 <option>
34 <?
35   $query = "SELECT DISTINCT category FROM sales ORDER BY category";
36   $sth = pg_exec ($dbh, $query);
37
38   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
39     $cat = pg_fetch_array ($sth, $nr);
40     printf ("<option value=\"%s\">%s", $cat['category'], $cat['category']);
41   }
42 ?></select><br>
43 <b>Zahlung</b>: <input type=checkbox name=input value=1 checked> Einnahmen <input type=checkbox name=output value=1 checked> Ausgaben<br>
44
45 <p><center>
46 <input class=button type=submit name=submit value="List"> 
47 <input class=button type=submit name=submit value="Overview"> 
48 <input class=button type=submit name=submit value="Tally"> 
49 <input class=button type=reset value="Reset">
50 </center></p>
51 </form>
52
53 <?
54   $form = 0;
55   $query = "SELECT nr,date,description,price FROM sales_dm WHERE paid=0 AND visible=1 ORDER BY date,nr";
56   $sth = pg_exec ($dbh, $query);
57
58   if (pg_NumRows ($sth) > 0) {
59     $form = 1;
60     echo ("<h3>Nicht bezahlte Rechnungen</h3>");
61     echo ("<form method=\"POST\" action=\"pay.php\">");
62   }
63
64   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
65     $row = pg_fetch_array ($sth, $nr);
66     $date = substr ($row['date'],6,2) . "." . substr ($row['date'],4,2) . "." . substr ($row['date'],0,4);
67     printf (" <input type=\"text\" id=\"date_%d\" name=\"date_%d\" size=\"7\" value=\"\">", $row['nr'], $row['nr']);
68     printf (" <img class=\"calendar\" src=\"<root_prefix>pix/calendar.gif\" onclick=\"event.cancelBubble=true;popcalendar('date_%d');\" alt=\"\">", $row['nr']);
69     printf (" %d. %s %s (%.2f&nbsp;DM)<br>", $row['nr'], $date, $row['description'], $row['price']);
70   }
71
72   $query = "SELECT nr,date,description,price FROM sales WHERE paid=0 AND visible=1 ORDER BY date,nr";
73   $sth = pg_exec ($dbh, $query);
74
75   if (!$form && pg_NumRows ($sth) > 0) {
76     $form = 1;
77     echo ("<h3>Nicht bezahlte Rechnungen</h3>");
78     echo ("<form method=\"POST\" action=\"pay.php\">");
79   }
80
81   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
82     $row = pg_fetch_array ($sth, $nr);
83     $date = substr ($row['date'],6,2) . "." . substr ($row['date'],4,2) . "." . substr ($row['date'],0,4);
84     printf (" <input type=\"text\" id=\"date_%d\" name=\"date_%d\" size=\"6\" value=\"\">", $row['nr'], $row['nr']);
85     printf (" <img class=\"calendar\" src=\"<root_prefix>pix/calendar.gif\" onclick=\"event.cancelBubble=true;popcalendar('date_%d');\" alt=\"\">", $row['nr']);
86     printf (' <span class="%s">%d. %s %s (%.2f&nbsp;&euro;)</span><br>',
87             $row['price'] < 0 ? 'out' : 'in',
88             $row['nr'], $date, $row['description'], $row['price']);
89   }
90
91   if ($form > 0) {
92     echo ("<p><input type=\"submit\" class=\"button\" value=\"Bezahlen\"> <input type=\"reset\" class=\"button\" value=\"Reset\"><p>");
93     echo ("</form>");
94   }
95 ?>
96
97 </page>
98
99 # Local variables:
100 # mode: text
101 # mode: auto-fill
102 # end: