Jump to content

Graph iterations


hitherescotty

Recommended Posts

I posted this on the JPGraph forums, but I don't think anyone actually reads those.  Plus, I think this might be an issue with straight PHP more than JPGraph:

 

Hi!  I have an array of accounts.  For each account I am generating information for a graph.  When I generate a graph for an array with just one account, things are fine.  When I generate  with an array that has two or more accounts, I get all of the graphs I should, but they all look the same - they are all the graph for the last account.  Because I'm iterating, it calls the following each time:

Code:

 

echo "<img src=\"graph.php\">"

 

 

but with different data (EDIT: graph.php relies on $_SESSION variables) each iteration.  I thought the returned graph would be different for each.  I'm guessing all of the graphs are updated each iteration rather than just spitting out to the browser and remaining static so the next one can do its job.  Any way of changing this so each iteration produces a graph but doesnt change those before it?  Maybe I'm doing something wrong?

 

I am NOT using cache.

 

When writing to file (like "graph_".$account.".png") it only writes ONE file, and that's the last account!  It's like it completely ignores the early ones!

Link to comment
Share on other sites

It is 1000 lines, and kind of sensitive code, so I'm trimming considerably. 

 

 

  <?php
    // Report all errors except E_NOTICE
error_reporting(E_ALL ^ E_NOTICE);
  	session_start();

if(!$_SESSION['graphWidth'] || !$_SESSION['graphHeight'])
{
	//echo "HI!"; 
	$_SESSION['graphWidth'] = 500;
	$_SESSION['graphHeight'] = 375;	
}

if ($_POST['Default'])
{
	$_SESSION['graphWidth'] = 500;
	$_SESSION['graphHeight'] = 375;		
}

if ($_POST['Increase'])
{
	$_SESSION['graphWidth'] = $_SESSION['graphWidth']*1.25;
	$_SESSION['graphHeight'] = $_SESSION['graphHeight']*1.25;
}

if ($_POST['Decrease'])
{
	$_SESSION['graphWidth'] = $_SESSION['graphWidth']*.8;
	$_SESSION['graphHeight'] = $_SESSION['graphHeight']*.8;
}

if ($_POST['ExportgD'])
{
	$exportgD = 1;
}

include "connect.php";


$buildingsID = $_SESSION['buildingsID'];

$sql = mysql_query("SELECT * FROM buildings WHERE buildingsID = '$buildingsID'");
$num_rows = mysql_num_rows($sql); //validate again	
echo "Current information for building $buildingsID:";

while($row = mysql_fetch_array( $sql ))			
{
	echo "not important"
}


//omitted


//foreach account create a gBill table 
foreach ($arr_accounts as $value) {
	echo "<br/><br/>";
	echo "Account $value:<br/>";

	//unset($arr_accounts);


	//arrays of data
	$arr_num = array();
	$arr_endDate = array();
	$arr_startDate = array();
	$arr_startDateStripped = array();
	$arr_billedDays = array();
	$arr_hdd = array();
	$arr_therms = array();
	$arr_dailyBaseload = array();
	$arr_billBaseload = array();
	$arr_isBaseload = array();
	$arr_heat = array();
	$arr_heatOverHdd = array();
	$arr_cost = array();
	$arr_costPerTherm = array();

	//array of arrays
	$arr_temps= array();		
	$arr_temps_full_years = array();	

	$total_hdd = 0;

	$query1 = "SELECT * FROM `gin` WHERE accountsID = '$value'";
	$sql1 = mysql_query($query1);

	$i = 0;
	while($row = mysql_fetch_assoc($sql1))
			{


				//LOTS OF CALCULATIONS WERE DONE IN HERE











				//END




	echo "<table border=1 cellpadding=3 cellspacing=0 width=50%><th colspan=3><b>Export Data as CSV</b></th><tr><td ><center>";



	$f1 = fopen("downloads/".$value."_gBill.csv", 'w');
	fclose($f1);
	unlink('downloads/'.$value.'_gBill.csv');

	$f1 = fopen('downloads/'.$value.'_gBill.csv', 'w');
	$count_arr_mon = count($arr_num);
	for ($y = 0; $y < $count_arr_mon; $y++)
	{
		fwrite($f1, $arr_startDate[$y]->format("Y-m-d").",".$arr_endDate[$y]->format("Y-m-d").",".$arr_billedDays[$y].",".$arr_hdd[$y].",".$arr_therms[$y].",".$arr_dailyBaseload[$y].",".$arr_billBaseload[$y].",".$arr_heat[$y].",".$arr_heatOverHdd[$y].",".$arr_cost[$y].",".$arr_costPerTherm[$y].",".$arr_isBaseload[$y]."\n");

	} unset($y);
	fclose($f1);

	echo "<font color=green size=medium>Successfu	lly exported bill data to ".$value."_gBill.csv.<br/></font>";
	echo "<a href=\"/downloads/".$value."_gBill.csv\">Download Bill Data as CSV.</a>";

	echo "</center></td>";


	/////////////////



	echo "<td><center>";

	$f2 = fopen("downloads/".$value."_gD.csv", 'w');
	fclose($f2);
	unlink('downloads/'.$value.'_gD.csv');

	$f2 = fopen('downloads/'.$value.'_gD.csv', 'w');
	$count_arr_temps = count($arr_temps);
	for ($r = 0; $r < $count_arr_temps; $r++)
	{
		$gluedgd = implode(",",$arr_temps[$r]);
		fwrite($f2, $gluedgd);
		fwrite($f2, "\n");
	} unset($r);
	fclose($f2);

	echo "<font color=green size=medium>Successfully exported daily data to ".$value."_gD.csv.<br/></font>";
	echo "<a href=\"/downloads/".$value."_gD.csv\">Download Daily Data as CSV.</a>";


	//send g365 to CSV file



	echo "<td><center>";

	$f3 = fopen("downloads/".$value."_365.csv", 'w');
	fclose($f3);
	unlink('downloads/'.$value.'_365.csv');

	$f3 = fopen('downloads/'.$value.'_365.csv', 'w');
	$count_arr_temps = count($arr_temps);
	for ($z = $count_arr_temps - 365; $z < $count_arr_temps; $z++)
	{
		$glued365 = implode(",",$arr_temps[$z]);
		fwrite($f3, $glued365);
		fwrite($f3, "\n");
	} unset($z);
	fclose($f3);

	echo "<font color=green size=medium>Successfully exported daily data to ".$value."_365.csv.<br/></font>";
	echo "<a href=\"/downloads/".$value."_365.csv\">Download One Full Year Data as CSV.</a>";


	echo "</center></td></tr></table><br/><br/><br/>";





	//begin graph stuff

	//sessions data for the graphs
	foreach($arr_startDate as $tempTimedate)
	{
		$arr_startDateStripped[] = $tempTimedate->format('m/d/y');			

	}		
	unset($tempTimedate);
	$_SESSION['startDate'] = $arr_startDateStripped;	

	$_SESSION['hdd'] = $arr_hdd;
	$_SESSION['therms'] = $arr_therms;

	$_SESSION['averageBaseload'] = $averageBaseload;



	//makes sure it begins on the first of a month
	if (date('d',strtotime($arr_temps[0]['date'])) == 1)
	{		
		$gDstartingPosition = 0;
	} else {
		$gDstartingPosition = date('t', strtotime($arr_temps[0]['date'])) - date('d',strtotime($arr_temps[0]['date'])) + 1;			
	}

	//makes sure it ends on the last of a month
	$count_arr_temps = count($arr_temps) - 1;

	if (date('d',strtotime($arr_temps[$count_arr_temps]['date'])) == date('t', strtotime($arr_temps[$count_arr_temps]['date'])))
	{		
		$gDendingPosition = $count_arr_temps;
	} else {
		$gDendingPosition = $count_arr_temps - date('d',strtotime($arr_temps[$count_arr_temps]['date']));			
	}

	echo "<br/>";
	for($t = $gDstartingPosition; $t < $gDendingPosition; $t++)
	{
		$arr_temps[$t]['date'] = date(U,strtotime($arr_temps[$t]['date']));
		$arr_temps_full_year[] = $arr_temps[$t];
	}
	unset($t);

	$_SESSION['arr_temps_full_year']=$arr_temps_full_year;




	//echo date('Y-m-d', $arr_temps_full_year[0]['date'])."<br/>";
	//probably dont need these but whatever
	$startingYearMonth;
	$arr_temps_by_month = array();	 //starts variable outside for loop
	$temp_averageDailyUsage;	//starts variable outside for loop
	$temp_daysInMonth;		//starts variable outside for loop


	// shouldnt need this $startingYearMonth = date(Ym, $arr_temps_full_year[0]['date']);  //sets starting month for for loop below




	for ($u = 0; $u <= count($arr_temps_full_year); )
	{	
		if (!$startingYearMonth) //new procedure!
		{
			$startingYearMonth = date('m/01/Y', $arr_temps_full_year[$u]['date']);
			$temp_daysInMonth = 1;
			$temp_averageDailyUsage = 0;
			//echo "nope <br/>";

		}elseif ($startingYearMonth != date('m/01/Y', $arr_temps_full_year[$u]['date'])) { //newly encountered month!
			$arr_daily1 = array(); //make temp array for storing 2d
			$arr_daily1['startingYear'] = date('Y', strtotime($startingYearMonth));
			$arr_daily1['startingYearMonth'] = date('M-y', strtotime($startingYearMonth)); 
			$arr_daily1['startingFullDate'] = date('U', strtotime($startingYearMonth));
			$arr_daily1['monthUsage'] = $temp_averageDailyUsage;
			$arr_daily1['daysInMonth'] = ($temp_daysInMonth-1);
			$arr_temps_by_month[] = $arr_daily1; //since all the pieces are in this temp array, save this temp array to the parent of the 2d structure.
			unset($arr_daily1);	//destroy the temp array

			$temp_daysInMonth = 1;
			$temp_averageDailyUsage = 0;
			$startingYearMonth = date('m/01/Y', $arr_temps_full_year[$u]['date']);	

		}else{ //is in the current month!				
			$temp_averageDailyUsage+=$arr_temps_full_year[$u]['heating'];
			$temp_daysInMonth++;
			$u++;
		}

	}unset($u);

	$_SESSION['arr_temps_by_month'] = $arr_temps_by_month;
	$_SESSION['account'] = $value;


	echo "<table width = 90% border=0 cellpadding=3 cellspacing = 0>";

	//first graph goes here
	echo "<tr>";
	echo "<td><center><img src=\"datevsusagehdd.php?".microtime()."\"><br/>";
	//enlarge/decrease buttons
	echo "<form method=\"post\" action=\"analysis.php\">";
		echo "<input type=\"submit\" name=\"Decrease\" value=\"Decrease Size\" /> ";
		echo "<input type=\"submit\" name=\"Default\" value=\"Default Size\" />";
		echo "<input type=\"submit\" name=\"Increase\" value=\"Increase Size\" />";									
	echo "</form>";
	echo "<br/><center></td>";

	///////next graph////////////
	echo "<td><center><img src=\"averagedailyusage.php?".microtime()."\"><br/>";
	//enlarge/decrease buttons
	echo "<form method=\"post\" action=\"analysis.php\">";
		echo "<input type=\"submit\" name=\"Decrease\" value=\"Decrease Size\" /> ";
		echo "<input type=\"submit\" name=\"Default\" value=\"Default Size\" />";
		echo "<input type=\"submit\" name=\"Increase\" value=\"Increase Size\" />";									
	echo "</form>";
	echo "<br/></center></td>";	

/*		echo "</tr>";
	////new line////////


	//first graph goes here
	echo "<tr>";*/
	echo "<td><center><img src=\"testgraphs.php?".microtime()."\"><br/>";
	//enlarge/decrease buttons
	echo "<form method=\"post\" action=\"analysis.php\">";
		echo "<input type=\"submit\" name=\"Decrease\" value=\"Decrease Size\" /> ";
		echo "<input type=\"submit\" name=\"Default\" value=\"Default Size\" />";
		echo "<input type=\"submit\" name=\"Increase\" value=\"Increase Size\" />";									
	echo "</form>";
	echo "<br/><center></td>";

	///////next graph////////////
	echo "</tr>";
	////new line////////


	echo "</center></table>";
	//end graph stuff		





//save variables and release them!  THIS IS THE LAST STAGE!  DONT PUT ANYTHING BENEATH THIS
	unset($arr_num);
	unset($arr_billedDays);
	unset($arr_endDate);
	unset($arr_startDate);
	unset($arr_cost);
	unset($arr_hdd);
	unset($arr_therms);
	unset($arr_costPerTherm);
	unset($arr_dailyBaseload);
	unset($arr_isBaseload);
	unset($arr_temps);
	unset($arr_startDateStripped);
	unset($arr_temps_full_year);
	unset($arr_temps_by_month);




}

?>

 

You notice those CSV exports in the middle - those work CORRECTLY for each account, so there's no reason the graphs shouldnt.

 

Link to comment
Share on other sites

The session data IS changing each iteration, but if JPGraph is computed after the HTML is, the graphs will only use the FINAL values.  So I guess it's a question of computation order.

 

What I essentially do, is wipe clean all variables after each iteration.  So trust me, that's not the problem.

Link to comment
Share on other sites

Hi There hitherescotty,

 

I use JPGraph, and handle iterations like this:

 

If you need more details, or have questions, contact me at: ScotDiddle 'at' webtdo 'dot' com

 

Scot L. Diddle, Richmond VA

 


<?php

	/**
	 * 
	 *  Partial contents of company_name_goes_hereGenerateGraph.php follows:
	 * 
	 *  	Requested SysID from previous user input Panels
	 * 
	 */


	foreach ($requestedSysIDs as $graphSysID) {

		$graph = new Graph();

		$_SESSION['currentGraphCounter'] = '00' . ++$currentGraphCount;

		$functionLine = __LINE__;

		switch($graphSysID) {

			case 'XYZ1' :
			case 'XYZ2' :
			case 'XYZ3' :
			case 'XYZ4' :
			case 'XYZ5' :
			case 'XYZ6' :
			case 'XYZ7' :

				$LPAR = 'LPAR1';

			break;

			case 'XYZ1' :
			case 'XYZ' :

				$LPAR = 'LPAR2';

			break;

			default :

				echo "Error on LPAR Selection in company_name_goes_hereGenerateGraph.php on line $functionLine";

				exit;

			break;
		}

		$metric = $graphSysID;

		$tableAlias = strtolower($tableAlias);

		$graph->generateGraph($db,$LPAR,$dateType,$metric,$tableDateOut,$tableName,$tableAlias,$calendarUnit,$calendarValue,$sortOrder);

		// returns: $_SESSION['sparklineDisplay']

		echo "</body> \n";

		echo "</html> \n";

		$graphFile = $_SESSION['graph'][$metric];

		$graphFileName  = $_SESSION['HTMLFileName'];

		$functionLine = __LINE__ + 2;

		$fh = fopen ("$graphFileName", "w");

		if (!$fh) {

			echo "Error opening $graphFileName for write in program UpgrGenerateGraph.php on line $functionLine <br /> <br />";
			exit;

		}
		else {

			$functionLine2 = __LINE__ + 2;

	    	$writeResults = fwrite($fh, $graphFile);

	    	if (!$writeResults) {

	    		echo "Error Writing $graphFileName in program UpgrGenerateGraph.php on line $functionLine2 <br /> <br />";
				exit;

	    	}

	    	fclose($fh);

	    }


	} // END foreach ($requestedSysIDs as $graphSysID) {


	/**
	 * 
	 *  Where the Graph class is defined here: 
	 * 
	 */

// END: company_name_goes_hereGenerateGraph.php


/**
 *  Generates JPGraph Image from users selected metrics criteria
 *
 *  Called from: production/company_name_goes_hereGenerateGraph.php
 *
 */

class Graph
{
    PUBLIC $dbConnect;        // Instantiation
    PUBLIC $OracleInstance;   // Instantiation Rose
    PUBLIC $currentClass;     // Class Name

    PUBLIC $graphDB;		  // Which Major Metric
    PUBLIC $dateType;		  // Single Date, or Date Range
    PUBLIC $graphSysID;		  // Sub-system ID
    PUBLIC $graphTable;		  // Table of Interest
    PUBLIC $graphAlias;       // transaction_by_count

    PUBLIC $queryRC;		  // Like the sign says...

    PUBLIC $SQLDateToConvert; // $SQLDate;
	PUBLIC $timestamp;        // UNIX EPOCH DATE, created from  $SQLDate

	PUBLIC $selectDate;       // SQL Select Date for User Selection in Unix Timestamp format
	PUBLIC $minDate;          // Starting Date for User Selection in Unix Timestamp format
	PUBLIC $maxDate;          // Ending   Date for User Selection in Unix Timestamp format

	PUBLIC $calendarUnit;     // 'Month' or 'Year'
	PUBLIC $calendarValue;    // 'Sep' | 'Oct' ... etc... OR '2007' | '2008' etc...

	PUBLIC $yearDate;		  // TRUE or False, depending on whether or not the incoming date is an INT
        PUBLIC $specificMonth;    // TRUE or False, depending on whether or not the incoming Calendar Unit ==
        						  //                'Month'
        PUBLIC $specificYear ;    // TRUE or False, depending on whether or not the incoming Calendar Unit ==
        						  //                'Year'

	PUBLIC $dbRows = array(); // Holds the results of the $mode = 'Row' query...

	PUBLIC $sortOrder;        // Default ( or user-selected ) sort order...

	PUBLIC $PDFImage;         // Holds the PDF image.
	PUBLIC $PDFFileName;      // Holds the Name of the PDF Output file.
	PUBLIC $XMLFileName;      // Holds the Name of the XML Output file.
	PUBLIC $ExcelFileName;    // Holds the Name of the Excel Output file.
	PUBLIC $HTMLFileName;     // Holds the Name of the HTML  Output file.

	PUBLIC $imageAddress;     // Holds the Name of the IP, and Port for images on HTML Graph Window content
	PUBLIC $c1;				  // Corner of PDF Image in header
	PUBLIC $c2;				  //           Ditto
	PUBLIC $h;				  // Height of PDF Image in header

    function __construct() {

		require_once('include/debugFunctions.php');
    	require('include/determineCallingProgram.php');

    	$this->className = __CLASS__;

    	require_once("include/jpgraph.php");
		require_once("include/jpgraph_line.php");
		require_once("include/jpgraph_date.php");
		require_once("include/jpgraph_plotband.php");
		require_once("include/jpgraph_bar.php");
		require_once("include/jpgraph_log.php");
		require_once("include//jpgraph_regstat.php");

		require_once("include/writeFile.php");

		$reportDate = Array();
		$reportTime = Array();

		require_once('classes/Oracle.class.php');

		//  Oracle Connect setup in  production/company_name_goes_hereMetricsDateSelect.php

		$user     = 'xxxx';
		$password = 'xxxx';
		$OCIID    = 'xxxx'; // Correct Value = xxxx

		$this->OracleInstance = new Oracle($connectArray);

		$_SESSION['dbc'] = $this->OracleInstance;

		// Set debug mode for more information about query.
		$this->OracleInstance->Debug = 0;

		unset($_POST);

		error_reporting(E_ALL ^ E_NOTICE);

		set_time_limit(0);

		// pae Print Array, Then Exit

		$serverAddress = $_SERVER['SERVER_ADDR'];
		$serverPort    = $_SERVER['SERVER_PORT'];

		$this->imageAddress  = $serverAddress . ':' . $serverPort;

    }

    function getTimeRangeForSelectedMetric($db,$LPAR,$dateType,$metric,$tableDate,$tableName,$tableAlias,$calendarUnit,$calendarValue,$sortOrder) {

    	require('include/assignIncomingParmValues.php');

    		$this->selectDate = $this->graphDate;
    		$this->selectDate = $this->dateToTimestamp($this->selectDate);

    		$tableAlias = strtolower($tableAlias);

    		switch($tableAlias) {

			case 'tran_count_by_date' :

    				$this->sql = "select distinct min(RECORDTIME) from db_prefix." . $this->graphTable . " where (EPOCHDATE = " . $this->selectDate . ")  AND (SYSID='" . $this->graphSysID . "') AND (RECORDTYPE='R')";

			break;


			case 'transactions_by_count' :

    				$this->sql = "select distinct min(RECORDTIME) from db_prefix." . $this->graphTable . " where (EPOCHDATE = " . $this->selectDate . ")  AND (SYSID='" . $this->graphSysID . "') AND (RECORDTYPE='R')";

			break;

		}


            $mode = 'Column';

       	    $this->queryResult = $_SESSION['dbc']->query($this->sql, $mode);

       	    // Check the return code for error messages...

       	    $this->queryRC = $_SESSION['dbc']->setQueryRC($this->queryResult);

       	    if (!$this->queryRC) {
			require('include/SQLMethodErrorDisplay.php');
       	    }

    		$MinTime = array();

   			 foreach($this->dbRows as $transactionRecord) {

			$transactionLineOut[] =  $transactionRecord;

			// printArray($transactionLineOut);

			// echo $transactionLineOut  . "<br /> <br /> \n";

	    }

//		   exit;


    }

    function generateGraph($db,$LPAR,$dateType,$metric,$tableDate,$tableName,$tableAlias,$calendarUnit,$calendarValue,$sortOrder) {

		require('include/assignIncomingParmValues.php');

        	$selectType = 'EOPCHDATE'; // Default

        	if ($this->dateType == 'DateSingle') {

	    	if ($selectType == 'EOPCHDATE') {

	    		$this->selectDate = $this->graphDate;
	    		$this->selectDate = $this->dateToTimestamp($this->selectDate);

	    		$this->sql = "select * from db_prefix." . $this->graphTable . " where (EPOCHDATE = " . $this->selectDate . ")  AND (SYSID='" . $this->graphSysID . "') AND (RECORDTYPE='R')";

	    	}

	    	if ($selectType == 'Month') {

	    		$this->selectDate = $this->graphDate;

	    		$this->sql = "select * from db_prefix." . $this->graphTable . " where (REPORTMONTH = '" . $this->calendarValue . "')  AND (REPORTYEAR='" . $this->metricDate . "') AND (SYSID='" . $this->graphSysID . "') AND (RECORDTYPE='R')";

	    	}

	    	if ($selectType == 'Year') {

	    		// $this->selectDate = $this->graphDate;

	    		// $this->sql = "select * from db_prefix." . $this->graphTable . " where (REPORTMONTH = " . $this->calendarUnit . ")  AND (REPORTYEAR='" . $this->metricDate . "')";

	    	}

	    	if ($selectType == 'Weekday') {

	    		// $this->selectDate = $this->graphDate;

	    		// $this->sql = "select * from db_prefix." . $this->graphTable . " where (REPORTMONTH = " . $this->calendarUnit . ")  AND (REPORTYEAR='" . $this->metricDate . "')";

	    	}

	    	/**
	    	 *
	    	 *  $metricDir Value is common for all graphs
	    	 *
	    	 */

	    	$arrayOfTableAlias = array(

										'tran_count_by_date',
										'tran_count_by_date_range',
										'tran_count_by_hour',
										'tran_count_by_month',
										'tran_count_by_week_day',
										'tran_count_by_year',
										'transactions_by_count',
										'transactions_by_response_time'

									  );

		    /**
			 *
			 *  Metric Directory Definitions
			 *
			 */

	    	$metricDir             = 'company_name_goes_hereData/ISMetrics/MetricGraphs/' . $this->graphDB . '/' . $this->graphLPAR  . '/';
	    	$_SESSION['metricDir'] = $metricDir;
	    	$_SESSION['PDFDir']    = 'company_name_goes_hereData/PDF/'   . $this->graphDB . '/' . $this->graphSysID  . '/';
	    	$_SESSION['ExcelDir']  = 'company_name_goes_hereData/Excel/' . $this->graphDB . '/' . $this->graphSysID  . '/';
	    	$_SESSION['XMLDir']    = 'company_name_goes_hereData/XML/'   . $this->graphDB . '/' . $this->graphSysID  . '/';

        		$functionline1 = __LINE__ + 2;

        		$graphTable = $this->graphTable;

        		$_SESSION['PDFTable'] = $this->graphTable;
        		
        		/**
        		 * 
        		 *  The includes just have the jpgraph class instantiations, and their associated parms.
        		 * 
        		 */

	    	switch($graphTable) {

	    		case 'cics_tran_count_by_hour' :

        			$functionLine2 = __LINE__ + 2;

        			switch($this->graphAlias) {

        				case 'tran_count_by_date' :
        					require('include/TCBHGraph.php'); // Tran_count_by_Hour for a specific date
        				break;

						default :

							if ($this->graphAlias == '') {
								$this->graphAlias = '** UNDEFINED **';
							}

							echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine2 ::</font> <br /><br /> \n";
							echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphAlias (<font color=\"red\">$this->graphAlias)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
							require('include/company_name_goes_hereMetricsErrorClose.php');
							exit;

						break;

        			}

        		break;

	    		case 'cics_transactions_by_sysid' :

        			$functionLine3 = __LINE__ + 2;

        			switch($this->graphAlias) {

        				case 'transactions_by_count' :
        					$this->sql = "select * from db_prefix." . $this->graphTable . " where (EPOCHDATE = " . $this->selectDate . ")  AND (RECORDTYPE='R')  AND (SYSID='" . $this->graphSysID . "')";
        					require('include/TCGraph.php');   // Transactions_by_count for a specific date
        				break;

        			    case 'transactions_by_responce' :
        					$this->sql = "select * from db_prefix." . $this->graphTable . " where (EPOCHDATE = " . $this->selectDate . ")  AND (RECORDTYPE='R')  AND (SYSID='" . $this->graphSysID . "')";
        					require('include/TCRespGraph.php');   // Transactions_by_count for a specific date
        				break;


						default :

							if ($this->graphAlias == '') {
								$this->graphAlias = '** UNDEFINED **';
							}

							echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine3 ::</font> <br /><br /> \n";
							echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphAlias (<font color=\"red\">$this->graphAlias)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
							require('include/company_name_goes_hereMetricsErrorClose.php');
							exit;

						break;

        			}

        		break;

        			// Generates: $graph->Stroke($currentMetric);

	    		default :

    					if ($this->graphName == '') {
						$this->graphName = '** UNDEFINED **';
					}

    					echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine1 ::</font> <br /><br /> \n";
					echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphName (<font color=\"red\">$this->graphName)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
					require('include/company_name_goes_hereMetricsErrorClose.php');
					exit;

	    		break;

        	}


        	} // END if ($this->dateType == 'DateSingle') {

	    if ($this->dateType == 'DateRange') {

	    	$this->minDate = $this->graphDate[0];
	    	$this->maxDate = $this->graphDate[1];

	    	$this->minDate = $this->dateToTimestamp($this->minDate);
	    	$this->maxDate = $this->dateToTimestamp($this->maxDate);

	        $function_line1 = __LINE__ + 2;

	        $graphTable = $this->graphTable;

	    	switch($graphTable) {

	    		case 'cics_tran_count_by_hour' :

        			$functionLine2 = __LINE__ + 2;

        			switch($this->graphAlias) {

        				case 'tran_count_by_date' :
        					$this->sql = "select * from db_prefix." . $this->graphTable . " where ((EPOCHDATE >= " . $this->minDate  . ") AND (EPOCHDATE <= " . $this->maxDate  . "))  AND (SYSID='" . $this->graphSysID . "')";
    							require('include/TCBHRGraph.php'); // Trans Count Per Hour By Date Range
        				break;


						default :

							if ($this->graphAlias == '') {
								$this->graphAlias = '** UNDEFINED **';
							}

							echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine2 ::</font> <br /><br /> \n";
							echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphAlias (<font color=\"red\">$this->graphAlias)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
							require('include/company_name_goes_hereMetricsErrorClose.php');
							exit;

						break;

        			}

        		break;

	    		case 'cics_transactions_by_sysid' :

        			$functionLine3 = __LINE__ + 2;

        			switch($this->graphAlias) {

        				case 'transactions_by_count' :
    							$this->sql = "select * from db_prefix." . $this->graphTable . " where ((EPOCHDATE >= " . $this->minDate  . ") AND (EPOCHDATE <= " . $this->maxDate  . "))  AND (RECORDTYPE='C')  AND (SYSID='" . $this->graphSysID . "')";
    							require('include/TCRGraph.php'); // Transaction Count By Date Range
        				break;

        			    case 'transactions_by_responce' :
    							$this->sql = "select * from db_prefix." . $this->graphTable . " where ((EPOCHDATE >= " . $this->minDate  . ") AND (EPOCHDATE <= " . $this->maxDate  . "))  AND (RECORDTYPE='C') AND (SYSID='" . $this->graphSysID . "')";
    							require('include/TCRRGraph.php'); // Transaction Count By Date Range
        				break;


						default :

							if ($this->graphAlias == '') {
								$this->graphAlias = '** UNDEFINED **';
							}

							echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine3 ::</font> <br /><br /> \n";
							echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphAlias (<font color=\"red\">$this->graphAlias)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
							require('include/company_name_goes_hereMetricsErrorClose.php');
							exit;

						break;

        			}

        			// Generates: $graph->Stroke($currentMetric);

        		break;

	    		default :

    					if ($this->graphName == '') {
						$this->graphName = '** UNDEFINED **';
					}

					echo "\t<div style=\"background-color:white;\"> \n";
    					echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine1 ::</font> <br /><br /> \n";
					echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphName (<font color=\"red\">$this->graphName)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
					echo "\t</div> \n";
					require('include/company_name_goes_hereMetricsErrorClose.php');
					exit;

	    		break;

        	}


        	} // END if ($this->dateType == 'DateSingle') {

		 // Add the UPS Logo to the graph, save the image, and Display it...
		require('include/addLogoTocompany_name_goes_hereGraph.php');

		// Grap the tools necessary to build PDF output for the user....
		require_once('classes/company_name_goes_hereGenerateGraphPDF.class.php');

		// Generate the PDF Page(s) for the current SysID...
		require('include/buildPDFPageForCurrentSysID.php');

		$currentGraphCounter = $_SESSION['currentGraphCounter'];

		$formName = 'dateSelectReturn' . '00' . $currentGraphCounter;

		$myimagemap = 'myimagemap' . $currentGraphCounter;

		if (!$_SESSION['HTMLPageSet']) {

		    // $_SESSION['HTMLPageSet'] = TRUE;

			$_SESSION['HTMLHead'] = <<<EOH

<html>

<head>


	    <!--  Prototype Window Class Part -->
	    <script type="text/javascript" src="javascript/prototype.js"> </script>
	  	<script type="text/javascript" src="javascript/effects.js"> </script>
	  	<script type="text/javascript" src="javascript/window.js"> </script>
	  	<script type="text/javascript" src="javascript/window_effects.js"> </script>
	  	<script type="text/javascript" src="javascript/debug.js"> </script>


		<script type="text/javascript" language="JavaScript" src="javascript/overlib.js"></script> \n

		<link href="css/company_name_goes_hereMetrics.css" rel="stylesheet" type="text/css"/> \n



</head>

<body>

		    <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> \n

EOH;

			echo $_SESSION['HTMLHead'];

			$_SESSION['HTMLPageSet'] = TRUE;

		}



		$currentImageMap =  $graph->GetHTMLImageMap("$myimagemap");

		// Generate the correct SparkLine Image...

		require_once('include/Sparkline_Line.php');
		require_once('include/Sparkline_Bar.php');

		$graphTable = $this->graphTable;

		$functionLine3 = __LINE__ + 2;

    	switch($graphTable) {

    		case 'cics_tran_count_by_hour' :

        			$functionLine4 = __LINE__ + 2;

        			switch($this->graphAlias) {

        				case 'tran_count_by_date' :

        					require('include/sparklineLineGraph.php');

        				break;


					default :

						if ($this->graphAlias == '') {
							$this->graphAlias = '** UNDEFINED **';
						}

						echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine5 ::</font> <br /><br /> \n";
						echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphAlias (<font color=\"red\">$this->graphAlias)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
						require('include/company_name_goes_hereMetricsErrorClose.php');
						exit;

					break;

        			}

        		break;

    		case 'cics_transactions_by_sysid' :

        			$functionLine5 = __LINE__ + 2;

        			switch($this->graphAlias) {

        				case 'transactions_by_count' :

        					require('include/sparklineBarGraph.php');

        				break;

        			    case 'transactions_by_response' :
        				break;


					default :

						if ($this->graphAlias == '') {
							$this->graphAlias = '** UNDEFINED **';
						}

						echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine5 ::</font> <br /><br /> \n";
						echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphAlias (<font color=\"red\">$this->graphAlias)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
						require('include/company_name_goes_hereMetricsErrorClose.php');
						exit;

					break;

        			}

        			// Generates: $graph->Stroke($currentMetric);

        		break;

    		default :

				if ($this->graphName == '') {
					$this->graphName = '** UNDEFINED **';
				}

				echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine3 ::</font> <br /><br /> \n";
				echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA1</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Alias Table Name \$this->graphName (<font color=\"red\">$this->graphName)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
				require('include/company_name_goes_hereMetricsErrorClose.php');
				exit;

    		break;

        	}

        	/**
        	 *
        	 *  Now that we have generated our graph image, let's wrap it in HTML so the user
        	 *  can find it.
        	 *
        	 * 	$_SESSION['requiredMetric'] = $currentMetric :
        	 *
        	 *  	Vis.: company_name_goes_hereData/ISMetrics/MetricGraphs/CICS/OP01/TCBD_FAF1_27-JAN-08_1152_by_864.jpg
        	 *
        	 */

		$_SESSION['requiredMetric'] = $currentMetric;

		// $XMLFile = $_SESSION['XMLFileName'];

		$this->touch_it($currentMetric);

		$this->touch_it($dirAndCurrentMetric);

		if(file_exists($currentMetric)) {
			chmod($currentMetric, 0777);
    	}

    	if (file_exists($dirAndCurrentMetric)) {
			chmod($dirAndCurrentMetric, 0777);
    	}

//			$HTMLHead = $_SESSION['HTMLHead'];
//
//			// pae Print Array, Then Exit
//
//			require_once('include/debugFunctions.php');
//			printArray($HTMLHead, '$HTMLHead');
//			exit();
//
//
//
		// Since the HTML lives way down deep,
		// back up links to images, JS, and CSS with ../../ etc.

		$this->PDFFileName = $_SESSION['PDFFileName'][$this->graphSysID];

		$downloadPDFURL = 'download.php?PDFFile=' . $this->PDFFileName;
		$ExcelWBURL     = 'company_name_goes_hereGenerateExcelWB.php?ExcelFile=' . $this->ExcelFileName;
		$XMLURL         = 'company_name_goes_hereDisplayXML.php?XMLFile=' . $this->XMLFileName;

		// Determine New Window centering parameters...

		require('determineCallingProgram.php');

		$_SESSION['callingProgram'] = $callingProgram;

		require('setUsersUIBasedOnScreenResolution.php');
		// Calls : 'include/setupGraphDisplayUIBasedOnScreenResolution.php'

		$computedWidth  = $_SESSION['computedWidth'];
		$computedHeight = $_SESSION['computedHeight'];

		$wleft = $_SESSION['wleft'];
		$wtop  = $_SESSION['wtop'];

		// $graphFile = $_SESSION['graph'][$metric];

		/**
		 *  $_SESSION['graph'][$this->graphSysID] is the HTML page which holds
		 *
		 *  the users final graph image and close button.
		 *
		 *  It is written out as: $graphFile = $_SESSION['graph'][$metric];
		 *
		 *  around line 319 in : 'production/company_name_goes_hereGenerateGraph.php'
		 *
		 */

		$usersScreenWidth = $_SESSION['javascriptScreenWidth'];

		if ($usersScreenWidth == 800) {
			$graphPageBreaks = "<br /> \n";
		}
		else {
			$graphPageBreaks = "<br /> <br /> \n";
		}


		$_SESSION['graph'][$this->graphSysID]  = <<<EOT

		<html> \n

			<head> \n

			<script type="text/javascript" language="JavaScript" src="../../../../../../javascript/overlib.js"></script>

			<link href="../../../../../../css/company_name_goes_hereMetrics.css" rel="stylesheet" type="text/css"/> \n

						<script> \n

					<!-- \n

						// From: http://www.boutell.com/newfaq/creating/windowcenter.html

						function centerWindow() { \n
						 \n
						// Fudge factors for window decoration space. \n
						 \n
						w = $computedWidth \n
						h = $computedHeight \n
						\n
						$wleft \n
						$wtop \n
			 			\n
						 window.resizeTo(w, h); \n
						 window.moveTo(wleft, wtop); \n
						 window.focus();  \n
						} \n
						// --> \n
						 \n
					</script> \n

			 </head> \n

		<body  onload="centerWindow(); return false;">

		<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> \n

		<center><img src="../../../../../../$currentMetric" ISMAP USEMAP="#$myimagemap" border=0><br /> \n

		$currentImageMap

		$graphPageBreaks

		<input type='image' name='closeCurrentWindow' title="Click to Close this Graph" src='http://$this->imageAddress/images/graphClose.bmp' onClick="window.close();"></center>

EOT;

//
//			echo "<xmp> \n";
//
//			echo $_SESSION['graph'][$this->graphSysID];
//
//			echo "</xmp> \n";
//
//			exit;
//

		unset($_SESSION['sparkLineDisplay'][$this->graphSysID]);

		require_once('include/graphSelectionHead.php');

		// $HTMLWithMap = "company_name_goes_hereDisplayGraph.php?graphName=" . $_SESSION['HTMLFileName'];

		$HTMLFileName = $this->HTMLFileName;

		$sparkLine = "<center><input type='image' height=\"30\" width=\"100\" name='" . $HTMLFileName . "' src=\"$sparklineImage\" border=\"0\" bordercolor=\"#FF00FF\" title=\"Click for $this->graphSysID Metric\"></center>";

		$reportDate = $_SESSION['reportdate'][ $this->graphSysID];

		// Sparkline $userInstructions (UI Buttons) are define around line 620
		// in : 'production/company_name_goes_hereGenerateGraph.php'
		//
		// Vis. : newDate, newMetric and return
		//

		$_SESSION['sparklineDisplay'][$this->graphSysID] = <<<EOL

		<center>

		<table border="1">

			<tr>

				<td>

					<table border="0"> \n

						<tr> \n
							<td colspan="3" class="sgUtilityGraph"> \n
					     		<center>  <font face="verdana" style="color:#205E75;">$this->graphSysID</font></center>
					     	</td> \n
					     </tr>

					     <tr> \n
					     	<td colspan="3" class="sgUtilityGraph"> \n
					     		<center><font face="verdana"  style="color:#205E75;"> Metric Date : $reportDate </font></center>
					     	</td> \n
					     </tr> \n


					     <tr> \n
					     	<td colspan="3" class="sgUtilityGraph"> \n
					     		<center> </center>
					     	</td> \n
					     </tr> \n

					     <tr> \n
					     	<td colspan="3" class="sgUtilityGraph"> \n
								$sparkLine
							<td> \n
						</tr> \n


					     <tr> \n
					     	<td colspan="3" class="sgUtilityGraph"> \n
					     		<center> </center>
					     	</td> \n
					     </tr> \n


						<tr> \n
							<td class='sgUtilityGraph'> \n
								    <a href=$downloadPDFURL title=" Click to display $this->graphSysID PDF"  /><img border="0" src=images/pdf7.gif></a>
							</td> \n

							<td class='sgUtilityGraph'> \n
								<a href=$ExcelWBURL title="Click to display $this->graphSysID Excel Spreadsheet"  /><img border="0" src=images/excelIcon.bmp></a>  
							</td> \n

							</td> \n
							<td class='sgUtilityGraph'> \n
								<a href=$XMLURL title="Click to display $this->graphSysID XML Data"  /><img border="0" src=images/XMLIcon.bmp></a>
							</td> \n

						</tr> \n
						<tr> \n
							<td colspan='3' class='sgUtilityGraph'> \n
								 
							</td> \n
						</tr>

					</table> \n

				</td>

			</tr>

		</table>



		</center>

		</html>

EOL;

    } // END Method :: generateGraph() {


	//	Method dateToTimestamp accepts a date as parameter. In SQLformat: yyyy-mm-dd (eg. 2001-03-16)
	//	Edit the delimiter to your convenience.
	//	returns $timestamp; the timestamp associated with the input.

	function dateToTimestamp ($SQLDate) {

		$dateToConvert = $SQLDate;
		$split_date = split ('-', $dateToConvert);

		$day   = $split_date[0];
		$month = $split_date[1];
		$year  = $split_date[2];

		$functionLine = __LINE__ + 2;

		switch ($month) {

			case 'Jan' :
				$month = '01';
			break;

			case 'Feb' :
				$month = '02';
			break;

			case 'Mar' :
				$month = '03';
			break;

			case 'Apr' :
				$month = '04';
			break;

			case 'May' :
				$month = '05';
			break;

			case 'Jun' :
				$month = '06';
			break;

			case 'Jul' :
				$month = '07';
			break;

			case 'Aug' :
				$month = '08';
			break;

			case 'Sep' :
				$month = '09';
			break;

			case 'Oct' :
				$month = '10';
			break;

			case 'Nov' :
				$month = '11';
			break;

			case 'Dec' :
				$month = '12';
			break;

			default:

				if ($month == '') {
						$month = '** UNDEFINED **';
				}

				echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">company_name_goes_hereGraph.class.php</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $functionLine ::</font> <br /><br /> \n";
				echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-GRA3</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">ISMetrics Genetated Calendar Month \$month (<font color=\"red\">$month)</font> is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
				require('include/company_name_goes_hereMetricsErrorClose.php');
				exit;

			break;

		}

		//  yyyy-mm-dd (eg. 2001-03-16)

		$this->timestamp = mktime (0, 0, 0, $month, $day, $year);
		return $this->timestamp;
	}


	function doublemax($mylist) {

  		$maxvalue=max($mylist);

  		while(list($key,$value) = each($mylist)) {

   			 if($value==$maxvalue) {
   			 	$maxindex=$key;
   			 }
  		}

  		return array("c" => $maxvalue, "i" => $maxindex);
	}

	function doublemin($mylist) {

  		$minvalue=min($mylist);

  		while(list($key,$value) = each($mylist)) {

  			if($value==$minvalue) {
   			 	$minindex=$key;
   			 }
  		}

  		return array("c"=>$minvalue,"i"=>$minindex);
	}


	function mergePix($sourcefile,$insertfile, $targetfile, $pos=0,$transition=50, $frameXOffset, $frameYOffset)  {

		//$sourcefile = Filename of the picture into that $insertfile will be inserted.

		//$insertfile = Filename of the picture that is to be inserted into $sourcefile.

		//$targetfile = Filename of the modified picture.

		//$transition = Intensity of the transition (in percent)

		//$pos          = Position where $insertfile will be inserted in $sourcefile

		//                0 = middle

		//                1 = top left

		//                2 = top right

		//                3 = bottom right

		//                4 = bottom left

		//                5 = top middle

		//                6 = middle right

		//                7 = bottom middle

		//                8 = middle left

		//Get the resource id's of the pictures

	   $sourcefile_id = imageCreateFromPNG($sourcefile);

	   imagejpeg( $sourcefile_id, $sourcefile, 100 );

	   $sourcefile_id = imageCreateFromJPEG($sourcefile);

	   $insertfile_id = imageCreateFromGIF($insertfile);


	//Get the sizes of both pix

	   $sourcefile_width=imageSX($sourcefile_id);

	   $sourcefile_height=imageSY($sourcefile_id);

	   $insertfile_width=imageSX($insertfile_id);

	   $insertfile_height=imageSY($insertfile_id);



	//middle

	   if( $pos == 0 ) {

	       $dest_x = ( $sourcefile_width / 2 ) - ( $insertfile_width / 2 );

	       $dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );

	   }



	//top left

	   if( $pos == 1 ) {

	       $dest_x = 0 + $frameXOffset;

	       $dest_y = 0 + $frameYOffset;

	   }



	//top right

	   if( $pos == 2 ) {

	       $dest_x = $sourcefile_width - $insertfile_width;

	       $dest_y = 0;

	   }



	//bottom right

	   if( $pos == 3 ) {

	       $dest_x = $sourcefile_width - $insertfile_width;

	       $dest_y = $sourcefile_height - $insertfile_height;

	   }



	//bottom left

	   if( $pos == 4 ) {

	       $dest_x = 0;

	       $dest_y = $sourcefile_height - $insertfile_height;

	   }



	//top middle

	   if( $pos == 5 ) {

	       $dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );

	       $dest_y = 0;

	   }



	//middle right

	   if( $pos == 6 ) {

	       $dest_x = $sourcefile_width - $insertfile_width;

	       $dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );

	   }



	//bottom middle

	   if( $pos == 7 ) {

	       $dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 );

	       $dest_y = $sourcefile_height - $insertfile_height;

	   }


	//middle left

	   if( $pos == 8 ) {

	       $dest_x = 0;

	       $dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );

	   }

	//The main thing : merge the two pix

	$imageCopyMergeResult =  imageCopyMerge($sourcefile_id, $insertfile_id,$dest_x,$dest_y,0,0,$insertfile_width,$insertfile_height,$transition);

	//Create a jpeg out of the modified picture

		$imagejpegResult = imagejpeg ($sourcefile_id,"$targetfile");

	$workFileName = 'images/fotog.jpg';

//		if (file_exists($workFileName)) {
//			unlink($workFileName);
//		}

	// $sourcefileSize =  getimagesize($sourcefile);

	$newFileName = 'images/fotog.jpg';

	$renameFunctionLine = __LINE__ + 2;

	// $renameResult = copy($sourcefile,$newFileName);

	$renameResult = copy($workFileName,$sourcefile);

	if (!$renameResult) {


		echo "\t<div style=\"background-color:white;\"> \n";

		echo "<font color=\"red\">Error in program :: </font><font color=\"#205E75\">'classes/company_name_goes_hereGraph.class.php' in function mergePix() {</font> <font color=\"red\">::</font> on Line <font color=\"red\">:: $renameFunctionLine ::</font> <br /><br /> \n";
		echo "<ul> <ul><font color=\"blue\">Error Number <font color=\"red\">ISM-AddLogo3</font> :: <br /><br /><ul><ul>Error Message  ::<br /><br /><ul><ul><font color=\"red\">:: </font><font color=\"#205E75\">Rename Image from generate graph name to 'images/fotog.jpg failed ( <font color=\"red\">This is the file which will have the UPS logo inserted into it. )</font> or is missing or invalid.</font> <font color=\"red\">::</font> </font><br /><br /><br /><br /></ul></ul></ul></ul></ul></ul> \n";
		echo "\t</div> \n";
		require('include/company_name_goes_hereMetricsErrorClose.php');
		exit;


	}

	if (file_exists($newFileName)) {

		// chmod($newFileName, 0777);

	}


	if (file_exists($sourcefile)) {

		// chmod($sourcefile, 0777);

	}


}


    function touch_it($filename) {

        exec("touch {$filename}");

    }



}


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.