From eaae46708be77993ecca55014f9f4a4aa440f39d Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Sun, 17 Jul 2011 22:20:11 +0200 Subject: [PATCH] bacula-web: Replaced old PEAR code by new CDB class in jobs page --- gui/bacula-web/jobs.php | 108 +++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 51 deletions(-) diff --git a/gui/bacula-web/jobs.php b/gui/bacula-web/jobs.php index 4adee0a6d4..12b6bd9b8f 100644 --- a/gui/bacula-web/jobs.php +++ b/gui/bacula-web/jobs.php @@ -84,62 +84,68 @@ $query .= "LIMIT 25 "; $dbSql->tpl->assign( 'jobs_per_page', $jobs_per_page ); - $jobsresult = $dbSql->db_link->query( $query ); + try { + $jobsresult = $dbSql->db_link->runQuery( $query ); - if( PEAR::isError( $jobsresult ) ) { - $dbSql->TriggerDBError( "Unable to get last failed jobs from catalog", $jobsresult ); - }else { - while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) { + if( !is_a($jobsresult,'CDBResult') ) { + throw new PDOException("Unable to get jobs list from catalog"); + }else { + foreach( $jobsresult->fetchAll() as $job ) { - // Determine icon for job status - switch( $job['jobstatus'] ) { - case J_RUNNING: - $job['Job_icon'] = "running.png"; - break; - case J_COMPLETED: - $job['Job_icon'] = "ok.png"; - break; - case J_CANCELED: - $job['Job_icon'] = "canceled.png"; - break; - case J_COMPLETED_ERROR: - $job['Job_icon'] = "warning.png"; - break; - case J_FATAL: - $job['Job_icon'] = "error.png"; - break; - case J_WAITING_CLIENT: - case J_WAITING_SD: - case J_WAITING_MOUNT_MEDIA: - case J_WAITING_NEW_MEDIA: - case J_WAITING_STORAGE_RES: - case J_WAITING_JOB_RES: - case J_WAITING_CLIENT_RES: - case J_WAITING_MAX_JOBS: - case J_WAITING_START_TIME: - case J_NOT_RUNNING: - $job['Job_icon'] = "waiting.png"; - break; - } // end switch + // Determine icon for job status + switch( $job['jobstatus'] ) { + case J_RUNNING: + $job['Job_icon'] = "running.png"; + break; + case J_COMPLETED: + $job['Job_icon'] = "ok.png"; + break; + case J_CANCELED: + $job['Job_icon'] = "canceled.png"; + break; + case J_COMPLETED_ERROR: + $job['Job_icon'] = "warning.png"; + break; + case J_FATAL: + $job['Job_icon'] = "error.png"; + break; + case J_WAITING_CLIENT: + case J_WAITING_SD: + case J_WAITING_MOUNT_MEDIA: + case J_WAITING_NEW_MEDIA: + case J_WAITING_STORAGE_RES: + case J_WAITING_JOB_RES: + case J_WAITING_CLIENT_RES: + case J_WAITING_MAX_JOBS: + case J_WAITING_START_TIME: + case J_NOT_RUNNING: + $job['Job_icon'] = "waiting.png"; + break; + } // end switch - // Odd or even row - if( count($last_jobs) % 2) - $job['Job_classe'] = 'odd'; - - // Elapsed time for the job - $start = $job['starttime']; - $end = $job['endtime']; - - // Job execution execution time - $job['elapsed_time'] = CTimeUtils::Get_Elapsed_Time( $start, $end); - // Job Level - $job['level'] = $job_level[ $job['level'] ]; - // Job Size - $job['jobbytes'] = CUtils::Get_Human_Size( $job['jobbytes'] ); + // Odd or even row + if( count($last_jobs) % 2) + $job['Job_classe'] = 'odd'; + + // Elapsed time for the job + $start = $job['starttime']; + $end = $job['endtime']; + + // Job execution execution time + $job['elapsed_time'] = CTimeUtils::Get_Elapsed_Time( $start, $end); + // Job Level + $job['level'] = $job_level[ $job['level'] ]; + // Job Size + $job['jobbytes'] = CUtils::Get_Human_Size( $job['jobbytes'] ); - array_push( $last_jobs, $job); - } + array_push( $last_jobs, $job); + } // end foreach + } // end if/else + + }catch(PDOException $e) { + CDBError::raiseError($e); } + $dbSql->tpl->assign( 'last_jobs', $last_jobs ); // Count jobs -- 2.39.5