-
Notifications
You must be signed in to change notification settings - Fork 1
/
complaint.php
113 lines (88 loc) · 3.9 KB
/
complaint.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
<?php
include 'header.php';
/*
topnav is for the navbar ontop
*/
?>
<div class="topnav">
<a class="active" href="http://localhost/badgewatch/index.php">Home</a>
<a href="https://badgewatch.org/">about</a>
<a href="#feedback">feedback</a>
<a href="https://us.openforms.com/Form/38ab03c4-c295-43f3-8692-73a723866ae4">File a complaint</a>
<div class="search-container">
<form action="search.php" method="POST">
<input type="text" name="search" placeholder="Insert Keyword...">
<button type="submit" name="submit-search" style="background-color: #0073BD;">Search</button>
</form>
</div>
</div>
<div class="officer-container">
<?php
#Grabs the data used to create unique page url and matches the badge id with the url badge
$last = mysqli_real_escape_string($conn, $_GET['last']);
$badge = mysqli_real_escape_string($conn, $_GET['badge']);
$sql = "SELECT * FROM officer Where badgeID = $badge";
$result = mysqli_query($conn, $sql);
$queryResults = mysqli_num_rows($result);
#Display officer info from the officer table
if ($queryResults > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='complaint-box'>
<h1>Officer Details<h1>
<h2>Officer Name: " . $row['firstName'] . " " . $row['lastName'] . " </h2>
<h2>Badge Number: " . $row['badgeID'] . "</h2>
</div>";
}
}
#Look for grading data in the Data table and display the information
$gradeSQL = " SELECT * FROM data WHERE badgeID_data_fk = $badge ";
$gradeResult = mysqli_query($conn, $gradeSQL);
$gradeQuery = mysqli_num_rows($gradeResult);
if ($gradeQuery > 0) {
while ($row = mysqli_fetch_assoc($gradeResult)) {
echo "<div class='complaint-box'>
<h1>Grades (Higher % is better)<h1>
<h2><b>Voilence Grade:</b> " . $row['violence_Grade'] . "%" . "</h2>
<h2>Conduct Grade: " . $row['conduct_grade'] . "%" . " </h2>
<h2>Education Grade: " . $row['education_grade'] . "%" . "</h2>
<h2>Total Grade: " . $row['total_grade'] . "%" . "</h2>
</div>";
}
}
?>
<?php #Grabs data from complaint table and displays it as a chart
$query = " SELECT classification, count(*) as number FROM complaint WHERE badgeID_fk = $badge GROUP BY classification ";
$connect = mysqli_query($conn, $query);
$gradeQuery = " SELECT total_grade FROM data WHERE badgeID_data_fk = $badge ";
?>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {
'packages': ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Classification', 'Number'],
<?php
while ($row = mysqli_fetch_array($connect)) {
echo "['" . $row["classification"] . "', " . $row["number"] . "],";
}
?>
]);
var options = {
title: 'Percentage of Complaints',
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
<div style="width: auto;">
<h3 align="center">Total Complaints</h3>
<h2>
<br />
<div id="piechart" style="width: auto; min-height: 450px;"></div>
</div>
</div>
</body>
</html>