-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatusoptions.php
392 lines (249 loc) · 10.3 KB
/
statusoptions.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<?php ob_start(); ?>
<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="//cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<body>
<div class="container-scroller">
<?php
include("includes/header.php");
$locations = getAllLocations();
$payrollData = GetAllPayRollData();
$message = $_GET['status'];
if (strtolower($_SESSION["role"])!="super admin" && strtolower($_SESSION["role"])!="admin"){
header("Location: index.php");
}
// var_dump($_SESSION);exit;
if(isset($_POST["add_status_option"])){
$location = escape_it($_POST["location"]);
$status_option = escape_it($_POST["status_option"]);
$remarks_option = escape_it($_POST["remarks_option"]);
if(empty($location) || empty($status_option) || empty($remarks_option)){
$stateMessage = "**Fields can't be empty**";
header("Location: statusoptions.php?status=$stateMessage");
}
elseif(strlen($remarks_option) > 3) {
echo "**Max 3 characters**";
}
elseif(strlen($status_option) > 30) {
$stateMessage = "**Max 30 characters**";
header("Location: statusoptions.php?status=$stateMessage");
}
elseif(add_Status_Option($location, $status_option, $remarks_option)){
echo "Successfully Added!";
}
else{
echo "Option Already Exist";
}
}
if(isset($_POST["add_remarks_option"])){
$location = escape_it($_POST["location"]);
$status_id = escape_it($_POST["status_option_id"]);
$site_location = escape_it($_POST["site_location"]);
if(empty($location) || empty($status_id) || empty($site_location)){
$stateMessage = "**Fields can't be empty**";
header("Location: statusoptions.php?status=$stateMessage");
}
elseif(strlen($site_location) > 30) {
$stateMessage = "**Max 30 characters**";
header("Location: statusoptions.php?status=$stateMessage");
}
elseif(add_Remarks_Option($site_location , $status_id)){
$stateMessage = "Successfully Added!";
header("Location: statusoptions.php?status=$stateMessage");
}
else{
$stateMessage = "Option Already Exist";
header("Location: statusoptions.php?status=$stateMessage");
}
}
// var_dump($payrollData);exit;
?>
<div class="container-fluid page-body-wrapper">
<?php include("includes/sidebar.php");
if (strtolower($_SESSION["role"])!="super admin" && strtolower($_SESSION["role"])!="admin"){
echo "<div class='col-md-8 grid-margin stretch-card' style='padding:75px;'><h3>Unauthorized Access!</h3></div>";exit;
}
?>
<div class="main-panel">
<div class="content-wrapper">
<div class="row">
<div class="col-md-6 grid-margin stretch-card" <?php if (strtolower($_SESSION["role"])!="super admin"){echo "hidden";} ?>>
<div class="card">
<div class="card-body">
<h3>View Status Options</h3>
<p class="card-description">
View All Status Options
</p>
<div class="card" style="background: #fcfcfc; padding: 15px;" id = "singleform">
<form action="" method="get">
<div class="form-group">
<label for="users">Select location</label>
<select name="location" id="locationselect" class="form-control">
<?php
$result = getlocations();
while($row = mysqli_fetch_assoc($result)) {
$location_name = $row["location_name"];
echo "<option value='{$location_name}'>{$location_name}</option>";
}
?>
</select>
</div>
</form>
<div class="col-md-5" id="statusoptionswrapper">
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3 grid-margin stretch-card" <?php if (strtolower($_SESSION["role"])!="super admin"){echo "hidden";} ?>>
<div class="card">
<div class="card-body">
<h3>Add Status Options</h3>
<p class="card-description">
Add New Status Options
</p>
<div class="card" style="background: #fcfcfc; padding: 15px;" id = "singleform">
<form action="" method="post">
<div class="form-group">
<label for="users">Select location</label>
<select name="location" class="form-control">
<?php
$result = getlocations();
while($row = mysqli_fetch_assoc($result)) {
$location_name = $row["location_name"];
echo "<option value='{$location_name}'>{$location_name}</option>";
}
?>
</select>
</div>
<div class="form-group col-md-11">
<label>Option Name</label>
<input class="form-control" type="text" placeholder="upto 30 characters" name="status_option">
</div>
<div class="form-group col-md-11">
<label>Code</label>
<input class="form-control" type="text" maxlength="3" placeholder="upto 3 characters" name="remarks_option">
</div>
<div class="form-group col-md-11">
<input type="submit" value="Add" style="background:#006a4a;" name="add_status_option" class="btn btn-success">
</div>
</form>
</div>
</div>
</div>
</div>
<div class="col-md-3 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h3>Add Site Location</h3>
<p class="card-description">
Add New Site Location
</p>
<div class="card" style="background: #fcfcfc; padding: 15px;" id = "singleform">
<form action="" method="post">
<div class="form-group">
<label for="users">Select location</label>
<select name="location" id="addremarksselect" class="form-control">
<option value=""></option>
<?php
if (strtolower($_SESSION["role"])=="super admin"){
$result = getlocations();
while($row = mysqli_fetch_assoc($result)) {
$location_name = $row["location_name"];
echo "<option value='{$location_name}'>{$location_name}</option>";
}
}else if (strtolower($_SESSION["role"])=="admin"){
echo "<option value='".$_SESSION["location"]."'>".$_SESSION["location"]."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label for="users">Select Status Option</label>
<select name="status_option_id" id="addremarkstatusselect" class="form-control">
</select>
</div>
<div class="form-group col-md-11">
<label>Site Location</label>
<input class="form-control" type="text" placeholder="upto 30 characters" name="site_location">
</div>
<div class="form-group col-md-11">
<input type="submit" value="Add" name="add_remarks_option" class="btn btn-success" style="background:#006a4a;">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
<?php include("includes/footer.php");?>
</div>
<!-- main-panel ends -->
</div>
<!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
</body>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Confirm Delete</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<h5 class="text-center">Are You Sure To remove this location, All employees on this location would be unchained?</h5>
</div>
<div class="modal-footer">
<a href="" class="btn btn-danger modal_delete_link">Remove</a>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<style>
#example{
font-size: 12px;
}
.dataTables_wrapper {
font-size: 12px;
}
</style>
<script>
$(document).ready( function () {
$("#allform").hide();
// $('#example').DataTable();
var status = "<?php echo $message; ?>";
if (status!="" && status != null){
alert(status);
}
$(function(){
var location = $('#locationselect').find(":selected").val();
var url = "status_options_for_location.php?location="+location;
$.get(url, function(data, status){
$("#statusoptionswrapper").html(data);
});
});
//loading status options
$('#locationselect').on('change', function() {
var location = $('#locationselect').find(":selected").val();
var url = "status_options_for_location.php?location="+location;
$.get(url, function(data, status){
$("#statusoptionswrapper").html(data);
});
});
$('#addremarksselect').on('change', function() {
var location = $('#addremarksselect').find(":selected").val();
var url = "get_status_options.php?location="+location;
$.get(url, function(data, status){
$("#addremarkstatusselect").html(data);
});
});
} );
</script>
</html>