-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphMonthlyReportDual.php
More file actions
230 lines (202 loc) · 9.99 KB
/
graphMonthlyReportDual.php
File metadata and controls
230 lines (202 loc) · 9.99 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
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
<?php
error_reporting(0);
include('login.php');
include('session.php');
include('redirectGraphData.php');
if(!isset($_SESSION['login_user'])){
header("location: index.php"); // Redirecting To Home Page
}
$servername = "localhost";
$username = "p_f21_16";
$password = "e3m6rq";
$dbname = "p_f21_16_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$userselect= $_SESSION['login_user'];
?>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<nav class="navbar navbar-expand-md navbar-dark bg-dark sticky-top">
<div class="container-fluid">
<h3><a class="navbar-brand" href="adminProfile.php"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-camera-fill" viewBox="0 0 16 16">
<path d="M10.5 8.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
<path d="M2 4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-1.172a2 2 0 0 1-1.414-.586l-.828-.828A2 2 0 0 0 9.172 2H6.828a2 2 0 0 0-1.414.586l-.828.828A2 2 0 0 1 3.172 4H2zm.5 2a.5.5 0 1 1 0-1 .5.5 0 0 1 0 1zm9 2.5a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0z"/>
</svg>
<span style="color: #6699FF">Library</span>Traffic</a></h3>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="adminProfile.php">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Traffic Reports</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="graphDailyReport.php">Daily</a>
<a class="dropdown-item" href="graphWeeklyReport.php">Weekly</a>
<a class="dropdown-item" href="graphMonthlyReport.php">Monthly</a>
<a class="dropdown-item" href="graphAnnualReport.php">Annual</a>
</li>
<?php
$query = "SELECT role from FinalUserTable where username = '$userselect'";
$ses_sql = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($ses_sql);
$num = $row['role'];
$output .= '<li class="nav-item">
<a class="nav-link" href="importExcelUsers.php">Upload Excel File</a>
</li>';
if($num == 2)
{
echo $output;
}else{
}
?>
</ul>
</div>
</div>
</nav>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawStuff);
function drawStuff() {
var data = new google.visualization.arrayToDataTable([
['Day of the Month', 'People Entered', 'People Exited'],
<?php
$sql = "SELECT * FROM MonthlyReportData INNER JOIN MonthlyReportDataExited ON MonthlyReportData.DayOfMonth=MonthlyReportDataExited.DayOfMonth";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result)){
echo "['".$row['DayOfMonth']."',".$row['PeopleEntered'].",".$row['PeopleExited']."],";
if(((int)$row['PeopleEntered'])>$max){
$max = ((int)$row['PeopleEntered']);
$maxtime = $row['DayOfMonth'];
}
if(((int)$row['PeopleExited'])>$max){
$maxexit = ((int)$row['PeopleExited']);
$maxtimeexit = $row['DayOfMonth'];
}
}
?>
]);
var options = {
width: 800,
chart: {
title: 'Monthly Traffic Report Enter/Exit',
subtitle: 'People entered on the left, people exited on the right'
},
bars: 'vertical', // Required for Material Bar Charts.
series: {
0: { axis: 'entered' }, // Bind series 0 to an axis named 'distance'.
1: { axis: 'exited' } // Bind series 1 to an axis named 'brightness'.
},
axes: {
x: {
entered: {label: 'people'}, // Bottom x-axis.
exited: {side: 'top', label: 'Monthly Traffic data of enter/exit'} // Top x-axis.
}
}
};
var chart = new google.charts.Bar(document.getElementById('dual_x_div'));
chart.draw(data, options);
};
</script>
<script type="text/javascript">
google.charts.load('current', {'packages':['line']});
google.charts.setOnLoadCallback(drawLineChart);
function drawLineChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Day of the Month');
data.addColumn('number', 'People Entered');
data.addColumn('number', 'People Exited');
data.addRows([
<?php
$sql = "SELECT * FROM MonthlyReportData INNER JOIN MonthlyReportDataExited ON MonthlyReportData.DayOfMonth=MonthlyReportDataExited.DayOfMonth";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($result)){
echo "['".$row['DayOfMonth']."',".$row['PeopleEntered'].",".$row['PeopleExited']."],";
}
?>
]);
var options = {
chart: {
title: 'Monthly Traffic Report',
subtitle: 'in people entered/exited'
},
width: 900,
height: 500,
axes: {
x: {
0: {side: 'top'}
}
}
};
var chart = new google.charts.Line(document.getElementById('line_top_x'));
chart.draw(data, google.charts.Line.convertOptions(options));
}
</script>
<script type="text/javascript">
google.charts.load('current', {'packages':['gauge']});
google.charts.setOnLoadCallback(drawGaugeChart);
function drawGaugeChart() {
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['People', 0]
]);
var options = {
width: 300, height: 700,
redFrom: 90, redTo: 100,
yellowFrom:75, yellowTo: 90,
minorTicks: 5
};
var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
chart.draw(data, options);
setInterval(function() {
data.setValue(0, 1, 40 + Math.round(60 * Math.random()));
chart.draw(data, options);
}, 5000);
}
</script>
</head>
<body>
<div id="dual_x_div" style="width: 900px; height: 500px; position:relative; left:800; top:100px;"></div>
<nav>
<ul id="mainMenu" style = "position:relative; left:1700px; top:-450px;" >
<li><a href="graphMonthlyReport.php">Entered</a></li>
<li><a href="graphMonthlyReportExit.php">Exited</a></li>
<li><a href="graphMonthlyReportDual.php">Enter/Exited</a></li>
</ul>
</nav>
<div class="small-chart-container" style = "position:relative; left:550px; top:0px;">
<div id="line_top_x" style ="position:relative; left:120px; top:90px;"></div>
<div id="chart_div" style="width: 400px; height: 120px; position:relative; left:-1320px; top:-400px;"></div>
</div>
<div class="dailyreportanalysis" style = "position:relative; left:250px; top:-600px;">
<p>The most people entered(<?php echo $max?>) was on day <?php echo $maxtime ?> of the month
<p>The most people exited(<?php echo $maxexit?>) was on day <?php echo $maxtimeexit ?> of the month
<br>
<?php $resultentered = mysqli_query($conn,"SELECT MIN(NULLIF(PeopleEntered,0)) AS min_people FROM MonthlyReportData");
$row = mysqli_fetch_array($resultentered);
$minpeopleenter = $row['min_people'];
$resultentertime = mysqli_query($conn,"SELECT DayOfMonth FROM MonthlyReportData WHERE PeopleEntered=$minpeopleenter");
$row2 = mysqli_fetch_array($resultentertime);
$mintimeenter = $row2['DayOfMonth'];
$resultexited = mysqli_query($conn,"SELECT MIN(NULLIF(PeopleExited,0)) AS min_peopleexit FROM MonthlyReportDataExited");
$row3 = mysqli_fetch_array($resultexited);
$minpeopleexited = $row3['min_peopleexit'];
$resultexitedtime = mysqli_query($conn,"SELECT DayOfMonth FROM MonthlyReportDataExited WHERE PeopleExited=$minpeopleexited");
$row4 = mysqli_fetch_array($resultexitedtime);
$mintimeexited = $row4['DayOfMonth'];
?>
<br>
<p>The least people entered(<?php echo $minpeopleenter ?>) was on day <?php echo $mintimeenter ?> of the month
<p>The least people exited(<?php echo $minpeopleexited?>) was on day <?php echo $mintimeexited?> of the month
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</body>
</html>