Location: PHPKode > projects > Opensheet > opensheet/graph.php
<?php
/*
 * Created on 06.07.2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 			graph.php
 **/
ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();


include ('start.php'); ## считаем время на генерацию страницы
include ("include/auth_chk.inc.php");
include("pChart/pData.class");
include("pChart/pChart.class");

require ('functions/base.functions.php');
require ('functions/financial.inc.php');
set_lang($_SESSION['lang']);

$year = isset($_GET[year])? $_GET['year'] : $_GET['year'];
$month =  date(n);
#require ('functions/financial.inc.php');
#require ('functions/draw.time.table.inc.php');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OpenSheet 0.3</title>
<link href="css/style.reports.inc.css" rel="stylesheet" type="text/css">
</head>
<body>
<table class="main" border="0">

	
	<table class="reports_header" border="0" cellpadding="0" cellspacing="0">
  		<tr>
          <td class="timesheet_link" scope="col"><A HREF="reports.php?year=<?php echo $year; ?>&month=<?php echo $month; ?>"><?php echo gettext('Company report'); ?></A></td>
          <td class="month_switch" scope="col">
       	  <form action="" method="GET" >
                     <input type="hidden" name="year" value=" <?php echo $year-1;  ?>">
                    <input type="submit" value="Prev Year" />
					 </form>          
       	</td>
         <td class="month_switch" scope="col">
 						<form action="" method="GET" >
                     <input type="hidden" name="year" value=" <?php echo $year+1;  ?>">
                   <input type="submit" value="Next Year" />
					 </form>         
  				</td>

	

          
          <td class="reports_header_block"  scope="col"><?php echo $year; ?></td>
          <td class="timesheet_link" scope="col"><A HREF="timesheet.php?year=<?php echo $year; ?>&month=<?php echo $month; ?>">Timesheet</A></td>
          <td class="reports_setup" scope="col"></td>
          <td class="reports_exit" scope="col"><A HREF="logout.php"><?php echo gettext('exit'); ?></A></td>
              </tr>
     
	</table>


<?php 





#echo "<div>";
#include('include/page.reports.table.menu.inc.html');
#echo "</div>";

$stats = get_br_and_ftee($year);
#echo HI;
 $DataSet = new pData;
 $DataSet->AddPoint(array(round($stats['0']['proj_hours'],2),round($stats['0']['office_hours'],2),get_sum_project_year(idle_hour,$year),get_sum_project_year(vacation,$year),get_sum_project_year(illness,$year),get_sum_project_year(paid_abs,$year),get_sum_project_year(unpaid_abs,$year)),"Serie1");
 $DataSet->AddPoint(array("проекты","внутренние проекты","часы простоя","отпуск","болезнь","оплаченные предоставленные дни","неоплаченные предоставленные дни"),"Serie2");
 $DataSet->AddAllSeries();
 $DataSet->SetAbsciseLabelSerie("Serie2");

 $Test = new pChart(535,200);
 $Test->drawFilledRoundedRectangle(7,7,373,193,5,240,240,240);

 // Draw the pie chart
 $Test->setFontProperties("fonts/tahoma.ttf",8);
 $Test->drawTitle(50,190,"Статистика за ".$year." год" ,50,50,50,260);
 $Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,90,110,TRUE,TRUE,50,20,5);
 $Test->drawPieLegend(310,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);
 $Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,90,110,PIE_PERCENTAGE,TRUE,50,20,5);
 $Test->Render("cache/full_stat".$year.".png");

 $DataSet = new pData;
$DataSet->AddPoint(array($stats[1]['FTEE'],$stats[2]['FTEE'],$stats[3]['FTEE'],$stats[4]['FTEE'],$stats[5]['FTEE'],$stats[6]['FTEE'],$stats[7]['FTEE'],$stats[8]['FTEE'],$stats[9]['FTEE'],$stats[10]['FTEE'],$stats[11]['FTEE'],$stats[12]['FTEE']),"Serie1");
# $DataSet->AddPoint(array(0,$stats[1]['BR'],$stats[2]['BR'],$stats[3]['BR'],$stats[4]['BR'],$stats[5]['BR'],$stats[6]['BR'],$stats[7]['BR'],$stats[8]['BR'],$stats[9]['BR'],$stats[10]['BR'],$stats[11]['BR'],$stats[12]['BR']),"Serie2");
$DataSet->AddPoint(array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),"Serie4");  
$DataSet->AddAllSeries();
#print_r ($DataSet);exit;
$DataSet->SetAbsciseLabelSerie("Serie4");   
#$DataSet->SetAbsciseLabelSerie();
 $DataSet->SetSerieName("FTEE","Serie1");

// Initialise the graph
 $Test = new pChart(700,230);
 $Test->setFixedScale(0,1);  
 $Test->setFontProperties("fonts/tahoma.ttf",8);
 $Test->setGraphArea(50,30,585,200);
 $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
 $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
 $Test->drawGraphArea(255,255,255,TRUE);
 $Test->setColorPalette(0,255,79,39);
 $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);
 $Test->drawGrid(5,TRUE,230,230,230,150);
# $Test->drawGraphArea(213,217,221,FALSE);  

 // Draw the 0 line
 $Test->setFontProperties("fonts/tahoma.ttf",6);
 $Test->drawTreshold(0,143,55,72,TRUE,TRUE);

 // Draw the bar graph
$DataSet->RemoveSerie("Serie4"); 
 $Test->drawOverlayBarGraph($DataSet->GetData(),$DataSet->GetDataDescription());

 // Finish the graph
 $Test->setFontProperties("fonts/tahoma.ttf",8);
 $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);
 $Test->setFontProperties("fonts/tahoma.ttf",10);
 $Test->drawTitle(50,22,"Статистика за ".$year." год",50,50,50,585);
 $Test->Render("cache/ftee_stat".$year.".png");



 $DataSet = new pData;
$DataSet->AddPoint(array($stats[1]['BR'],$stats[2]['BR'],$stats[3]['BR'],$stats[4]['BR'],$stats[5]['BR'],$stats[6]['BR'],$stats[7]['BR'],$stats[8]['BR'],$stats[9]['BR'],$stats[10]['BR'],$stats[11]['BR'],$stats[12]['BR']),"Serie1");
$DataSet->AddPoint(array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),"Serie4");  
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie4");   
$DataSet->SetSerieName("BR","Serie1");


// Initialise the graph
 $Test = new pChart(700,230);
 #$Test->drawGraphAreaGradient(132,153,172,50,TARGET_BACKGROUND); 
 $Test->setFixedScale(0,50);  
 $Test->setColorPalette(0,255,0,0);   
 $Test->setFontProperties("fonts/tahoma.ttf",8);
 $Test->setGraphArea(50,30,585,200);

 $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
 $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
 #$Test->drawGraphArea(255,255,255,TRUE);
 $Test->drawGraphArea(213,217,221,FALSE);  
 $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);
 $Test->drawGrid(4,TRUE,230,230,230,50);

 // Draw the 0 line
 $Test->setFontProperties("fonts/tahoma.ttf",6);
 $Test->drawTreshold(0,143,55,72,TRUE,TRUE);

 // Draw the bar graph
$DataSet->RemoveSerie("Serie4"); 
 $Test->drawOverlayBarGraph($DataSet->GetData(),$DataSet->GetDataDescription());

 // Finish the graph
 $Test->setFontProperties("fonts/tahoma.ttf",8);
 $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);
 $Test->setFontProperties("fonts/tahoma.ttf",10);
 $Test->drawTitle(50,22,"Статистика за ".$year." год",50,50,50,585);
 $Test->Render("cache/br_stat".$year.".png");





#include ('end.php');


?>



   <div style="width: 80%; height: 200px;">
<img src="cache/full_stat<?php echo $year; ?>.png" >
</div>


<div style="width: 80%; height: 200px;">
<img src="cache/br_stat<?php echo $year; ?>.png" >
<img src="cache/ftee_stat<?php echo $year; ?>.png" >
</div>


Return current item: Opensheet