-
Notifications
You must be signed in to change notification settings - Fork 0
/
pending_updates.php
461 lines (407 loc) · 14.5 KB
/
pending_updates.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
<?php
session_start();
require_once('includes/dbh.inc.php');
if(!isset($_SESSION['student']) && !isset($_COOKIE['student'])){
header("Location: login.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Pending Updates | IAS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/profile.css">
<link rel="stylesheet" type="text/css" href="css/animate.css">
<link rel="stylesheet" type="text/css" href="css/pending_updates.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i" rel="stylesheet">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="icon" type="image/jpg"
href="images/logo.jpg" />
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="index.php" class="pull-left hidden-xs"><img src="images/logo.jpg " height="35" width="45" style="margin:8px;"></a>
<a class="navbar-brand" href="index.php"><span class="brand"><span>I</span>NSTITUTE OF <span>A</span>PPLIED <span>S</span>CIENCE</span></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>
<form class="navbar-form" action="includes/logout.inc.php" method="POST">
<button type="submit" name="logout"><span class="fa fa-sign-out"></span>Log Out</button>
</form>
</li>
</ul>
</div>
</div>
</nav>
<?php
if(isset($_SESSION['student'])){
$email = $_SESSION['student'];
$query = "select * from students where stu_email='$email'";
}
elseif(isset($_COOKIE['student'])){
$email = $_COOKIE['student'];
$query = "select * from students where stu_email='$email'";
}
$result = mysqli_query($conn, $query);
?>
<div class="container profile-wrapper" style="min-height: calc(100vh - 196px)!important;">
<div class="row">
<div class="col-md-3 navigation shadow" >
<div class="img-name">
<?php
$row = mysqli_fetch_array($result);
echo '
<div class="contain">
<img class="img-thumbnail" src="'.$row['stu_imageLocation'].'" />
<div class="overlay">
<div class="text">
<form action="includes/change.inc.php" method="POST" enctype="multipart/form-data" >
<input type="file" id="fileLoader" accept=".jpg, .jpeg, .png" onchange="this.form.submit();" name="image"/>
<input type="hidden" name="id" value="'.$row['stu_id'].'"></input>
<input type="button" class="btn btn-default btn-sm" id="btnOpenFileDialog" value = "Change Image" onclick="openfileDialog();" />
</form>
</div>
</div>
</div><br>
<p class="name">'.$row['stu_roll'].'</p>
';
?>
</div>
<div class="nav-menu shadow">
<ul>
<li class="link">
<a href="profile.php">
<i class="fa fa-home" aria-hidden="true"></i>PROFILE HOME</span>
</a>
</li>
<li class="link">
<a href="account_settings.php">
<i class="fa fa-cogs" aria-hidden="true"></i>ACCOUNT SETTINGS</span>
</a>
</li>
<li class="link">
<a href="change_course.php">
<i class="fa fa-book" aria-hidden="true"></i>CHANGE COURSE / CENTER</span>
</a>
</li>
<li class="link">
<a href="add_course.php">
<i class="fa fa-plus-square-o" aria-hidden="true"></i>APPLY FOR ANOTHER COURSE</span>
</a>
</li>
<li class="link active">
<a href="#">
<i class="fa fa-spinner" aria-hidden="true"></i>VIEW PENDING UPDATES</span>
</a>
</li>
<li class="link">
<a href="downloads.php">
<i class="fa fa-download" aria-hidden="true"></i>DOWNLOADS</span>
</a>
</li>
<li class="link" id="exam">
<a href="505.php" id="exam_link">
<i class="fa fa-pencil" aria-hidden="true"></i>EXAMS</span>
<?php
$sql = "select * from exams natural join exam_course where exam_status=1 and course_id in (select course_id from students_courses where student_id=".$row['stu_id'].");";
$resultset = mysqli_query($conn,$sql);
$i=0;
while($r = mysqli_fetch_array($resultset)){
$query = "select * from results where exam_id = '".$r['exam_id']."' and student_id = ".$row['stu_id'];
$res = mysqli_query($conn,$query);
$num_res = mysqli_num_rows($res);
if($num_res == 0){
$i++;
}
}
if($i!=0){
echo '<span class="notification">'.$i.'</span>';
}
?>
</a>
</li>
<li class="link" id="result">
<a href="505.php">
<i class="fa fa-list-alt" aria-hidden="true"></i>RESULTS</span>
<?php
$sql = "select * from results where student_id =".$row['stu_id']." and publish_status=1";
$res = mysqli_query($conn,$sql);
$rescount = mysqli_num_rows($res);
if($rescount > 0)
echo '<span class="res_no">'.$rescount.'</span>';
?>
</a>
</li>
<li class="link logout">
<form action="includes/logout.inc.php" method="POST">
<button type="submit" name="logout"><span class="fa fa-sign-out"></span>LOG OUT</button>
</form>
</li>
</ul>
</div>
</div>
<div class="col-md-9 content shadow">
<h4>Queued Updates</h4>
<a href="profile.php" class="btn btn-xs pending pull-right hidden-xs"><span class="fa fa-cogs"></span> Back to Account Settings</a>
<hr>
<?php
$id=$row['stu_id'];
$query="select * from student_profile_update where student_id=$id AND spu_status=0";
$res=mysqli_query($conn, $query);
$check=mysqli_num_rows($res);
$i=1;
if($check<1){
echo '<p>No queued updates.</p>';
}
else{
echo '
<table class="table table-bordered" >
<thead class="thead-dark">
<tr>
<th>#</th>
<th>Attribute</th>
<th>Current Value</th>
<th>Requested Value</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
';
while($row_spu=mysqli_fetch_array($res)){
$attr = $row_spu['spu_field'];
$attrName= findAttribute($attr);
echo '
<tr>
<form action="includes/profile_update.inc.php" method="POST">
<td>'.$i.'</td>
<td>'.$attrName.'</td>
<td>'.$row[$attr].'</td>
<td><span id="val'.$i.'">'.$row_spu['spu_newValue'].'</span>
<input type="text" name="newVal" id="newVal'.$i.'" value="'.$row_spu['spu_newValue'].'"/>
</td>
<td>
<input type="hidden" name="id" value="'.$row['stu_id'].'"/>
<input type="hidden" name="attr" value="'.$attr.'"/>
<button type="button" class="btn btn-danger btn-xs" name="delete_req" data-target="#Modalrem'.$i.'" data-toggle="modal">Delete</button>
<div class="modal fade modalrem" id="Modalrem'.$i.'">
<div class="modal-dialog">
<div class="modal-content modal-cnt" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4><i class="fa fa-bullhorn animated infinite tada" aria-hidden="true"></i> SURE ABOUT DELETING YOUR REQUEST?</h4>
</div>
<div class="modal-body">
Deleting your request would mean that your <b>'.$attrName.'</b> won\'t be queued for updation anymore.<br><br>
Are you sure about doing this?<br><br>
<button name="rmvReq" class="btn btn-danger btn-sm request" >Yes, please remove</button>
<button type="button" class="btn btn-success btn-sm no" data-dismiss="modal">No, keep the Request</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-warning btn-xs" id="edit'.$i.'">Edit</button>
<button name="save"class="btn btn-success btn-xs " id="save'.$i.'">Save</button>
</td>
<script src="js/jquery-3.2.1.min.js"></script>
<script>
$(document).ready(function() {
$("#newVal'.$i.'").hide();
$("#save'.$i.'").hide();
$("#edit'.$i.'").on("click", function () {
$("#newVal'.$i.'").show();
$("#save'.$i.'").show();
$("#edit'.$i.'").hide();
$("#val'.$i.'").hide();
}) ;
})
</script>
</form>
</tr>
';
$i++;
}
echo '
</tbody>
</table><br>
';
}
?>
<h4>Approved Changes</h4> <hr>
<?php
$id=$row['stu_id'];
$query="select * from student_profile_update where student_id=$id AND spu_status IN(1,2)";
$res=mysqli_query($conn, $query);
$check=mysqli_num_rows($res);
$i=1;
if($check<1){
echo '<p>No approved changes.</p>';
}
else{
echo '
<table class="table table-bordered" >
<thead class="thead-dark">
<tr>
<th>#</th>
<th>Attribute</th>
<th>Requested Value</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
';
while($row_spu=mysqli_fetch_array($res)){
$attr = $row_spu['spu_field'];
$attrName= findAttribute($attr);
echo '
<tr>
<td>'.$i.'</td>
<td>'.$attrName.'</td>
<td>'.$row_spu['spu_newValue'].'</td>
';
if($row_spu['spu_status'] == 1){
echo '<td><span class="label label-success">Approved</span></td>';
}
elseif($row_spu['spu_status'] == 2){
echo '<td><span class="label label-danger">Denied</span></td>';
}
echo '
<td>
<form action="includes/profile_update.inc.php" method="POST">
<input type="hidden" name="id" value="'.$row['stu_id'].'"/>
<input type="hidden" name="attr" value="'.$attr.'"/>
<button class="btn btn-danger btn-xs" name="remove-update">Remove</button>
</form>
</td>
</tr>
';
$i++;
}
echo '
</tbody>
</table>
';
}
?>
<a href="profile.php" class="btn btn-xs pending hidden-md hidden-lg"><span class="fa fa-cogs"></span> Back to Account Settings</a>
</div>
</div>
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="text-center">
Copyright © Institute of Applied Science 2017
</div>
</div>
</div>
</div>
</footer>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="js/bootstrap.js"></script>
<script>
window.onload = function () {
document.getElementById('button').onclick = function () {
document.getElementById('success-modal').style.display = "none"
window.location.replace('profile_updates.php');
};
};
</script>
<script>
$('#new-pwd,#renew-pwd').on('keyup', function () {
if ($('#new-pwd').val() == $('#renew-pwd').val()) {
$('#message').html('').css('color', '#5fcf80');
$('#change').prop('disabled',false);
} else{
$('#message').html('Passwords do not Match.').css('color', '#D32F2F');
$('#change').prop('disabled',true);
}
});
$('#new-pwd').on('blur', function(){
if(this.value.length < 8){
$('#message1').html('Passwords must be atleast 8 characters long.').css('color', '#D32F2F');
return false;
} else{
$('#message1').html('');
}
});
</script>
<script>
function openfileDialog() {
$("#fileLoader").click();
}
</script>
</body>
</html>
<?php
function findAttribute($attr){
if($attr == 'stu_name'){
return 'Name';
}
elseif($attr == 'stu_gurdianname'){
return 'Guardian\'s Name';
}
elseif($attr == 'stu_address'){
return 'Address';
}
elseif($attr == 'stu_subjectCombo'){
return 'Subject Combination';
}
elseif($attr == 'stu_dob'){
return 'Date of Birth';
}
elseif($attr == 'stu_gender'){
return 'Gender';
}
elseif($attr == 'stu_email'){
return 'Email';
}
elseif($attr == 'stu_contact'){
return 'Contact';
}
elseif($attr == 'stu_gcontact'){
return 'Guardian\'s Contact';
}
elseif($attr == 'stu_currentinstitute'){
return 'Current Institute';
}
elseif($attr == 'stu_university'){
return 'Board / University';
}
elseif($attr == 'stu_highestdegree'){
return 'Class / Course';
}
elseif($attr == 'stu_dept'){
return 'Department';
}
elseif($attr == 'stu_yop'){
return 'Year of Passing';
}
elseif($attr == 'stu_currentStatus'){
return 'Current Status';
}
elseif($attr == 'stu_category'){
return 'Category';
}
elseif($attr == 'stu_blood'){
return 'Blood Group';
}
elseif($attr == 'stu_religion'){
return 'Religion';
}
}
?>