]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Fixed bug with Volumes by Pool in main dashboard
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 27 Jun 2011 14:47:06 +0000 (16:47 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:17 +0000 (14:49 +0200)
 - Fixed pgsql sql query
 - Changed some variables name

gui/bacula-web/includes/bweb.inc.php
gui/bacula-web/index.php

index 992b175fafbfc6a3e774bf6b5baf672111bbde6d..a7fc2cfd4cbde74f3e5a5aa46ed898f72830620e 100644 (file)
@@ -442,18 +442,35 @@ class Bweb extends DB
        
        public function CountVolumesByPool( $pool_id )
        {
-               var_dump( $pool_id );
                $res    = null;
                $nb_vol = null;
-               $query  = "SELECT COUNT(*) as nb_vol FROM media WHERE poolid = $pool_id";
+               $query  = '';
+
+               switch( $this->driver )
+               {
+                       case 'sqlite':
+                       case 'mysql':
+                               $query  = 'SELECT COUNT(*) as vols,Pool.name as pool_name ';
+                               $query .= 'FROM Media ';
+                               $query .= 'LEFT JOIN Pool ON (Media.PoolId = Pool.PoolId) ';
+                               $query .= 'WHERE Media.poolid = ' . $pool_id;
+                       break;
+                       case 'pgsql':
+                               $query  = 'SELECT COUNT(*) as vols,Pool.name as pool_name ';
+                               $query .= 'FROM Media ';
+                               $query .= 'LEFT OUTER JOIN Pool ON (Media.PoolId = Pool.PoolId) ';
+                               $query .= 'WHERE Media.poolid = ' . $pool_id;
+                               $query .= 'GROUP BY pool.name';
+                       break;
+               }
                
                $res = $this->db_link->query( $query );
                if( PEAR::isError( $res ) )
                        $this->triggerDBError( 'Unable to get volume number from pool', $res );
                else
-                       $nb_vol = $res->fetchRow( );
+                       $vols = $res->fetchRow( );
                
-               return array( $pool_name, $nb_vol['nb_vol'] );
+               return array( $vols['pool_name'], $vols['vols'] );
        }
        
        public function GetStoredFiles( $delay = LAST_DAY )
index 795e36347dadf2fa0d8a7b82ac31fe5a2abd8aef..88e6e46ba136b8c4210ebe6e3e209b35110b03e2 100644 (file)
@@ -81,8 +81,9 @@ $data = array();
 $graph = new BGraph( "graph1.png" );
 
 $pools = $dbSql->Get_Pools_List();
-while( $pool = $pools->fetchRow( ) )
-       array_push( $data, $pool );
+while( $pool = $pools->fetchRow( ) ) {
+       array_push( $data, $dbSql->CountVolumesByPool( $pool['poolid']) );
+}
 
 $graph->SetData( $data, 'pie', 'text-data-single' );
 $graph->SetGraphSize( 400, 230 );