-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattendance.php
More file actions
121 lines (99 loc) · 2.92 KB
/
attendance.php
File metadata and controls
121 lines (99 loc) · 2.92 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
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
<!DOCTYPE html>
<?php
include("util.php");
$sql = SQL::get_connection();
$attendanceEntriesResult = false;
// If a member ID is given to the page, load only attendance records from
// that particular member. Otherwise, load records for all members.
$WHERE_cond = ((isset($_GET["memID"])) ?
"WHERE memberID=$_GET[memID] " : " ");
$attendanceEntriesResult = $sql->query(
"SELECT *
FROM AttendanceData
$WHERE_cond
ORDER BY id DESC;"
);
unset($WHERE_cond);
?>
<html>
<head>
<title>Attendance Log</title>
<link rel="stylesheet" type="text/css" href="theme.css" />
<link rel="stylesheet" type="text/css" href="header.css" />
</head>
<body>
<?php include("header.php"); ?>
<form action="attendance.php" method="get">
Search: <input type="text" name="s">
</form>
<div id="formbox">
<h1>Sign In/Out</h1>
<form action="addAtt.php" method="post">
Member:
<select name="memID">
<?php
$membersResult = $sql->query("SELECT * FROM members ORDER BY lName ASC");
if($membersResult === FALSE) echo("<option value='-1'>Error</option>");
else if ($membersResult->num_rows == 0) echo("<option value='-1'>No members</option>");
else {
while($memberEntry = $membersResult->fetch_assoc()) {
if($memberEntry === false) continue;
echo "<option value='";
echo $memberEntry["id"];
echo "'>";
echo $memberEntry["fName"];
echo " ";
echo $memberEntry["lName"];
echo "</option>";
}
}
?>
</select> <br/>
Output Type:
<select name="output">
<option value="redirect">Normal</option>
<option value="formatted">Arduino</option>
<option value="">None</option>
<option value="json">JSON</option>
</select>
<input type="submit" value="Sign In/Out">
</form>
</div>
<div id="tablebody">
<h1>Attendance Log</h1>
<?php
// If mysqli->query() returned false, there was an invalid query
if ($attendanceEntriesResult === false)
die ("<p class=\"error\">Invalid query</p>");
// Add a hint telling the number of results found
echo ("<p class=\"hint\">");
if ($attendanceEntriesResult->num_rows === 0)
die ("No results found</p>");
else
echo ($attendanceEntriesResult->num_rows." results found</p>");
?>
<table class="data">
<tr>
<td>Timestamp</td>
<td>First Name</td>
<td>Last Name</td>
<td>In/Out</td>
</tr>
<?php
// Iterate through every Attendance Entry
while($entry = $attendanceEntriesResult->fetch_assoc())
{
// Loads member associated with the ID in the entry
$member = Member::SQL_Load_Member_ID($entry["memberID"]);
// Skip to next member if this one's invalid
if($member === false)
continue;
// Prints the table row
printf("\t\t\t<tr><td> %s </td><td> %s </td><td> %s </td><td> %s </td></tr>\n",
$entry["entryDate"], $member->firstName, $member->lastName, ucfirst($entry["io"]));
}
?>
</table>
</div>
</body>
</html>