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