001.
<?php
002.
include
(
"config/config.inc.php"
);
003.
$month_check
=
$_REQUEST
[
"month_check"
];
004.
$year_check
=
$_REQUEST
[
"year_check"
];
005.
$Txt_dateStart
=
date
(
"d-m-Y"
,
strtotime
(
$dateStart
));
006.
$Txt_dateStop
=
date
(
"d-m-Y"
,
strtotime
(
$dateStop
));
007.
008.
009.
if
(
$month_check
==
"01"
) {
010.
$Text_month
=
"มกราคม"
;
011.
}
elseif
(
$month_check
==
"02"
) {
012.
$Text_month
=
"กุมพาพันธ์"
;
013.
}
elseif
(
$month_check
==
"03"
) {
014.
$Text_month
=
"มีนาคม"
;
015.
}
elseif
(
$month_check
==
"04"
) {
016.
$Text_month
=
"เมษายน"
;
017.
}
elseif
(
$month_check
==
"05"
) {
018.
$Text_month
=
"พฤษภาคม"
;
019.
}
elseif
(
$month_check
==
"06"
) {
020.
$Text_month
=
"มิถุนายน"
;
021.
}
elseif
(
$month_check
==
"07"
) {
022.
$Text_month
=
"กรกฎาคม"
;
023.
}
elseif
(
$month_check
==
"08"
) {
024.
$Text_month
=
"สิงหาคม"
;
025.
}
elseif
(
$month_check
==
"09"
) {
026.
$Text_month
=
"กันยายน"
;
027.
}
elseif
(
$month_check
==
"10"
) {
028.
$Text_month
=
"ตุลาคม"
;
029.
}
elseif
(
$month_check
==
"11"
) {
030.
$Text_month
=
"พฤศจิกายน"
;
031.
}
elseif
(
$month_check
==
"12"
) {
032.
$Text_month
=
"ธันวาคม"
;
033.
}
034.
035.
036.
?>
037.
038.
<!DOCTYPE html>
039.
<html>
040.
<head>
041.
<meta charset=
"utf-8"
>
042.
<meta http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
043.
<title>รายงาน Production ประจำเดือน <?php
echo
$Text_month
;?> <?php
echo
$year_check
;?> </title>
044.
<!-- Tell the browser to be responsive to screen width -->
045.
<meta content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
name=
"viewport"
>
046.
<!-- Bootstrap 3.3.7 -->
047.
<link rel=
"stylesheet"
href=
"bower_components/bootstrap/dist/css/bootstrap.min.css"
>
048.
<!-- Font Awesome -->
049.
<link rel=
"stylesheet"
href=
"bower_components/font-awesome/css/font-awesome.min.css"
>
050.
<!-- Ionicons -->
051.
<link rel=
"stylesheet"
href=
"bower_components/Ionicons/css/ionicons.min.css"
>
052.
<!-- Theme style -->
053.
<link rel=
"stylesheet"
href=
"dist/css/AdminLTE.min.css"
>
054.
<!-- AdminLTE Skins. Choose a skin from the css/skins
055.
folder instead of downloading all of them to reduce the load. -->
056.
<link rel=
"stylesheet"
href=
"dist/css/skins/_all-skins.min.css"
>
057.
058.
<!-- HTML5 Shim
and
Respond.js IE8 support of HTML5 elements
and
media queries -->
059.
<!-- WARNING: Respond.js doesn't work
if
you view the page via file:
060.
<!--[
if
lt IE 9]>
063.
<![
endif
]-->
064.
<!-- Favicon -->
065.
<link rel=
"shortcut icon"
href=
"img/fv_mme.png"
>
066.
067.
<!-- Google Font -->
069.
</head>
070.
<body>
071.
<div
class
=
"wrapper"
>
072.
<!-- Main content -->
073.
<section
class
=
"invoice"
>
074.
<!-- title row -->
075.
076.
<!-- title row -->
077.
<div
class
=
"row"
>
078.
<div
class
=
"col-xs-12"
>
079.
080.
<img src=
"img/fv_mme.png"
class
=
"pull-left"
width=
"55"
></img> ใบรายงานสรุปเที่ยว
081.
<br> ห้างหุ้นส่วนจำกัด แม่เมาะวิศวกรรมเหมืองแร่
082.
<small
class
=
"pull-right"
>ประจำวันที่ : <?php
echo
$Text_month
;?> <?php
echo
$year_check
;?> <input type=
"button"
class
=
"btn btn-success btn-sm"
name=
"Button"
value=
"Print"
083.
onclick=
"javascript:this.style.display='none';window.print();"
></small>
084.
085.
<hr>
086.
087.
</div>
088.
<!-- /.col -->
089.
</div>
090.
091.
<?php
092.
093.
$allEquipData
=
array
();
094.
095.
$sql2
=
"SELECT * from equipment where Equip_category='รถรับ' order by Equip_id ASC"
;
096.
$resultA
=mysql_db_query (
$objDB
,
$sql2
);
097.
while
(
$arr2
=mysql_fetch_array(
$resultA
)){
098.
$allEquipData
[
$arr2
[
'Equip_id'
]] =
$arr2
[
'Equip_codename'
];
099.
}
100.
101.
102.
103.
104.
105.
106.
107.
108.
$allReportData
=
array
();
109.
$strSQL
= "SELECT production.*,equipment.*,
110.
DAY(`Prod_date`) AS dayToday,
111.
SUM(Oil)
as
Total_Oil_dt,
112.
SUM(Prod_trip)
as
Total_Trip_dt,
113.
SUM(Prod_bcm)
as
Total_BCM_dt,
114.
SUM(Total_kilo)
as
Total_kilo_dt
115.
FROM `production`
116.
left join equipment on production.Equip_id=equipment.Equip_id
117.
";
118.
$strSQL
.=
"WHERE `Prod_date` LIKE '$year_check-$month_check%' AND Equip_category='รถรับ' "
;
119.
$strSQL
.=
"GROUP by equipment.Equip_id,dayToday"
;
120.
$result
=mysql_db_query (
$objDB
,
$strSQL
);
121.
while
(
$objResult
=mysql_fetch_array(
$result
)){
122.
123.
124.
125.
$allReportData
[
$objResult
[
'Equip_id'
]][
$objResult
[
'dayToday'
]] =
$objResult
[
'Total_Oil_dt'
];
126.
127.
128.
129.
130.
}
131.
132.
$allEquipTotal
=
array
();
133.
134.
$sql3
="SELECT production.*,equipment.*,
135.
DAY(`Prod_date`) AS dayToday,
136.
SUM(Oil)
as
Total_Oil_dt,
137.
SUM(Prod_trip)
as
Total_Trip_dt,
138.
SUM(Prod_bcm)
as
Total_BCM_dt,
139.
SUM(Total_kilo)
as
Total_kilo_dt
140.
FROM `production`
141.
left join equipment on production.Equip_id=equipment.Equip_id
142.
WHERE `Prod_date` LIKE
'$year_check-$month_check%'
AND Equip_category=
'รถรับ'
143.
GROUP by equipment.Equip_id,dayToday
144.
";
145.
$resultA
=mysql_db_query (
$objDB
,
$sql3
);
146.
while
(
$arr2
=mysql_fetch_array(
$resultA
)){
147.
148.
149.
$Total_sum
=
$Total_sum
+
$arr2
[
'Total_Oil_dt'
];
150.
$allEquipTotal
[
$arr2
[
'Equip_id'
]] =
$Total_sum
;
151.
}
152.
153.
154.
155.
156.
157.
158.
159.
?>
160.
<!-- Table row -->
161.
<div
class
=
"row"
>
162.
163.
<div
class
=
"col-xs-12 table-responsive"
>
164.
165.
<div
class
=
"box-header with-border"
>
166.
<h3
class
=
"box-title"
>สรุปเติมน้ำโซล่า รถรับ</h3>
167.
</div>
168.
169.
<table
class
=
"table table-striped table-condensed table-bordered"
>
170.
<thead>
171.
<tr>
172.
<th
class
=
"text-center"
>เครื่องจักร</th>
173.
<?php
174.
175.
$timeDate
=
strtotime
(
$year_check
.
'-'
.
$month_check
.
"-01"
);
176.
$lastDay
=
date
(
"t"
,
$timeDate
);
177.
178.
179.
for
(
$day
=1;
$day
<=
$lastDay
;
$day
++){
180.
echo
'<th>'
.
substr
(
"0"
.
$day
, -2) .
'</th>'
;
181.
} ?>
182.
<th>Total</th>
183.
</tr>
184.
<?php
185.
186.
187.
foreach
(
$allEquipData
as
$empCode
=>
$empName
){
188.
189.
echo
'<tr>'
;
190.
echo
'<td>'
.
$empName
.
'</td>'
;
191.
192.
for
(
$j
=1;
$j
<=
$lastDay
;
$j
++){
193.
194.
$numBook
= isset(
$allReportData
[
$empCode
][
$j
]) ?
'<div>'
.
$allReportData
[
$empCode
][
$j
].
'</div>'
: 0;
195.
196.
echo
"<td class='number'>"
,
$numBook
,
"</td>"
;
197.
198.
}
199.
200.
201.
202.
203.
echo
"<td class='number'>"
,
array_sum
(
$allReportData
),
"</td>"
;
204.
205.
206.
207.
208.
echo
'</tr>'
;
209.
}
210.
echo
"</table>"
;
211.
212.
213.
214.
215.
216.
217.
218.
?>
219.
220.
221.
</div>
222.
</div>
223.
<!-- /.col -->
224.
225.
</section>
226.
<!-- /.content -->
227.
</div>
228.
<!-- ./wrapper -->
229.
</body>
230.
</html>