<?php
include_once('ofc-library/open-flash-chart.php' );
srand((double)microtime()*1000000);

/*
$conn = mysql_connect("localhost", "root", "");

if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

if (!mysql_select_db("bansbilling")) {
    echo "Unable to select mydbname: " . mysql_error();
    exit;
}


$day_time = mktime(0,0,0,date("m"),date("d")-20,date("Y"));
$callStart = date("Y-m-d", $day_time);
$callEnd = date('Y-m-d');


$callStartStr = $callStart." 00:00:00";
$callEndStr = $callEnd." 23:59:59";

$sql = "SELECT
		SUBSTRING(callstart, 1, 10) AS callDate,
		COUNT(id_call) AS totalCall,
		SUM(duration) AS totalDuration
		FROM calls WHERE call_status = 'ANSWER' AND callstart BETWEEN '$callStartStr' AND '$callEndStr'
		GROUP BY CallDate ORDER BY callDate DESC";



$result = mysql_query($sql);
mysql_num_rows($result);




$bar_red = new bar_3d( 75, '#D54C78' );
$bar_red->key( 'Number of Call', 10 );


//
// create a 2nd set of bars:
//
$bar_blue = new bar_3d( 75, '#3334AD' );
$bar_blue->key( 'Duration (Min)', 10 );




// add random height bars:



$i=0;
while ($row = mysql_fetch_assoc($result))
{
   $bar_red->data[$i] = $row['sucessCallCount'];
   $bar_blue->data[$i] = round($row['totalDuration']/60,0);
   $callHour[$i] = $row['callOur'];

$i++;
}

//echo $provider;

//for( $i=0; $i<10; $i++ )
 // $bar_red->data[] = rand(2,5);





// add random height bars:
 //for( $i=0; $i<10; $i++ )
 //$bar_blue->data[] = rand(5,9);

// create the graph object:
$g = new graph();
$g->title( 'Today Hourly Call Summary', '{font-size:20px; color: #FFFFFF; margin: 5px; background-color: #505050; padding:5px; padding-left: 20px; padding-right: 20px;}' );

//$g->set_data( $data_1 );
//$g->bar_3D( 75, '#D54C78', '2006', 10 );

//$g->set_data( $data_2 );
//$g->bar_3D( 75, '#3334AD', '2007', 10 );

$g->data_sets[] = $bar_red;
$g->data_sets[] = $bar_blue;

$g->set_x_axis_3d( 12 );
$g->x_axis_colour( '#909090', '#ADB5C7' );
$g->y_axis_colour( '#909090', '#ADB5C7' );

//$g->set_x_labels( array( 'January','February','March','April','May','June','July','August','September','October' ) );
$g->set_x_labels($callHour );
$g->set_y_max( 90000 );
$g->y_label_steps( 10 );
$g->set_y_legend( 'Call Hours Vs Duration', 12, '#736AFF' );
echo $g->render();
*/



$bar_red = new bar_3d( 75, '#D54C78' );
$bar_red->key( '2006', 10 );

// add random height bars:
for( $i=0; $i<10; $i++ )
  $bar_red->data[] = rand(2,5);

//
// create a 2nd set of bars:
//
$bar_blue = new bar_3d( 75, '#3334AD' );
$bar_blue->key( '2007', 10 );

// add random height bars:
for( $i=0; $i<10; $i++ )
  $bar_blue->data[] = rand(5,9);

// create the graph object:
$g = new graph();
$g->title( '3D Bar Chart', '{font-size:20px; color: #FFFFFF; margin: 5px; background-color: #505050; padding:5px; padding-left: 20px; padding-right: 20px;}' );

//$g->set_data( $data_1 );
//$g->bar_3D( 75, '#D54C78', '2006', 10 );

//$g->set_data( $data_2 );
//$g->bar_3D( 75, '#3334AD', '2007', 10 );

$g->data_sets[] = $bar_red;
$g->data_sets[] = $bar_blue;

$g->set_x_axis_3d( 12 );
$g->x_axis_colour( '#909090', '#ADB5C7' );
$g->y_axis_colour( '#909090', '#ADB5C7' );

$g->set_x_labels( array( 'January','February','March','April','May','June','July','August','September','October' ) );
$g->set_y_max( 10 );
$g->y_label_steps( 5 );
$g->set_y_legend( 'Open Flash Chart', 12, '#736AFF' );
echo $g->render();



?>