]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Added last know good backup job to client report
authorDavide Franco <bacula-dev@dflc.ch>
Sun, 24 Jul 2011 09:08:29 +0000 (11:08 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:27 +0000 (14:49 +0200)
 - Fixed some typo in template
 - Fixed code indentation

gui/bacula-web/client-report.php
gui/bacula-web/templates/client-report.tpl

index fd4291eb0850150c1f3cf440891cc53350bb3a3a..69976459755efb62f4b5714960aa160e4ac62f7f 100644 (file)
        include_once( 'config/global.inc.php' );
 
        $dbSql = new Bweb();
+       
        $clientid               = '';
     $client                    = '';
        $client_jobs    = array();
+       $backup_jobs    = array();
+       
+       $job_levels = array( 'D' => 'Differential', 'I' => 'Incremental', 'F' => 'Full' );
        
        $http_post = CHttpRequest::getRequestVars( $_POST ); 
        $http_get  = CHttpRequest::getRequestVars( $_GET );
        // Client informations
        $client = $dbSql->getClientInfos($clientid);
        
+       // Client's backup jobs
+       $query  = 'SELECT Job.Name, Job.Jobid, Job.Level, Job.Jobbytes, Job.Jobfiles, Status.JobStatusLong FROM Job ';
+       $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus ";
+       $query .= "WHERE Job.ClientId = '$clientid' AND Job.JobStatus = 'T' ";
+    $query .= 'ORDER BY Job.EndTime DESC ';
+       $query .= 'LIMIT 1';
+       
+       try{
+               $jobs_result = $dbSql->db_link->runQuery($query);
+               
+               foreach( $jobs_result->fetchAll() as $job ) {
+                       $job['level']    = $job_levels[ $job['level'] ];
+                       $job['jobfiles'] = number_format( $job['jobfiles'], 0, '.', "'");
+                       $job['jobbytes'] = CUtils::Get_Human_Size( $job['jobbytes'] );
+                       
+                       $backup_jobs[] = $job;
+               }
+       }catch(PDOException $e) {
+               CDBError::raiseError($e);
+       }
+       $dbSql->tpl->assign( 'backup_jobs', $backup_jobs);
+       
        $dbSql->tpl->assign( 'client_name', $client['name']);
        $dbSql->tpl->assign( 'client_os', $client['os']);
        $dbSql->tpl->assign( 'client_arch', $client['arch']);
index 962d61d971eccb5dfeb0dddc3b3aaee892f05afb..6f93b146f825235cccbb7a26b59eddc809e9390e 100644 (file)
@@ -9,13 +9,13 @@
 {include file=header.tpl}
 
   <div id="nav">
-    <a href="index.php" title="Back to the dashboard">Dashboard</a> > Client(s) report
+    <a href="index.php" title="Back to the dashboard">Dashboard</a> > Client report
   </div>
 
   <div id="main_center">
   
   <div class="box">
-       <p class="title">Client(s) Report</p>
+       <p class="title">Client Report</p>
     <h4>Client informations</h4>       
     <table width="300px">
          <tr>
          </tr>
     </table>
        
+       <h4>Last good backup job</h4>
+       <table>
+               <tr>
+                       <td class="tbl_header">Name</td>
+                       <td class="tbl_header">Jod Id</td>
+                       <td class="tbl_header">Level</td>
+                       <td class="tbl_header">Bytes</td>
+                       <td class="tbl_header">Files</td>
+                       <td class="tbl_header">Status</td>
+               </tr>
+               {foreach from=$backup_jobs item=job}
+               <tr>
+                       <td class="{$job.Job_classe}">{$job.name}</td>
+                       <td class="{$job.Job_classe}">{$job.jobid}</td>
+                       <td class="{$job.Job_classe}">{$job.level}</td>
+                       <td class="{$job.Job_classe}">{$job.jobbytes}</td>
+                       <td class="{$job.Job_classe}">{$job.jobfiles}</td>
+                       <td class="{$job.Job_classe}">{$job.jobstatuslong}</td>
+               </tr>
+               {/foreach}
+       </table>
+       
   </div> <!-- end div class=box -->
   
   </div> <!-- end div id=main_center -->