/
set-state.php
executable file
·231 lines (197 loc) · 5.47 KB
/
set-state.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
<?
#This program is copyright by Andre Coetzee email: ac@main.me
#and is licensed under the GPL v3
#
#
#
#
#Please add yourself to: http://www.accounting-123.com
#Developers, Software Vendors, Support, Accountants, Users
#
#
#The full software license can be found here:
#http://www.accounting-123.com/a.php?a=153/GPLv3
#
#
#
#
#
#
#
#
#
#
#
require ("settings.php");
if ($_POST) {
switch ($_POST["key"]) {
case "confirm":
$OUTPUT = confirm ($_POST);
break;
case "write":
$OUTPUT = write ($_POST);
break;
default:
$OUTPUT = enter();
}
} else {
$OUTPUT = enter();
}
require ("template.php");
# Enter settings
function enter()
{
$chc = "";
$chs = "";
db_connect();
$sql = "SELECT * FROM ms WHERE set = 'statement type' AND val='open'";
$rslt = db_exec ($sql) or errDie ("ERROR: Unable to view settings", SELF); // Die with custom error if failed
if(pg_numrows($rslt) > 0){
$chc = "";
$chs = "checked='yes'";
} else {
$chc = "checked='yes'";
$chs = "";
}
# Connect to db
$enter = "<h3>Cubit Settings</h3>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<form action='".SELF."' method=post>
<input type=hidden name=key value=confirm>
<tr><th colspan=2>Statement Type</th></tr>
<tr class='bg-odd'><td><input type=radio size=20 name=typ value='sys' $chs>Use Open Item Statement</td>
<td><input type=radio size=20 name=typ value='mon' $chc>Use Running Balance Statement</td></tr>
<tr><td><br></td></tr>
<tr><td align=right colspan=2><input type=submit value='Continue »'></td></tr>
</form>
</table>
<p>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<tr><th>Quick Links</th></tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
return $enter;
}
# confirm entered info
function confirm($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
$$key = $value;
}
# validate input
require_lib("validate");
$v = new validate ();
$v->isOk ($typ, "string", 1, 50, "Invalid Debtors age type Selection.");
# display errors, if any
if ($v->isError ()) {
$theseErrors = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$theseErrors .= "-".$e["msg"]."<br>";
}
$Errors = "<tr><td class=err colspan=2>$theseErrors</td></tr>
<tr><td colspan=2><br></td></tr>";
return entererr($accc, $Errors);
}
$confirm ="<h3>Cubit Settings</h3>
<h4>Confirm</h4>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<form action='".SELF."' method=post>
<input type=hidden name=key value=write>
<input type=hidden name=typ value='$typ'>
<tr><th colspan>Debtors Age Analysis Period</th></tr>
<tr class='bg-odd'>";
if($typ == "sys"){
$confirm .= "<td>Use open statement</td>";
}else{
$confirm .= "<td>Use running statement</td>";
}
$confirm .= "</tr>
<tr><td><br></td></tr>
<tr><td align=right colspan=2><input type=submit value='Confirm »'></td></tr>
</form>
</table>
<p>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<tr><th>Quick Links</th></tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
return $confirm;
}
# write user to db
function write ($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
$$key = $value;
}
# validate input
require_lib("validate");
$v = new validate ();
$v->isOk ($typ, "string", 1, 50, "Invalid Debtors age type Selection.");
# display errors, if any
if ($v->isError ()) {
$theseErrors = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$theseErrors .= "-".$e["msg"]."<br>";
}
$Errors = "<tr><td class=err colspan=2>$theseErrors</td></tr>
<tr><td colspan=2><br></td></tr>";
return entererr($accc, $Errors);
}
db_conn('cubit');
$Sl="DELETE FROM ms WHERE set='statement type'";
$Ri=db_exec($Sl);
if($typ == "sys"){
$descript = "Use open statement";
$Sl="INSERT INTO ms(set,val) VALUES('statement type','open')";
$Ri=db_exec($Sl);
}else{
$descript = "Use running statement";
}
# Connect to db
db_connect ();
# status report
$write ="
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."' width='50%'>
<tr><th>Cubit Settings</th></tr>
<tr class=datacell><td>Setting has been successfully saved.</td></tr>
</table>
<p>
<tr>
<table border=0 cellpadding='2' cellspacing='1'>
<tr><th>Quick Links</th></tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
return $write;
}
function printSet ()
{
// Connect to database
Db_Connect ();
// Query server
$sql = "SELECT * FROM set WHERE label = 'DEBT_AGE'";
$rslt = db_exec ($sql) or errDie ("ERROR: Unable to view settings", SELF); // Die with custom error if failed
if (pg_numrows ($rslt) < 1) {
$OUTPUT = "<li class=err> No Setting currently in database.";
} else {
// Set up table to display in
$OUTPUT = "
<h3>Settings</h3>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."' width=300>
<tr><th>Setting Type</th><th>Current Setting</th></tr>";
$set =pg_fetch_array ($rslt);
$OUTPUT .= "<tr class='".bg_class()."'><td>$set[type]</td><td>$set[descript]</td></tr>";
$OUTPUT .= "</table>";
}
$OUTPUT .= "
<p>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<tr><th>Quick Links</th></tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
return $OUTPUT;
}
?>