<page func=InfoCon title="Buchhaltung">
-<table class=font width=100% border=0 cellpadding=2 cellspacing=0>
-<tr bgcolor=#<colh>>
- <th width=15%>Datum</th>
- <th width=20%>Kategorie</th>
- <th width=50%>Verwendungszweck</th>
- <th width=15%>Betrag</th>
-</tr>
<?
$dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
or die("Unable to connect to SQL server");
$table = "sales";
if ($_POST["submit"] == "List") {
+?>
+<table class="smallfont border" width=100% border=0 cellpadding=1 cellspacing=1>
+<tr class="head">
+ <th width=10%>Datum</th>
+ <th width=10%>Kategorie</th>
+ <th width=70%>Verwendungszweck</th>
+ <th width=10%>Betrag</th>
+</tr>
+<?
if (strlen($_POST[year])) {
# $where[] = "date >= '$year-01-01'";
# $year++;
$sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
$sum = 0.0;
- $color = "<cold>";
+ $color = 0;
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);
- printf ("<tr bgcolor=\"#%s\">", $color);
- printf ("<td width=\"15%%\" align=\"right\">%s</td>", $date);
- printf ("<td width=\"20%%\">%s</td>", $row['category']);
- printf ("<td width=\"50%%\"><a href=\"edit.php?oid=%d\">%s</a></td>",
+ printf ("<tr class=\"t%d\">", $color);
+ printf ("<td width=\"10%%\" align=\"right\">%s</td>", $date);
+ printf ("<td width=\"10%%\" align=\"center\">%s</td>", $row['category']);
+ printf ("<td width=\"70%%\"><a href=\"edit.php?oid=%d\">%s</a></td>",
$row['oid'], $row['description']);
- printf ("<td width=\"15%%\" align=\"right\">%5.2f</td>", $row['price']);
+ printf ("<td width=\"10%%\" align=\"right\">%5.2f</td>", $row['price']);
$sum += $row['price'];
echo ("</tr>");
+ $color = !$color;
}
- echo ("<tr>");
+ printf ("<tr class=\"t%d\">", $color);
echo ("<td width=\"85%\" colspan=\"3\"><b>Summe</b></td>");
printf ("<td width=\"15%%\" align=\"right\"><b>%5.2f</b></td>", $sum);
echo ("</tr>");
- echo ("</table><p>");
+ echo ("</table>");
} elseif ($_POST["submit"] == "Overview") {
if (count ($catz) > 0) {
echo ("<h3>Nach Kategorien sortiert</h3>");
- echo ("<div align=\"center\"><table class=\"font\" width=\"80%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" summary=\"\">");
- echo ("<tr bgcolor=\"#<colh>\">"
- ."<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 class=\"smallfont border\" width=\"60%\" cellpadding=\"1\" cellspacing=\"1\" summary=\"\">");
+ echo ("<tr class=\"head\">"
+ ."<th width=\"40%\">Kategorie</th>"
+ ."<th width=\"20%\">Einnahmen</th>"
+ ."<th width=\"20%\">Ausgaben</th>"
+ ."<th width=\"20%\">Summe</th></tr>");
sort ($catz);
- $color = "<cold>";
+ $color = 0;
$sum_output = 0;
for ($i=0; $i < count ($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($_POST[year])) {
$query .= " AND date ~* '$_POST[year]'";
$row = pg_fetch_array ($sth, 0);
$output = -$row[0]; $sum_output += $output;
- printf ("<tr bgcolor=\"#%s\"><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>",
- $color, $catz[$i], $input, $output, $input - $output);
+ $sum = $input - $output;
+ printf ("<tr class=\"t%d\"><td width=\"40%%\">%s</td>"
+ ."<td align=\"right\" width=\"20%%\">%.2f</td>"
+ ."<td align=\"right\" width=\"20%%\">%.2f</td>"
+ ."<td align=\"right\" width=\"20%%\" class=\"%s\">%.2f</td></tr>",
+ $color, $catz[$i], $input, $output, $sum>0?'in':'out', $sum);
+ $color = !$color;
}
- printf ("<tr bgcolor=\"#%s\"><td width=\"70%%\"><b>Summe</b></td>"
- ."<td align=\"right\" width=\"10%%\"><b>%.2f</b></td>"
- ."<td align=\"right\" width=\"10%%\"><b>%.2f</b></td>"
- ."<td align=\"right\" width=\"10%%\"><b>%.2f</b></td></tr>",
- $color, $sum_input, $sum_output, $sum_input - $sum_output);
+ $sum = $sum_input - $sum_output;
+ printf ("<tr class=\"t%d\"><td width=\"40%%\"><b>Summe</b></td>"
+ ."<td align=\"right\" width=\"20%%\"><b>%.2f</b></td>"
+ ."<td align=\"right\" width=\"20%%\"><b>%.2f</b></td>"
+ ."<td align=\"right\" width=\"20%%\" class=\"%s\"><b>%.2f</b></td></tr>",
+ $color, $sum_input, $sum_output, $sum>0?'in':'out', $sum);
echo ("</table></div>");
}
else
$where = '';
- echo ("<h3>Abrechnung</h3>");
+ if (strlen($_POST[year]))
+ printf("<h3>Jahresabrechnung %d</h3>", $_POST[year]);
+ else
+ echo ("<h3>Abrechnung</h3>");
$output = tally ($dbh, "Ausgaben", $where . "price < 0.0");
+ echo '<div style="padding-top: 15px;"></div>';
$input = tally ($dbh, "Einnahmen", $where . "price > 0.0");
+ if (strlen($_POST[year])) {
$foo = $input["tax"] - $output["tax"];
printf ("<p>Summe Steuern: %.2f", $foo);
if ($foo > 0)
echo (" (<strong>Gewinn</strong>)");
elseif ($foo < 0)
echo (" (<strong>Verlust</strong>)");
+ }
}
function tally ($dbh, $head, $where)
{
- echo ("<div align=\"center\"><table class=\"font\" width=\"80%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" summary=\"\">");
- printf ("<tr bgcolor=\"#<colh>\"><th colspan=\"4\" align=\"left\"><strong>%s</strong></td></tr>", $head);
- printf ("<tr bgcolor=\"#<colh>\">"
- ."<th width=\"10%%\">%%</th>"
+ echo ("<div align=\"center\"><table class=\"smallfont border\" width=\"60%\" cellpadding=\"1\" cellspacing=\"1\" summary=\"\">");
+ printf ("<tr class=\"head\"><th colspan=\"4\" align=\"left\"><strong>%s</strong></td></tr>", $head);
+ printf ("<tr class=\"head\">"
+ ."<th width=\"10%%\">USt.</th>"
."<th width=\"30%%\">Steuer</th>"
."<th width=\"30%%\">netto</th>"
."<th width=\"30%%\">brutto</th></tr>");
. " FROM sales WHERE " . $where
. " GROUP BY tax_percent ORDER BY tax_percent";
- $color = "<cold>";
+ $color = 0;
$sum = array();
$sth = pg_exec ($dbh, $query); // or die("Datenbank-Abfrage!");
for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
$row = pg_fetch_array ($sth, $nr);
- $color = $color=="<cold>"?"<coln>":"<cold>";
if ($row["brutto"] < 0) {
$row["tax"] = -$row["tax"];
$row["brutto"] = -$row["brutto"];
}
- printf ("<tr bgcolor=\"#%s\"><td align=\"right\" width=\"10%%\">%d%%</td>"
+ printf ("<tr class=\"t%d\"><td align=\"right\" width=\"10%%\">%d%%</td>"
."<td align=\"right\" width=\"30%%\">%.2f</td>"
."<td align=\"right\" width=\"30%%\">%.2f</td>"
."<td align=\"right\" width=\"30%%\">%.2f</td></tr>",
$sum["tax"] += $row["tax"];
$sum["netto"] += $row["netto"];
$sum["brutto"] += $row["brutto"];
+ $color = !$color;
}
- printf ("<tr bgcolor=\"#%s\"><td width=\"10%%\"><b>Sum</b></td>"
+ printf ("<tr class=\"t%d\"><td width=\"10%%\"><b>Sum</b></td>"
."<td align=\"right\" width=\"30%%\"><b>%.2f</b></td>"
."<td align=\"right\" width=\"30%%\"><b>%.2f</b></td>"
."<td align=\"right\" width=\"30%%\"><b>%.2f</b></td></tr>",
}
?>
+<div style="padding-top: 5px;"></div>
</page>