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