1 #include <infocon.style>
2 #include <phptools.inc>
5 <page func=InfoCon title="Kontoführung">
10 <table class="border smallfont" width=100% border=0 cellpadding=0 cellspacing=1>
12 <th width=10%>Datum</th>
13 <th width=10%>Kategorie</th>
14 <th width=70%>Verwendungszweck</th>
15 <th width=10%>Betrag</th>
18 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
23 if ((strlen ($_POST[currency]) > 0) && ($_POST[currency] == "dm")) {
24 $table = "account_dm";
29 $where[] = "blz_kto = '$_POST[blzkto]'";
30 if (strlen($_POST[year])) {
31 $where[] = sprintf ("datum >= '%04d-01-01'", $_POST[year]);
33 $where[] = sprintf ("datum < '%04d-01-01'", $_POST[year]+1);
36 if (strlen($_POST[deadline]) && strlen(trim($_POST[deadline]))) {
37 $date = form_to_yyyymmdd ($_POST[deadline]);
38 $where[] = sprintf ("datum < '%s'", $date);
41 if (strlen($_POST[statement]) && strlen(trim($_POST[statement]))) {
42 $where[] = "statement = '$_POST[statement]'";
45 if (strlen($_POST[category]) && strlen(trim($_POST[category]))) {
46 $where[] = "category = '$_POST[category]'";
49 if (strlen($_POST[keyword]) && strlen(trim($_POST[keyword]))) {
50 $where[] = "descr ~* '$_POST[keyword]'";
53 if (strlen($_POST[from_to]) && strlen(trim($_POST[from_to]))) {
54 $where[] = "from_to = '$_POST[from_to]'";
57 if ($_POST[input] && !$_POST[output]) {
58 $where[] = "$value > 0.0";
59 } elseif ($_POST[output] && !$_POST[input]) {
60 $where[] = "$value < 0.0";
63 $query = "SELECT datum,id,category,descr,$value FROM $table WHERE "
64 . implode ($where, " AND ")
65 . " ORDER BY datum,id";
66 $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
72 for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
73 $row = pg_fetch_array ($sth, $nr);
77 $date = explode (" ", $row['datum']);
78 $date = explode ("-", $date[0]);
79 $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
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?id=%d%s\">%s</a></td>",
85 $row['id'], $add, $descr[0]);
86 printf ("<td width=\"10%%\" align=\"right\" class=\"%s\">%5.2f</td>",
87 $row[$value]>0?"in":"out", $row[$value]);
89 if ($row[$value] > 0) {
90 $sum_in += $row[$value];
92 $sum_out += $row[$value];
97 if (strlen($statement)) {
98 printf ("<tr class=\"t%d\">", $color);
99 echo ("<td width=\"90%\" colspan=\"3\"><strong>Summe Einnahmen</strong></td>");
100 printf ("<td width=\"10%%\" align=\"right\" class=\"in\">%5.2f</td>",$sum_in);
102 printf ("<tr class=\"t%d\">", $color);
103 echo ("<td width=\"90%\" colspan=\"3\"><strong>Summe Ausgaben</strong></td>");
104 printf ("<td width=\"10%%\" align=\"right\" class=\"out\">%5.2f</td>", $sum_out*-1);
107 printf ("<tr class=\"t%d\">", $color);
108 echo ("<td width=\"90%\" colspan=\"3\" align=\"left\"><strong>Summe</strong></td>");
109 printf ("<td width=\"10%%\" align=\"right\" class=\"%s\"><strong>%5.2f</strong></td>",
110 $sum>0?"in":"out", $sum);