Location: PHPKode > projects > T-77.com Operational Management System > omis/cum_month.php
<?php require_once('Connections/t77_connect.php'); ?>
<?
//error_reporting(E_ALL);

if(!isset($_GET['typeID'])) {

	$type = 3;
	
} else {
	
	$type = $_GET['typeID'];
	
}

$colname_typen = "1";
if (isset($type)) {
  $colname_typen = (get_magic_quotes_gpc()) ? $type : addslashes($type);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_typen = sprintf("SELECT * FROM t77_bill_types WHERE t77_bill_types.bill_type = %s", $colname_typen);
$typen = mysql_query($query_typen, $t77_connect) or die(mysql_error());
$row_typen = mysql_fetch_assoc($typen);
$totalRows_typen = mysql_num_rows($typen);

include("./src/jpgraph.php");
include("./src/jpgraph_line.php");
include( "./src/jpgraph_bar.php"); 

// Create the graph. These two calls are always required
$gJpgBrandTiming =true;
$graph = new Graph(650,400,"auto");	
$graph->SetScale("textlin");
$graph->SetY2Scale("lin" );
$graph->img ->SetAntiAliasing();
//$graph->SetBackgroundImage ('images/spacer.gif', BGIMG_FILLFRAME);
$graph->legend->SetShadow('hide@address.com',3);
$graph->yaxis->scale->SetGrace(20);
$graph->yaxis->SetTitleMargin(40);

mysql_select_db($database_t77_connect, $t77_connect);
$query_Companies = "SELECT * FROM t77_bill_companies";
$Companies = mysql_query($query_Companies, $t77_connect) or die(mysql_error());
$row_Companies = mysql_fetch_assoc($Companies);
$totalRows_Companies = mysql_num_rows($Companies);

$t77color = array("blue","orange","teal","springgreen","red","tomato","steelblue","purple","orchid","navy","maroon","firebrick","deepskyblue","darkolivegreen", "darkorchid","deeppink","gold","greenyellow","hotpink","lightpink","magenta","plum","salmon","yellow","turquoise","aquamarine","beige","black","brown","cadetblue","chartreuse","chocolate","deeppink");
$datax = array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$graph->xaxis->SetTickLabels($datax);

$comi=0;
do {

	$i = 0;
	
	do {

		$datevar = $i;
		$comVar = $row_Companies['company_id'];
		
		$colname4_maanden = date('Y');
		if (isset($_GET['year'])) {
		  $colname4_maanden = (get_magic_quotes_gpc()) ? $_GET['year'] : addslashes($_GET['year']);
		}
		$colname3_maanden = "3";
		if (isset($type)) {
		  $colname3_maanden = (get_magic_quotes_gpc()) ? $type : addslashes($type);
		}
		$colname2_maanden = "1";
		if (isset($comVar)) {
		  $colname2_maanden = (get_magic_quotes_gpc()) ? $comVar : addslashes($comVar);
		}
		$colname_maanden = "1";
		if (isset($datevar)) {
		  $colname_maanden = (get_magic_quotes_gpc()) ? $datevar : addslashes($datevar);
		}
		mysql_select_db($database_t77_connect, $t77_connect);
		$query_maanden = sprintf("SELECT * FROM t77_bill_bills, t77_bill_items, t77_bill_companies, t77_bill_contacts WHERE t77_bill_contacts.contact_id = t77_bill_bills.bill_contact AND t77_bill_contacts.contact_company_name = t77_bill_companies.company_id AND t77_bill_bills.bill_id = t77_bill_items.bill_id AND MONTH( t77_bill_bills.bill_date) = %s AND t77_bill_companies.company_id = %s AND t77_bill_bills.bill_type = %s AND YEAR(t77_bill_bills.bill_date) =%s", $colname_maanden,$colname2_maanden,$colname3_maanden,$colname4_maanden);
		$maanden = mysql_query($query_maanden, $t77_connect) or die(mysql_error());
		$row_maanden = mysql_fetch_assoc($maanden);
		$totalRows_maanden = mysql_num_rows($maanden);

		$monthprice[$i] = 0;
		
			do {
			
				$monthprice[$i] = $monthprice[$i] + $row_maanden['item_price'];
				$stotal[$i] = $monthprice[$i] + $stotal[$i];
				
			} while ($row_maanden = mysql_fetch_assoc($maanden)); 
			
			$total[$i] = $total[$i-1] + $stotal[$i];
			
			$i++;
	
		} while ($i <= 12);

			$ydata{$comi} = $monthprice;
			$bplot{$comi}=new BarPlot($ydata{$comi});
			$bplot{$comi}->SetFillColor($t77color[$comi]);
			$bplot{$comi}->SetLegend($row_Companies['company_name']);
			$bla[$comi] = $bplot{$comi};

		$comi++; 
		
	} while ($row_Companies = mysql_fetch_assoc($Companies)); 

// Create the linear plot
$graph->ygrid->Show(true,true);
$graph->xgrid->Show(true,false);

$gbplot = new AccBarPlot($bla);
$lineplot = new LinePlot($total);
$lineplot->SetColor("red");
$lineplot->SetWeight(2);
$lineplot->SetLegend("cumulative"); 
$lineplot->SetBarCenter();

$graph->Add($gbplot);
$graph->AddY2($lineplot);
$gbplot->value->SetFormat('%01.2f');
$gbplot->value->SetColor('black');
$gbplot->value->SetAngle(90);
$gbplot->value->show();
$graph->y2axis->SetColor("red");
$graph->SetY2OrderBack(false);

// Add the plot to the graph
$graph->img->SetMargin(60,200,20,40);
$graph->title->Set($row_typen['type_description']);
$graph->xaxis->title->Set("months");
$graph->yaxis->title->Set("Total (cumulative)");
$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT2,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD);
$graph->legend->Pos(0.02,0.5,"right","center");
// Display the graph
$graph->Stroke(); 
mysql_free_result($maanden); 
mysql_free_result($Companies);
mysql_free_result($typen);
?>
Return current item: T-77.com Operational Management System