001.
<?php
002.
include
'../function.inc.php'
;
003.
include
'chk_sess.php'
;
004.
$stdate
=
$_GET
[
'stdate'
];
005.
$x
=
''
;
006.
?>
007.
<!DOCTYPE html>
008.
<html lang=
"en"
>
009.
<head>
010.
<meta charset=
"UTF-8"
>
011.
<meta http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
012.
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
013.
<title><?php
echo
$sys_title
; ?></title>
014.
<link rel=
"stylesheet"
type=
"text/css"
href=
"../css/bootstrap.css"
>
015.
<link rel=
"stylesheet"
href=
"../css/font-awesome.min.css"
>
016.
<script type=
"text/javascript"
src=
"../js/jquery.js"
></script>
017.
<script type=
"text/javascript"
src=
"../js/bootstrap.min.js"
></script>
018.
</head>
019.
<body>
020.
<div
class
=
"container"
>
021.
022.
<div
class
=
"page-header"
>
023.
<h3>รายงานยอดขายแบ่งตารางเฉพาะวันที่</h3>
024.
<p>ตั้งแต่วันที่ : <?php
echo
thaidate(
$_GET
[
'stdate'
]); ?> ถึงวันที่ : <?php
echo
thaidate(
$_GET
[
'endate'
]); ?></p>
025.
</div>
026.
<?php
while
(
strtotime
(
$stdate
) <=
strtotime
(
$_GET
[
'endate'
])) {
027.
$where
=
' where orders_date="'
.
$stdate
.
'" '
;
028.
$query
= sprintf(
'select * from orders %s '
,
$where
);
029.
$result
= mysqli_query(
$con
,
$query
);
030.
if
(mysqli_num_rows(
$result
)>0) {
031.
032.
033.
034.
035.
?>
036.
<table
class
=
"table table-bordered"
>
037.
<p>วันที่ : <?php
echo
thaidate(
$stdate
); ?></p>
038.
<thead>
039.
<tr>
040.
<th>ลำดับ</th>
041.
<th>ชื่อสินค้า</th>
042.
<th>จำนวน</th>
043.
<th>ราคา</th>
044.
<th>รวมเป็นเงิน</th>
045.
</tr>
046.
</thead>
047.
048.
<?php
049.
$sum
=0;
$sum_total
=0;
050.
051.
$query
= sprintf(
'select * from orders %s '
,
$where
);
052.
$result
= mysqli_query(
$con
,
$query
);
053.
if
(mysqli_num_rows(
$result
)>0)
054.
{
055.
$val
=
''
;
056.
for
(
$i
=1;
$i
<=mysqli_num_rows(
$result
);
$i
++) {
057.
$rs
= mysqli_fetch_array(
$result
);
058.
059.
$query2
= sprintf(
'select * from orders_detail where orders_id="%s" group by pro_no '
,
$rs
[
'orders_id'
]);
060.
061.
$result2
= mysqli_query(
$con
,
$query2
);
062.
for
(
$j
=1;
$j
<=mysqli_num_rows(
$result2
);
$j
++) {
063.
$rs2
= mysqli_fetch_array(
$result2
);
064.
$query3
= sprintf(
'select * from product where pro_no="%s" '
,
$rs2
[
'pro_no'
]);
065.
$result3
= mysqli_query(
$con
,
$query3
);
066.
$rs3
= mysqli_fetch_array(
$result3
);
067.
$sum
=
$rs3
[
'pro_price'
] *
$rs2
[
'pro_amount'
];
068.
$sum_total
+=
$sum
; ?>
069.
<tbody>
070.
<tr>
071.
<td><?php
echo
$rs3
[
'pro_no'
]; ?></td>
072.
<td><?php
echo
$rs3
[
'pro_name'
]; ?></td>
073.
<td><?php
echo
$rs2
[
'pro_amount'
].
' '
.
$rs3
[
'pro_unit'
]; ?></td>
074.
<td><?php
echo
$rs3
[
'pro_price'
] ?> บาท</td>
075.
076.
<td>
077.
<?php
echo
number_format(
$sum
,2); ?> บาท
078.
</td>
079.
080.
081.
<?php
082.
083.
$x
+=
$rs2
[
'pro_amount'
] *
$rs3
[
'pro_price'
];
084.
085.
$val
+=
$rs2
[
'pro_amount'
] *
$rs3
[
'pro_price'
];
086.
} }} ?>
087.
088.
089.
090.
</tr>
091.
092.
093.
</tbody>
094.
095.
<tr>
096.
097.
098.
099.
</tr>
100.
101.
102.
<?php }
$stdate
=
date
(
"Y-m-d"
,
strtotime
(
"+1 day"
,
strtotime
(
$stdate
)));}?>
103.
104.
105.
106.
</table>
107.
108.
109.
110.
111.
112.
<?php
113.
114.
$where
=
' where orders_date>="'
.
$_GET
[
'stdate'
].
'" and orders_date<="'
.
$_GET
[
'endate'
].
'" '
;
115.
$query
= sprintf(
'select * from orders %s order by orders_id desc'
,
$where
);
116.
$result
= mysqli_query(
$con
,
$query
);
117.
if
(mysqli_num_rows(
$result
)<=0) {msgbox(
'ไม่มีข้อมูลที่ค้นหา'
,
'report.php'
);}
118.
else
{
$val
=0;
119.
for
(
$i
=1;
$i
<=mysqli_num_rows(
$result
);
$i
++) {
120.
$rs
= mysqli_fetch_array(
$result
);
121.
$sum
=0;
122.
$query2
=
'select * from orders_detail where orders_id='
.
$rs
[
'orders_id'
];
123.
$result2
= mysqli_query(
$con
,
$query2
);
124.
for
(
$j
=1;
$j
<=mysqli_num_rows(
$result2
);
$j
++) {
125.
$rs2
= mysqli_fetch_array(
$result2
);
126.
127.
$query3
=
'select * from product where pro_no="'
.
$rs2
[
'pro_no'
].
'"'
;
128.
$result3
= mysqli_query(
$con
,
$query3
);
129.
$rs3
= mysqli_fetch_array(
$result3
);
130.
131.
$val
+=
$rs2
[
'pro_amount'
] *
$rs3
[
'pro_price'
];
132.
$sum
+=
$rs2
[
'pro_amount'
] *
$rs3
[
'pro_price'
];
133.
}
134.
135.
$query4
= sprintf(
'select * from branch where br_id=%s'
,
$rs
[
'branch_id'
]);
136.
$result4
= mysqli_query(
$con
,
$query4
);
137.
$rs4
= mysqli_fetch_array(
$result4
);
138.
139.
?>
140.
141.
142.
<?php } } ?>
143.
144.
145.
<h4
class
=
"text-right"
>
146.
147.
รวมทั้งหมด <?php
echo
$i
-1; ?> รายการ<br><br>
148.
149.
รวมเงินทั้งสิ้น <?php
$t
=
$x
*7/100 ;
150.
$c
=
$x
+
$t
;
echo
number_format(
$x
,2);?> บาท
151.
</h4>
152.
153.
154.
<hr>
155.
<p><a href=
"#"
onclick=
"window.print()"
><i
class
=
"fa fa-print"
></i> พิมพ์</a></p>
156.
</div>
157.
158.
</body>
159.
</html>