001.
<?php
002.
require_once
(
"connect.php"
);
003.
$rdo
=
$_POST
[
"rdoSex"
];
004.
if
(!
empty
(
$_POST
[
"mat_name"
])) {
005.
$q
=
"AND mat_data.id_mat = "
.
$_POST
[
"mat_name"
] .
""
;
006.
}
else
{
007.
$q
=
""
;
008.
}
009.
if
(!
empty
(
$_POST
[
"startdate"
])) {
010.
if
(!
empty
(
$_POST
[
"enddate"
])) {
011.
$l
=
"AND DATE(mat_tranfer.tranfer_date) BETWEEN '"
.
$_POST
[
"startdate"
] .
"' AND '"
.
$_POST
[
"enddate"
] .
"'"
;
012.
}
else
{
013.
$l
=
"AND DATE(mat_tranfer.tranfer_date) = '"
.
$_POST
[
"startdate"
] .
"'"
;
014.
}
015.
}
else
{
016.
$l
=
""
;
017.
}
018.
if
(!
empty
(
$_POST
[
"mat_type"
])) {
019.
$j
=
"AND mat_data.id_type = "
.
$_POST
[
"mat_type"
] .
""
;
020.
}
else
{
021.
$j
=
""
;
022.
}
023.
if
(!
empty
(
$_POST
[
"rdoSex"
])) {
024.
$i
=
$_POST
[
"rdoSex"
];
025.
026.
if
(
$i
== 3) {
027.
$k
=
""
;
028.
}
else
{
029.
$k
=
"AND mat_tranfer.tranfer_flg = "
.
$_POST
[
"rdoSex"
] .
""
;
030.
}
031.
}
else
{
032.
$k
=
""
;
033.
}
034.
$strSQL
= "SELECT mat_name,
035.
SUM(tranfer_out)
as
total_out,SUM(tranfer_in)
as
total_in
036.
FROM mat_tranfer
037.
JOIN mat_data
038.
ON mat_tranfer.id_mat = mat_data.id_mat
039.
WHERE del_tr_flg = 0
".$j."
".$l."
".$q."
" . $k . "
040.
GROUP BY mat_name";
041.
$dataPoints
=
array
();
042.
$dataPoints1
=
array
();
043.
$objQuery
= mysqli_query(
$con
,
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
044.
while
(
$objResult
= mysqli_fetch_array(
$objQuery
)) {
045.
if
(!
empty
(
$_POST
[
"rdoSex"
])) {
046.
$i
=
$_POST
[
"rdoSex"
];
047.
if
(
$i
== 1) {
048.
$dataPoints
[] =
array
(
"label"
=>
$objResult
[
"mat_name"
],
"y"
=>
$objResult
[
"total_out"
] );
049.
}
elseif
(
$i
== 2) {
050.
$dataPoints
[] =
array
(
"label"
=>
$objResult
[
"mat_name"
],
"y"
=>
$objResult
[
"total_in"
] );
051.
}
elseif
(
$i
== 3){
052.
$dataPoints
[] =
array
(
"label"
=>
$objResult
[
"mat_name"
],
"y"
=>
$objResult
[
"total_in"
] );
053.
$dataPoints1
[] =
array
(
"label"
=>
$objResult
[
"mat_name"
],
"y"
=>
$objResult
[
"total_out"
] );
054.
}
055.
}
else
{
056.
057.
}
058.
}
059.
060.
?>
061.
<script>
062.
function
cht () {
063.
var
gg =
""
;
064.
var
i = <?php
echo
json_encode(
$rdo
,JSON_NUMERIC_CHECK) ?>;
065.
if
(i == 1){
066.
gg =
"Material Out"
;
067.
}
else
if
(i == 2){
068.
gg =
"Material In"
;
069.
}
else
if
(i == 3){
070.
gg =
"Material In-Out"
;
071.
}
072.
if
(i == 3) {
073.
var
chart =
new
CanvasJS.Chart(
"chartContainer"
, {
074.
animationEnabled: true,
075.
theme:
"light2"
,
076.
title: {
077.
text: gg
078.
},
079.
axisY: {
080.
title:
"UNIT"
,
081.
includeZero: false
082.
},
083.
axisY2: {
084.
title:
"OUT"
,
085.
includeZero: false
086.
},
087.
toolTip: {
088.
shared: true
089.
},
090.
091.
data: [{
092.
type:
"column"
,
093.
name:
"In"
,
094.
dataPoints: <?php
echo
json_encode(
$dataPoints
, JSON_NUMERIC_CHECK); ?>
095.
},
096.
{
097.
type:
"column"
,
098.
name:
"Out"
,
099.
dataPoints: <?php
echo
json_encode(
$dataPoints1
, JSON_NUMERIC_CHECK); ?>
100.
}
101.
]
102.
});
103.
chart.render();
104.
}
else
{
105.
var
chart =
new
CanvasJS.Chart(
"chartContainer"
, {
106.
animationEnabled: true,
107.
theme:
"light2"
,
108.
title: {
109.
text: gg
110.
},
111.
axisY: {
112.
title:
"Number of Unit Picking"
,
113.
includeZero: false
114.
},
115.
116.
data: [{
117.
type:
"column"
,
118.
name:
"In"
,
119.
dataPoints: <?php
echo
json_encode(
$dataPoints
, JSON_NUMERIC_CHECK); ?>
120.
}]
121.
});
122.
chart.render();
123.
}
124.
}
125.
cht();
126.
</script>
127.
<div id=
"chartContainer"
style=
"height: 400px; width: 100%;"
></div>
128.
129.
<?php
130.
if
(!
empty
(
$_POST
[
"fr"
])) {
131.
if
(
$_POST
[
"fr"
] == 1) {
132.
$q
=
""
;
133.
$j
=
""
;
134.
$k
=
""
;
135.
if
(!
empty
(
$_POST
[
"mat_name"
])) {
136.
$q
=
"AND mat_data.id_mat = "
.
$_POST
[
"mat_name"
] .
""
;
137.
}
else
{
138.
$q
=
""
;
139.
}
140.
if
(!
empty
(
$_POST
[
"mat_type"
])) {
141.
$j
=
"AND mat_data.id_type = "
.
$_POST
[
"mat_type"
] .
""
;
142.
}
else
{
143.
$j
=
""
;
144.
}
145.
if
(!
empty
(
$_POST
[
"rdoSex"
])) {
146.
$i
=
$_POST
[
"rdoSex"
];
147.
if
(
$i
== 3) {
148.
$k
=
""
;
149.
}
else
{
150.
$k
=
"AND mat_tranfer.tranfer_flg = "
.
$_POST
[
"rdoSex"
] .
""
;
151.
}
152.
}
else
{
153.
$k
=
""
;
154.
}
155.
if
(!
empty
(
$_POST
[
"startdate"
])) {
156.
if
(!
empty
(
$_POST
[
"enddate"
])) {
157.
$l
=
"AND DATE(mat_tranfer.tranfer_date) BETWEEN '"
.
$_POST
[
"startdate"
] .
"' AND '"
.
$_POST
[
"enddate"
] .
"'"
;
158.
}
else
{
159.
$l
=
"AND DATE(mat_tranfer.tranfer_date) = '"
.
$_POST
[
"startdate"
] .
"'"
;
160.
}
161.
}
else
{
162.
$l
=
""
;
163.
}
164.
$strSQL
= "SELECT (SELECT mat_name FROM mat_data WHERE mat_tranfer.id_mat = mat_data.id_mat)
as
mat,
165.
bfbalance,
166.
tranfer_in,
167.
tranfer_out,
168.
balance,
169.
(SELECT concat(fname,
' '
,lname) FROM pic_data WHERE mat_tranfer.id_pic_need = pic_data.id_pic)
as
pic,
170.
tranfer_date,
171.
(SELECT FORMAT(SUM((tranfer_in*inv_price)),
'N2'
) FROM inv_data WHERE inv_data.id_inv = mat_tranfer.id_inv)
as
price_in,
172.
(SELECT FORMAT(SUM((tranfer_out*inv_price)),
'N2'
) FROM inv_data WHERE inv_data.id_inv = mat_tranfer.id_inv)
as
price_out,
173.
(SELECT invoice FROM inv_data WHERE inv_data.id_inv = mat_tranfer.id_inv)
as
invoice,
174.
(SELECT inv_price FROM inv_data WHERE inv_data.id_inv = mat_tranfer.id_inv)
as
inv_price
175.
FROM mat_tranfer
176.
JOIN mat_data
177.
ON mat_tranfer.id_mat = mat_data.id_mat
178.
WHERE del_tr_flg = 0
" . $q . "
" . $j . "
" . $k . "
".$l."
";
179.
180.
$objQuery
= mysqli_query(
$con
,
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
181.
?>
182.
<form name=
"form2"
action=
"exportcsvHis.php"
method=
"post"
id=
"about"
class
=
"center_div container"
>
183.
<input type=
"text"
name=
"sql"
class
=
"sql"
id=
"sql"
hidden value=
"<?php echo $strSQL; ?>"
>
184.
<button type=
"submit"
class
=
"btn btn-primary"
value=
""
>Export Excel</button>
185.
</form><br>
186.
<?php
187.
echo
"<table class='table table-bordered table-striped table-hover'><tr class='thead-dark'><th>Material Name</th><th>B/F Balance</th><th>IN</th><th>Price_In</th><th>OUT</th><th>Price_Out</th><th>BALANCE</th><th>PICK PIC</th><th>invoice</th><th>Date</th></tr>"
;
188.
189.
while
(
$objResult
= mysqli_fetch_array(
$objQuery
)) {
190.
191.
192.
193.
echo
"<tr >
194.
<td>
" . $objResult["
mat
"] . "
</td>
195.
<td>
" . $objResult["
bfbalance
"] . "
</td>
196.
<td>
" . $objResult["
tranfer_in
"] . "
</td>
197.
<td>
" . $objResult["
price_in
"] . "
</td>
198.
<td>
" . $objResult["
tranfer_out
"] . "
</td>
199.
<td>
" . $objResult["
price_out
"] . "
</td>
200.
<td>
" . $objResult["
balance
"] . "
</td>
201.
202.
<td>
" . $objResult["
pic
"] . "
</td>
203.
<td>
" . $objResult["
invoice
"] . "
</td>
204.
<td>
" . $objResult["
tranfer_date
"] . "
</td>
205.
</tr>";
206.
}
207.
echo
"</table>"
;
208.
}
209.
}
210.
?>