-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhome.php
709 lines (650 loc) · 28.4 KB
/
home.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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
<?php
session_start();
if(!isset($_SESSION["id"]))
{
header('Location: ./index.php');
}
else
{
$staffid=$_SESSION['id'];
}
include_once("./db.php");
include_once("./navbar.php");
include_once("./AJAX/header.php");
$staffid = $_SESSION['id'];
//echo '<script>alert("'.$staffid.'");</script>';
$sql = "SELECT * from `staff` where `staffid` like '$staffid'";
$data = $con->query($sql);
$row = $data->fetch_assoc();
if ($row['status'] == 'Not Changed') {
echo "<script>$(function(){
$('body')
.toast({
position: 'bottom right',
title: 'Warning',
class: 'warning',
displayTime: 3000,
closeIcon: true,
showIcon: true,
message: 'Password needs to be changed atleast once',
showProgress: 'top'
});
});</script>";
}
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
</head>
<body>
<style>
body {
background-image: url("./images/bgpic.jpg");
}
</style>
<div id="tabl">
<div class="ui header" style="text-align:center;font-size:30px;margin-top:2%;color:#ADEFD1FF">Your Class Associations
</div>
<table class="ui selectable striped table" style="margin:auto;width:80%;margin-top:2%">
<thead>
<tr style="color:black;font-size:20px" class="center aligned">
<th>Year</th>
<th>Section</th>
<th>Course Code</th>
<th>Course Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody class="center aligned">
<?php
$id=$_SESSION["id"];
$result=$con->query("SELECT * FROM `course_list` WHERE staffA LIKE '%$id%' OR staffB LIKE '%$id%' OR staffC LIKE '%$id%' OR staffD LIKE '%$id%' ORDER BY batch desc");
$core_list=array();
$elect_list=array();
$lab_list=array();
$proj_list=array();
while($row=$result->fetch_assoc())
{
if($row["category"]==="core")
{
array_push($core_list,$row);
}
else if($row["category"]==="elective")
{
array_push($elect_list,$row);
}
else if($row["category"]==="lab")
{
array_push($lab_list,$row);
}
else if($row["category"]==="proj")
{
array_push($proj_list,$row);
}
}
if(!empty($core_list))
{
echo '<tr ><td colspan="5" style="font-size:17px" class="left aligned"><em>General Course</em></td></tr>';
foreach ($core_list as $core)
{
$batch=(2020%intval($core["batch"]))+1;
$year=$batch==2?"II":($batch==3?"III":"IV");
$sec="";
if(substr_count($core["staffA"],$id))
{
$sec="A";
}
if(substr_count($core["staffB"],$id))
{
$sec="B";
}
if(substr_count($core["staffC"],$id))
{
$sec="C";
}
if(substr_count($core["staffD"],$id))
{
$sec="D";
}
if($batch==1)
{
$year='ME';
$sec='-';
}
$code=$core["code"];
$name=$core["name"];
$btn=strval($core["batch"]%2000)."-".$core["dept"]."-".$sec."/".$code;
echo '<tr>
<td>'.$year.'</td>
<td>'.$sec.'</td>
<td>'.$code.'</td>
<td>'.$name.'</td>
<td class="right aligned"><button class="ui primary right icon button" id="'.$btn.'" onclick="attend(this.id)"> Mark Attendance   <i class="check icon"></i></button><button class="ui black right icon button" id="'.$btn.'" onclick="history(this.id)"> View History   <i class="history icon"></i></button><button class="ui purple right icon button" id="'.$btn.'" onclick="consolidate(this.id)"> Report   <i class="file export icon"></i></button></td>
</tr>';
}
}
if(!empty($elect_list))
{
echo '<tr ><td colspan="5" style="font-size:17px" class="left aligned"><em>Elective Course</em></td></tr>';
foreach ($elect_list as $row)
{
$batch=(2020%intval($row["batch"]))+1;
$year=$batch==2?"II":($batch==3?"III":"IV");
$sec="";
if($row["staffA"]==$id)
{
$sec.="A ";
}
if($row["staffB"]==$id)
{
$sec.="B ";
}
if($row["staffC"]==$id)
{
$sec.="C ";
}
if($row["staffD"]==$id)
{
$sec.="D ";
}
if($batch==1)
{
$year='ME';
$sec='-';
}
$code=$row["code"];
$name=$row["name"];
if(($code=="18ITO03")||($code=="18CSO04"))
{
$btn="18---a/".$code;
$sec="-";
}
else
{
$btn=strval($row["batch"]%2000)."-".$row["dept"]."-".$sec[0]."/".$code;
}
if($code==="18CSE02")
{
$sec="A ".$sec;
}
echo '<tr>
<td>'.$year.'</td>
<td>'.$sec.'</td>
<td>'.$code.'</td>
<td>'.$name.'</td>
<td class="right aligned">
<button class="ui primary right icon button" id="'.$btn.'" onclick="attend(this.id)"> Mark Attendance <i class="check icon"></i></button>
<button class="ui black right icon button" id="'.$btn.'" onclick="history(this.id)"> View History <i class="history icon"></i></button>
<button class="ui purple right icon button" id="'.$btn.'" onclick="consolidate(this.id)"> Report <i class="file export icon"></i></button>
</td>
</tr>';
}
}
if(!empty($lab_list))
{
echo '<tr ><td colspan="5" style="font-size:17px" class="left aligned"><em>Laboratory Course</em></td></tr>';
foreach ($lab_list as $core)
{
$batch=(2020%intval($core["batch"]))+1;
$year=$batch==2?"II":($batch==3?"III":"IV");
if(substr_count($core["staffA"],$id))
{
$sec="A";
}
if(substr_count($core["staffB"],$id))
{
$sec="B";
}
if(substr_count($core["staffC"],$id))
{
$sec="C";
}
if(substr_count($core["staffD"],$id))
{
$sec="D";
}
if($batch==1)
{
$year='ME';
$sec='-';
}
$code=$core["code"];
$name=$core["name"];
if($staffid!=="CSE065SF")
{
$btn=strval($core["batch"]%2000)."-".$core["dept"]."-".$sec."/".$code;
echo '<tr>
<td>'.$year.'</td>
<td>'.$sec.'</td>
<td>'.$code.'</td>
<td>'.$name.'</td>
<td class="right aligned"><button class="ui primary right icon button " id="'.$btn.'" onclick="attend(this.id)"> Mark Attendance <i class="check icon"></i></button><button class="ui black right icon button" id="'.$btn.'" onclick="history(this.id)"> View History <i class="history icon"></i></button><button class="ui purple right icon button" id="'.$btn.'" onclick="consolidate(this.id)"> Report <i class="file export icon"></i></button></td>
</tr>';
}
else{
foreach (array("A","B","C") as $sec) {
$btn=strval($core["batch"]%2000)."-".$core["dept"]."-".$sec."/".$code;
echo '<tr>
<td>'.$year.'</td>
<td>'.$sec.'</td>
<td>'.$code.'</td>
<td>'.$name.'</td>
<td class="right aligned"><button class="ui primary right icon button " id="'.$btn.'" onclick="attend(this.id)"> Mark Attendance <i class="check icon"></i></button><button class="ui black right icon button" id="'.$btn.'" onclick="history(this.id)"> View History <i class="history icon"></i></button><button class="ui purple right icon button" id="'.$btn.'" onclick="consolidate(this.id)"> Report <i class="file export icon"></i></button></td>
</tr>';
}
}
}
}
if(!empty($proj_list))
{
echo '<tr ><td colspan="5" style="font-size:17px" class="left aligned"><em>Project Course</em></td></tr>';
foreach ($proj_list as $core)
{
$batch=(2020%intval($core["batch"]))+1;
$year=$batch==2?"II":($batch==3?"III":"IV");
if(substr_count($core["staffA"],$id))
{
$sec="A";
}
if(substr_count($core["staffB"],$id))
{
$sec="B";
}
if(substr_count($core["staffC"],$id))
{
$sec="C";
}
if(substr_count($core["staffD"],$id))
{
$sec="D";
}
if($batch==1)
{
$year='ME';
$sec='-';
}
$code=$core["code"];
$name=$core["name"];
$btn=strval($core["batch"]%2000)."-".$core["dept"]."-".$sec."/".$code;
echo '<tr>
<td>'.$year.'</td>
<td>'.$sec.'</td>
<td>'.$code.'</td>
<td>'.$name.'</td>
<td class="right aligned"><button class="ui primary right icon button" id="'.$btn.'" onclick="attend(this.id)"> Mark Attendance   <i class="check icon"></i></button><button class="ui black right icon button" id="'.$btn.'" onclick="history(this.id)"> View History   <i class="history icon"></i></button><button class="ui purple right icon button" id="'.$btn.'" onclick="consolidate(this.id)"> Report   <i class="file export icon"></i></button></td>
</tr>';
}
}
?>
</tbody>
</table>
</div>
<div id="seg" style="display:none">
</div>
<script type="text/javascript">
function frm2check()
{
var date=document.getElementById("dat").value;
var period=document.getElementById("hr").value;
if(date =='' || period=='')
{
Notiflix.Notify.Failure('Please select Date and Period');
return false;
}
else
{
return true;
}
}
</script>
<div class="ui tiny inverted modal" id="datepickermod">
<div class="header">
KEC Student+
<button class="ui right floated negative icon button" id="closebtn1">
<i class=" close icon"></i>
</button>
</div>
<div class="content">
<form autocomplete="off" class="ui form" id="frm2" method="POST" action="./import.php" onsubmit="frm2check()">
<br></br>
<center>
<div id="fm1">
<div class="two fields">
<div class="field">
<div class="ui header"><span class="ui inverted grey text"> Choose Date to mark the
Attendance</span></div><br>
<div class="ui calendar" id="cal">
<div class="ui focus input left icon">
<i class="calendar icon"></i>
<input type="text" name="dates" placeholder="Date/Time" id="dat" required readonly style="cursor:pointer">
</div>
</div>
</div>
<div class="field">
<div class="ui header"><span class="ui inverted grey text"> Select <br>Period Handled</span>
</div>
<br>
<select name="hrs[]" multiple="" class="ui selection dropdown" id="hr" required>
<option value="">Select Period</option>
</select>
</div>
</div>
<input type="hidden" name="tab" id="tab">
<input type="hidden" name="code" id="code">
<!-- <input type="hidden" name="" id=""> -->
<br></br>
<br></br>
<div class="ui inverted floating icon message">
<i class="info icon"></i>
<div class="content">
<p style="font-size:16px;">Only Dates for Pending Attendance will be enabled!</p>
</div>
</div>
</div>
<div id="fm2">
</div>
</center>
</div>
<div class="actions">
<button class="ui primary right labeled icon button" id="modalnxt">
Next<i class="checkmark icon"></i>
</button>
<button class="ui positive right labeled icon button"
type="submit" name="homy" id="homy" disabled>
Proceed<i class="arrow circle right icon"></i></i>
</button>
</form>
</div>
</div>
<script>
var d = "";
var x,y;
var response;
var dt;
var elec=<?php echo json_encode($ele)?>;
function getWeekDay(date)
{
var weekdays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var day = date.getDay();
if((date.getDate()==2)&&(date.getMonth()==0)&&(date.getFullYear()==2021))
{
day=3;
}
return weekdays[day];
}
function attend(id) {
$('.preloader').css("display","");
var btn = id.split("/");
d = "tab=" + btn[0] + "&code=" + btn[1];
$.ajax({
url: "./AJAX/handler.php",
data: d,
type: "POST",
success: function(res) {
// console.log(res);
// return false;
response=JSON.parse(res);
var i;
var dates =response[0];
var alted=response[1];
if ((!(Object.keys(dates).length))) {
$('body')
.toast({
position: 'bottom right',
title: 'All Done!',
displayTime: 5000,
class: 'success',
closeIcon: true,
showIcon: true,
message: 'You have no pending attendance to be uploaded',
showProgress: 'top'
});
return false;
}
var arr = [];
for (i of Object.keys(dates))
{
var r = i.split("-");
arr.push(new Date(r[0], r[1] - 1, r[2]));
}
var foc=[];
if(alted.length>0)
{
for (const alteddat in alted) {
var r = alteddat.split("-");
foc.push(new Date(r[0], r[1] - 1, r[2]));
}
}
$('#cal').calendar({
type: 'date',
enabledDates: arr,
eventClass: 'inverted red',
maxDate: new Date(),
eventDates: [
{
date: foc,
message: 'Altered Period'
}
],
formatter: {
date: function(date, settings) {
if (!date) return '';
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
return day + '/' + month + '/' + year;
}
},
onChange : function(date, settings) {
var datecreated;
$('#hr').dropdown('clear');
$("#hr").html("<option class='item' value=''>Select Period</option>");
if (!date) return '';
x=(date.getMonth() + 1);
y=date.getDate()
if(x<=9)
{
x="0"+x;
}
if(y<=9)
{
y="0"+y;
}
var day = date.getFullYear() + '-' +x+ '-' +y ;
for (i of dates[day])
{
$("#hr").append("<option class='item' value='"+i+"'>"+i+"</option>");
}
if($('#hr > option').length==1)
{
$('#frm2').form('set value', 'hrs', ar[0]);
}
}
});
$('#hr').dropdown({
maxSelections: 3
});
$('#tab').val(btn[0]);
$('#code').val(btn[1]);
if(elec.includes(btn[1]))
{
$('#frm2').attr('action','importElec.php');
}
$("#fm1").show();
$("#fm2").html("");
$("#modalnxt").show();
$( "#homy" ).prop( "disabled", true );
$("#datepickermod").modal({
centered: false
}).modal("show");
}
});
$('.preloader').css("display","none");
}
function history(id) {
$('.preloader').show();
var btn1 = id.split("/");
d1 = "cls=" + btn1[0] + "&code=" + btn1[1];
$.ajax({
url: "./AJAX/handler.php",
data: d1,
type: "POST",
success: function(r) {
r=r.trim();
if (r === '') {
// Notiflix.Notify.Info("You haven't uploaded any Attendance reports yet");
$('body')
.toast({
position: 'bottom right',
title: 'No History !',
displayTime: 3000,
class: 'warning',
closeIcon: true,
showIcon: true,
message: 'You have not uploaded any Attendance reports yet',
showProgress: 'top'
});
$('.preloader').hide();
return false;
}
$("#seg").html("");
$("#seg").append(
'<button class="ui left floated circular teal icon button" id="bt" data-tooltip="Back to Home" data-position="right center" data-inverted="" onclick="clss()" style="margin-left:2%;"><i class="arrow left icon"></i></button><div class="ui header" style="text-align:center;font-size:30px;margin-top:2%;color:#ADEFD1FF">Attendance History <i class="history icon"></i></div>' +
r);
$("#tabl").hide();
$("#seg").show();
// Notiflix.Notify.Info("Hover on Absentees count to the view Absentees List");
$('body').toast({
position: 'bottom right',
title: 'Tip !',
displayTime: 5000,
closeIcon: true,
showIcon: true,
message: 'Hover on Absentees count to view Absentee List',
showProgress: 'top'
});
$('.preloader').hide();
}
})
}
function consolidate(id) {
$('.preloader').show();
var btn2 = id.split("/");
d2 = "tname=" + btn2[0] + "&ccode=" + btn2[1] + "&consolidate=true";
$.ajax({
url: "./AJAX/handler.php",
data: d2,
type: "POST",
success: function(r) {
r=r.trim();
// console.log(r);
// return false;
if (r == 'empty') {
$('.preloader').hide();
// Notiflix.Notify.Info("You haven't uploaded any Attendance reports yet to consolidate");
$('body').toast({
position: 'bottom right',
title: 'Error!',
displayTime: 3000,
closeIcon: true,
class: 'error',
showIcon: true,
message: 'You have not uploaded any attendance yet to get Report.',
showProgress: 'top'
});
return false;
} else if (r == "export_ready") {
window.location.href = "export.php";
}else if (r == "export_ready_for_Elec") {
window.location.href = "exportElec.php";
} else {
$('.preloader').hide();
// Notiflix.Notify.Warning("Error in retrieving data.Please try again Else Contact Admin");
$('body').toast({
position: 'bottom right',
title: 'Error!',
displayTime: 3000,
closeIcon: true,
class: 'error',
showIcon: true,
message: 'Error in retrieving data. Please try again Else Contact Admin.',
showProgress: 'top'
});
}
}
})
}
$(document).ready(function() {
//$('.message .close').on('click', function() {
//$(this).closest('.message').transition('fade');});
$("#datepickermod").modal();
$('.ui.dropdown').dropdown();
$("#closebtn1").click(function() {
$("#datepickermod").modal("hide");
$('form').form('clear');
$('#hr').dropdown('clear');
});
$('#cal').calendar({
type: 'date'
});
$("#modalnxt").click(function (e) {
var pds=$("#hr").val();
$("#fm1").hide();
$("#fm2").html("");
pds.forEach(i => {
$("#fm2").append(
'<div class="two fields">'+
'<div class="field"><span class="ui large text">'
+((i>3)?i+'<sup>th</sup>':((i==1)?'1<sup>st</sup>':((i==2)?'2<sup>nd</sup>':((i==3)?'3<sup>rd</sup>':''))))+' Hour'+
'</span></div>'+
'<div class="field">'+
'<select name="'+i+'" class="ui dropdown" required>'+
'<option class="item" value="">Select Class Type</option><option class="item" value="Theory">Theory</option>'+
'<option class="item" value="Tutorial">Tutorial</option><option class="item" value="Test">Test</option>'+
'<option class="item" value="Laboratory">Laboratory</option><option class="item" value="Project">Project</option>'+
'</select>'+
'</div>'+
'</div>');
});
$(".ui.dropdown").dropdown();
$("#modalnxt").hide();
$( "#homy" ).prop( "disabled", false );
e.preventDefault();
});
});
function googleForm()
{
$(".ui.modal").modal("hide");
}
function clss() {
$("#tabl").show();
$("#seg").hide();
}
function editor(val) {
var e = val.split("/");
var arr = {
"e_code": e[0],
"e_date": e[1],
"e_period": e[2],
"edittab": e[3],
"editor": "edit"
};
$.ajax({
url: "./AJAX/handler.php",
type: "POST",
data: arr,
success: function(r) {
if (r == "go&edit") {
window.location.href = "editAttdAdv.php";
}
else if (r == "go&editElec") {
window.location.href = "editAttdElec.php";
}
}
});
}
</script>
</body>
</html>