-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreports.php
332 lines (289 loc) · 11.4 KB
/
reports.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png">
<link rel="icon" type="image/png" href="../assets/img/favicon.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>
Reports
</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet"/>
<!-- CSS Files -->
<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">
<link href="css/dashboard.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="home.css">
<!-- <link href="css/bootstrap.min.css" rel="stylesheet"> -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!--Load the API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
<?php
$servername = "localhost";
$username = "root";
$password = "SIpnz0Sjel";
// Create connection
$conn = mysqli_connect($servername, $username, $password, 'team018');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT type, COUNT(type) as amount FROM live JOIN problem USING (problem_no) GROUP BY type";
$res = mysqli_query($conn, $sql);
$result = json_encode(mysqli_fetch_all($res, MYSQLI_ASSOC));
$current_year = date("Y")-1;
$sql_2 = "SELECT count(problem_no) from resolved WHERE date BETWEEN '$current_year-01-01' and '$current_year-12-31'";
$res = mysqli_query($conn, $sql_2);
$result_2 = json_encode(mysqli_fetch_all($res, MYSQLI_NUM));
$sql_3 = "SELECT count(problem_no) from live";
$res = mysqli_query($conn, $sql_3);
$result_3 = json_encode(mysqli_fetch_all($res, MYSQLI_NUM));
$sql_4 = "SELECT name, COUNT(problem_no) as amount FROM live INNER JOIN personnel ON live.specialist_id = personnel.id GROUP BY name";
$res = mysqli_query($conn, $sql_4);
$result_4 = json_encode(mysqli_fetch_all($res, MYSQLI_ASSOC));
?>
var temp = JSON.parse('<?php echo $result?>');
var pie_chart_data = [];
var headings = ['Problem type', 'Amount'];
for (x in temp){
pie_chart_data.push([temp[x]['type'], parseInt(temp[x]['amount'])]);
}
pie_chart_data.splice(0,0,headings);
var total_resolved_queries = JSON.parse('<?php echo $result_2?>');
document.getElementById("resolved-queries").innerHTML = total_resolved_queries[0];
var queries_in_progress = JSON.parse('<?php echo $result_3?>');
document.getElementById("in-progress-queries").innerHTML = queries_in_progress[0];
var temp2 = JSON.parse('<?php echo $result_4?>');
console.log(temp2);
var bar_chart_data = [];
for (x in temp2){
bar_chart_data.push([temp2[x]['name'], parseInt(temp2[x]['amount']),'color: #76A7FA']);
}
var headings_2 = ['Specialist', 'Job No',{role:'style'}];
bar_chart_data.splice(0,0,headings_2);
console.log(bar_chart_data);
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawPieChart);
google.charts.setOnLoadCallback(drawLineGraph);
google.charts.setOnLoadCallback(drawBarGraph);
function drawPieChart(){
var data = google.visualization.arrayToDataTable(pie_chart_data);
var options = {
title: '',
is3D: true,
'width':400,
'height':300
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
function drawLineGraph(){
var data = google.visualization.arrayToDataTable([
['Month', 'Resolved'],
['Jan', 10],
['Feb', 11],
['Mar', 66],
['Apr', 56],
['May', 30],
['Jun', 14],
['Jul', 8],
['Aug', 17],
['Sep', 16],
['Oct', 26],
['Nov', 20],
['Dec', 23],
]);
var options = {
title: 'Company Performance',
legend: { position: 'bottom' },
'width':600,
'height':300
};
var chart = new google.visualization.LineChart(document.getElementById('line_chart'));
chart.draw(data, options);
}
function drawBarGraph() {
/*var data = google.visualization.arrayToDataTable([
['Specialist', 'Job No',{role:'style'}],
['John Smith', 10, 'color: #76A7FA'],
['Dean Tean', 6, 'color: #76A7FA'],
['Robert Maito', 14, 'color: #76A7FA'],
['Pat Bright', 9, 'color: #76A7FA'],
['Jack Jones', 3, 'color: #76A7FA'],
]);
*/
var data = google.visualization.arrayToDataTable(bar_chart_data);
var options = {
title: '',
hAxis: {
title: 'Specialist',
},
vAxis: {
title: 'Number of job'
},
'width':1000,
'height':450
};
var chart = new google.visualization.ColumnChart(document.getElementById('bar_chart'));
chart.draw(data, options);
}
});
</script>
<link rel="stylesheet" type="text/css" href="home.css">
</head>
<body>
<nav class="navbar navbar-default navbar-dark bg-d">
<a class="navbar-brand" href="finalhomepage.php">Make-It-All</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="finalhomepage.php">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="logCall.html">Log Call</a>
</li>
<li class="nav-item">
<a class="nav-link" href="allProblems.html">Live Jobs</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Analytics</a>
</li>
</ul>
<ul>
<ul class="nav navbar-nav" style="float: right">
<button class="btn btn btn-danger" type="button" onclick="location.href = 'index.html'">Sign Out</button>
</ul>
</ul>
</div>
</nav>
<div class="main-panel" >
<div class="content">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">
<div class="card card-stats">
<div class="card-body ">
<div class="row">
<div class="col-5 col-md-4">
<div class="icon-big text-center icon-warning">
<i class="nc-icon nc-globe text-warning"></i>
</div>
</div>
<div class="col-7 col-md-8">
<div class="numbers">
<p class="card-category">Total queries</p>
<p class="card-title" id="total-queries">150<p>
</div>
</div>
</div>
</div>
<div class="card-footer ">
<hr>
<div class="stats">
<i class="fa fa-refresh"></i> Update Now
</div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6 col-sm-6">
<div class="card card-stats">
<div class="card-body ">
<div class="row">
<div class="col-5 col-md-4">
<div class="icon-big text-center icon-warning">
<i class="nc-icon nc-money-coins text-success"></i>
</div>
</div>
<div class="col-7 col-md-8">
<div class="numbers">
<p class="card-category">Resolved queries</p>
<p class="card-title" id="resolved-queries">130
<p>
</div>
</div>
</div>
</div>
<div class="card-footer ">
<hr>
<div class="stats">
<i class="fa fa-calendar-o"></i> Past year
</div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6 col-sm-6">
<div class="card card-stats">
<div class="card-body ">
<div class="row">
<div class="col-5 col-md-4">
<div class="icon-big text-center icon-warning">
<i class="nc-icon nc-vector text-danger"></i>
</div>
</div>
<div class="col-7 col-md-8">
<div class="numbers">
<p class="card-category">In progress</p>
<p class="card-title" id="in-progress-queries">10<p>
</div>
</div>
</div>
</div>
<div class="card-footer ">
<hr>
<div class="stats">
<i class="fa fa-clock-o"></i> Latest
</div>
</div>
</div>
</div>
<div class="row row-charts">
<div class="col-md-16">
<div class="card card-stats">
<div class="card-header">
<h6>Problems grouped by type</h6>
<hr>
</div>
<div class="card-body">
<div id="chart_div"></div>
</div>
</div>
</div>
<div class="col">
<div class="card card-stats">
<div class="card-header">
<h6>Completed queries</h6>
<hr>
</div>
<div class="card-body">
<div id="line_chart"></div>
</div>
</div>
</div>
</div>
<div class="row row-charts">
<div class="col">
<div class="card card-stats">
<div class="card-header">
<h6> Job per specialist </h6>
</div>
<div class="card-body">
<div id="bar_chart"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>