/
empdepartment-view.php
executable file
·94 lines (78 loc) · 1.84 KB
/
empdepartment-view.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
<?
#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");
# show current stock
$OUTPUT = printDep ();
require ("template.php");
# show stock
function printDep ()
{
# Set up table to display in
$printDep = "
<h3>View Employee Departments</h3>
<table ".TMPL_tblDflts.">
<tr>
<th>Department</th>
<th colspan='2'>Options</th>
</tr>";
# connect to database
db_connect ();
# Query server
$i = 0;
$sql = "SELECT * FROM departments ORDER BY department ASC";
$depRslt = db_exec ($sql) or errDie ("Unable to retrieve employee departments from database.");
if (pg_numrows ($depRslt) < 1) {
return "<li>There are no employee departments in Cubit.</li>";
}
while ($dep = pg_fetch_array ($depRslt)) {
$printDep .= "
<tr class='".bg_class()."'>
<td align='center'>$dep[department]</td>
<td><a href='empdepartment-edit.php?id=$dep[id]'>Edit</a></td>";
$sql = "SELECT * FROM employees WHERE department='$dep[id]'";
$depRslt = db_exec ($sql) or ereDie ("Unable to retrieve employee departments from database.");
if (pg_numrows ($depRslt) < 1) {
$printDep .= "<td><a href='empdepartment-rem.php?id=$dep[id]'>Remove</a></td></tr>";
}else{
$printDep .= "</tr>";
}
$i++;
}
$printDep .= "
</table>
<p>
<table ".TMPL_tblDflts." width='15%'>
<tr><td><br></td></tr>
<tr>
<th>Quick Links</th>
</tr>
<tr class='".bg_class()."'>
<td><a href='empdepartment-add.php'>Add Employee Department</a></td>
</tr>
<script>document.write(getQuicklinkSpecial());</script>
</table>";
return $printDep;
}
?>