<?php
include("config.php");
define('TTF_DIR',dirname(__FILE__).'/fonts/');
include_once("libraries/jpgraph/src/jpgraph.php");
include_once("libraries/jpgraph/src/jpgraph_bar.php");
include_once("libraries/jpgraph/src/jpgraph_line.php");
include_once("libraries/jpgraph/src/jpgraph_flags.php");
$rpt_sql="select A50 from (Select A50, Case When A50=0 Then 0 Else A1512/A50 End As A51,
MinA15 As A52, MaxA15 As A53, A54, A55,
Case When A50=0 Then 0 Else A55/A50 End As A56,
A57, A58, A59,
Case When A50=0 Then 0 Else A59/A50 End As A60
From (
Select Sum(A12) As A50,
Sum(A15*A12) As A1512,
Min(A15) As MinA15,
Max(A15) As MaxA15,
Sum((A12*A15)/100) As A54,
Sum(A13) As A55,
Min(A13/A12) As A57,
Max(A12/A12) As A58,
Sum(A14) As A59
From acq Where A17>='".$start_date."' and A17<='".$end_date."') As A) as B
";
mysql_query('set names utf8');
$rpt_query=mysql_query($rpt_sql) or die('Error query ['.$rpt_sql.']');
while($rpt_rows= mysql_fetch_array($rpt_query)){
$ydata[]=$rpt_rows["A50"];
$xdata[]=iconv('TIS-620', 'UTF-8', 'ระบบ');
}
$graph=new Graph(1000,900);
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
$graph->SetBackgroundGradient("white","whitesmoke",GRAD_HOR, BGRAD_MARGIN);
$graph->SetShadow();
$graph->SetMargin(200,100,100,300);
$graph->title->Set("กราฟแสดงรายงาน");
$graph->title->SetFont(FF_ANGSA,FS_BOLD,25);
$graph->subtitle->Set("แบบ EXTRA-LOAD");
$graph->subtitle->SetFont(FF_ANGSA,FS_BOLD,25);
$graph->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->xaxis->SetTickLabels($xdata);
$graph->xaxis->SetLabelAngle(45);
$graph->xaxis->SetFont(FF_ANGSA,FS_NORMAL,15);
$graph->SetMarginColor('white');
$graph->SetBackgroundGradient("white","whitesmoke",GRAD_HOR, BGRAD_MARGIN);
$bplot = new BarPlot($ydata);
$bplot->SetFillGradient('white','orchid',GRAD_VERT);
$bplot->SetColor('gainsboro');
$bplot->SetWeight(1);
$bplot->value->Show();
$bplot->value->SetFont(FF_ANGSA,FS_BOLD,15);
$bplot->value->SetAngle(45);
$graph->Add($bplot);
$graph->Stroke();
?>
<?php
include("config.php");
define('TTF_DIR',dirname(__FILE__).'/fonts/');
include_once("libraries/jpgraph/src/jpgraph.php");
include_once("libraries/jpgraph/src/jpgraph_bar.php");
include_once("libraries/jpgraph/src/jpgraph_line.php");
include_once("libraries/jpgraph/src/jpgraph_flags.php");
$rpt_sql="select A50 from (Select A50, Case When A50=0 Then 0 Else A1512/A50 End As A51,
MinA15 As A52, MaxA15 As A53, A54, A55,
Case When A50=0 Then 0 Else A55/A50 End As A56,
A57, A58, A59,
Case When A50=0 Then 0 Else A59/A50 End As A60
From (
Select Sum(A12) As A50,
Sum(A15*A12) As A1512,
Min(A15) As MinA15,
Max(A15) As MaxA15,
Sum((A12*A15)/100) As A54,
Sum(A13) As A55,
Min(A13/A12) As A57,
Max(A12/A12) As A58,
Sum(A14) As A59
From acq Where A17>='2014-01-01' and A17<='2014-10-01') As A) as B
";
mysql_query('set names utf8');
$rpt_query=mysql_query($rpt_sql) or die('Error query ['.$rpt_sql.']');
while($rpt_rows= mysql_fetch_array($rpt_query)){
$ydata[]=$rpt_rows["A50"];
//$xdata[]=iconv('TIS-620', 'UTF-8', $rpt_rows["major_name"]);
$xdata[]=iconv('TIS-620', 'UTF-8', 'aa');
}
$graph=new Graph(1000,900);
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
$graph->SetBackgroundGradient("white","whitesmoke",GRAD_HOR, BGRAD_MARGIN);
$graph->SetShadow();
$graph->SetMargin(200,100,100,300);
$graph->title->Set("กราฟแสดงรายงานยอดเงินค่าสอนพิเศษ");
$graph->title->SetFont(FF_ANGSA,FS_BOLD,25);
$graph->subtitle->Set("แบบ EXTRA-LOAD");
$graph->subtitle->SetFont(FF_ANGSA,FS_BOLD,25);
//$graph->xaxis->title->Set("สาขา");
$graph->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
//$graph->yaxis->title->Set("บาท");
$graph->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->xaxis->SetTickLabels($xdata);
$graph->xaxis->SetLabelAngle(45); // ตรงนี้ทำให้ข้อมูลเป็นแนวเฉียงนะคะ
$graph->xaxis->SetFont(FF_ANGSA,FS_NORMAL,15);
$graph->SetMarginColor('white');
$graph->SetBackgroundGradient("white","whitesmoke",GRAD_HOR, BGRAD_MARGIN);
$bplot = new BarPlot($ydata);
$bplot->SetFillGradient('white','orchid',GRAD_VERT);
$bplot->SetColor('gainsboro');
$bplot->SetWeight(1);
$bplot->value->Show();
$bplot->value->SetFont(FF_ANGSA,FS_BOLD,15);
$bplot->value->SetAngle(45);
$graph->Add($bplot);
$graph->Stroke();
?>
<?php
include ('jpgraph/src/jpgraph.php');
include ("jpgraph/src/jpgraph_bar.php");
include ("jpgraph/src/jpgraph_line.php");
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("Tod");
$strSQL = "SELECT * FROM Tspc";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");