<?php
include_once("../jpgraph/src/jpgraph.php");
include_once("../jpgraph/src/jpgraph_pie.php");
//include_once("../jpgraph/src/jpgraph_pie3d.php");
include_once ("../dbconnect.php");
$data = array();
$labels= array();
$sql = "SELECT * , per_name
FROM paymentextra_load
LEFT JOIN personnel ON paymentextra_load.per_id = personnel.per_id
LEFT JOIN position_technical ON personnel.position_idtec = position_technical.position_idtec
LEFT JOIN major ON personnel.major_id = major.major_id
LEFT JOIN sort ON major.sort_id = sort.sort_id
WHERE major.major_id=$ma2 AND paymentextra_load.status=3 AND paymentextra_load.term=$t3 AND paymentextra_load.year=$y3
";
$result = mysql_query($sql) or die("query error 1 ".mysql_error());
$sql1 = "SELECT * , per_name
FROM paymentextra_load
LEFT JOIN personnel ON paymentextra_load.per_id = personnel.per_id
LEFT JOIN position_technical ON personnel.position_idtec = position_technical.position_idtec
LEFT JOIN major ON personnel.major_id = major.major_id
LEFT JOIN sort ON major.sort_id = sort.sort_id
WHERE major.major_id=$ma2 AND paymentextra_load.status=3 AND paymentextra_load.term=$t3 AND paymentextra_load.year=$y3
";
$result1 = mysql_query($sql1) or die("query error 1 ".mysql_error());
$i = 0;
$j = 0;
while($rw = mysql_fetch_array($result)) {
$data[$i]= $rw["net"];
$i++;
}
while($rw1 = mysql_fetch_array($result1)){
$labels[$j] = iconv('TIS-620','UTF-8',$rw1["per_name"]);
$j++;
}
// Create the Pie Graph.
$graph = new PieGraph(650,500);
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set($title);
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->title->SetColor("darkblue");
$graph->legend->Pos(0.1,0.2);
// Create 3D pie plot
$p1 = new PiePlot($data);
$p1->SetTheme("sand");
$p1->SetCenter(0.4);
$p1->SetSize(100);
$p1->ExplodeSlice(3);
$p1->value->SetFont(FF_ANGSA,FS_BOLD,18);
$p1->value->SetColor("navy");
$p1->SetLegends($labels);
$graph->title->Set("กราฟแสดงรายงานยอดเงินค่าสอนพิเศษ แบบ EXTRA-LOAD");
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->Add($p1);
$graph->Stroke();
?>