]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Fixed bug and improved last know good backup jobs in client report's...
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 25 Jul 2011 20:48:25 +0000 (22:48 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:28 +0000 (14:49 +0200)
gui/bacula-web/client-report.php
gui/bacula-web/includes/bweb.inc.php

index 8211c662519c7124b050348e7114ec4b85a40efc..705b5ce524e697803d5880cbaceba53bdc7df0a0 100644 (file)
        // Client informations
        $client = $dbSql->getClientInfos($clientid);
        
-       // Client's backup jobs
-       $query  = 'SELECT Job.Name, Job.Jobid, Job.Level, Job.Endtime, 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'] );
+           $job_names = $dbSql->getJobsName( $clientid );
+       
+               foreach( $job_names as $jobname ) {
+                       //Client's backup jobs
+                       $query  = 'SELECT Job.Name, Job.Jobid, Job.Level, Job.Endtime, Job.Jobbytes, Job.Jobfiles, Status.JobStatusLong FROM Job ';
+                       $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus ";
+                       $query .= "WHERE Job.Name = '$jobname' AND Job.JobStatus = 'T' ";
+                       $query .= 'ORDER BY Job.EndTime DESC ';
+                       $query .= 'LIMIT 1';
+                       
+                       $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;
-               }
+                               $backup_jobs[] = $job;
+                       }
+               }               
        }catch(PDOException $e) {
                CDBError::raiseError($e);
        }
index dfc4b2c3e5a013d68339786974075c77ce6dfb73..358995360f82fbdb60cd4c5645f65cdc7622a973 100644 (file)
@@ -326,9 +326,10 @@ class Bweb
                return $pools;
        }
        
-       public function getJobsName()
+       public function getJobsName( $client_id = null )
        {
                $query          = '';
+               
                $result         = '';
                $backupjobs = array();
                
@@ -336,12 +337,18 @@ class Bweb
                {
                        case 'sqlite':
                        case 'mysql':
-                               $query          = "SELECT name FROM Job GROUP BY name ORDER BY name";
+                               $query          = "SELECT name FROM Job ";
                        break;
                        case 'pgsql':
-                               $query          = "SELECT name FROM Job GROUP BY name ORDER BY name";
+                               $query          = "SELECT name FROM Job ";
                        break;
                }
+               
+               if( !is_null($client_id) )
+                       $query .= "WHERE clientid = '$client_id' ";
+               
+               $query .= 'GROUP BY name ORDER BY name';
+               
                try {
                        $result = $this->db_link->runQuery($query);
                        foreach( $result->fetchAll() as $jobname )