<?php
ob_start();
session_start();
if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
 include("../include/db.inc.php");
 include("../include/pager.php"); 
 include("../include/bit_functions.inc.php");
   $db1=new db;
   $db1->open();
    mysql_query("SET NAMES 'utf8'");
  $sql_closed=mysql_num_rows(mysql_query("select * from t123go_product_sold "));
	
   $sql_future=mysql_num_rows(mysql_query("SELECT * FROM t123go_product where  start_time > DATE_ADD(now(), INTERVAL 72 HOUR)  "));
	 $sql_penny=mysql_num_rows(mysql_query("select * from t123go_product where type1='2' "));
	 $sql_fixed=mysql_num_rows(mysql_query("select * from t123go_product where type1='1' "));
	 $sql_100off=mysql_num_rows(mysql_query("select * from t123go_product where type1='3' "));
	 
 $total=$sql_closed + $sql_future + $sql_penny + $sql_fixed + $sql_100off ;
// This array of values is just here for the example.

    $values = array($total,$sql_closed,$sql_future,$sql_penny,$sql_fixed,$sql_100off);
	
//$values = array('3400','2570','245','473','1000','3456','780','780');
// Get the total number of columns we are going to plot

    $columns  = count($values);

// Get the height and width of the final image

    $width = 500;
    $height = 200;

// Set the amount of space between each column

    $padding = 5;

// Get the width of 1 column

    $column_width = $width / $columns ;

// Generate the image variables

    $im        = imagecreate($width,$height);
    $gray      = imagecolorallocate ($im,0xff,0xff,0xff);
	$gray1     = imagecolorallocate ($im,910000,06516,0xcc);
	$gray2     = imagecolorallocate ($im,0xcc,000,000);
	$gray3     = imagecolorallocate ($im,0x11,0xcc,0xcc);
	$gray4     = imagecolorallocate ($im,000,000,0xcc);
	$gray5     = imagecolorallocate ($im,910000,0xcc,0xff);
	$gray_lite = imagecolorallocate ($im,0xff,0xff,0xff);
    $gray_dark = imagecolorallocate ($im,0xff,0xff,0xff);
	$gray_da =   imagecolorallocate ($im,0xff,0xff,0xff);
    $white     = imagecolorallocate ($im,0xff,0xff,0xff);
	
    
    
// Fill in the background of the image


    imagefilledrectangle($im,0,0,$width,$height,$white);
    
    $maxv = 0;

// Calculate the maximum value we are going to plot

    for($i=0;$i<$columns;$i++)$maxv = max($values[$i],$maxv);

// Now plot each column
        
    for($i=0;$i<$columns;$i++)
    {
        $column_height = ($height / 100) * (( $values[$i] / $maxv) *100);

        $x1 = $i*$column_width;
        $y1 = $height-$column_height;
        $x2 = (($i+1)*$column_width)-$padding;
        $y2 = $height;

        imagefilledrectangle($im,$x1,$y1,$x2,$y2,$gray.$i);

// This part is just for 3D effect

        imageline($im,$x1,$y1,$x1,$y2,$gray_lite);
        imageline($im,$x1,$y2,$x2,$y2,$gray_lite);
        imageline($im,$x2,$y1,$x2,$y2,$gray_dark);
		imageline($im,$x2,$y1,$x2,$y2,$gray_da);


    }

// Send the PNG header information. Replace for JPEG or GIF or whatever

    header ("Content-type: image/png");
    imagepng($im);
?>
