-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudents.php
235 lines (192 loc) · 6.28 KB
/
students.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
<?php
include 'connection.php';
session_start();
if (empty($_SESSION['username'])){
header('location:index.php');
}
else if ($_SESSION['type']=='student'){
header('location:main.php?type=student');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/admin/student.css">
<script src="js/overlay.js"></script>
<link rel="stylesheet" href="css/admin/edit-overlay.css">
<script src="js/status-overlay.js"></script>
<title>Students</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="DataTables/datatables.css">
<script type="text/javascript" charset="utf8" src="DataTables/datatables.js"></script>
<script>
$(document).ready( function () {
$('#table_id').DataTable();
} );
</script>
</head>
<body>
<?php
include 'header-admin.php';
include 'sidebar-admin.php';
?>
<div class='main-wrap'>
<div class='box'>
<?php
if (isset($_GET['add']) or isset($_GET['remove']) ){
?>
<body onload="editSuccess_on();">
</body>
<?php }
?>
<div id='status-overlay'><div id='status-box'>
<h2>
<img src='images/green-check.png'/>
<br>
<?php
if (isset($_GET['add'])){
echo "Added Successfully!";
}
else if (isset($_GET['remove'])){
echo "All Students Removed!";
}
?>
</h2>
<button onclick='edit_off();'>Close</button>
</div></div>
<h2>Students</h2>
<div class='add'>
<h3>List of Sections</h3>
<?php
$get_date = "SELECT * FROM schedule WHERE sched_id=1";
$result_date = mysqli_query($connection,$get_date);
$count_date = mysqli_num_rows($result_date);
while ($row_date = mysqli_fetch_assoc($result_date)){
$start_date = $row_date['start_date'];
$end_date = $row_date['end_date'];
$election = $row_date['election'];
$drafting = $row_date['drafting'];
}
$curr_date = date('Y-m-d');
?>
<a onclick='addStudent();'><h4 ><i class='fas fa-plus-circle'></i> Add Student</h4></a>
<h4 style='margin-left:15px; width:70px;' onclick='importcsv_on();'><i class='fas fa-upload'></i>Import</h4>
<?php
if ($drafting==1 and ( $curr_date<$start_date or $curr_date>$end_date)){
?>
<a href='remove-all.php' onclick="return confirm('Are you sure you want to remove all students?')">
<h4 style='width:170px; color:#c23b22; margin-left:15px;'>
<i class='fas fa-user-slash'></i>Remove all students </h4></a>
<?php
}
else{
?>
<a nohref='remove-all.php' >
<h4 style='width:170px; color:#c23b22; margin-left:15px; cursor:not-allowed;'>
<i class='fas fa-user-slash'></i>Remove all students </h4></a>
<?php
}
?>
</div>
<!-- Import csv form !-->
<div class='form' id='csv-form' style="display:none; height:275px;">
<div class='form-header'><h2>Import Student List</h2></div>
<form action="importcsv.php" method = "POST" enctype="multipart/form-data">
<input type = "file" name = "file"/>
<input type = "submit" name ="importSubmit" value="Import"/>
</form>
<button class='cancel' onclick='importcsv_off();'>Cancel</button>
<br>
<a href="http://www.tyronesm.co.nf/?t=61305" target="_blank"
style="margin-left:25px; color:#3f72b8;">See sample format here </a>
</div>
<!-- END !-->
<!-- List of Students Start!-->
<div id ='table-hide'>
<table id="table_id" >
<thead>
<tr>
<th class='sec'>Section</th>
<th class='stud-num'>Students</th>
</tr>
</thead>
<tbody>
<?php
$get_section = "SELECT * FROM section WHERE active =1
ORDER BY level ASC";
$res_section = mysqli_query($connection,$get_section);
while($row_section=mysqli_fetch_assoc($res_section)){
$sec_id = $row_section['section_id'];
$section = $row_section['section_name'];
$level = $row_section['level'];
$get_student_count = "SELECT * FROM users INNER JOIN section
ON users.section = section.section_id WHERE section = '$sec_id'
AND users.active=1 AND section.active=1";
$res_student_count = mysqli_query($connection,$get_student_count);
$count = mysqli_num_rows($res_student_count);
$get_vote_count = "SELECT * FROM users INNER JOIN response
ON users.username = response.voter_id WHERE section= '$sec_id'
AND users.active=1 ";
$res_vote_count = mysqli_query($connection,$get_vote_count);
$count_voter = mysqli_num_rows($res_vote_count);
echo "
<tr>
<td>
<a href='student-list.php?sec_id=$sec_id'>
$level-$section
</a>
</td>
<td>
$count_voter/$count
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
<!-- List of Students End!-->
<!-- Add Student Start!-->
<div class='form' id='form-hide'>
<div class='form-header'><h2>Add Student</h2></div>
<form action="add_student.php" method="post" autocomplete='off'>
<label for = 'student-no'>Student Number:</label>
<input type="text" name="username" id="student-no" required/>
<br>
<br>
<label for = 'name'>Name:</label>
<input type="text" name="name" id="name" required/>
<br>
<br>
<label for = 'section'>Section:</label>
<select name="section" id="section" required >
<option value="">Select Section</option>
<?php
$get_section = "SELECT * FROM section WHERE active =1 ";
$res_section = mysqli_query($connection,$get_section);
while($row_section=mysqli_fetch_assoc($res_section)){
$sec_id = $row_section['section_id'];
$section = $row_section['section_name'];
$level = $row_section['level'];
echo "<option value='$sec_id' >$level-$section</option>";
}
?>
</select>
<br>
<br>
<label for = 'password'>Password:</label>
<input type="password" name="password" id="password" required/>
<input type="submit" value="Submit" name = 'submit-form'>
<button class='cancel' onclick='addStudent_off();'>Cancel</button>
</form>
</div>
<!-- Add Student End!-->
</div>
</div>
<div id="overlay" style="display:none;"></div>
</body>
</html>