]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New function GetStoredBytesByJob in bweb.inc.php
authorDavide Franco <bacula-dev@dflc.ch>
Fri, 28 Jan 2011 16:25:36 +0000 (17:25 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 3 Mar 2011 09:39:30 +0000 (10:39 +0100)
 - The new function GetStoredBytesByJob return the total stored bytes for a specific backup job name during an interval of time

gui/bacula-web/bweb.inc.php

index a3b4f0a2fdd8de3b87ed75fa59a881f98caca7b6..ba2685e5d18408deacf7423ed3bde83c2b4ff70f 100644 (file)
@@ -637,5 +637,33 @@ class Bweb extends DB {
                                return array( $day, $stored_bytes );
                        }
                }
+               
+               public function GetStoredBytesByJob( $jobname, $start_date, $end_date )
+               {
+                       $query  = "SELECT SUM(JobBytes) as stored_bytes, EndTime FROM Job ";
+                       $query .= "WHERE EndTime BETWEEN ( '$start_date' AND '$end_date' ) AND ";
+                       $query .= "Name = '$jobname'";
+                       
+                       echo 'query ' . $query . '<br />';
+                       
+                       $result = $this->db_link->query( $query );
+                       
+                       if( PEAR::isError( $result ) ) {
+                               die( "Unable to get Job Bytes from catalog" );
+                       }else{
+                               $stored_bytes = 0;
+                               $tmp = $result->fetchRow( DB_FETCHMODE_ASSOC );
+                               
+                               $day = date( "D d", strtotime($end_date) );
+                               
+                               if( isset( $tmp['stored_bytes'] ) ) {
+                                       $hbytes = $this->human_file_size( $tmp['stored_bytes'], 3, 'GB');
+                                       $hbytes = explode( " ", $hbytes );
+                                       $stored_bytes = $hbytes[0];
+                               }
+                               
+                               return array( $day, $stored_bytes );
+                       }                       
+               }
 } // end class Bweb
 ?>