Support for PHP > 3
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / index.wml
1 #include <infocon.style>
2
3 <page func=InfoCon title="Buchhaltung">
4
5 <form method=POST action=list.php>
6 <input type=hidden name=blzkto value="<? echo $blzkto; ?>">
7 <b>Jahr</b>: <input name=year size=10 maxlength=4><br>
8 <b>Kategorie:</b> <select name=category>
9 <option>
10 <?
11   $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
12          or die("Unable to connect to SQL server");
13
14   $query = "SELECT DISTINCT category FROM sales ORDER BY category";
15   $sth = pg_exec ($dbh, $query);
16
17   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
18     $cat = pg_fetch_array ($sth, $nr);
19     printf ("<option value=\"%s\">%s", $cat['category'], $cat['category']);
20   }
21 ?></select><br>
22 <b>Währung</b>: <input type=radio name=currency value=eur checked> Euro <input type=radio name=currency value=dm> DM<br>
23 <b>Zahlung</b>: <input type=checkbox name=input value=1 checked> Einnahmen <input type=checkbox name=output value=1 checked> Ausgaben<br>
24
25 <p><center><input type=submit value="Query"> <input type=reset value="Reset"></center><p>
26 </form>
27
28 <?
29   $form = 0;
30   $query = "SELECT nr,date,description,price FROM sales_dm WHERE paid=0 ORDER BY date,nr";
31   $sth = pg_exec ($dbh, $query);
32
33   if (pg_NumRows ($sth) > 0) {
34     $form = 1;
35     echo ("<h3>Nicht bezahlte Rechnungen</h3>");
36     echo ("<form method=\"POST\" action=\"pay.php\">");
37   }
38
39   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
40     $row = pg_fetch_array ($sth, $nr);
41     $date = substr ($row['date'],6,2) . "." . substr ($row['date'],4,2) . "." . substr ($row['date'],0,4);
42     printf (" <input type=\"checkbox\" name=\"pay_dm_%d\" value=\"1\">", $row['nr']);
43     printf ("%d. %s %s (%.2f&nbsp;DM)<br>", $row['nr'], $date, $row['description'], $row['price']);
44   }
45
46   $query = "SELECT nr,date,description,price FROM sales WHERE paid=0 ORDER BY date,nr";
47   $sth = pg_exec ($dbh, $query);
48
49   if (!form && pg_NumRows ($sth) > 0) {
50     $form = 1;
51     echo ("<h3>Nicht bezahlte Rechnungen</h3>");
52     echo ("<form method=\"POST\" action=\"pay.php\">");
53   }
54
55   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
56     $row = pg_fetch_array ($sth, $nr);
57     $date = substr ($row['date'],6,2) . "." . substr ($row['date'],4,2) . "." . substr ($row['date'],0,4);
58     printf (" <input type=\"checkbox\" name=\"pay_%d\" value=\"1\">", $row['nr']);
59     printf ("%d. %s %s (%.2f&nbsp;&euro;)<br>", $row['nr'], $date, $row['description'], $row['price']);
60   }
61
62   if ($form > 0) {
63     echo ("<p><input type=\"submit\" value=\"Bezahlen\"> <input type=\"reset\" value=\"Reset\"><p>");
64     echo ("</form>");
65   }
66 ?>
67
68 </page>
69
70 # Local variables:
71 # mode: text
72 # mode: auto-fill
73 # end: