/
empdepartment-rem.php
executable file
·164 lines (146 loc) · 4.02 KB
/
empdepartment-rem.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
<?
#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
#
#
#
#
#
#
#
#
#
#
#
# get settings
require("settings.php");
if (isset($_POST['key'])) {
switch ($_POST["key"]) {
case "rem":
$OUTPUT = rem ($_POST);
break;
default:
if (isset($_GET['id'])){
$OUTPUT = confirm ($_GET['id']);
} else {
$OUTPUT = "<li> - Invalid use of module";
}
}
} else {
if (isset($_GET['id'])){
$OUTPUT = confirm ($_GET['id']);
} else {
$OUTPUT = "<li> - Invalid use of module";
}
}
# get template
require("template.php");
# confirm
function confirm($catid)
{
# validate input
require_lib("validate");
$v = new validate ();
$v->isOk ($id, "num", 1, 50, "Invalid Employee Department id.");
# display errors, if any
if ($v->isError ()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>-".$e["msg"]."<br>";
}
return $confirm;
}
# Select Stock
db_connect();
$sql = "SELECT * FROM departments WHERE id = '$id'";
$depRslt = db_exec($sql) or errDie("Unable to access database.", SELF);
if(pg_numrows($depRslt) < 1){
return "<li> Invalid Employee Department ID.";
}else{
$dep = pg_fetch_array($depRslt);
}
# get stock vars
extract ($dep);
// Layout
$confirm =
"<h3>Remove Employee Department</h3>
<h4>Confirm entry</h4>
<table ".TMPL_tblDflts.">
<form action='".SELF."' method='POST'>
<input type=hidden name=key value=rem>
<input type=hidden name=id value='$id'>
<tr><th width=40%>Field</th><th width=60%>Value</th></tr>
<tr class='".bg_class()."'><td>Department</td><td>$department</td></tr>
<tr><td align=right><input type=button value='« Back' onClick='javascript:history.back()'></td><td align=left><input type=submit value='Confirm »'></td></tr>
</form>
</table>
<p>
<table ".TMPL_tblDflts." width='100'>
<tr><th>Quick Links</th></tr>
<tr class='".bg_class()."'><td><a href='empdepartment-view.php'>View Employee Departments</a></td></tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
return $confirm;
}
# write
function rem($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
$$key = $value;
}
# validate input
require_lib("validate");
$v = new validate ();
$v->isOk ($id, "num", 1, 50, "Invalid employee department id.");
# Display errors, if any
if ($v->isError ()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>".$e["msg"];
}
$confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
# Select Stock
db_connect();
$sql = "SELECT * FROM departments WHERE id = '$id'";
$catRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
if(pg_numrows($catRslt) < 1){
return "<li> Invalid Stock Category ID.";
}else{
$dep = pg_fetch_array($catRslt);
}
# get stock vars
extract ($dep);
// remove stock
db_connect();
$sql = "DELETE FROM departments WHERE id = '$id'";
$rslt = db_exec($sql) or errDie("Unable to remove employee department from Cubit.",SELF);
$write ="
<table ".TMPL_tblDflts." width='50%'>
<tr><th>Employee Department removed from Cubit</th></tr>
<tr class=datacell><td>Employee Department $department has been successfully removed from Cubit.</td></tr>
</table>
<p>
<table border=0 cellpadding='".TMPL_tblCellPadding."' cellspacing='".TMPL_tblCellSpacing."'>
<tr><th>Quick Links</th></tr>
<tr bgcolor='#88BBFF'><td><a href='empdepartment-add.php'>Add Employee Department</a></td></tr>
<tr bgcolor='#88BBFF'><td><a href='empdepartment-view.php'>View Stock Categories</a></td></tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
return $write;
}
?>