forked from utkarshadeshmukh05/Faculty-Data-Management
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddattendance.php
370 lines (263 loc) · 11.5 KB
/
addattendance.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
<?php
error_reporting(0) ;
$year=$_POST["year"];
$branch=$_POST["branch"];
$division=$_POST["division"];
$faculty=$_POST["faculty"];
$subject=$_POST["subject"];
// connect to the database
$conn = mysqli_connect('localhost', 'root', '', 'faculty_project');
// Uploads files
if (isset($_POST['submit'])) { // if save button on the form is clicked
// name of the uploaded file
$filename = $_FILES['myfile']['name'];
// destination of the file on the server
$destination = 'attendancelist_uploads/' . $filename;
// get the file extension
$extension = pathinfo($filename, PATHINFO_EXTENSION);
// the physical file on a temporary uploads directory on the server
$file = $_FILES['myfile']['tmp_name'];
$size = $_FILES['myfile']['size'];
$fileop=fopen($file,"r");
if (!in_array($extension, ['csv'])) {
echo "You file extension must be .csv";
} elseif ($_FILES['myfile']['size'] > 1000000) { // file shouldn't be larger than 1Megabyte
echo "File too large!";
} else {
// move the uploaded (temporary) file to the specified destination
if (move_uploaded_file($file, $destination)) {
$sql = "INSERT INTO attendancelist(year,branch,division, subject,faculty_name,attendance_file) VALUES ('$year','$branch','$division','$subject','$faculty','$filename')";
$myresult=mysqli_query($conn,$sql);
if(!empty($myresult))
{
echo"Move to Folder";
}
else
{
echo "NotMoved";
}
// move the uploaded (temporary) file to the specified destination
while(($column=fgetcsv($fileop,1000,","))!==FALSE)
{
$insql = "INSERT INTO data(rollno,name,year,branch,division,subject,lecture_conduct,lecture_attend) VALUES ('".$column[0]."','".$column[1]."','".$column[2]."','".$column[3]."','".$column[4]."','".$column[5]."','".$column[6]."','".$column[7]."')";
$result=mysqli_query($conn, $insql) ;
if(!empty($result))
{
echo"Imported";
}
else
{
echo "NotImported";
}}
}}}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Teachplan</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js"
integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./tech.css">
</head>
<body>
<nav class="navbar" id="nav" style="background-color:#d40b0b; ">
<span class="navbar-brand " id="nav2" style="color:white; margin-left: 5%;
text-shadow: 0 3px 10px rgb(0 0 0 / 0.5);"><h3>Add Attendance</h3></span>
</nav>
<div class="wrapper">
<div class="sidebar">
<ul>
<li><a href="./setclass.php">Set Profile</a></li>
<li><a href="./addteachplan.php">Add Teach plan</a></li>
<li><a href="./addattendance.php">Add Attendance</a></li>
<li><a href="./viewtimetable.php">View Timetable</a></li>
<li><a href="./Viewstudentlist.php">View class List</a></li>
<li><a href="checkform.php">Class Incharge</a></li>
<li><a href="./login.php">Logout</a></li>
</ul>
</div>
</div>
<div id="back" style=" padding: 10px; margin-top: 2%; margin-left: 35%; border: 1px solid #fdfeff; width: 55%; height:auto;" >
<div style="margin-left: 10%; padding-right: 15px;">
<div style="margin-left: 26px; font-weight: bolder; font-size:larger;
font-family: 'PT Sans', sans-serif;"></div>
<form id="form" action=" " method="post" enctype="multipart/form-data">
<div class="row mb-3">
<div class="col-sm-10" id="true">
<span id="pass3" style="color: red; "></span>
<h6 style="font-weight: bold;">Year</h6>
<select id="year1" name="year">
<option value="Select Year">Select Year</option>
<option value="1">I</option>
<option value="2">II</option>
<option value="3">III</option>
<option value="4">IV</option>
</select>
</div>
<div class="col-sm-10" style="margin-top: 4%;" id="true">
<div class="select">Branch</div>
<select id="Branch" name="branch">
<option value="Branch">Select Branch</option>
<option value="CS">Computer Science</option>
<option value="IT">Information Technology</option>
<option value="MECH">Mechanical</option>
<option value="INSTRU">Instrumentation</option>
<option value="ENTC">Electronics and Telecommunication</option>
</select>
</div>
<div class="col-sm-10" style="margin-top: 4%;" id="true">
<span id="pass4" style="color: red; "></span>
<h6 style="font-weight: bold;">Division</h6>
<select id="year2" name="division">
<option value="Select Division">Select Division</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="F">F</option>
<option value="G">G</option>
<option value="H">H</option>
<option value="I">I</option>
</select>
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8" id="true">
<input type="text" id= "user" class="form-control" value="" placeholder="enter subject" name="subject">
<span id="pass1" style="color: red; "></span>
</div>
<div class="col-sm-8" style="margin-top: 4%;" id="false">
<input type="text" class="form-control" id="phone" placeholder="enter faculty name" name="faculty">
<span id="pass2" style="color: red; padding: 0%; "> </span>
</div>
</div>
<div class="row mb-3" style="margin-top: 4%;" >
<div class="col-sm-10"id="true" >
<input type="file" id="file" name="myfile">
<span id="passed" style="color: red; padding: 0%; "> </span>
<div>
<table>
<tr>Add .csv File only in this format</tr>
<tr>
<th> Rollno </th>
<th>Name </th>
<th>Year</th>
<th>Branch </th>
<th>DIvision </th>
<th>Subject </th>
<th> Lecture Conducted </th>
<th> Lecture Attended </th>
</tr>
</table>
</div>
</div>
</div>
</div>
<button type="submit" class="btn" id ="color" style="margin-left:30%;
width: 30%; padding: 10px; margin-top: 4% ; color: white;" name="submit">Save</button>
</div>
</form>
</div>
</body>
<script>
form.addEventListener('submit' ,(event)=>
{
var form = document.getElementById("form");
var sub = document.getElementById("user").value;
var form2 = document.getElementById("phone").value;
var form3 = document.getElementById('file');
var form4 =document.getElementById("year1").value;
var form5 =document.getElementById("year2").value;
var valid =document.getElementById("pass1");
var valid2 =document.getElementById("pass2");
if((sub == '') && (form2 == '') && (form3.files.length == 0) && (form4 == "Select Year") && (form5 == "Select Division")){
alert("please fill the form ");
event.preventDefault();
}
else if ((sub == '') || (form2 == ''))
{
alert("please fill all the fields");
event.preventDefault();
}
else{
validation();
}
}
)
function validation(){
var form = document.getElementById("form");
var sub = document.getElementById("user").value;
var form2 = document.getElementById("phone").value;
var form3 = document.getElementById('file');
var form4 = document.getElementById("year1").value;
var form5 =document.getElementById("year2").value;
var valid =document.getElementById("pass1");
var valid2 =document.getElementById("pass2");
if(sub == '')
{
document.getElementById("pass1").innerHTML="<h6>**not be empty</h6>";
document.getElementById("user").style.borderColor="red";
event.preventDefault();
console.log("prevent");
}
else if(!isNaN(sub)) {
document.getElementById('pass1').innerHTML="<h6>**not be number</h6>";
document.getElementById('user').style.borderColor="red";
event.preventDefault();
console.log("prevent");
}
else{
document.getElementById('user').style.borderColor="green";
document.getElementById('pass1').innerHTML=" ";
console.log(sub);
}
if(form2 == '')
{
document.getElementById("pass2").innerHTML="<h6>**not be empty</h6>";
document.getElementById("phone").style.borderColor="red";
event.preventDefault();
console.log("prevent");
}
else if(!isNaN(form2)) {
document.getElementById('pass2').innerHTML="<h6>**not be number</h6>";
document.getElementById('phone').style.borderColor="red";
event.preventDefault();
console.log("prevent");
}
else{
document.getElementById('phone').style.borderColor="green";
document.getElementById('pass2').innerHTML=" ";
console.log(sub);
}
if(form3.files.length == 0){
document.getElementById("passed").innerHTML="**select file";
event.preventDefault();
}
else{
document.getElementById("passed").innerHTML=" ";
}
if((form4 == "1")||(form4 == "2")||(form4 == "3")||(form4 == "4")){
document.getElementById('pass3').innerHTML=" ";
}
else{
document.getElementById('pass3').innerHTML="<h6>**select valid option</h6>";
event.preventDefault();
}
if((form5 == "A")||(form5 == "B")||(form5 == "C")||(form5 == "D")){
document.getElementById('pass4').innerHTML=" ";
}
else{
document.getElementById('pass4').innerHTML="<h6>**select valid option</h6>";
event.preventDefault();
console.log("prevent");
}
}
</script>
</html>