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