Support for Register globals = off
[infodrom.org/service.infodrom.org] / src / InfoCon / account / list.wml
1 #include <infocon.style>
2 #include "account.inc"
3
4 <page func=InfoCon title="Kontoführung">
5
6 <account_heading>
7
8 <table class=font width=100% border=0 cellpadding=2 cellspacing=0>
9 <tr bgcolor=#<colh>>
10   <th width=10%><font face="Helvetica,Arial">Datum</font></th>
11   <th width=10%><font face="Helvetica,Arial">Kategorie</font></th>
12   <th width=70%><font face="Helvetica,Arial">Verwendungszweck</font></th>
13   <th width=10%><font face="Helvetica,Arial">Betrag</font></th>
14 </tr>
15 <?
16   pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
17
18   $table = "account";
19   $value = "value_eur";
20   $add = '';
21   if ((strlen ($currency) > 0) && ($currency == "dm")) {
22     $table = "account_dm";
23     $value = "value_dm";
24     $add = "&cur=dm";
25   }
26
27   $where[] = "blz_kto = '$_GET[blzkto]'";
28   if (strlen($year)) {
29     $where[] = sprintf ("datum >= '%04d-01-01'", $year);
30     $year++;
31     $where[] = sprintf ("datum < '%04d-01-01'", $year);
32   }
33   if (strlen($statement)) {
34     $where[] = "statement = '$statement'";
35   }
36   if (strlen($category)) {
37     $where[] = "category = '$category'";
38   }
39   if (strlen($keyword)) {
40     $where[] = "descr ~* '$keyword'";
41   }
42   if (strlen($from_to)) {
43     $where[] = "from_to = '$from_to'";
44   }
45   if ($input && !$output) {
46     $where[] = "$value > 0.0";
47   } elseif ($output && !$input) {
48     $where[] = "$value < 0.0";
49   }
50
51   $query = "SELECT datum,oid,category,descr,$value FROM $table WHERE "
52          . implode ($where, " AND ")
53          . " ORDER BY datum,oid";
54   $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
55
56   $sum = 0.0;
57   $sum_in = 0.0;
58   $sum_out = 0.0;
59   $color = "<cold>";
60   for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
61     $row = pg_fetch_array ($sth, $nr);
62     $color = $color=="<cold>"?"<coln>":"<cold>";
63
64     $descr = explode ("
65 ", $row['descr']);
66     $date = explode (" ", $row['datum']);
67     $date = explode ("-", $date[0]);
68     $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
69
70     printf ("<tr bgcolor=\"#%s\">", $color);
71     printf ("<td width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%s</font></td>", $date);
72     printf ("<td width=\"10%%\" align=\"center\"><font face=\"Helvetica,Arial\">%s</font></td>", $row['category']);
73     printf ("<td width=\"70%%\"><font face=\"Helvetica,Arial\"><a href=\"edit.php3?oid=%d%s\">%s</a></font></td>",
74             $row['oid'], $add, $descr[0]);
75     printf ("<td width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></td>", $row[$value]);
76     $sum += $row[$value];
77     if ($row[$value] > 0) {
78       $sum_in += $row[$value];
79     } else {
80       $sum_out += $row[$value];
81     }
82     echo ("</tr>");
83   }
84     $color = $color=="<cold>"?"<coln>":"<cold>";
85     printf ("<tr bgcolor=\"#%s\">", $color);
86     echo ("<th width=\"90%\" colspan=\"3\"><font face=\"Helvetica,Arial\">Summe</font></th>");
87     printf ("<th width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></th>", $sum);
88     echo ("</tr>");
89     if (strlen($statement)) {
90       $color = $color=="<cold>"?"<coln>":"<cold>";
91       printf ("<tr bgcolor=\"#%s\">", $color);
92       echo ("<th width=\"90%\" colspan=\"3\"><font face=\"Helvetica,Arial\">Summe Einnahmen</font></th>");
93       printf ("<th width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></th>", $sum_in);
94       echo ("</tr>");
95       $color = $color=="<cold>"?"<coln>":"<cold>";
96       printf ("<tr bgcolor=\"#%s\">", $color);
97       echo ("<th width=\"90%\" colspan=\"3\"><font face=\"Helvetica,Arial\">Summe Ausgaben</font></th>");
98       printf ("<th width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></th>", $sum_out*-1);
99       echo ("</tr>");
100     }
101
102 ?>
103 </table><p>
104
105 <? printf ("<a href=\"edit.php3?blzkto=%s\">Neuer Eintrag</a>", $_GET[blzkto]); ?>
106
107 </page>
108
109 # Local variables:
110 # mode: text
111 # mode: auto-fill
112 # end: