-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattTable.php
161 lines (161 loc) · 8.28 KB
/
attTable.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
<?php session_start(); include_once 'DBconnect.php' ?>
<table class="table table-bordered white table-striped" style="margin:0px;">
<tr>
<th rowspan="2" class="center pt-4">NO.</th>
<th rowspan="2" class="center pt-4" style="width:1000px;padding:2px 45px">Students Name</th>
<?php
$vm =$_SESSION['formTeacher'];
$myClass = $_SESSION['formTeacher'];
$numberschoolweek= mysqli_query($pcon,"SELECT * FROM attendence WHERE studentFullName='numberschoolweek'");
$numWeek = mysqli_fetch_array($numberschoolweek);
$term = $numWeek['academicTerm'];
$section = $numWeek['academicSection'];
$todayAtt = $numWeek['currDay'];
$wekAtt = $numWeek['week'];
$runweek=0;
while ($runweek < $numWeek['studentClass']){
++$runweek;
?>
<th colspan="5" class="center">WEEK <?php echo $runweek; ?></th>
<?php
}
?>
</tr>
<tr>
<?php
$runDay=0;
while ($runDay < $numWeek['studentClass']){
++$runDay;
?>
<th>M</th>
<th>T</th>
<th>W</th>
<th>TH</th>
<th>F</th>
<?php
}
?>
</tr>
<?php
$myClass = $_SESSION['formTeacher'];
$getMyStudents= mysqli_query($pcon,"SELECT * FROM studentinfo WHERE studentCurrentClass='$myClass'");
$nStds=mysqli_num_rows($getMyStudents);
$run=0;
if($nStds > 0){
while ($student = mysqli_fetch_array($getMyStudents)){
++$run;
?>
<tr>
<th><?php echo $run.'.' ?></th>
<td style="word-spacing: 9px;text-transform:capitalize">
<?php
$stdName = $student['surName'].' '.$student['firstName'].' '.$student['otherName'];
echo $stdName;
?>
</td>
<?php
$runAtt=0;
while ($runAtt < $numWeek['studentClass']){
++$runAtt;
?>
<th>
<?php
$holi= mysqli_query($pcon,"SELECT * FROM attendence WHERE week='$runAtt' AND currDay='monday' AND academicTerm='$term' AND academicSection='$section'");
$holiDay=mysqli_fetch_array($holi);
if($holiDay > 0){
echo checkAttendance($stdName, $term, 'monday', $runAtt, $pcon);
}else{
if($runAtt < $numWeek['studentClass']){
?>
<i class="material-icons red-text-lighten-5 text-2 mt-2">highlight_off</i>
<?php
}
}
?>
</th>
<th>
<?php
$holi= mysqli_query($pcon,"SELECT * FROM attendence WHERE week='$runAtt' AND currDay='tuesday' AND academicTerm='$term' AND academicSection='$section'");
$holiDay=mysqli_fetch_array($holi);
if($holiDay > 0){
echo checkAttendance($stdName, $term, 'tuesday', $runAtt, $pcon);
}else{
if($runAtt < $numWeek['studentClass']){
?>
<i class="material-icons red-text-lighten-5 text-2 mt-2">highlight_off</i>
<?php
}
}
?>
</th>
<th>
<?php
$holi= mysqli_query($pcon,"SELECT * FROM attendence WHERE week='$runAtt' AND currDay='wednesday' AND academicTerm='$term' AND academicSection='$section'");
$holiDay=mysqli_fetch_array($holi);
if($holiDay > 0){
echo checkAttendance($stdName, $term, 'wednesday', $runAtt, $pcon);
}else{
if($runAtt < $numWeek['studentClass']){
?>
<i class="material-icons red-text-lighten-5 text-2 mt-2">highlight_off</i>
<?php
}
}
?>
</th>
<th>
<?php
$holi= mysqli_query($pcon,"SELECT * FROM attendence WHERE week='$runAtt' AND currDay='thursday' AND academicTerm='$term' AND academicSection='$section'");
$holiDay=mysqli_fetch_array($holi);
if($holiDay > 0){
echo checkAttendance($stdName, $term, 'thursday', $runAtt, $pcon);
}else{
if($runAtt < $numWeek['studentClass']){
?>
<i class="material-icons red-text-lighten-5 text-2 mt-2">highlight_off</i>
<?php
}
}
?>
</th>
<th>
<?php
$holi= mysqli_query($pcon,"SELECT * FROM attendence WHERE week='$runAtt' AND currDay='friday' AND academicTerm='$term' AND academicSection='$section'");
$holiDay=mysqli_fetch_array($holi);
if($holiDay > 0){
echo checkAttendance($stdName, $term, 'friday', $runAtt, $pcon);
}else{
if($runAtt < $numWeek['studentClass']){
?>
<i class="material-icons red-text-lighten-5 text-2 mt-2">highlight_off</i>
<?php
}
}
?>
</th>
<?php
}
?>
</tr>
<?php
}
}else{
?>
<tr>
<th colspan="<?php echo $numWeek['studentClass']*5+2 ?>">No student in your class yet !</th>
</tr>
<?php
}
?>
</table>
<?php
function checkAttendance($student,$term, $day, $week, $pcon, $acadeYear=null){
$attdence= mysqli_query($pcon,"SELECT * FROM attendence WHERE week='$week' AND currDay='$day' AND academicTerm='$term' AND studentFullName='$student'");
$nunows=mysqli_num_rows($attdence);
if($nunows > 0){
return '<i class="material-icons teal-text text-2 mt-2">done_all</i>';
}else{
return '<i class="material-icons text-2 red-text mt-2">radio_button_checked</i>';
}
}
?>