From 19918dc70e91ce32b9b52b6555434b6e49f3ab35 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Fri, 28 Jan 2011 17:25:36 +0100 Subject: [PATCH] bacula-web: New function GetStoredBytesByJob in bweb.inc.php - 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 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gui/bacula-web/bweb.inc.php b/gui/bacula-web/bweb.inc.php index a3b4f0a2fd..ba2685e5d1 100644 --- a/gui/bacula-web/bweb.inc.php +++ b/gui/bacula-web/bweb.inc.php @@ -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 . '
'; + + $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 ?> -- 2.39.5