]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New PHP scrips for Backup Job report
authorDavide Franco <bacula-dev@dflc.ch>
Fri, 28 Jan 2011 16:05:46 +0000 (17:05 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 3 Mar 2011 09:39:30 +0000 (10:39 +0100)
 - backupjob-report.php and templates/backupjob-report.tpl

gui/bacula-web/backupjob-report.php [new file with mode: 0644]
gui/bacula-web/templates/backupjob-report.tpl [new file with mode: 0644]

diff --git a/gui/bacula-web/backupjob-report.php b/gui/bacula-web/backupjob-report.php
new file mode 100644 (file)
index 0000000..26a1b23
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+  session_start();
+  require_once ("paths.php");
+  require_once ($smarty_path."Smarty.class.php");
+  require_once ("bweb.inc.php");
+  require_once ("config.inc.php");  
+
+  $smarty = new Smarty();     
+  $dbSql = new Bweb();
+
+  require("lang.php");
+
+  // Smarty configuration
+  $smarty->compile_check = true;
+  $smarty->debugging = false;
+  $smarty->force_compile = true;
+
+  $smarty->template_dir = "./templates";
+  $smarty->compile_dir = "./templates_c";
+  $smarty->config_dir     = "./configs";
+
+  $backupjob_name = "";
+  
+  if( isset( $_POST["backupjob_name"] ) )
+    $backupjob_name = $_POST["backupjob_name"];
+  elseif( isset( $_GET["backupjob_name"] ) )
+       $backupjob_name = $_GET["backupjob_name"];
+  else
+       die( "Please specify a backup job name " );
+       
+  $smarty->assign('backupjob_name', $backupjob_name );
+       
+  // 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->GetStoredBytesByJob( $backupjob_name, $day['start'], $day['end'] ) );
+  }
+
+  $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
+  $graph->SetGraphSize( 400, 230 );
+
+  $graph->Render();
+  $smarty->assign('graph_stored_bytes', $graph->Get_Image_file() );    
+  
+  
+  // Process and display the template 
+  $smarty->display('backupjob-report.tpl'); 
+  
+?>
\ No newline at end of file
diff --git a/gui/bacula-web/templates/backupjob-report.tpl b/gui/bacula-web/templates/backupjob-report.tpl
new file mode 100644 (file)
index 0000000..d633db3
--- /dev/null
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
+  "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<title>bacula-web</title>
+<link rel="stylesheet" type="text/css" href="style/default.css">
+{literal}
+<script type="text/javascript">
+       function OpenWin(URL,wid,hei) {
+               window.open(URL,"window1","width="+wid+",height="+hei+",scrollbars=yes,menubar=no,location=no,resizable=no")
+       }
+</script>
+{/literal}
+
+</head>
+<body>
+{popup_init src='./external_packages/js/overlib.js'}
+{include file=header.tpl}
+
+  <div id="nav">
+    <a href="index.php" title="Back to the dashboard">Dashboard</a> > Backup Job Report
+  </div>
+
+  <div id="main_center">
+  
+  <div class="box">
+       <p class="title">Backup Job Report</p>
+       
+       <table>
+               <tr>
+                       <td width="150">Backup Job name:</td>
+                       <td>{$backupjob_name}</td>
+               </tr>
+               <tr>
+                       <td>Period:</td>
+                       <td>ppp{$backupjob_period}</td>
+               </tr>
+               <tr>
+                       <td>Transfered Bytes</td>
+                       <td>ppp{$backupjob_bytes}</td>
+               </tr>
+               <tr>
+                       <td>Transfered Files</td>
+                       <td>ppp{$backupjob_files}</td>
+               </tr>
+
+       </table>
+  </div> <!-- end div class=box -->
+  
+  <!-- Last jobs list -->
+  <div class="box">
+       <p class="title">Last jobs</p>
+  </div> <!-- end div class=box -->
+  
+  <!-- Transfered Bytes graph -->
+  <div class="box">
+       <p class="title">Transfered Bytes (last week)</p>
+       <img src="{$graph_stored_bytes}" alt="" />
+  </div> <!-- end div class=box -->
+
+  <!-- Transfered Files graph -->
+  <div class="box">
+       <p class="title">Transfered Files</p>
+  </div> <!-- end div class=box -->
+  
+  </div> <!-- end div id=main_center -->
+
+{include file="footer.tpl"}
\ No newline at end of file