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