c4d72c38030dce8c9e9d8e14bb56458ad8caeece
[infodrom.org/service.infodrom.org] / src / InfoCon / account / edit.wml
1 #include <infocon.style>
2 #include "account.inc"
3
4 <page func=InfoCon title="Kontoführung">
5 <calendar_init 5>
6
7 <?
8   $table = "account";
9   $value = "value_eur";
10   $add = '';
11   $hidden = '';
12   if ((strlen ($_GET[cur]) > 0) && ($_GET[cur] == "dm")) {
13     $table = "account_dm";
14     $value = "value_dm";
15     $hidden = '<input type=hidden name=currency value="dm">';
16     $add = "&currency=dm";
17   }
18
19   if (!isset($_GET[blzkto]) && isset($_GET[id])) {
20     pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
21
22     $query = "SELECT $table.blz_kto,datum,category,descr,from_to,statement,$value,name "
23             ."FROM $table JOIN account_names using(blz_kto) "
24             ."WHERE $table.id = $_GET[id]";
25     $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
26
27     if (pg_NumRows ($sth) > 0) {
28       $row = pg_fetch_array ($sth, 0);
29       $date = explode (" ", $row['datum']);
30       $date = explode ("-", $date[0]);
31       $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
32       $blzkto = $row['blz_kto'];
33       $add .= '&blzkto='. $blzkto;
34     }
35   } else {
36     $blzkto = $_GET[blzkto];
37   }
38 ?>
39
40 <style type="text/css">
41 label {
42   display: block;
43   font-weight: bold;
44   font-size: 12px;
45   width: 160px;
46   text-align: left;
47   padding-left: 5px;
48   padding-top: 0px;
49   padding-bottom: 0px;
50   background-color: #1aa2fe;
51   color: white;
52 }
53 input {
54   width: 400px;
55   margin-bottom: 10px;
56   border: solid #1aa2fe;
57   border-width: 1px;
58 }
59 select {
60   display: block;
61   width: 400px;
62   margin-bottom: 10px;
63   border: solid #1aa2fe;
64   border-width: 1px;
65 }
66 textarea {
67   width: 400px;
68   border: 1px solid #1aa2fe;
69   border-width: 1px;
70   margin-top: -1px;
71 }
72 </style>
73
74 <h3 class=bar><?=$row['name']?></h3>
75
76 <form method=post action="update.php">
77 <input class=none type="hidden" name="id" value="<? echo $_GET[id]; ?>">
78 <?
79   echo ("<input class=\"none\" type=\"hidden\" name=\"blzkto\" value=\"$blzkto\">");
80   echo $hidden;
81 ?>
82
83 <label for=statement>Auszug</label>
84 <input id=statement name=statement size=15 maxlength=15 value="<?=$row['statement']?>" tabindex=1>
85
86 <br class="none">
87 <label for=datum>Datum</label>
88 <input id=datum name=datum size=15 maxlength=10 value="<?=$date?>" tabindex=2>
89 <calendar "datum">
90
91 <br class="none">
92 <label for=category>Kategorie</label>
93 <select id=category name=category tabindex=3>
94 <option>
95 <?
96   $query = "SELECT DISTINCT category FROM $table WHERE blz_kto = '$blzkto' ORDER BY category";
97   $sth = pg_exec ($dbh, $query);
98
99   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
100     $cat = pg_fetch_array ($sth, $nr);
101     printf ("<option value=\"%s\"%s>%s", $cat['category'], $cat['category'] == $row['category']?" selected":"", $cat['category']);
102   }
103 ?></select> <input id=category name=newcategory size=20 maxlength=50 value="" tabindex=4>
104
105 <br class="none">
106 <label for=from_to>Abs./Empf.</label>
107 <select id=from_to name=from_to tabindex=5>
108 <option>
109 <?
110   $query = "SELECT DISTINCT from_to FROM $table ";
111
112   if (!isset($_GET[id])) {
113     $query .= "WHERE blz_kto = '$blzkto' AND datum >= now() - interval '2 years' ";
114   }
115
116   $query .= "ORDER BY from_to";
117
118   $sth = pg_exec ($dbh, $query);
119
120   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
121     $cat = pg_fetch_array ($sth, $nr);
122     printf ("<option value=\"%s\"%s>%s", $cat['from_to'], $cat['from_to'] == $row['from_to']?" selected":"", $cat['from_to']);
123   }
124 ?></select> <input id=from_to name=newfrom_to size=30 maxlength=120 value="" tabindex=6>
125
126 <br class="none">
127 <label for=value>Betrag</label>
128 <input id=value name=value size=40 maxlength=20 value="<? echo $row[$value]; ?>" tabindex=7>
129
130 <br class="none">
131 <label for=descr>Verwendungszweck</label>
132 <textarea id=descr name=descr rows=5 cols=67 tabindex=8><? echo $row['descr']; ?></textarea>
133
134 <p><center>
135 <? if (isset ($_GET[id])) { ?>
136 <input class=button type=submit value="Update" tabindex=9>
137 &nbsp;&nbsp;&nbsp;
138 <input class=button type=submit value="Delete" name=delete tabindex=9>
139 <? } else { ?>
140 <input class=button type=submit value="Insert" tabindex=9>
141 <? } ?>
142 </center><p>
143 </form>
144
145 <h3 class=bar>Hinweise zur Bearbeitung</h3>
146
147 <ul>
148
149 <li> Das Datum wird in der Form dd.mm.yyyy erwartet
150
151 <li> Wenn die Kategorie bzw. Absender/Empfänger noch nicht existieren,
152      werden diese manuell im Textfeld eingegeben
153
154 <li> Betrag als 999.44 angeben.
155
156 <li> Die erste Zeile des Verwendungszwecks wird in der Übersicht angezeigt
157
158 </ul>
159
160 </page>
161
162 # Local variables:
163 # mode: text
164 # mode: auto-fill
165 # mode: iso-accents
166 # end: