-
Notifications
You must be signed in to change notification settings - Fork 2
/
employees.php
268 lines (212 loc) · 8.96 KB
/
employees.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
258
259
260
261
262
263
264
265
266
267
268
<?php
include("includes/header.php");
if(!isset($_SESSION['admin_username']))
{
echo "<script>document.location='login.php'</script>";
}
else
{
?>
<!-- Main Content-->
<div class="main-content pt-0">
<div class="container">
<div class="inner-body">
<!-- Page Header -->
<div class="page-header">
<div>
<h2 class="main-content-title tx-24 mg-b-5">Manage Employees</h2>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Manage Employees</li>
</ol>
</div>
</div>
<!-- End Page Header -->
<!-- Row -->
<div class="row sidemenu-height">
<div class="col-lg-12">
<div class="card custom-card">
<div class="card-body">
<a href="#add" data-target="#add" data-toggle="modal" class="btn btn-primary">Add New Employee</a><hr class="mb-4">
<table class="table" id="example1">
<thead>
<tr>
<th class="wd-15p">Full Name</th>
<th class="wd-15p">Role</th>
<th class="wd-15p">Username</th>
<th class="wd-15p">Password</th>
<th class="wd-15p">Status</th>
<th class="wd-15p">Action</th>
</tr>
</thead>
<tbody>
<?php
$select_ad = "SELECT * FROM tbl_employees";
$run_ad = mysqli_query($db, $select_ad);
while($row = mysqli_fetch_array($run_ad))
{
$admin_id = $row['emp_id'];
$fullname = $row['fullname'];
$role = $row['role'];
$username = $row['emp_username'];
$password = $row['emp_password'];
$status = $row['status'];
?>
<tr>
<td><?php echo $fullname; ?></td>
<td><?php echo $role; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo "**********"; ?></td>
<td>
<?php
if($status == "Active")
{
echo "<span class='badge badge-success'>Active</span>";
}
else
{
echo "<span class='badge badge-danger'>Inactive</span>";
}
?>
</td>
<td>
<a class="btn ripple btn-primary" data-target="#update<?php echo $admin_id; ?>" data-toggle="modal" href="#update<?php echo $admin_id; ?>"><i class="fa fa-eye"></i></a>
<a class="btn ripple btn-danger" data-target="#delete<?php echo $admin_id; ?>" data-toggle="modal" href="#delete<?php echo $admin_id; ?>"><i class="fa fa-trash"></i></a>
</td>
</tr>
<!-- Large Modal -->
<div class="modal" id="update<?php echo $admin_id; ?>">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content modal-content-demo">
<div class="modal-header">
<h6 class="modal-title">Update Employee Details</h6>
<button aria-label="Close" class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form method="post" action="update-employee.php" enctype="multipart/form-data">
<div class="row row-sm">
<div class="col-md-12 col-lg-12 col-xl-12">
<div class="">
<div class="form-group col-md-9">
<label class=""> Full Name </label>
<input class="form-control" value="<?php echo $admin_id; ?>" required="" name="admin_id" type="hidden">
<input class="form-control" value="<?php echo $fullname; ?>" required="" name="fullname" type="text">
</div>
<div class="form-group col-md-9">
<label class="">Role</label>
<input class="form-control" value="<?php echo $admin_id; ?>" required="" name="admin_id" type="hidden">
<select name="role" class="form-control select select2">
<option value="<?php echo $role; ?>"><?php echo $role; ?></option>
<option value="Administrator">Administrator</option>
<option value="Employee">Employee</option>
</select>
</div>
<div class="form-group col-md-9">
<label class="">Status</label>
<input class="form-control" value="<?php echo $admin_id; ?>" required="" name="admin_id" type="hidden">
<select name="status" class="form-control select select2">
<option value="<?php echo $status; ?>"><?php echo $status; ?></option>
<option value="Active">Active</option>
<option value="Inactive">Inactive</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn ripple btn-primary" type="submit">Update Details</button>
<button class="btn ripple btn-secondary" data-dismiss="modal" type="button">Close</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!--End Large Modal -->
<!-- Delete Modal -->
<div class="modal" id="delete<?php echo $admin_id;?>">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content modal-content-demo">
<div class="modal-header">
<h6 class="modal-title">Delete Employee Details</h6><button aria-label="Close" class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form action="employee-del.php" method="post">
<input type="hidden" class="form-control" name="admin_id" value="<?php echo $admin_id; ?>" required>
<p>Are you sure you want to <b>Delete</b> this Employee?</p>
</div>
<div class="modal-footer">
<button class="btn ripple btn-primary" name="delete" type="submit">Yes</button>
<button class="btn ripple btn-danger" data-dismiss="modal" type="button">No</button>
</div>
</form>
</div>
</div>
</div>
<!--End Delete Modal -->
<!-- Delete Modal -->
<div class="modal" id="add">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content modal-content-demo">
<div class="modal-header">
<h6 class="modal-title">Employee Details</h6><button aria-label="Close" class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<form method="post" action="add-employee.php" enctype="multipart/form-data">
<div class="row row-sm">
<div class="col-md-12 col-lg-12 col-xl-12">
<div class="">
<div class="form-group col-md-9">
<label class=""> Full Name </label>
<input class="form-control" required="" name="fullname" type="text">
</div>
<div class="form-group col-md-9">
<label class="">Role</label>
<select name="role" class="form-control select select2">
<option label="date"></option>
<option value="Administrator">Administrator</option>
<option value="Employee">Employee</option>
</select>
</div>
<div class="form-group col-md-9">
<label class="">Username</label>
<input class="form-control" required="" name="username" type="text">
</div>
<div class="form-group col-md-9">
<label class=""> Password </label>
<input class="form-control" required="" name="password" type="text">
</div>
<div class="form-group col-md-9">
<label class="">Status</label>
<select name="status" class="form-control select select2">
<option label="date"></option>
<option value="Active">Active</option>
<option value="Inactive">Inactive</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn ripple btn-primary" type="submit">Add Details</button>
<button class="btn ripple btn-secondary" data-dismiss="modal" type="button">Close</button>
</div>
</form>
</div>
</div>
</div>
<!--End Delete Modal -->
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- End Row -->
</div>
</div>
</div>
<!-- End Main Content-->
<?php include("includes/footer.php"); ?>
<?php } ?>