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

// include the jpgraph files
include ("./src/jpgraph.php");
include ("./src/jpgraph_line.php");

// get the type for the plot
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);

// Create the graph
$gJpgBrandTiming =true; 											//show the time taken to draw the graph on the graph...
$graph = new Graph(650,400,"auto");									// set the size of the graph...
//$graph->SetBackgroundImage('./images/spacer.gif', 2); 				// make the background white! instead of the ugly gray of jpgraph.
$graph->SetScale("textlin"); 										// set the scale
$graph->img ->SetAntiAliasing(); 									// set antialiasing. For improved performance turn off antiAliasing (ugly, but faster)
$graph->legend->SetShadow('hide@address.com',3); 						// draw a shadow under the legend... why not?
$graph->yaxis->scale->SetGrace(5); 									// create some margin on top of the graph
$graph->yaxis->SetTitleMargin(40); 									// make space between the titles and the axi...

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'];
				
			} while ($row_maanden = mysql_fetch_assoc($maanden)); 
			
			$i++;
	
		} while ($i <= 12);

			//add the data to this plot
			$ydata{$comi} = $monthprice;
			
			// create the lineplot
			$lineplot{$comi}=new LinePlot($ydata{$comi});
			
			// show and format the values
			$lineplot{$comi}->value->show();
			$lineplot{$comi}->value->SetFormat('%01.2f');
			$lineplot{$comi}->value->SetColor($t77color[$comi]);
			
			// set the color of the plot
			$lineplot{$comi}->SetColor($t77color[$comi]);
			
			// set the weight of the line
			$lineplot{$comi}->SetWeight(2);
			
			// add it to the graph
			$lineplot{$comi}->SetLegend($row_Companies['company_name']);
			
			// add it to the legend
			$graph->Add($lineplot{$comi}); 
			
		$comi++; 
		
	} while ($row_Companies = mysql_fetch_assoc($Companies)); 

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

// Add the plot to the graph
$graph->img->SetMargin(60,200,20,40);

// set the titles
$graph->title->Set($row_typen['type_description']);
$graph->xaxis->title->Set("months");
$graph->yaxis->title->Set("Total");
$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT2,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD);

//create the legend
$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