01.
<?php
02.
include
(
"config.php"
);
03.
include
(
".../jpgraph/jpgraph.php"
);
04.
include
(
".../jpgraph/jpgraph_bar.php"
);
05.
06.
$m
=
$_POST
[
'month'
];
07.
$y
=
$_POST
[
'year'
]-(543);
08.
$arr
=
array
(
"มกราคม-ธันวาคม"
,
"มกราคม"
,
"กุมภาพันธ์"
,
"มีนาคม"
,
"เมษายน"
,
"พฤษภาคม"
,
"มิถุนายน"
,
"กรกฎาคม"
,
"สิงหาคม"
,
"กันยายน"
,
"ตุลาคม"
,
09.
"พฤศจิกายน"
,
"ธันวาคม"
);
10.
11.
12.
13.
14.
if
(
$m
==0)
15.
{
16.
$strSQL
= "SELECT o.ot_code
as
ot_code,
Count
(t.ot_id)
as
count_ot_id FROM patient AS t INNER JOIN ot AS o ON o.ot_id = t.ot_id
17.
WHERE MONTH(pat_date) =
$m
OR YEAR(pat_date) =
$y
GROUP BY o.ot_code";
18.
}
else
{
19.
$strSQL
= "SELECT o.ot_code
as
ot_code,
Count
(t.ot_id)
as
count_ot_id FROM patient AS t INNER JOIN ot AS o ON o.ot_id = t.ot_id
20.
WHERE MONTH(pat_date) =
$m
AND YEAR(pat_date) =
$y
GROUP BY o.ot_code";
21.
}
22.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
23.
24.
25.
26.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
27.
{
28.
$datay
[] =
$objResult
[
"count_ot_id"
];
29.
$datax
[] =
$objResult
[
"ot_code"
];
30.
}
31.
32.
33.
$graph
=
new
Graph(600,400,
'auto'
);
34.
$graph
->SetScale(
"textlin"
);
35.
$graph
->SetMarginColor(
'navy:1.9'
);
36.
$graph
->SetBox();
37.
$graph
->SetMargin(60,50,0,80);
38.
39.
40.
$txt
=
new
Text(
'เดือน '
.
$arr
[
$m
].
' ปี '
.((int)
$y
+543));
41.
$txt
->SetPos(220,360);
42.
$txt
->SetColor(
'#000000'
);
43.
$txt
->SetFont(FF_ANGSA,FS_BOLD,15);
44.
$txt
->SetBox(
'yellow'
,
'navy'
,
'#E8E8E8@0.5'
);
45.
$graph
->AddText(
$txt
);
46.
47.
48.
$graph
->title->Set(
'กราฟแสดงจำนวนผู้ป่วยต่อนักกิจกรรมบำบัด'
);
49.
$graph
->xaxis->title->Set(
'OT'
);
50.
$graph
->yaxis->title->Set(
'จำนวนผู้ป่วย'
);
51.
$graph
->ygrid->SetFill(true,
'#ffffff@0.5'
,
'#E8E8E8@0.5'
);
52.
53.
54.
55.
$graph
->title->SetFont(FF_ANGSA,FS_BOLD,16);
56.
$graph
->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,16);
57.
$graph
->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,16);
58.
59.
$graph
->title->Set(
'กราฟแสดงจำนวนผู้ป่วยต่อนักกิจกรรมบำบัด'
);
60.
$graph
->title->SetFont(FF_ANGSA,FS_BOLD,18);
61.
62.
$graph
->SetTitleBackground(
'lightblue:1.3'
,TITLEBKG_STYLE2,TITLEBKG_FRAME_BEVEL);
63.
$graph
->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,
'lightblue'
,
'blue'
);
64.
65.
66.
$bplot
=
new
BarPlot(
$datay
);
67.
$bplot
->SetFillColor(
'#ff9900'
);
68.
$bplot
->SetWidth(0.6);
69.
70.
$bplot
->SetPattern(PATTERN_CROSS1,
'navy'
);
71.
$graph
->Add(
$bplot
);
72.
$graph
->Stroke();
73.
74.
?>