-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.php
193 lines (181 loc) · 6.01 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
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
<!DOCTYPE html>
<html>
<head>
<title>Statistics</title>
<div align="center">
<img src="dbms.jpg"/>
</div>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
<?php
$con=mysqli_connect("localhost","root","root","warehouse");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$p[1] =0;
$p[2] =0;
$p[3] =0;
$p[4] =0;
$l[1] =0;
$l[2] =0;
$l[3] =0;
$l[4] =0;
$sql = "SELECT product_ID,rate FROM product_details";
$result = mysqli_query($con,$sql);
while($rows = mysqli_fetch_array($result)) {
if($rows['product_ID']==1)
$r[1] = $rows['rate'];
else if ($rows['product_ID']==2)
$r[2] = $rows['rate'];
else if ($rows['product_ID']==3)
$r[3] = $rows['rate'];
else
$r[4] = $rows['rate'];
}
$sql = "SELECT SUM(quantity),product_ID FROM sales GROUP BY product_ID";
$result = mysqli_query($con,$sql);
while($rows = mysqli_fetch_array($result)) {
if($rows['product_ID']==1)
$p[1] = $rows['SUM(quantity)'] * $r[1];
else if ($rows['product_ID']==2)
$p[2] = $rows['SUM(quantity)'] * $r[2];
else if ($rows['product_ID']==3)
$p[3] = $rows['SUM(quantity)'] * $r[3];
else
$p[4] = $rows['SUM(quantity)'] * $r[4];
}
$sql = "SELECT SUM(quantity),product_ID FROM central_storage WHERE valid=0 and quantity!=0 GROUP BY product_ID";
$result = mysqli_query($con,$sql);
while($rows = mysqli_fetch_array($result)) {
if($rows['product_ID']==1)
$l[1] = $rows['SUM(quantity)'] * $r[1];
else if ($rows['product_ID']==2)
$l[2] = $rows['SUM(quantity)'] * $r[2];
else if ($rows['product_ID']==3)
$l[3] = $rows['SUM(quantity)'] * $r[3];
else
$l[4] = $rows['SUM(quantity)'] * $r[4];
}
mysqli_close($con);
?>
var data2 = [
['Products', 'Profit', 'Loss'],
['Milk', <?php echo $p[1] ?>, <?php echo $l[1] ?>],
['Eggs', <?php echo $p[2] ?>, <?php echo $l[2] ?>],
['Bread', <?php echo $p[3] ?>, <?php echo $l[3] ?>],
['Juice', <?php echo $p[4] ?>, <?php echo $l[4] ?>]
];
var data = google.visualization.arrayToDataTable(data2);
var options = {
title: 'All the Profit/ Loss till current Date',
vAxis: {title: 'Products', titleTextStyle: {color: 'red'}},
hAxis: {title: 'Cost', titleTextStyle: {color: 'blue'}}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<style>
.wrapper{position:relative;}
.right,.left{width:50%; position:absolute;}
.right{right:0;}
.left{left:0;}
</style>
<style type="text/css" media="screen">@import "tabs.css";</style>
</head>
<body>
<ul id="tab_ul" class="tabs">
<li><a href="home.php">Home</a></li>
<li><a href="incoming.php">Incoming</a></li>
<li><a href="stats.php">Stats</a></li>
<li><a href="sell.php">Sell</a></li>
<li><a href="storage.php">Storage</a></li>
<li><a href="store1.php">Store_1</a></li>
<li><a href="store2.php">Store_2</a></li>
<li><a href="store3.php">Store_3</a></li>
<li><a href="store4.php">Store_4</a></li>
</ul><br><br>
<div align="center"; style="width:100 %" overflow: "hidden";>
<div class="right" id="chart_div" style="width: 600px; height: 400px;" float="right";></div>
<div class="left" style="width: 930px; float:left;">
<form action="stats_refined.php" method="post">
<b>Profit/Loss Between:</b><br>
Start Date: <input type="date" name="sdate"></br>
End Date : <input type="date" name="edate"></br>
<input type="submit" value="find"></br>
</form>
<div align="left" style="width: 1130px; float:left;">
<?php
$con=mysqli_connect("localhost","root","root","warehouse");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT * FROM product_details";
$result = mysqli_query($con,$sql);
echo "<b>Product Details</b><br>";
echo "<table border='1'>";
echo "<tr><th>Product Name</th><th>Rate</th><th>Shelf Life</th></tr>";
while($rows = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$rows['product_name']."</td>";
echo "<td>".$rows['rate']."</td>";
echo "<td>".$rows['period']."</td>";
// echo "<td>".$rows['t_stamp']."</td>";
echo "</tr>";
}
echo "</table><br><br>";
mysqli_close($con);
?>
</div>
<div align="left" style="width: 1130px; float:left;">
<?php
$con=mysqli_connect("localhost","root","root","warehouse");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT * FROM sales";
$result = mysqli_query($con,$sql);
echo "<b>Sales made by the Central Store till current date</b><br>";
echo "<table border='1'>";
echo "<tr><th>Branch Name</th><th>Product Sold</th><th>Quantity Sold</th><th>Time Stamp</th></tr>";
while($rows = mysqli_fetch_array($result)) {
if($rows['store_ID']==1)
$s = "North Store";
else if($rows['store_ID']==2)
$s = "East Store";
else if($rows['store_ID']==3)
$s = "West Store";
else if($rows['store_ID']==4)
$s = "South Store";
if($rows['product_ID']==1)
$p = "Milk";
else if ($rows['product_ID']==2)
$p = "Eggs";
else if ($rows['product_ID']==3)
$p = "Bread";
else
$p = "Juice";
echo "<tr>";
echo "<td>".$s."</td>";
echo "<td>".$p."</td>";
echo "<td>".$rows['quantity']."</td>";
echo "<td>".$rows['t_stamp']."</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</div>
</div>
</div>
</body>
</html>