/
default-comments.php
executable file
·112 lines (100 loc) · 2.44 KB
/
default-comments.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
<?
#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 (isset($_POST["key"])) {
switch ($_POST["key"]) {
default:
case "enter":
$OUTPUT = enter();
break;
case "confirm":
$OUTPUT = confirm($_POST);
break;
case "write":
$OUTPUT = write($_POST);
break;
}
} else {
$OUTPUT = enter();
}
require ("template.php");
function enter($error="")
{
$sql = "SELECT value FROM settings WHERE constant='DEFAULT_COMMENTS'";
$rslt = db_exec($sql) or errDie("Unable to retrieve default comments from Cubit.");
$comments = base64_decode(pg_fetch_result($rslt, 0));
$OUTPUT = "<h3>Default Comments for Invoices</h3>
<form method=post action='".SELF."'>
<input type=hidden name=key value='confirm'>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<tr>
<th>Option</th>
<th>Value</th>
<tr>
<tr class='bg-odd'>
<td>".REQ."Comment text</td>
<td><textarea rows=5 cols=20 name=comments>$comments</textarea></td>
</tr>
<tr>
<td colspan=2 align=right><input type=submit value='Confirm »'></td>
</tr>
</table>
</form>";
return $OUTPUT;
}
function confirm($_POST)
{
extract ($_POST);
$OUTPUT = "<h3>Default Comments for Invoices</h3>
<form method=post action='".SELF."'>
<input type=hidden name=key value='write'>
<input type=hidden name=comments value='$comments'>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<tr>
<th>Option</th>
<th>Value</th>
</tr>
<tr class='bg-odd'>
<td>Comment Text</td>
<td>$comments</td>
</tr>
<tr>
<td colspan=2 align=right>
<input type=submit value='Write »'>
</td>
</tr>
</table>
</form>";
return $OUTPUT;
}
function write($_POST)
{
extract ($_POST);
$sql = "UPDATE settings SET value='".base64_encode($comments)."' WHERE constant='DEFAULT_COMMENTS'";
$rslt = db_exec($sql) or errDie("Unable to update default comments");
$OUTPUT = "<li>Successfully updated default comments.</li>";
return $OUTPUT;
}
?>