-
Notifications
You must be signed in to change notification settings - Fork 0
/
clearance.php
567 lines (509 loc) · 19.7 KB
/
clearance.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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<?php
session_start();
error_reporting(0);
include('connect.php');
if(empty($_SESSION['matric_no']))
{
header("Location: login.php");
}
else{
}
date_default_timezone_set('Africa/Lagos');
$current_date = date('Y-m-d H:i:s');
//get neccesary session details
$ID = $_SESSION["ID"];
$matric_no = $_SESSION["matric_no"];
$dept = $_SESSION['dept'];
$faculty = $_SESSION['faculty'];
$sql = "select * from students where matric_no='$matric_no'";
$result = $conn->query($sql);
$rowaccess = mysqli_fetch_array($result);
// check if student has sent request
$sqlcheck = "SELECT * FROM clearance_apply WHERE student_id = $ID";
$resultcheck = $conn->query($sqlcheck);
$row = mysqli_fetch_array($resultcheck);
$academy_head = $row["is_accademic_head"];
$faculty_cle = $row["is_faculty"];
$dip_library = $row["is_dip_library"];
$kill_library = $row["is_kill"];
$is_sport = $row["is_sport"];
$is_hostel = $row["is_hostel"];
if ($academy_head == 1) {
$condition = "btn btn-danger disabled";
$condition_txt = "Request Sent";
} else if ($academy_head == 2) {
$condition = "btn btn-success disabled";
$condition_txt = "Request Approved";
} else {
$condition = "btn btn-primary";
$condition_txt = "Send Request";
}
if ($faculty_cle == 1) {
$condition1 = "btn btn-danger disabled";
$condition_txt1 = "Request Sent";
} else if ($faculty_cle == 2) {
$condition1 = "btn btn-success disabled";
$condition_txt1 = "Request Approved";
} else {
$condition1 = "btn btn-primary";
$condition_txt1 = "Send Request";
}
if ($dip_library == 1) {
$condition2 = "btn btn-danger disabled";
$condition_txt2 = "Request Sent";
} else if ($dip_library == 2) {
$condition2 = "btn btn-success disabled";
$condition_txt2 = "Request Approved";
} else {
$condition2 = "btn btn-primary";
$condition_txt2 = "Send Request";
}
if ($kill_library == 1) {
$condition3 = "btn btn-danger disabled";
$condition_txt3 = "Request Sent";
} else if ($kill_library == 2) {
$condition3 = "btn btn-success disabled";
$condition_txt3 = "Request Approved";
} else {
$condition3 = "btn btn-primary";
$condition_txt3 = "Send Request";
}
if ($is_sport == 1) {
$condition4 = "btn btn-danger disabled";
$condition_txt4 = "Request Sent";
} else if ($is_sport == 2) {
$condition4 = "btn btn-success disabled";
$condition_txt4 = "Request Approved";
} else {
$condition4 = "btn btn-primary";
$condition_txt4 = "Send Request";
}
if ($is_hostel == 1) {
$condition5 = "btn btn-danger disabled";
$condition_txt5 = "Request Sent";
} else if ($is_hostel == 2) {
$condition5 = "btn btn-success disabled";
$condition_txt5 = "Request Approved";
} else {
$condition5 = "btn btn-primary";
$condition_txt5 = "Send Request";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apply Clearance | Online Student clearance system</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.css" rel="stylesheet">
<!-- Morris -->
<link href="css/plugins/morris/morris-0.4.3.min.css" rel="stylesheet">
<!-- Gritter -->
<link href="js/plugins/gritter/jquery.gritter.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon.png">
<style type="text/css">
<!--
.style1 {color: #000000}
-->
</style>
</head>
<body>
<div id="wrapper">
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav metismenu" id="side-menu">
<li class="nav-header">
<div class="dropdown profile-element"> <span>
<img src="<?php echo $rowaccess['photo']; ?>" alt="image" width="100" height="100" class="img-circle" />
</span>
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<span class="clear"><span class="text-muted text-xs block">Matric No:<?php echo $rowaccess['matric_no']; ?> <b class="caret"></b></span> </span> </a>
<ul class="dropdown-menu animated fadeInRight m-t-xs">
<li><a href="logout.php">Logout</a></li>
</ul>
</div>
<?php
include('sidebar.php');
?>
</ul>
</div>
</nav>
<div id="page-wrapper" class="gray-bg">
<div class="row border-bottom">
<nav class="navbar navbar-static-top white-bg" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
</div>
<ul class="nav navbar-top-links navbar-right">
<li>
<span class="m-r-sm text-muted welcome-message">Welcome <?php echo $rowaccess['fullname']; ?></span>
</li>
<li class="dropdown">
<li>
<a href="logout.php">
<i class="fa fa-sign-out"></i> Log out
</a>
</li>
</ul>
</nav>
</div>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-10">
<h2></h2>
<ol class="breadcrumb">
<li>
<a href="index.php">Home</a>
</li>
<li class="active"><strong>Apply Clearance </strong></li>
</ol>
</div>
<div class="col-lg-2">
</div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
</div>
<div class="ibox-content">
<div class="row">
<div class="col-lg-8">
<table class="table" cellpadding="5" cellspacing="8">
<tr>
<th> Designee Name</th>
<th> Action</th>
</tr>
<tr>
<td>Academic Head</td>
<td>
<button type='button' id='ac_request' class="<?php echo $condition; ?>"><i class="fa fa-send"></i> <?php echo $condition_txt; ?></button>
</td>
</tr>
<tr>
<td>Faculty</td>
<td>
<button type='button' id='faculty_request' class="<?php echo $condition1; ?>"><i class="fa fa-send"></i> <?php echo $condition_txt1; ?></button>
</td>
</tr>
<tr>
<td>Departmental Library</td>
<td>
<button type='button' id='dipl_request' class="<?php echo $condition2; ?>"><i class="fa fa-send"></i> <?php echo $condition_txt2; ?></button>
</td>
</tr>
<tr>
<td>Kashim Ibrahim Library</td>
<td>
<button type='button' id='kil_request' class="<?php echo $condition3; ?>"><i class="fa fa-send"></i> <?php echo $condition_txt3; ?></button>
</td>
</tr>
<tr>
<td>Sport</td>
<td>
<button type='button' id='sport_request' class="<?php echo $condition4; ?>"><i class="fa fa-send"></i> <?php echo $condition_txt4; ?></button>
</td>
</tr>
<tr>
<td>Hall Of Residence</td>
<td>
<button type='button' id='hall_request' class="<?php echo $condition5; ?>"><i class="fa fa-send"></i> <?php echo $condition_txt5; ?></button>
</td>
</tr>
</table>
</div>
<div class="col-lg-4 hidden" id="proof_section">
<form action="#" method="POST" class="ibox" id="hostel_form" enctype="multipart/form-data">
<div class="ibox-title">
<h3 class="ibox-text">Provide Hostel Documents</h3>
</div>
<div class="ibox-content">
<div class="form-group">
<label for="h_item">Select Item <span class="text-danger">*</span></label>
<select name="h_item" id="h_item" class="form-control" required>
<option value="">Choose Item</option>
<option value="Hostel Clearance Slip">Hostel Clearance Slip</option>
<option value="Other Document">Other Document</option>
</select>
</div>
<div class="form-group">
<label for="clearance_file">Clearance Form <span class="text-danger">*</span></label>
<input type="file" class="form-control" id="clearance_file" name="clearance_file" required>
</div>
<button type="submit" id="btn_send_proof" class="btn btn-primary"><i class="fa fa-upload"></i> Send Proof</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-5"></div>
</div>
<div class="row"></div>
</div>
<div class="footer">
<div class="pull-right"></div>
<div><?php include('../footer.php'); ?></div>
</div>
</div>
</div>
<!-- Mainly scripts -->
<script src="js/jquery-3.6.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<!-- Custom and plugin javascript -->
<script src="js/inspinia.js"></script>
<script src="js/plugins/pace/pace.min.js"></script>
<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>
<script>
$(document).ready(function () {
$('.i-checks').iCheck({
checkboxClass: 'icheckbox_square-green',
radioClass: 'iradio_square-green',
});
});
</script>
<link rel="stylesheet" href="popup_style.css">
<?php if(!empty($_SESSION['success'])) { ?>
<div class="popup popup--icon -success js_success-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
<strong>Success</strong>
</h1>
<p><?php echo $_SESSION['success']; ?></p>
<p>
<button class="button button--success" data-for="js_success-popup">Close</button>
</p>
</div>
</div>
<?php unset($_SESSION["success"]);
} ?>
<?php if(!empty($_SESSION['error'])) { ?>
<div class="popup popup--icon -error js_error-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
<strong>Error</strong>
</h1>
<p><?php echo $_SESSION['error']; ?></p>
<p>
<button class="button button--error" data-for="js_error-popup">Close</button>
</p>
</div>
</div>
<?php unset($_SESSION["error"]); } ?>
<script>
var addButtonTrigger = function addButtonTrigger(el) {
el.addEventListener('click', function () {
var popupEl = document.querySelector('.' + el.dataset.for);
popupEl.classList.toggle('popup--visible');
});
};
Array.from(document.querySelectorAll('button[data-for]')).
forEach(addButtonTrigger);
</script>
<script>
$(document).ready(function(){
$("#hall_request").on('click', function(e){
e.preventDefault();
$("#proof_section").removeClass("hidden");
$(this).removeClass('btn-primary');
$(this).addClass('btn-secondary');
});
//Request for academy clearance
$('#ac_request').on('click', function(e){
e.preventDefault();
let cl_request = "1";
// Store a reference to the button
let button = $(this);
$.ajax({
url: 'request_script.php',
method: 'POST',
dataType: 'json',
data: {cl_request: cl_request},
beforeSend: function() {
button.html('Requesting.....');
button.attr('disabled', 'disabled');
},
success: function(data) {
if (data.error != "") {
alert(data.error);
button.html('Send Request');
button.attr('disabled', false);
} else {
button.html(data.message);
button.removeClass('btn-primary');
button.addClass('btn-danger');
button.attr('disabled', true);
}
}
});
});
//Request for Faculty clearance
$('#faculty_request').on('click', function(e){
e.preventDefault();
let cl_request = "2";
// Store a reference to the button
let button = $(this);
$.ajax({
url: 'request_script.php',
method: 'POST',
dataType: 'json',
data: {cl_request: cl_request},
beforeSend: function() {
button.html('Requesting.....');
button.attr('disabled', 'disabled');
},
success: function(data) {
if (data.error != "") {
alert(data.error);
button.html('Send Request');
button.attr('disabled', false);
} else {
button.html(data.message);
button.removeClass('btn-primary');
button.addClass('btn-danger');
button.attr('disabled', true);
}
}
});
});
//Request for dipartmental clearance
$('#dipl_request').on('click', function(e){
e.preventDefault();
let cl_request = "3";
// Store a reference to the button
let button = $(this);
$.ajax({
url: 'request_script.php',
method: 'POST',
dataType: 'json',
data: {cl_request: cl_request},
beforeSend: function() {
button.html('Requesting.....');
button.attr('disabled', 'disabled');
},
success: function(data) {
if (data.error != "") {
alert(data.error);
button.html('Send Request');
button.attr('disabled', false);
} else {
button.html(data.message);
button.removeClass('btn-primary');
button.addClass('btn-danger');
button.attr('disabled', true);
}
}
});
});
//Request for Kill Library clearance
$('#kil_request').on('click', function(e){
e.preventDefault();
let cl_request = "4";
// Store a reference to the button
let button = $(this);
$.ajax({
url: 'request_script.php',
method: 'POST',
dataType: 'json',
data: {cl_request: cl_request},
beforeSend: function() {
button.html('Requesting.....');
button.attr('disabled', 'disabled');
},
success: function(data) {
if (data.error != "") {
alert(data.error);
button.html('Send Request');
button.attr('disabled', false);
} else {
button.html(data.message);
button.removeClass('btn-primary');
button.addClass('btn-danger');
button.attr('disabled', true);
}
}
});
});
//Request for sport clearance
$('#sport_request').on('click', function(e){
e.preventDefault();
let cl_request = "5";
// Store a reference to the button
let button = $(this);
$.ajax({
url: 'request_script.php',
method: 'POST',
dataType: 'json',
data: {cl_request: cl_request},
beforeSend: function() {
button.html('Requesting.....');
button.attr('disabled', 'disabled');
},
success: function(data) {
if (data.error != "") {
alert(data.error);
button.html('Send Request');
button.attr('disabled', false);
} else {
button.html(data.message);
button.removeClass('btn-primary');
button.addClass('btn-danger');
button.attr('disabled', true);
}
}
});
});
// Upload hostel proof
$("#hostel_form").on('submit', function(event) {
event.preventDefault();
var hostelItem = $("#h_item").val();
var hostelProof = $("#clearance_file")[0].files[0]; // Get the selected file
if (hostelProof == undefined || hostelItem == "") {
alert("Please select an item and upload a file to submit.");
} else {
var formData = new FormData();
formData.append('h_item', hostelItem);
formData.append('clearance_file', hostelProof); // Use 'clearance_file' as the key
$.ajax({
url: 'upload_proof.php',
method: 'POST',
dataType: 'json',
data: formData,
processData: false, // Prevent jQuery from automatically processing the data
contentType: false, // Prevent jQuery from setting content type
beforeSend: function() {
$("#btn_send_proof").html('Loading..');
$("#btn_send_proof").attr('disabled', 'disabled');
},
success: function(data) {
if (data.error) {
alert("Error: " + data.error);
} else if (data.message) {
$("#proof_section").addClass("hidden");
$("#hall_request").removeClass('btn-secondary');
$("#hall_request").addClass('btn-danger');
$("#hall_request").html(data.message);
$("#hall_request").attr('disabled', 'disabled');
}
$("#btn_send_proof").html('<i class="fa fa-upload"></i> Send Proof');
$("#btn_send_proof").attr('disabled', false);
},
error: function() {
alert("An error occurred while processing the request.");
}
});
}
});
});
</script>
</body>
</html>