From: Davide Franco Date: Tue, 10 May 2011 16:04:44 +0000 (+0200) Subject: bacula-web: some php code cleanup in backupjob-report.php X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e548ceb4d493f1e4141261b5f37c2c8415b8c015;p=bacula%2Fbacula bacula-web: some php code cleanup in backupjob-report.php --- diff --git a/gui/bacula-web/backupjob-report.php b/gui/bacula-web/backupjob-report.php index 23115dbdd8..d62c534cb5 100644 --- a/gui/bacula-web/backupjob-report.php +++ b/gui/bacula-web/backupjob-report.php @@ -4,10 +4,17 @@ $dbSql = new Bweb(); - $backupjob_name = ""; - $days = array(); + $backupjob_name = ""; + $backupjob_bytes = 0; + $backupjob_files = 0; + $days = array(); + $days_stored_bytes = array(); + $days_stored_files = array(); + + // =============================================================== // Get Backup Job name from GET or POST + // =============================================================== if( isset( $_POST["backupjob_name"] ) ) $backupjob_name = $_POST["backupjob_name"]; elseif( isset( $_GET["backupjob_name"] ) ) @@ -20,14 +27,15 @@ $today = ( mktime() - ($c * LAST_DAY) ); array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) ); } + // Generate Backup Job report period string $backupjob_period = "From " . date( "Y-m-d", mktime()-LAST_WEEK ) . " to " . date( "Y-m-d", mktime() ); + + // =============================================================== // Last 7 days stored Bytes graph + // =============================================================== $graph = new BGraph( "graph2.png" ); - $days_stored_bytes = array(); - $backupjob_bytes = 0; - foreach( $days as $day ) array_push( $days_stored_bytes, $dbSql->GetStoredBytesByJob( $backupjob_name, $day['start'], $day['end'] ) ); @@ -41,12 +49,11 @@ $graph->Render(); $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() ); + // =============================================================== // Getting last 7 days stored files graph + // =============================================================== $graph = new BGraph("graph3.png" ); - $days_stored_files = array(); - $backupjob_files = 0; - foreach( $days as $day ) array_push( $days_stored_files, $dbSql->GetStoredFilesByJob( $backupjob_name, $day['start'], $day['end'] ) ); @@ -76,13 +83,11 @@ while( $job = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) { $job['Level'] = $joblevel[ $job['Level'] ]; array_push( $jobs, $job); - } - + } }else die( "Unable to get last jobs from catalog " . $result->getMessage() ); $dbSql->tpl->assign('jobs', $jobs ); - $dbSql->tpl->assign('backupjob_name', $backupjob_name ); $dbSql->tpl->assign('backupjob_period', $backupjob_period ); $dbSql->tpl->assign('backupjob_bytes', $backupjob_bytes );