]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/backupjob-report.php
bacula-web: Added Total stored bytes to the BackupJob Report's page
[bacula/bacula] / gui / bacula-web / backupjob-report.php
1 <?php
2   session_start();
3   require_once ("paths.php");
4   require_once ($smarty_path."Smarty.class.php");
5   require_once ("bweb.inc.php");
6   require_once ("config.inc.php");  
7
8   $smarty = new Smarty();     
9   $dbSql = new Bweb();
10
11   require("lang.php");
12
13   // Smarty configuration
14   $smarty->compile_check = true;
15   $smarty->debugging = false;
16   $smarty->force_compile = true;
17
18   $smarty->template_dir = "./templates";
19   $smarty->compile_dir = "./templates_c";
20   $smarty->config_dir     = "./configs";
21
22   $backupjob_name = "";
23   
24   if( isset( $_POST["backupjob_name"] ) )
25     $backupjob_name = $_POST["backupjob_name"];
26   elseif( isset( $_GET["backupjob_name"] ) )
27         $backupjob_name = $_GET["backupjob_name"];
28   else
29         die( "Please specify a backup job name " );
30         
31   // Last 7 days stored Bytes graph
32   $graph = new BGraph( "graph2.png" );
33   $days  = array();
34
35   // Get the last 7 days interval (start and end)
36   for( $c = 6 ; $c >= 0 ; $c-- ) {
37           $today = ( mktime() - ($c * LAST_DAY) );
38           array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) );
39   }
40
41   $days_stored_bytes    = array();
42   $backupjob_bytes              = 0;
43
44   foreach( $days as $day ) {
45     array_push( $days_stored_bytes, $dbSql->GetStoredBytesByJob( $backupjob_name, $day['start'], $day['end'] ) );
46   }
47  
48   // Calculate total bytes for this period
49   foreach( $days_stored_bytes as $day )
50         $backupjob_bytes += $day[1];
51         
52   $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
53   $graph->SetGraphSize( 400, 230 );
54
55   $graph->Render();
56   $smarty->assign('graph_stored_bytes', $graph->Get_Image_file() );     
57   
58   $smarty->assign('backupjob_name', $backupjob_name );
59   $smarty->assign('backupjob_bytes', $backupjob_bytes );
60   
61   // Process and display the template 
62   $smarty->display('backupjob-report.tpl'); 
63   
64 ?>