From: Davide Franco Date: Mon, 25 Jul 2011 20:48:25 +0000 (+0200) Subject: bacula-web: Fixed bug and improved last know good backup jobs in client report's... X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fee314e5fc960c13d67677f353e995b9a511b4ee;p=bacula%2Fbacula bacula-web: Fixed bug and improved last know good backup jobs in client report's page --- diff --git a/gui/bacula-web/client-report.php b/gui/bacula-web/client-report.php index 8211c66251..705b5ce524 100644 --- a/gui/bacula-web/client-report.php +++ b/gui/bacula-web/client-report.php @@ -48,23 +48,27 @@ // 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); } diff --git a/gui/bacula-web/includes/bweb.inc.php b/gui/bacula-web/includes/bweb.inc.php index dfc4b2c3e5..358995360f 100644 --- a/gui/bacula-web/includes/bweb.inc.php +++ b/gui/bacula-web/includes/bweb.inc.php @@ -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 )