From 38f769159d67bc398e2e94dd763a07aff1dccb4b Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Fri, 22 Jul 2011 18:55:24 +0200 Subject: [PATCH] bacula-web: Improved last 10 used volumes in main dashboard --- gui/bacula-web/index.php | 24 ++++++++++++------------ gui/bacula-web/templates/index.tpl | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index c73910fae7..5cd27a6fe9 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -102,23 +102,23 @@ // Last 15 used volumes - $vol_list = array(); - - $query = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job "; - $query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId "; - $query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId "; - $query .= "ORDER BY Job.JobId DESC "; - $query .= "LIMIT 10 "; + $last_volumes = array(); - try { - $result = $dbSql->db_link->runQuery($query); - foreach($result->fetchall() as $vol) - $vol_list[] = $vol; + try{ + $result = $dbSql->db_link->runQuery( "SELECT Media.MediaId,Media.Volumename, Media.Lastwritten, Media.VolStatus FROM Media ORDER BY Media.Lastwritten DESC LIMIT 10" ); + + foreach( $result->fetchAll() as $volume ) { + $query = "SELECT COUNT(*) as jobs_count FROM JobMedia WHERE JobMedia.MediaId = '" . $volume['mediaid'] . "'"; + $jobs_by_vol = $dbSql->db_link->runQuery($query); + $jobs_by_vol = $jobs_by_vol->fetchAll(); + $volume['jobs_count'] = $jobs_by_vol[0]['jobs_count']; + $last_volumes[] = $volume; + } }catch(PDOException $e) { CDBError::raiseError($e); } - $dbSql->tpl->assign( 'volume_list', $vol_list ); + $dbSql->tpl->assign( 'volumes_list', $last_volumes ); // Render template $dbSql->tpl->display('index.tpl'); diff --git a/gui/bacula-web/templates/index.tpl b/gui/bacula-web/templates/index.tpl index c2976a7893..dff6d232ac 100644 --- a/gui/bacula-web/templates/index.tpl +++ b/gui/bacula-web/templates/index.tpl @@ -39,7 +39,7 @@ -
+

Last used volumes

@@ -48,12 +48,12 @@ - {foreach from=$volume_list item=vol} + {foreach from=$volumes_list item=vol} - + {/foreach}
Last written Job Id
{$vol.volumename} {$vol.volstatus} {$vol.lastwritten}{$vol.jobid}{$vol.jobs_count}
-- 2.39.5