-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverview.php
629 lines (534 loc) · 24.3 KB
/
overview.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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dashboard</title>
<meta content="" name="description">
<meta content="" name="keywords">
<?php
require('./admin/db.php');
require('header2.php');
?>
<body>
<?php require('./menu.php'); ?>
<main id="main" class="main">
<div class="pagetitle">
<h1>Overview</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item active">Overview</li>
</ol>
</nav>
</div><!-- End Page Title -->
<section class="section dashboard">
<div class="row">
<!-- Left side columns -->
<div class="col-lg-8">
<div class="row">
<!-- Popular car Card -->
<div class="col-xxl-4 col-md-6">
<div class="card info-card revenue-card">
<?php
$maxyear_query = "select max(year) as MaxYear from sales;";
$maxyear_result = mysqli_query($con,$maxyear_query);
$maxyear_row = mysqli_fetch_assoc($maxyear_result);
$maxyear = $maxyear_row['MaxYear'];
$popular_query = "Select Make, Model, Variant, Total from sales where Year=" . $maxyear . " order by Total desc;";
$popular_result = mysqli_query($con,$popular_query);
$row = mysqli_fetch_assoc($popular_result);
$popular = $row['Make']." ".$row['Model']." ".$row['Variant'];
?>
<div class="card-body">
<h5 class="card-title">Most Popular Car <span>| <?php echo $maxyear; ?></span></h5>
<div class="d-flex align-items-center">
<div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
<i class="bi bi-cart"></i>
</div>
<div class="ps-3">
<h6><?php echo $popular; ?></h6>
</div>
</div>
</div>
</div>
</div><!-- End Most popular car card -->
<!-- Sales Card -->
<div class="col-xxl-4 col-md-6">
<div class="card info-card sales-card">
<?php
$popular_query = "Select Specs.Body_Type, SUM(Demography.Total) as STotal from Demography INNER JOIN Specs ON Demography.Make = Specs.Make AND Demography.Model = Specs.Model AND Demography.Variant = Specs.Variant AND Demography.Year = " . $maxyear . " group by Specs.Body_Type ORDER BY STotal DESC;";
$popular_result = mysqli_query($con,$popular_query);
$row = mysqli_fetch_assoc($popular_result);
$popular = $row['Body_Type'];
?>
<div class="card-body">
<h5 class="card-title">Popular Car Body Type <span>| <?php echo $maxyear; ?></span></h5>
<div class="d-flex align-items-center">
<div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
<i class="bi bi-hdd-fill"></i>
</div>
<div class="ps-3">
<h6><?php echo $popular; ?></h6>
</div>
</div>
</div>
</div>
</div><!-- End Sales Card -->
<!-- FUel type Card -->
<div class="col-xxl-4 col-md-6">
<div class="card info-card revenue-card">
<?php
$popular_query = "Select Specs.Fuel_Type, SUM(Demography.Total) as STotal from Specs, Demography where Specs.Make = Demography.Make and Specs.Model = Demography.Model and Specs.Variant = Demography.Variant and Demography.Year = " . $maxyear . " group by Specs.Fuel_Type order by STotal DESC;";
$popular_result = mysqli_query($con,$popular_query);
$row = mysqli_fetch_assoc($popular_result);
$popular = $row['Fuel_Type'];
?>
<div class="card-body">
<h5 class="card-title">Popular Car Fuel Type<span> | <?php echo $maxyear; ?></span></h5>
<div class="d-flex align-items-center">
<div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
<i class="bi bi-droplet-fill"></i>
</div>
<div class="ps-3">
<h6><?php echo $popular; ?></h6>
</div>
</div>
</div>
</div>
</div><!-- End Fuel type card -->
<!-- Transmission type Card -->
<div class="col-xxl-4 col-md-6">
<div class="card info-card sales-card">
<?php
$popular_query = "Select Specs.Transmission, sum(Total) as STotal from Sales,Specs where Year = " . $maxyear . " group by Specs.Transmission order by STotal DESC;";
$popular_result = mysqli_query($con,$popular_query);
$row = mysqli_fetch_assoc($popular_result);
$popular = $row['Transmission'];
?>
<div class="card-body">
<h5 class="card-title">Top Transmission Type <span>| <?php echo $maxyear; ?></span></h5>
<div class="d-flex align-items-center">
<div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
<i class="bi bi-joystick"></i>
</div>
<div class="ps-3">
<h6><?php echo $popular; ?></h6>
</div>
</div>
</div>
</div>
</div><!-- End Transmission type Card -->
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<center><h2><br>Car Variants available in the market<br></h2></center></div></div></div>
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Based on Seating Capacity</h5>
<!-- Bar Chart -->
<div id="seatsChart" style="min-height: 400px;" class="echart"></div>
<script>
<?php
$count = 0;
$capacity_query = "SELECT COUNT(*), Seating_capacity FROM Specs GROUP BY Seating_capacity ORDER BY Seating_capacity asc;";
$capacity_result = mysqli_query($con,$capacity_query);
$data = "";
$cols = "";
while($row = mysqli_fetch_assoc($capacity_result))
{
if($count>0)
{
$data .= ", ";
$cols .= ", ";
}
$data .= $row['COUNT(*)'];
$cols .= "'".$row['Seating_capacity']."'";
$count++;
}
?>
document.addEventListener("DOMContentLoaded", () => {
echarts.init(document.querySelector("#seatsChart")).setOption({
xAxis: {
type: 'category',
data: [<?php echo $cols;?>]
},
yAxis: {
type: 'value'
},
series: [{
data: [<?php echo $data;?>],
type: 'bar'
}]
});
});
</script>
<!-- End Bar Chart -->
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Based on Fuel Type</h5>
<!-- Bar Chart -->
<div id="fuelChart" style="min-height: 400px;" class="echart"></div>
<script>
<?php
$count = 0;
$capacity_query = "SELECT COUNT(*), Fuel_Type FROM Specs GROUP BY Fuel_Type ORDER BY Fuel_Type asc;";
$capacity_result = mysqli_query($con,$capacity_query);
$data = "";
$cols = "";
while($row = mysqli_fetch_assoc($capacity_result))
{
if($count>0)
{
$data .= ", ";
$cols .= ", ";
}
$data .= $row['COUNT(*)'];
$cols .= "'".$row['Fuel_Type']."'";
$count++;
}
?>
document.addEventListener("DOMContentLoaded", () => {
echarts.init(document.querySelector("#fuelChart")).setOption({
xAxis: {
type: 'category',
data: [<?php echo $cols;?>]
},
yAxis: {
type: 'value'
},
series: [{
data: [<?php echo $data;?>],
type: 'bar'
}]
});
});
</script>
<!-- End Bar Chart -->
</div>
</div>
</div>
<!-- Reports -->
<!--div class="col-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Top 5 Performers <span>/<?php echo $row['year']; ?></span></h5-->
<?php
/*$performers_query = "select *, sum(Total) from sales where Year in (select max(year) from sales) group by Make order by sum(Total) desc;";
$performers_result = mysqli_query($con,$performers_query);
$count = 0;*/
?>
<!-- Line Chart -->
<!--div id="reportsChart"></div>
<script>
document.addEventListener("DOMContentLoaded", () => {
new ApexCharts(document.querySelector("#reportsChart"), {
series: [
<?php
/*$count = 0;
while($row = mysqli_fetch_assoc($performers_result))
{
if($count == 0 && $count<5)
{
echo "{
name: '".$row['Make']."',
data: [".$row['Jan'].", ".$row['Feb'].", ".$row['Mar'].", ".$row['Apr'].", ".$row['May'].", ".$row['Jun'].", ".$row['Jul'].", ".$row['Aug'].", ".$row['Sep'].", ".$row['Oct'].", ".$row['Nov'].", ".$row['Dcm']."],
}";
}
else if($count>0 && $count<5)
{
echo "\n,{
name: '".$row['Make']."',
data: [".$row['Jan'].", ".$row['Feb'].", ".$row['Mar'].", ".$row['Apr'].", ".$row['May'].", ".$row['Jun'].", ".$row['Jul'].", ".$row['Aug'].", ".$row['Sep'].", ".$row['Oct'].", ".$row['Nov'].", ".$row['Dcm']."],
}";
}
$count++;
} */
?>],
chart: {
height: 350,
type: 'area',
toolbar: {
show: false
},
},
markers: {
size: 4
},
colors: ['#5470C6','#FAC858','#EE6666','#91CC75', '#698396'],
fill: {
type: "gradient",
gradient: {
shadeIntensity: 1,
opacityFrom: 0.3,
opacityTo: 0.4,
stops: [0, 90, 100]
}
},
dataLabels: {
enabled: false
},
stroke: {
curve: 'smooth',
width: 2
},
xaxis: {
type: 'category',
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
tooltip: {
x: {
//format: 'dd/MM/yy HH:mm'
},
}
}).render();
});
</script-->
<!-- End Line Chart -->
<!--/div>
</div>
</div--><!-- End Reports -->
<!-- Top 5 Selling cars -->
<!--div class="col-12">
<div class="card top-selling overflow-auto">
<?php
$top_query = "Select Sales.Make, Sales.Model, Sales.Variant, Specs.Ex_showroom_price, SUM(Sales.Total) as STotal from Specs INNER JOIN Sales ON Sales.Year = " . $maxyear . " and Sales.Make = Specs.Make and Sales.Model = Specs.Model and Sales.Variant = Specs.Variant group by Sales.Make order by STotal DESC;";
//echo $top_query;
$result = mysqli_query($con,$top_query);
?>
<div class="card-body pb-0">
<h5 class="card-title">Top Selling Companies and their Prices<span>| 2021</span></h5>
<table class="table table-borderless">
<thead>
<tr>
<th scope="col">Product</th>
<th scope="col">Model</th>
<th scope="col">Price</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$count = 0;
while($row = mysqli_fetch_assoc($result))
{
if($count<5)
{
?>
<td><a href="#" class="text-primary fw-bold"><?php echo $row['Make']; ?></a></td>
<td class="fw-bold"><?php echo $row['Model']; ?></td>
<td>₹<?php echo number_format($row['Ex_showroom_price']); ?></td>
</tr>
<?php $count++;
}
}
?>
</tbody>
</table>
</div>
</div>
</div--><!-- End Top 5 Selling Cars -->
</div>
</div><!-- End Left side columns -->
<!-- Right side columns -->
<div class="col-lg-4">
<!-- News & Updates Traffic -->
<div class="card">
<div class="card-body pb-0">
<h5 class="card-title">News & Updates <span>| Today</span></h5>
<div class="news">
<div class="post-item clearfix">
<img src="assets/img/news-1.jpg" alt="">
<h4><a href="https://www.careerizma.com/blog/data-analytics-automotive-industry/">Data analytics for Automotive Industry - Careerizma </a></h4>
<p>Today, automotive innovations like electric and self-driving cars have completely changed the world...</p>
</div>
<div class="post-item clearfix">
<img src="assets/img/news-2.jpg" alt="">
<h4><a href="https://www.dataiku.com/stories/automotive-industry/" rel="nofollow">The Automotive Industry: Driving the Future of AI</a></h4>
<p>Automobile data analytics isn't just about self-driving cars; data science and machine learning technologies can help...</p>
</div>
<div class="post-item clearfix">
<img src="assets/img/news-3.jpg" alt="">
<h4><a href="https://www.industryarc.com/Report/17997/automotive-data-analytics-market.html" rel="nofollow">Automotive Data Analytics Market - Forecast</a></h4>
<p>Google Inc., Microsoft Corporation, Drust, Sight Machine and ZenDrive are considered to be the key...</p>
</div>
<div class="post-item clearfix">
<img src="assets/img/news-4.jpg" alt="">
<h4><a href="https://www.techtarget.com/searchbusinessanalytics/feature/Customer-centric-automotive-data-analytics-proves-maturity" rel="nofollow">Automotive analytics drives consumer-focused industry</a></h4>
<p> Analytics of consumer trends can help automakers identify purchase patterns, optimize vehicle manufacturing...</p>
</div>
<!--div class="post-item clearfix">
<img src="assets/img/news-5.jpg" alt="">
<h4><a href="https://www.forbes.com/sites/markminevich/2020/07/13/the-automotive-industry-and-the-data-driven-approach/" rel="nofollow">The Automotive Industry And The Data Driven Approach</a></h4>
<p>Leveraging data on millions of individual vehicle histories...</p>
</div-->
</div><!-- End sidebar recent posts-->
</div>
</div><!-- End News & Updates -->
</div><!-- End Right side columns -->
</div>
<div class="row">
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Based on Car Body Type</h5>
<!-- Bar Chart -->
<div id="bodyChart" style="min-height: 400px;" class="echart"></div>
<script>
<?php
$count = 0;
$capacity_query = "SELECT COUNT(*), Body_Type FROM Specs GROUP BY Body_Type ORDER BY Body_Type asc;";
$capacity_result = mysqli_query($con,$capacity_query);
$data = "";
$cols = "";
while($row = mysqli_fetch_assoc($capacity_result))
{
if($count>0)
{
$data .= ", ";
$cols .= ", ";
}
$data .= $row['COUNT(*)'];
$cols .= "'".$row['Body_Type']."'";
$count++;
}
?>
document.addEventListener("DOMContentLoaded", () => {
echarts.init(document.querySelector("#bodyChart")).setOption({
xAxis: {
type: 'category',
data: [<?php echo $cols;?>]
},
yAxis: {
type: 'value'
},
series: [{
data: [<?php echo $data;?>],
type: 'bar'
}]
});
});
</script>
<!-- End Bar Chart -->
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Based on Transmission Type</h5>
<!-- Bar Chart -->
<div id="transmissionChart" style="min-height: 400px;" class="echart"></div>
<script>
<?php
$count = 0;
$capacity_query = "SELECT COUNT(*), Transmission FROM Specs GROUP BY Transmission ORDER BY Transmission asc;";
$capacity_result = mysqli_query($con,$capacity_query);
$data = "";
$cols = "";
while($row = mysqli_fetch_assoc($capacity_result))
{
if($count>0)
{
$data .= ", ";
$cols .= ", ";
}
$data .= $row['COUNT(*)'];
$cols .= "'".$row['Transmission']."'";
$count++;
}
?>
document.addEventListener("DOMContentLoaded", () => {
echarts.init(document.querySelector("#transmissionChart")).setOption({
xAxis: {
type: 'category',
data: [<?php echo $cols;?>]
},
yAxis: {
type: 'value'
},
series: [{
data: [<?php echo $data;?>],
type: 'bar'
}]
});
});
</script>
<!-- End Bar Chart -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-10">
<div class="card">
<div class="card-body">
<br>
<h3>Number of options for various budget ranges</h3>
<br><br>
<table class="table datatable">
<thead>
<tr>
<th></th>
<th>Budget Range</th>
<th>Number of Options</th>
</tr>
</thead>
<?php
$min_query="Select MIN(Ex_showroom_price) from specs;";
$max_query="Select MAX(Ex_showroom_price) from specs;";
$min_result = mysqli_query($con,$min_query);
$min_row = mysqli_fetch_assoc($min_result);
$max_result = mysqli_query($con,$max_query);
$max_row = mysqli_fetch_assoc($max_result);
$analysis = "";
$range = round(($max_row['MAX(Ex_showroom_price)']-$min_row['MIN(Ex_showroom_price)'])/10);
$iter = 10;
$count = 1;
for($i = 1; $i<$iter;$i++)
{
echo "<tr>";
$lower = round(($i-1)*$range/100000)*100000;
$upper = round($i*$range/100000)*100000;
//echo "₹".($lower/100000)." lakh - ";
//echo "₹".($upper/100000)." lakh";
$budget_query = "Select COUNT(*) as carCount from Specs where Ex_showroom_price between ".$lower." and ".$upper.";";
$budget_result = mysqli_query($con,$budget_query);
$budget_row = mysqli_fetch_assoc($budget_result);
//echo " ---> ".$budget_row['carCount'];
echo "<td>".$count."</td>";
echo "<td>₹".($lower/100000)." lakh - ₹".($upper/100000)." lakh</td>";
echo "<td>".$budget_row['carCount']."</td>";
echo "</tr>";
$count++;
}
echo "</table></div></div></div></div>";
?>
</section>
</main><!-- End #main -->
<!-- ======= Footer ======= -->
<footer id="footer" class="footer">
<div class="copyright">
© Copyright <strong><span>CarDB</span></strong>. All Rights Reserved
</div>
</footer><!-- End Footer -->
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- Vendor JS Files -->
<script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/chart.js/chart.min.js"></script>
<script src="assets/vendor/echarts/echarts.min.js"></script>
<script src="assets/vendor/quill/quill.min.js"></script>
<script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>