-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.php
89 lines (65 loc) · 2.08 KB
/
stats.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
<?php
include('adminheader.php');
include_once('Config.php');
$res=$pro->find();
date_default_timezone_set("Asia/Kolkata");
$from = new DateTime($_GET['from']);
$to = new DateTime($_GET['to']);
include "libchart/libchart/classes/libchart.php";
$chart = new VerticalBarChart();
$dataSet = new XYDataSet();
$temp=array('$group' => array('_id' => '$Order.date','total' => array('$sum' => '$Order.total_bill') ) );
$out = $pro->aggregate($temp);
if($from>$to)
{
echo "<script type='text/javascript'>alert('Invalid range of Date'); window.location.href='graph.php';</script>";
}
else if($from==$to){$total=0;
foreach ($out as $key2 ) {
foreach ($key2 as $key3 ) {
if($from->format('d/m/Y')==$key3['_id'])
{$total=$key3['total'];
break;}
}
}
$dataSet->addPoint(new Point($from->format('d-M-y'), $total));
$from->modify('+1 day');
}
else{
do{
$total=0;
foreach ($out as $key2 ) {
foreach ($key2 as $key3 ) {
if($from->format('d/m/Y')==$key3['_id'])
{$total=$key3['total'];
break;}
}
}
$dataSet->addPoint(new Point($from->format('d-M-y'), $total));
$from->modify('+1 day');
}while($from!=$to);
$total=0;
foreach ($out as $key2 ) {
foreach ($key2 as $key3 ) {
if($from->format('d/m/Y')==$key3['_id'])
{$total=$key3['total'];
break;}
}
}
$dataSet->addPoint(new Point($from->format('d-M-y'), $total));
}
$chart->setDataSet($dataSet);
$chart->setTitle("Usage for www.WaterCorps.com");
$chart->render("demo1.png");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Libchart vertical bars demonstration</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
</head>
<body>
<center>
<label style="color:red; size:45px;"><h2> Sales Graph </h2></label><img alt="Vertical bars chart" src="demo1.png" style="border: 1px solid gray;"/><br><br><br><a class="btn btn-info btn-lg" href="admin.php">Back To Admin Panel</center>
</body>
</html>