-
Notifications
You must be signed in to change notification settings - Fork 19
/
staff_mang.php
306 lines (268 loc) · 18.1 KB
/
staff_mang.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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
<div class="row">
<ol class="breadcrumb">
<li><a href="#">
<em class="fa fa-home"></em>
</a></li>
<li class="active">Staff Management</li>
</ol>
</div><!--/.row-->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Staff Management</h1>
</div>
</div><!--/.row-->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">Employee Details:
<a href="index.php?add_emp" class="btn btn-info pull-right">Add Employee</a>
</div>
<div class="panel-body">
<?php
if (isset($_GET['error'])) {
echo "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Error on Shift Change !
</div>";
}
if (isset($_GET['success'])) {
echo "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> Shift Successfully Changed!
</div>";
}
?>
<table class="table table-striped table-bordered table-responsive" cellspacing="0" width="100%"
id="rooms">
<thead>
<tr>
<th>Sr. No</th>
<th>Employee Name</th>
<th>Staff</th>
<th>Shift</th>
<th>Joining Date</th>
<th>Salary</th>
<th>Change Shift</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
//$staff_query = "SELECT * FROM staff JOIN staff_type JOIN shift ON staff.staff_type_id =staff_type.staff_type_id ON shift.";
$staff_query = "SELECT * FROM staff NATURAL JOIN staff_type NATURAL JOIN shift";
$staff_result = mysqli_query($connection, $staff_query);
if (mysqli_num_rows($staff_result) > 0) {
while ($staff = mysqli_fetch_assoc($staff_result)) { ?>
<tr>
<td><?php echo $staff['emp_id']; ?></td>
<td><?php echo $staff['emp_name']; ?></td>
<td><?php echo $staff['staff_type']; ?></td>
<td><?php echo $staff['shift'] . ' - ' . $staff['shift_timing']; ?></td>
<td><?php echo date('M j, Y', strtotime($staff['joining_date'])); ?></td>
<td><?php echo $staff['salary']; ?></td>
<td>
<button class="btn btn-primary" data-toggle="modal" data-target="#changeShift"
data-id="<?php echo $staff['emp_id']; ?>" id="change_shift">Change Shift</button>
</td>
<td>
<button data-toggle="modal"
data-target="#empDetail<?php echo $staff['emp_id']; ?>"
data-id="<?php echo $staff['emp_id']; ?>" id="editEmp"
class="btn btn-info"><i class="fa fa-pencil"></i></button>
<a href='functionmis.php?empid=<?php echo $staff['emp_id']; ?>'
class="btn btn-danger" onclick="return confirm('Are you Sure?')"><i
class="fa fa-trash"></i></a>
<a href='index.php?emp_history&empid=<?php echo $staff['emp_id']; ?>'
class="btn btn-success" title="Employee Histery"><i class="fa fa-eye"></i></a>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p class="back-link">MIS Developed by <a href="https://www.pcsaini.in">pcsaini</a></p>
</div>
</div>
</div> <!--/.main-->
<?php
//$staff_query = "SELECT * FROM staff JOIN staff_type JOIN shift ON staff.staff_type_id =staff_type.staff_type_id ON shift.";
$staff_query = "SELECT * FROM staff NATURAL JOIN staff_type NATURAL JOIN shift";
$staff_result = mysqli_query($connection, $staff_query);
if (mysqli_num_rows($staff_result) > 0) {
while ($staffGlobal = mysqli_fetch_assoc($staff_result)) {
$fullname = explode(" ", $staffGlobal['emp_name']);
?>
<!-- Employee Detail-->
<div id="empDetail<?php echo $staffGlobal['emp_id']; ?>" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Employee Detail</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">Employee Detail:</div>
<div class="panel-body">
<form data-toggle="validator" role="form" action="functionmis.php"
method="post">
<div class="row">
<div class="form-group col-lg-6">
<label>Staff</label>
<select class="form-control" id="staff_type" name="staff_type_id"
required>
<option selected disabled>Select Staff Type</option>
<?php
$query = "SELECT * FROM staff_type";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) {
while ($staff = mysqli_fetch_assoc($result)) {
// echo '<option value=" ' . $staff['staff_type_id'] . ' " selected >' . $staff['staff_type'] . '</option>';
echo '<option value="' . $staff['staff_type_id'] . '" ' . (($staff['staff_type_id'] == $staffGlobal['staff_type_id']) ? 'selected="selected"' : "") . '>' . $staff['staff_type'] . '</option>';
}
}
?>
</select>
</div>
<div class="form-group col-lg-6">
<select style="visibility: hidden;" class="form-control" id="shift" name="shift_id" required>
<option selected disabled>Select Staff Type</option>
<?php
$query = "SELECT * FROM shift";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) {
while ($shift = mysqli_fetch_assoc($result)) {
// echo '<option value="' . $shift['shift_id'] . '">' . $shift['shift'] . ' - ' . $shift['shift_timing'] . '</option>';
echo '<option value="' . $shift['shift_id'] . '" ' . (($shift['shift_id'] == $staffGlobal['shift_id']) ? 'selected="selected"' : "") . '>' . $shift['shift_timing'] . '</option>';
}
}
?>
</select>
</div>
<input type="hidden" value="<?php echo $staffGlobal['emp_id']; ?>"
id="emp_id" name="emp_id">
<div class="form-group col-lg-6">
<label>First Name</label>
<input type="text" value="<?php echo $fullname[0]; ?>"
class="form-control" placeholder="First Name" id="first_name"
name="first_name" required>
</div>
<div class="form-group col-lg-6">
<label>Last Name</label>
<input type="text" value="<?php echo $fullname[1]; ?>"
class="form-control" placeholder="Last Name" id="last_name"
name="last_name" required>
</div>
<div class="form-group col-lg-6">
<label>ID Card Type</label>
<select class="form-control" id="id_card_id" name="id_card_type"
required>
<option selected disabled>Select ID Card Type</option>
<?php
$query = "SELECT * FROM id_card_type";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) {
while ($id_card_type = mysqli_fetch_assoc($result)) {
// echo '<option value="' . $id_card_type['id_card_type_id'] . '">' . $id_card_type['id_card_type'] . '</option>';
echo '<option value="' . $id_card_type['id_card_type_id'] . '" ' . (($id_card_type['id_card_type_id'] == $staffGlobal['id_card_type']) ? 'selected="selected"' : "") . '>' . $id_card_type['id_card_type'] . '</option>';
}
}
?>
</select>
</div>
<div class="form-group col-lg-6">
<label>ID Card No</label>
<input type="text" class="form-control" placeholder="ID Card No"
id="id_card_no"
value="<?php echo $staffGlobal['id_card_no']; ?>"
name="id_card_no" required>
</div>
<div class="form-group col-lg-6">
<label>Contact Number</label>
<input type="number" class="form-control"
placeholder="Contact Number" id="contact_no"
value="<?php echo $staffGlobal['contact_no']; ?>"
name="contact_no" required>
</div>
<div class="form-group col-lg-6">
<label>Address</label>
<input type="text" class="form-control" placeholder="address"
id="address" value="<?php echo $staffGlobal['address']; ?>"
name="address">
</div>
<div class="form-group col-lg-6">
<label>Salary</label>
<input type="number" class="form-control" placeholder="Salary"
id="salary" value="<?php echo $staffGlobal['salary']; ?>"
name="salary" required>
</div>
</div>
<button type="submit" class="btn btn-lg btn-primary" name="submit">Submit
</button>
<button type="reset" class="btn btn-lg btn-danger">Reset</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Employee Detail-->
<div id="changeShift" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Change Shift</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-body">
<form data-toggle="validator" role="form" action="ajax.php" method="post">
<div class="row">
<div class="form-group col-lg-12">
<label>Shift</label>
<select class="form-control" id="shift" name="shift_id" required>
<option selected disabled>Select Staff Type</option>
<?php
$query = "SELECT * FROM shift";
$result = mysqli_query($connection, $query);
if (mysqli_num_rows($result) > 0) {
while ($shift = mysqli_fetch_assoc($result)) {
// echo '<option value="' . $shift['shift_id'] . '">' . $shift['shift'] . ' - ' . $shift['shift_timing'] . '</option>';
echo '<option value="' . $shift['shift_id'] . '" ' . (($shift['shift_id'] == $staffGlobal['shift_id']) ? 'selected="selected"' : "") . '>' . $shift['shift_timing'] . '</option>';
}
}
?>
</select>
</div>
</div>
<input type="hidden" name="emp_id" value="" id="getEmpId">
<button type="submit" class="btn btn-lg btn-primary" name="change_shift">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
}