#include <infocon.style>
-<page title="Kontoführung">
-
-<headline "Buchhaltung">
-
-<table width=100% border=1 cellpadding=2 cellspacing=0>
-<tr>
- <th width=15%>Datum</th>
- <th width=20%>Kategorie</th>
- <th width=50%>Verwendungszweck</th>
- <th width=15%>Betrag</th>
+<page func=InfoCon title="Buchhaltung">
+
+<table width=100% border=0 cellpadding=2 cellspacing=0>
+<tr bgcolor=#<colh>>
+ <th width=15%><font face="Helvetica,Arial">Datum</font></th>
+ <th width=20%><font face="Helvetica,Arial">Kategorie</font></th>
+ <th width=50%><font face="Helvetica,Arial">Verwendungszweck</font></th>
+ <th width=15%><font face="Helvetica,Arial">Betrag</font></th>
</tr>
<?
- $dbh = pg_pconnect ("kuolema", "5432", "<db>")
+ $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
or die("Unable to connect to SQL server");
pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
+ if ($currency == "eur") {
+ $table = "sales";
+ } elseif ($currency == "dm") {
+ $table = "sales_dm";
+ } else {
+ die ("Unknown currency");
+ }
+
if (strlen($year)) {
# $where[] = "date >= '$year-01-01'";
# $year++;
# $where[] = "date < '$year-01-01'";
$where[] = "date ~* '$year'";
+
+ # Implicit selection of currency
+ if ($year < 2002) {
+ $table = "sales_dm";
+ } elseif ($year > 2001) {
+ $table = "sales";
+ }
}
if (strlen($category)) {
$where[] = "category = '$category'";
$where[] = "price < 0.0";
}
- $query = "SELECT date,oid,category,description,price FROM sales ";
+ $query = "SELECT date,oid,category,description,price FROM $table ";
if (count($where) > 0) {
$query .= " WHERE " . implode ($where, " AND ");
}
$sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
$sum = 0.0;
+ $color = "<cold>";
for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
$row = pg_fetch_array ($sth, $nr);
+ $color = $color=="<cold>"?"<coln>":"<cold>";
# $date = explode (" ", $row['date']);
# $date = explode ("-", $date[0]);
# $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
$date = substr ($row['date'],6,2) . "." . substr ($row['date'],4,2) . "." . substr ($row['date'],0,4);
- echo ("<tr>");
- printf ("<td width=\"15%%\" align=\"right\">%s</td>", $date);
- printf ("<td width=\"20%%\">%s</td>", $row['category']);
- printf ("<td width=\"50%%\"><a href=\"edit.php3?oid=%d\">%s</a></td>", $row['oid'], $row['description']);
- printf ("<td width=\"15%%\" align=\"right\">%5.2f</td>", $row['price']);
+ printf ("<tr bgcolor=\"#%s\">", $color);
+ printf ("<td width=\"15%%\" align=\"right\"><font face=\"Helvetica,Arial\">%s</font></td>", $date);
+ printf ("<td width=\"20%%\"><font face=\"Helvetica,Arial\">%s</font></td>", $row['category']);
+ printf ("<td width=\"50%%\"><font face=\"Helvetica,Arial\"><a href=\"edit.php3?oid=%d&cur=%s\">%s</a></font></td>",
+ $row['oid'], $currency, $row['description']);
+ printf ("<td width=\"15%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></td>", $row['price']);
$sum += $row['price'];
echo ("</tr>");
}
echo ("<tr>");
- echo ("<td width=\"85%\" colspan=\"3\">Summe</td>");
- printf ("<td width=\"15%%\" align=\"right\">%5.2f</td>", $sum);
+ echo ("<td width=\"85%\" colspan=\"3\"><font face=\"Helvetica,Arial\"><b>Summe</b></font></td>");
+ printf ("<td width=\"15%%\" align=\"right\"><font face=\"Helvetica,Arial\"><b>%5.2f</b></font></td>", $sum);
echo ("</tr>");
+ echo ("</table><p>");
if (!strlen($category)) {
- $query = "SELECT DISTINCT category FROM sales ";
+ $query = "SELECT DISTINCT category FROM $table ";
if (strlen($year)) {
$query .= "WHERE date ~* '$year'";
}
if (count ($catz) > 0) {
echo ("<h3>Nach Kategorien sortiert</h3>");
- echo ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">");
- echo ("<tr><th width=\"70%\">Kategorie</th><th width=\"10%\">Einnahmen</th><th width=\"10%\">Ausgaben</th>"
- ."<th width=\"10%\">Summe</th></tr>");
+ echo ("<div align=\"center\"><table width=\"80%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" summary=\"\">");
+ echo ("<tr bgcolor=\"#<colh>\">"
+ ."<th width=\"70%\"><font face=\"Helvetica,Arial\">Kategorie</font></th>"
+ ."<th width=\"10%\"><font face=\"Helvetica,Arial\">Einnahmen</font></th>"
+ ."<th width=\"10%\"><font face=\"Helvetica,Arial\">Ausgaben</font></th>"
+ ."<th width=\"10%\"><font face=\"Helvetica,Arial\">Summe</font></th></tr>");
sort ($catz);
+ $color = "<cold>";
for ($i=0; $i < count ($catz); $i++) {
- $query = sprintf ("SELECT SUM (price) FROM sales WHERE category = '%s' AND price > 0.0", $catz[$i]);
+ $query = sprintf ("SELECT SUM (price) FROM $table WHERE category = '%s' AND price > 0.0", $catz[$i]);
+ $color = $color=="<cold>"?"<coln>":"<cold>";
+
if (strlen($year)) {
$query .= " AND date ~* '$year'";
}
$sth = pg_exec ($dbh, $query); // or die("Datenbank-Abfrage!");
$row = pg_fetch_array ($sth, 0);
$input = $row[0]; $sum_input += $input;
- $query = sprintf ("SELECT SUM (price) FROM sales WHERE category = '%s' AND price < 0.0", $catz[$i]);
+ $query = sprintf ("SELECT SUM (price) FROM $table WHERE category = '%s' AND price < 0.0", $catz[$i]);
if (strlen($year)) {
$query .= " AND date ~* '$year'";
}
$row = pg_fetch_array ($sth, 0);
$output = -$row[0]; $sum_output += $output;
- printf ("<tr><td width=\"70%%\">%s</td><td align=\"right\" width=\"10%%\">%.2f</td>"
- ."<td align=\"right\" width=\"10%%\">%.2f</td>"
- ."<td align=\"right\" width=\"10%%\">%.2f</td></tr>",$catz[$i], $input, $output, $input - $output);
+ printf ("<tr bgcolor=\"#%s\"><td width=\"70%%\"><font face=\"Helvetica,Arial\">%s</font></td>"
+ ."<td align=\"right\" width=\"10%%\"><font face=\"Helvetica,Arial\">%.2f</font></td>"
+ ."<td align=\"right\" width=\"10%%\"><font face=\"Helvetica,Arial\">%.2f</font></td>"
+ ."<td align=\"right\" width=\"10%%\"><font face=\"Helvetica,Arial\">%.2f</font></td></tr>",
+ $color, $catz[$i], $input, $output, $input - $output);
}
- printf ("<tr><td width=\"70%%\">Summe</td><td align=\"right\" width=\"10%%\">%.2f</td>"
- ."<td align=\"right\" width=\"10%%\">%.2f</td>"
- ."<td align=\"right\" width=\"10%%\">%.2f</td></tr>",$sum_input, $sum_output, $sum_input - $sum_output);
- echo ("</table>");
+ printf ("<tr bgcolor=\"#%s\"><td width=\"70%%\"><font face=\"Helvetica,Arial\"><b>Summe</b></font></td>"
+ ."<td align=\"right\" width=\"10%%\"><font face=\"Helvetica,Arial\"><b>%.2f</b></font></td>"
+ ."<td align=\"right\" width=\"10%%\"><font face=\"Helvetica,Arial\"><b>%.2f</b></font></td>"
+ ."<td align=\"right\" width=\"10%%\"><font face=\"Helvetica,Arial\"><b>%.2f</b></font></td></tr>",
+ $color, $sum_input, $sum_output, $sum_input - $sum_output);
+ echo ("</table></div>");
}
}
?>
-</table><p>
-
-<a href="edit.php3">Neuer Eintrag</a><p>
-
</page>
# Local variables:
# mode: text
# mode: auto-fill
-# mode: iso-accents
# end: