001.
<?
002.
function
HeaderingExcel(
$filename
) {
003.
header(
"Content-type: application/vnd.ms-excel"
);
004.
header(
'Expires: '
.
gmdate
(
'D, d M Y H:i:s'
) .
' GMT'
);
005.
header(
"Content-Disposition: attachment; filename=$filename"
);
006.
header(
"Cache-Control: must-revalidate, post-check=0,pre-check=0"
);
007.
header(
"Pragma: public"
);
008.
}
009.
function
HeaderingPDF(
$filename
) {
010.
header(
"Content-type: application/pdf"
);
011.
header(
'Expires: '
.
gmdate
(
'D, d M Y H:i:s'
) .
' GMT'
);
012.
header(
"Content-Disposition: attachment; filename=$filename"
);
013.
}
014.
error_reporting
(E_ALL ^ E_NOTICE);
015.
if
(
$exp
==
"XLS"
) {
016.
HeaderingExcel(
"reportmonth.xls"
);
017.
}
018.
if
(
$exp
==
"PDF"
) {
019.
HeaderingPDF(
"reportmonth.pdf"
);
020.
}
021.
?>
022.
<?php
$monthname
=
array
(
"มกราคม"
,
"กุมภาพันธ์"
,
"มีนาคม"
,
"เมษายน"
,
"พฤษภาคม"
,
"มิถุนายน"
,
"กรกฎาคม"
,
"สิงหาคม"
,
"กันยายน"
,
"ตุลาคม"
,
"พฤศจิกายน"
,
"ธันวาคม"
);?>
023.
<?
$day
=
array
(
"วันจันทร์"
,
"วันอังคาร"
,
"วันพุธ"
,
"วันพฤหัส"
,
"วันศุกร์"
,
"วันเสาร์"
,
"วันอาทิตย์"
); ?>
024.
<?
025.
list(
$day1
,
$month1
,
$year1
) = split(
'[/.-]'
,
$daymonthyear1
);
026.
$year1
=
$year1
- 543;
027.
$daymonthyear1
=
"$year1-$month1-$day1"
;
028.
029.
list(
$day2
,
$month2
,
$year2
) = split(
'[/.-]'
,
$daymonthyear2
);
030.
$year2
=
$year2
- 543;
031.
$daymonthyear2
=
"$year2-$month2-$day2"
;
032.
?>
033.
<?php
034.
035.
036.
?>
037.
<HTML>
038.
<HEAD>
039.
<TITLE>reportgroup</TITLE>
040.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=windows-874"
/>
041.
<?
042.
if
(
$exp
==
"HTML"
) {
043.
echo
"<LINK REL='StyleSheet' HREF='../../html/css/style.css' TYPE='text/css'>"
;
044.
}
045.
?>
046.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=windows-874"
>
047.
<style type=
"text/css"
>
048.
<!--
049.
.unnamed1 {
050.
font-family:
"Tahoma"
, Tahoma, sans-serif;
051.
font-size: 12px;
052.
}
053.
-->
054.
</style>
055.
<link href=
"fileinclude/stylesheet.css"
rel=
"stylesheet"
type=
"text/css"
>
056.
<style type=
"text/css"
>
057.
<!--
058.
.style2 {font-family:
"ms Sans Serif"
}
059.
-->
060.
</style>
061.
<link href=
"css.css"
rel=
"stylesheet"
type=
"text/css"
>
062.
<style type=
"text/css"
>
063.
<!--
064.
.style3 {font-size: 12px}
065.
-->
066.
</style>
067.
</HEAD>
068.
<BODY topmargin=
"0"
>
069.
<table width=
"100%"
border=
"0"
cellspacing=
"0"
cellpadding=
"0"
>
070.
<tr> </tr>
071.
</table>
072.
<?
073.
$yearsql
=
$sel1_year
- 543;
074.
075.
?>
076.
<div align=
"center"
class
=
"unnamed1"
>
077.
<span
class
=
"style2"
>
078.
<?
if
(
$month1
==
'1'
) {
$showmonth1
=
'มกราคม'
;}
079.
if
(
$month1
==
'2'
) {
$showmonth1
=
'กุมภาพันธ์'
;}
080.
if
(
$month1
==
'3'
) {
$showmonth1
=
'มีนาคม'
;}
081.
if
(
$month1
==
'4'
) {
$showmonth1
=
'เมษายน'
;}
082.
if
(
$month1
==
'5'
) {
$showmonth1
=
'พฤษภาคม'
;}
083.
if
(
$month1
==
'6'
) {
$showmonth1
=
'มิถุนายน'
;}
084.
if
(
$month1
==
'7'
) {
$showmonth1
=
'กรกฏาคม'
;}
085.
if
(
$month1
==
'8'
) {
$showmonth1
=
'สิงหาคม'
;}
086.
if
(
$month1
==
'9'
) {
$showmonth1
=
'กันยายน'
;}
087.
if
(
$month1
==
'10'
) {
$showmonth1
=
'ตุลาคม'
;}
088.
if
(
$month1
==
'11'
) {
$showmonth1
=
'พฤศจิกายน'
;}
089.
if
(
$month1
==
'12'
) {
$showmonth1
=
'ธันวาคม'
;}
090.
091.
if
(
$month2
==
'1'
) {
$showmonth2
=
'มกราคม'
;}
092.
if
(
$month2
==
'2'
) {
$showmonth2
=
'กุมภาพันธ์'
;}
093.
if
(
$month2
==
'3'
) {
$showmonth2
=
'มีนาคม'
;}
094.
if
(
$month2
==
'4'
) {
$showmonth2
=
'เมษายน'
;}
095.
if
(
$month2
==
'5'
) {
$showmonth2
=
'พฤษภาคม'
;}
096.
if
(
$month2
==
'6'
) {
$showmonth2
=
'มิถุนายน'
;}
097.
if
(
$month2
==
'7'
) {
$showmonth2
=
'กรกฏาคม'
;}
098.
if
(
$month2
==
'8'
) {
$showmonth2
=
'สิงหาคม'
;}
099.
if
(
$month2
==
'9'
) {
$showmonth2
=
'กันยายน'
;}
100.
if
(
$month2
==
'10'
) {
$showmonth2
=
'ตุลาคม'
;}
101.
if
(
$month2
==
'11'
) {
$showmonth2
=
'พฤศจิกายน'
;}
102.
if
(
$month2
==
'12'
) {
$showmonth2
=
'ธันวาคม'
;}
103.
$showyear1
=
$year1
+543;
104.
$showyear2
=
$year2
+543;
105.
?>
106.
</span>
107.
<p
class
=
"unnamed1"
><span
class
=
"style2"
><strong> <br>
108.
<br>
109.
รายงานวิศวกรรมความปลอดภัยและสภาพแวดล้อมในโรงพยาบาล<br><br>
110.
ระหว่างวันที่ <?
echo
"$day1 $showmonth1 $showyear1"
?> ถึงวันที่ <strong><?
echo
"$day2 $showmonth2 $showyear2"
?></strong></strong></span><br>
111.
<br>
112.
<strong><br>
113.
</strong><br>
114.
<table width=
"447"
border=
"1"
cellpadding=
"0"
cellspacing=
"0"
bordercolordark=
"#FFFFFF"
>
115.
<tr bgcolor=
"#FFA4FF"
class
=
"unnamed1"
>
116.
<td width=
"268"
height=
"20"
bgcolor=
"#00CC99"
><div align=
"center"
class
=
"style2"
>ระดับความไม่ปลอดภัย</div></td>
117.
<td width=
"173"
bgcolor=
"#00CC99"
><div align=
"center"
class
=
"style2"
>จำนวนครั้ง</div></td>
118.
<tr bgcolor=
""
class
=
"unnamed1"
>
119.
<?
120.
121.
include
(
"config.php"
);
122.
123.
$sql
="SELECT s1,secur_name ,
count
(s1)
124.
FROM secur_data WHERE
date
BETWEEN
'$daymonthyear1'
AND
'$daymonthyear2'
125.
GROUP BY s1";
126.
127.
128.
$dbquery
= mysql_db_query(
$dbname
,
$sql
);
129.
130.
while
(
$fet
=mysql_fetch_array(
$dbquery
)){
131.
132.
$s1
=
$fet
[
's1'
];
133.
$secur_name
=
$fet
[
'secur_name'
];
134.
135.
?>
136.
<td
class
=
"unnamed1"
><span
class
=
"style2 style3"
><?
echo
"$secur_name"
;?></span></td>
137.
<td
class
=
"unnamed1 style2 style3"
><center><?
echo
"$s1"
;?></center></td>
138.
</tr>
139.
<?
140.
141.
142.
}
143.
144.
?>
145.
<tr
class
=
"unnamed1"
>
146.
</table>
147.
<br>
148.
<br>
149.
<br>
150.
<table width=
"650"
border=
"0"
cellspacing=
"0"
cellpadding=
"0"
>
151.
<tr>
152.
<?php
$monthname
=
array
(
"มกราคม"
,
"กุมภาพันธ์"
,
"มีนาคม"
,
"เมษายน"
,
"พฤษภาคม"
,
"มิถุนายน"
,
"กรกฎาคม"
,
"สิงหาคม"
,
"กันยายน"
,
"ตุลาคม"
,
"พฤศจิกายน"
,
"ธันวาคม"
);?>
153.
<?
$day
=
array
(
"วันจันทร์"
,
"วันอังคาร"
,
"วันพุธ"
,
"วันพฤหัส"
,
"วันศุกร์"
,
"วันเสาร์"
,
"วันอาทิตย์"
); ?>
154.
<td
class
=
"unnamed1"
><div align=
"right"
>วันที่ออกรายงาน : <?
echo
$day
[
date
(
'w'
)-1].
" "
.
date
(
'd'
).
" "
.
$monthname
[
date
(
'n'
)-1].
" "
.(
date
(
'Y'
)+543).
" เวลา "
.
date
(
'H:i:s'
);?></div></td>
155.
</tr>
156.
</table>
157.
</div>
158.
</BODY>
159.
</HTML>