-
Notifications
You must be signed in to change notification settings - Fork 3
/
categoryedit.php
257 lines (192 loc) · 8.17 KB
/
categoryedit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
/**************************************************************************\
* PHPAdvocat *
* http://phpadvocat.sourceforge.net *
* By Burkhard Obergoeker <[email protected]> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
require("./include/phpadvocat.inc.php");
require("./include/dialog.php");
define("DETAIL_EXPEND", 1);
/* Get User Account from Session Vars */
$user = $_SESSION["dbuser"];
$passwd = $_SESSION["dbpasswd"];
$changecheck="";
/* initialize database */
$db = new www_db;
$db->connect($user, $passwd);
/* import invoice number if transmitted by GET or POST */
if($_POST["number"] !=0) {
$number = $_POST["number"];
} elseif($_GET["number"] !=0) {
$number = $_GET["number"];
}
/********** handle updates and inserts begin ********************************/
/****************** begin change data of expends *************************/
/* add an amount */
if($_POST["amountaddbutton"]) {
/* import POST-VARS */
$createdate = toisodate($_POST["createdate"],$LOCALE);
$description = $_POST["description"];
$exp_category = $_POST["number"];
$incomingamount = toisonum($_POST["incomingamount"],$LOCALE);
$outgoingamount = toisonum($_POST["outgoingamount"],$LOCALE);
/* set detail for display */
$detail=DETAIL_EXPEND;
// echo "<hr> in: ".$incomingamount ." | out: ".$outgoingamount ."<hr>";
/* set vatrate from input else set to 0 */
$querystring = sprintf("insert into phpa_amounts ".
"(createdate, description, exp_category, ".
"incomingamount, outgoingamount) " .
"values(%s, '%s', %s, %s, %s)",
nullcorr($createdate), $description, $number,
$incomingamount, $outgoingamount);
// echo "<hr>".$querystring ."<hr>";
if (!$db->query($querystring)) {
$changecheck="Eintrag erstellt";
}
}
/* delete an expenditure */
elseif($_GET["amountdel"]) { /* use elseif to prevent double call */
/* import POST-VARS */
$number = $_GET["number"];
$exnumber = $_GET["exnumber"];
/* set detail for display */
$detail = DETAIL_EXPEND;
$querystring = sprintf("delete from phpa_amounts " .
"where number =%s", $exnumber);
// echo "<hr>".$querystring."<hr>";
if (!$db->query($querystring)) {
$changecheck="Eintrag gelöscht";
}
}
/****************** end change data of expends *************************/
/********** handle updates and inserts end *********************************/
?>
<HTML>
<script language="JavaScript">
<!--
function heute()
{
jetzt = new Date();
var tag = jetzt.getDate();
var monat = jetzt.getMonth();
var jahr = jetzt.getYear();
if(jahr < 1000) jahr+=1900;
monat+=1;
var datum = tag + "." + monat + "." + jahr;
return datum;
}
//-->
</script>
<?php
/* get category name */
$querystring =
sprintf("select * from phpa_exp_categories where number=%s", $number);
if(!$db->query($querystring) && $db->next_record()) {
$categoryname=$db->record["description"];
}
echo "<HEAD><TITLE>PHPAdvocat - ".$categoryname."</TITLE>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/phpadvocat.css\">";
echo "</HEAD>";
echo "<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n";
echo "<TABLE width=100%><TR><TD width=200 valign=top>";
/* here comes the menue */
$phpa_menue->account=$user;
$phpa_menue->selected = 5;
array_insert($phpa_menue->contents,
array(' <b>Kategorie '.$number.'</b>'), 5);
$phpa_menue->draw_menue();
/* display Title */
echo "</TD><TD><CENTER><H1>Kategorie \"".$categoryname."\"</H1></CENTER>";
/* database connection for drop down lists */
$dblist = new www_db;
$dblist->connect($user, $passwd);
echo "<table width=100%><tr>\n";
echo "<td>" . date("d.m.Y", time()) . "</td>";
/* display status at right side */
echo "<TD ALIGN=RIGHT><b>". $changecheck. "</b></A></TD>";
print "</tr>";
/* **************************** Detail ********************************** */
echo "<hr><a NAME=detail></a>";
if (!$detail) $detail=DETAIL_EXPEND;
/* display details */
switch ($detail) {
case (DETAIL_EXPEND):
$querystring = sprintf("select * from phpa_amounts ".
"where exp_category=%s order by createdate, number", $number);
// echo "<hr>" . $querystring . "<hr>";
$db->query($querystring);
printf("<table class=listtable>\n");
/* Display header */
printf("<tr><th>Datum/Beleg</th>".
"<th>Beschreibung</th>".
"<th>Eingang</th>".
"<th>Ausgang</th>".
"<th>Gesamt</th><th></th></tr>");
/* set sum variables */
$incomingamountsum = 0.0;
$incomingvatsum = 0.0;
$outgingamountsum = 0.0;
$outgingvatsum = 0.0;
$allamountsum = 0.0;
/* Display all attached expenditures */
while($db->next_record()) {
printf("<tr BGCOLOR=white>");
printf("<td>%s/%s</td>", tolocaldate($db->record["createdate"],$LOCALE), $db->record["number"]);
printf("<td>%s</td>", $db->record["description"]);
printf("<td align=right>%s</td>", tolocalnum($db->record["incomingamount"],$LOCALE));
printf("<td align=right>%s</td>", tolocalnum($db->record["outgoingamount"],$LOCALE));
/* compute sum of all */
$amountsum= $db->record["incomingamount"]-$db->record["outgoingamount"];
printf("<td align=right><b>%s</b></td>",
tolocalnum(sprintf('%.2f',$amountsum), $LOCALE));
$incomingamountsum += $db->record["incomingamount"];
$outgingamountsum += $db->record["outgoingamount"];
$allamountsum += $amountsum;
/* delete row */
printf("<td><a href=\"$PHP_SELF?number=%s&exnumber=%s" .
"&amountdel=1&detail=%s#detail\" " .
"onClick=\"return confirm('Eintrag loeschen?')\">" .
"<img alt=Del src=\"images/trash-x.png\" border=0>".
"</a></td></tr>\n",
$number, $db->record["number"], $detail);
}
/* display sum of all */
printf("<tr>");
printf("<td colspan=2><b>Gesamtsummen</b></td>");
printf("<td align=right><b>%s</b></td>",
tolocalnum(sprintf('%.2f',$incomingamountsum),$LOCALE));
printf("<td align=right><b>%s</b></td>",
tolocalnum(sprintf('%.2f',$outgingamountsum),$LOCALE));
printf("<td align=right><b>%s</b></td>",
tolocalnum(sprintf('%.2f',$allamountsum),$LOCALE));
printf("</tr>");
/* last row is an input for new invoices */
printf("<tr><FORM METHOD=POST ACTION=\"$PHP_SELF\">");
printf("<td><input name=number type=hidden value=%s>".
"<input name=detail type=hidden value=%s>",
$number, $detail);
printf("<input name=createdate type=text size=10 value='%s'></td>\n",
date("d.m.Y", time()));
printf("<td><input name=description type=text size=40></td>\n");
printf("<td><input name=incomingamount type=float size=10 value=0,00></td>\n");
printf("<td><input name=outgoingamount type=float size=10 value=0,00></td>\n");
printf("<td><input name=amountaddbutton type=submit value=Neu></td>");
printf("</FORM></tr>");
printf("</table><hr>\n");
break;
}
$dblist->close();
$db->close();
echo "<hr>";
/* end framework */
echo "</TD></TR></TABLE>";
/* End HTML PAGE */
echo "</BODY></HTML>";
?>