Kontoverwaltung mit Query
[infodrom.org/service.infodrom.org] / src / InfoCon / account / list.wml
1 #include <infocon.style>
2
3 <page title="Kontoführung">
4
5 <h1 align=center><font face="Helvetica,Arial">Kontoführung</font></h1>
6
7 <h3 align=center><font face="Helvetica,Arial"> - <?
8   $both = explode (":", $blzkto);
9   printf ("BLZ %s, Konto %s", $both[0], $both[1]);
10 ?> - </font></h1>
11
12 <table width=100% border=1 cellpadding=2 cellspacing=0>
13 <tr>
14   <th width=15%>Datum</th>
15   <th width=20%>Kategorie</th>
16   <th width=50%>Verwendungszweck</th>
17   <th width=15%>Betrag</th>
18 </tr>
19 <?
20   $dbh = pg_pconnect ("kuolema", "5432", "<db>")
21                or die("Unable to connect to SQL server");
22
23   pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
24
25   $where[] = "blz_kto = '$blzkto'";
26   if (strlen($year)) {
27     $where[] = "datum > '$year-01-01'";
28   }
29   if (strlen($category)) {
30     $where[] = "category = '$category'";
31   }
32   if (strlen($from_to)) {
33     $where[] = "from_to = '$from_to'";
34   }
35   if ($input && !$output) {
36     $where[] = "value_dm > 0.0";
37   } elseif ($output && !$input) {
38     $where[] = "value_dm < 0.0";
39   }
40
41   $query = "SELECT datum,oid,category,descr,value_dm FROM account WHERE "
42          . implode ($where, " AND ")
43          . " ORDER BY datum,oid";
44   $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
45
46   $sum = 0.0;
47   for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
48     $row = pg_fetch_array ($sth, $nr);
49
50     $descr = explode ("
51 ", $row['descr']);
52     $date = explode (" ", $row['datum']);
53     $date = explode ("-", $date[0]);
54     $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
55
56     echo ("<tr>");
57     printf ("<td width=\"15%%\" align=\"right\">%s</td>", $date);
58     printf ("<td width=\"20%%\">%s</td>", $row['category']);
59     printf ("<td width=\"50%%\"><a href=\"edit.php3?oid=%d\">%s</a></td>", $row['oid'], $descr[0]);
60     printf ("<td width=\"15%%\" align=\"right\">%5.2f</td>", $row['value_dm']);
61     $sum += $row['value_dm'];
62     echo ("</tr>");
63   }
64     echo ("<tr>");
65     echo ("<td width=\"85%\" colspan=\"3\">Summe</td>");
66     printf ("<td width=\"15%%\" align=\"right\">%5.2f</td>", $sum);
67     echo ("</tr>");
68
69 ?>
70 </table><p>
71
72 <? printf ("<a href=\"edit.php3?blzkto=%s\">Neuer Eintrag</a>", $blzkto); ?>
73
74
75 </page>
76
77 # Local variables:
78 # mode: text
79 # mode: auto-fill
80 # mode: iso-accents
81 # end: