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