-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.php
More file actions
92 lines (86 loc) · 3.2 KB
/
events.php
File metadata and controls
92 lines (86 loc) · 3.2 KB
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
<?php
include('dbconnection.php');
$rollno = $_POST['studentID'];
$sql = "select * from studentsubject where studentid=$rollno";
$result = $conn->query($sql);
$events = array();
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$subid = $row['subjectid'];
$sql2 = "select * from subject where id=$subid";
$result2 = $conn->query($sql2);
$row2 = $result2->fetch_assoc();
$currentDate = new DateTime();
$currentTS = $currentDate->format('Y-m-d H:i:s');
$subjectsql = "select * from plannedlecture where subjectid=$subid AND date>='$currentTS'";
$subresult = $conn->query($subjectsql);
while($row1 = $subresult->fetch_assoc())
{
$enddate = strtotime($row1["date"]);
$enddate = $enddate +3600;
$subname = $row2['name']." Lecture";
$temp = array("title"=>$subname,"start"=>$row1['date'],"end"=>$enddate,"color"=>"skyblue");
$events[] = $temp;
}
$subjectsql2 = "select * from actuallecture where subjectid=$subid AND date<='$currentTS'";
$subresult2 = $conn->query($subjectsql2);
while($row3 = $subresult2->fetch_assoc())
{
$lecid = $row3['lectureid'];
$lecsql = "select * from attendence where lectureid=$lecid AND studentid=$rollno";
$lecresult = $conn->query($lecsql);
if($r = $lecresult->fetch_assoc())
{
$color = "lightgreen";
$eventText="black";
}
else
{
$color = "red";
$eventText="white";
}
$enddate = strtotime($row3["date"]);
$enddate = $enddate +3600;
$subname = $row2['name']." Lecture";
$temp = array("title"=>$subname,"start"=>$row3['date'],"end"=>$enddate, "color"=>$color, "textColor"=>$eventText);
$events[] = $temp;
}
}
$exam = "select * from exams";
$examresult = $conn->query($exam);
while($row4 = $examresult->fetch_assoc())
{
if($row4['allday']==1)
{
$allday = "true";
}
else
{
$allday = "false";
}
$temp = array("title"=>$row4['testname'],"start"=>$row4['startdate'],"end"=>$row4["enddate"], "allday"=>$allday,"color"=>"yellow");
$events[] = $temp;
}
$holidays = "select * from holidays";
$holidayresult = $conn->query($holidays);
while($row5 = $holidayresult->fetch_assoc())
{
$temp = array("title"=>$row5['HolidayName'],"start"=>$row5['Date'], "allday"=>"true","color"=>"pink");
$events[] = $temp;
}
$event = "select * from event";
$eventresult = $conn->query($event);
while($row6 = $eventresult->fetch_assoc())
{
$temp = array("title"=>$row6['name'],"start"=>$row6['startdate'],"end" => $row6['enddate'] ,"allday"=>"true","color"=>"brown", "textColor"=>"white");
$events[] = $temp;
}
echo json_encode($events);
}
else
{
echo "0 results";
}
$conn->close();