-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
337 lines (269 loc) · 9.87 KB
/
index.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
<?php
require_once("functions/function.php");
get_header();
get_sidebar();
get_bread();
?>
<script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js">
</script>
<script type = "text/javascript">
google.charts.load('current', {packages: ['corechart','line']});
</script>
<?php
include("includes/connection.php");
$sql = "SELECT doc_date,description,material_number,quantity,SUM(price) as price
from document join inq_has_mat using (doc_id)
join material using (material_number) GROUP BY doc_date,description; ";
$result=mysqli_query($connect,$sql); //rs.open sql,con
$sql2 = "SELECT sum(price*quantity) as total
FROM (document t1 LEFT OUTER JOIN document t2 ON t1.doc_id = t2.ref_doc)
join inq_has_mat on t1.doc_id = inq_has_mat.doc_id
join material using (material_number)
where t2.doc_id like 'INV%'
group by description
order by total desc limit 4
";
$result2=mysqli_query($connect,$sql2);
$sql3 = "SELECT description,sum(quantity) as qty
FROM (document t1 LEFT OUTER JOIN document t2 ON t1.doc_id = t2.ref_doc)
join inq_has_mat on t1.doc_id = inq_has_mat.doc_id
join material using (material_number)
where t2.doc_id like 'INV%'
group by description
order by qty desc limit 4 ";
$result3=mysqli_query($connect,$sql3);//rs.open sql,con
$sql5 = "select CONCAT(first_name, ' ', last_name) as name , customer_type_description as type , count(doc_type_id) as count
from customer join customer_type using (customer_type_id)
join document using (customer_id)
where doc_type_id = '1'
group by first_name";
$result5=mysqli_query($connect,$sql5);
$sql6 = "SELECT ref_doc from document where doc_type_id = 5";
$result6=mysqli_query($connect,$sql6);//rs.open sql,con
$row_num = 0 ;
while ($row=mysqli_fetch_array($result6)) {
$ref_doc[]= $row['ref_doc'];
$row_num++;
}
$total_sum_in = 0;
for($x=0; $x<$row_num;$x++ ){
$sql4 = "select doc_id,sum(cost_price*quantity) as sum
from document join inq_has_mat using
(doc_id) join material using (material_number) where doc_id = $ref_doc[$x]";
$result4=mysqli_query($connect,$sql4);
while ($row=mysqli_fetch_array($result4)) {
$total_sum_in = $total_sum_in+$row['sum'];
}
}
$sql7 = "select sum(net_price) as total from document where doc_type_id = 5 ;";
$result7=mysqli_query($connect,$sql7);
// echo $total_sum_in ;
?>
<?php while ($row=mysqli_fetch_array($result2)) {
$number[]= $row['total'];
// echo $row['total'];
// echo '\n';
}
while ($row=mysqli_fetch_array($result3)) {
$name[]= $row['description'];
$qty[]= $row['qty'];
// echo $row['qty'];
// echo '\n';
}
?>
<script>
var number =<?= $qty[0]?>;
var number2 =<?= $qty[1]?>;
var number3 =<?= $qty[2]?>;
var number4 =<?= $qty[3]?>;
var name ='<?= $name[0]?>';
var name2 ='<?= $name[1]?>';
var name3 ='<?= $name[2]?>';
var name4 ='<?= $name[3]?>';
google.charts.load('current', {
callback: function () {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
[name, number],
[name2, number2],
[name3, number3],
[name4, number4],
]);
var options = {
title:'สัดส่วนของสินค้าที่ขายดี 4 อันดับแรก',
width:500,
height:300
};
for (var i = 0; i < 1; i++) {
var container = document.getElementById('draw-charts').appendChild(document.createElement('div'));
var chart = new google.visualization.PieChart(container);
chart.draw(data, options);
}
},
packages: ['corechart']
});
</script>
<script>
var number =<?= $number[0]?>;
var number2 =<?= $number[1]?>;
var number3 =<?= $number[2]?>;
var number4 =<?= $number[3]?>;
var name ='<?= $name[0]?>';
var name2 ='<?= $name[1]?>';
var name3 ='<?= $name[2]?>';
var name4 ='<?= $name[3]?>';
google.charts.load('current', {
callback: function () {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'จำนวนเงินที่ขายได้');
data.addRows([
[name, number],
[name2, number2],
[name3, number3],
[name4, number4],
]);
var options = {
title:'สัดส่วนของสินค้าที่ขายดี 4 อันดับแรก',
width:500,
height:300
};
for (var i = 0; i < 1; i++) {
var container = document.getElementById('line-charts').appendChild(document.createElement('div'));
var chart = new google.visualization.LineChart(container);
chart.draw(data, options);
}
},
packages: ['corechart']
});
</script>
<div class="row-fluid sortable">
<div class="container">
<button type="button" class="btn btn-primary">New Tasks! <span class="badge">5 </span></button>
<button type="button" class="btn btn-primary">New Orders!<span class="badge">20</span></button>
</div>
<br><br><br>
<div class="container">
<div class="box span6">
<div class="box-header" data-original-title;>
<h2><i class="fa fa-area-chart"></i><span class="break"></span>จำนวนการสั่งสินค้ารายวัน</h2>
</div>
<div class="box-content" >
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Date</th>
<th>Product</th>
<th>Quantity</th>
<th>Price (Bath)</th>
<!-- <th>Sub-Total (Bath)</th> -->
</tr>
</thead>
<tbody>
<?php $total_price =50;
while ($row=mysqli_fetch_array($result))
{ ?><!--open of while -->
<tr>
<td><?php echo $row['doc_date']; ?></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['quantity']; ?></td>
<td><?php echo number_format($row['price'],2); ?></td>
<?php $total_price = $row['quantity']*$row['price']; ?>
<!-- <td><?php echo number_format($total_price,2) ?></td> -->
</tr>
<?php
} //close of while
?>
</tbody>
</table>
</div></div>
<div class="box span6">
<div class="box-header" data-original-title;>
<h2><i class="fa fa-area-chart"></i><span class="break"></span>ปริมาณยอดขายที่เกิดขึ้น</h2>
</div>
<div class="box-content" >
<ul id="line-charts"></ul>
</div>
</div>
<div class="box span6">
<div class="box-header" data-original-title;>
<h2><i class="fa fa-area-chart"></i><span class="break"></span>สัดส่วนสินค้าที่ขายดี</h2>
</div>
<div class="box-content" >
<ul id="draw-charts"></ul>
<br>
<br> <br> <br> <br>
</div>
</div>
</div>
<div class="container">
<div class="box span6">
<div class="box-header" data-original-title;>
<h2><i class="fa fa-area-chart"></i><span class="break"></span>ยอดขายที่เกิดขึ้น</h2>
</div>
<div class="box-content" >
<!-- Bar Chart -->
<div class="card-header">
<i class=""></i> </div>
<div class="card-body">
<div class="row">
<canvas id="myBarChart" width="100" height="50"></canvas>
<div class="text-center ">
<br>
<div class="text-primary"><?php $pofit = 0; while ($row=mysqli_fetch_array($result7)) {
$pofit = $row['total'];
echo "$"; echo number_format($row['total'],2) ;} ?> </div>
<div class="small text-muted">ยอดขายทั้งหมดที่เกิดขึ้น</div>
<hr>
<div class=" text-warning"><?php $pofit = $pofit-$total_sum_in; echo "$"; echo number_format($pofit,2) ;?></div>
<div class="small text-muted">กำไรสุทธิ</div>
</div>
</div>
</div>
</div>
</div>
<div class="box span6">
<div class="box-header" data-original-title;>
<h2><i class="fa fa-area-chart"></i><span class="break"></span>ลูกค้าของเรา</h2>
</div>
<div class="box-content" >
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>NAME</th>
<th>ระดับ</th>
<th>จำนวนคำสั่งซื้อ</th>
</tr>
</thead>
<tbody>
<?php $total_price =50;
while ($row=mysqli_fetch_array($result5))
{ ?><!--open of while -->
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['type']; ?></td>
<td><?php echo $row['count']; ?></td>
</tr>
<?php
} //close of while
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
get_footer();
?>
<!-- <div class="common-modal modal fade" id="common-Modal1" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<ul class="list-inline item-details">
<li><a href="http://themifycloud.com">Admin templates</a></li>
<li><a href="http://themescloud.org">Bootstrap themes</a></li>
</ul>
</div>
</div> -->