-else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){
- $tmp1 = array();
- if ( $dbSql->driver == "mysql")
- $query = "select SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) )
- as elapsed,Job.Name,Job.StartTime,Job.EndTime,Job.Level,Pool.Name,Job.JobStatus from Job
- LEFT JOIN Pool ON Job.PoolId=Pool.PoolId where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400
- order by elapsed "; // Full report array
- if ( $dbSql->driver == "pgsql")
- $query = "select (Job.EndTime - Job.StartTime )
- as elapsed,Job.Name,Job.StartTime,Job.EndTime,Job.Level,Pool.Name,Job.JobStatus from Job
- LEFT JOIN Pool ON Job.PoolId=Pool.PoolId where EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'
- order by elapsed ";
- $status = $dbSql->db_link->query($query)
- or die ("Error: query at row 138");
- while ( $tmp = $status->fetchRow() ) {
- $tdate = explode (":",$tmp[0]);
- if ( $tdate[0] > 300000 ) // Temporal "workaround" ;) Fix later
- $tmp[0] = "00:00:00";
- array_push($tmp1,$tmp);
- }
-
- $smarty->assign('clients',$tmp1);
-}
-
-
-if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes")
- $smarty->display('full_popup.tpl');
-else
- $smarty->display('index.tpl');
+
+$graph = new BGraph( "graph.png" );
+$graph->SetData( $data, 'pie', 'text-data-single' );
+$graph->SetGraphSize( 400, 230 );
+
+$graph->Render();
+$dbSql->tpl->assign('graph_jobs', $graph->Get_Image_file() );
+unset($graph);
+
+// Pool and volumes graph
+$data = array();
+$graph = new BGraph( "graph1.png" );
+
+$pools = $dbSql->Get_Pools_List();
+
+foreach( $pools as $pool ) {
+ array_push( $data, $dbSql->GetPoolsStatistics( $pool ) );
+}
+
+$graph->SetData( $data, 'pie', 'text-data-single' );
+$graph->SetGraphSize( 400, 230 );
+
+$graph->Render();
+$dbSql->tpl->assign('graph_pools', $graph->Get_Image_file() );
+
+// Last 7 days stored Bytes graph
+$data = array();
+$graph = new BGraph( "graph2.png" );
+$days = array();
+
+// Get the last 7 days interval (start and end)
+for( $c = 6 ; $c >= 0 ; $c-- ) {
+ $today = ( mktime() - ($c * LAST_DAY) );
+ array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) );
+}
+
+$days_stored_bytes = array();
+
+foreach( $days as $day ) {
+ array_push( $days_stored_bytes, $dbSql->GetStoredBytesByInterval( $day['start'], $day['end'] ) );
+}
+
+$graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
+$graph->SetGraphSize( 400, 230 );
+
+$graph->Render();
+$dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );
+
+// Last 15 used volumes
+$vol_list = array();
+
+$query = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job ";
+$query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId ";
+$query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId ";
+$query .= "ORDER BY Job.JobId DESC ";
+$query .= "LIMIT 10 ";
+
+$result = $dbSql->db_link->query( $query );
+
+if ( PEAR::isError( $result ) )
+ die( "Unable to get last used volumes from catalog \n " . $result->getMessage() );
+else {
+ while ( $vol = $result->fetchRow( DB_FETCHMODE_ASSOC ) )
+ array_push( $vol_list, $vol );
+}
+$dbSql->tpl->assign( 'volume_list', $vol_list );
+
+//if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes")
+// $smarty->display('full_popup.tpl');
+//else
+
+// Render template
+$dbSql->tpl->display('index.tpl');