#include <infocon.style>
#include "account.inc"
+<future>
<page func=InfoCon title="Kontoführung">
<calendar_init 5>
$value = "value_eur";
$add = '';
$hidden = '';
- if ((strlen ($_GET[cur]) > 0) && ($_GET[cur] == "dm")) {
+ if ((strlen ($_GET['cur']) > 0) && ($_GET['cur'] == "dm")) {
$table = "account_dm";
$value = "value_dm";
$hidden = '<input type=hidden name=currency value="dm">';
$add = "¤cy=dm";
}
- if (!isset($_GET[blzkto]) && isset($_GET[id])) {
- pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
+ if (!isset($_GET['blzkto']) && isset($_GET['id'])) {
+ if ($table == 'account')
+ $accounting = new Accounting($_GET['id']);
+ else
+ $accounting = new AccountingDM($_GET['id']);
+ $row = $accounting->fetch();
- $query = "SELECT $table.blz_kto,datum,category,descr,from_to,statement,$value,name "
- ."FROM $table JOIN account_names using(blz_kto) "
- ."WHERE $table.id = $_GET[id]";
- $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
-
- if (pg_NumRows ($sth) > 0) {
- $row = pg_fetch_array ($sth, 0);
- $date = explode (" ", $row['datum']);
+ if ($row) {
+ $date = explode (" ", $row->datum);
$date = explode ("-", $date[0]);
$date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
- $blzkto = $row['blz_kto'];
+ $blzkto = $row->blz_kto;
$add .= '&blzkto='. $blzkto;
}
} else {
- $blzkto = $_GET[blzkto];
+ $accounting = new Accounting(false);
+ $blzkto = $_GET['blzkto'];
}
+ $account = new AccountName($blzkto);
?>
<style type="text/css">
}
</style>
-<h3 class=bar><?=$row['name']?></h3>
+<h3 class=bar><?=$account->fetch()->name;?></h3>
<form method=post action="update.php">
<input class=none type="hidden" name="id" value="<? echo $_GET[id]; ?>">
?>
<label for=statement>Auszug</label>
-<input id=statement name=statement size=15 maxlength=15 value="<?=$row['statement']?>" tabindex=1>
+<input id=statement name=statement size=15 maxlength=15 value="<?=$row->statement?>" tabindex=1>
<br class="none">
<label for=datum>Datum</label>
<select id=category name=category tabindex=3>
<option>
<?
- $query = "SELECT DISTINCT category FROM $table WHERE blz_kto = '$blzkto' ORDER BY category";
- $sth = pg_exec ($dbh, $query);
+ foreach ($accounting->distinctCategories($blzkto) as $cat)
+ printf ("<option value=\"%s\"%s>%s", $cat->category, $cat->category == $row->category?" selected":"", $cat->category);
- for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
- $cat = pg_fetch_array ($sth, $nr);
- printf ("<option value=\"%s\"%s>%s", $cat['category'], $cat['category'] == $row['category']?" selected":"", $cat['category']);
- }
?></select> <input id=category name=newcategory size=20 maxlength=50 value="" tabindex=4>
<br class="none">
<select id=from_to name=from_to tabindex=5>
<option>
<?
- $query = "SELECT DISTINCT from_to FROM $table ";
-
- if (!isset($_GET[id])) {
- $query .= "WHERE blz_kto = '$blzkto' AND datum >= now() - interval '2 years' ";
- }
+ foreach ($accounting->distinctFromTo($blzkto, isset($_GET['id']) ? false : "datum >= now() - interval '2 years'") as $name)
+ printf ("<option value=\"%s\"%s>%s", $name->from_to, $name->from_to == $row->from_to?" selected":"", $name->from_to);
- $query .= "ORDER BY from_to";
-
- $sth = pg_exec ($dbh, $query);
-
- for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
- $cat = pg_fetch_array ($sth, $nr);
- printf ("<option value=\"%s\"%s>%s", $cat['from_to'], $cat['from_to'] == $row['from_to']?" selected":"", $cat['from_to']);
- }
?></select> <input id=from_to name=newfrom_to size=30 maxlength=120 value="" tabindex=6>
<br class="none">
<label for=value>Betrag</label>
-<input id=value name=value size=40 maxlength=20 value="<? echo $row[$value]; ?>" tabindex=7>
+<input id=value name=value size=40 maxlength=20 value="<? echo $row->$value; ?>" tabindex=7>
<br class="none">
<label for=descr>Verwendungszweck</label>
-<textarea id=descr name=descr rows=5 cols=67 tabindex=8><? echo $row['descr']; ?></textarea>
+<textarea id=descr name=descr rows=5 cols=67 tabindex=8><? echo $row->descr; ?></textarea>
<p><center>
<? if (isset ($_GET[id])) { ?>