From: Davide Franco Date: Fri, 28 Jan 2011 16:25:36 +0000 (+0100) Subject: bacula-web: New function GetStoredBytesByJob in bweb.inc.php X-Git-Tag: Release-5.2.1~541 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=eef83adb11f52d10ff37f4f934eb9df057917ce7;p=bacula%2Fbacula 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 --- 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 ?>