]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Replaced old PEAR code by new CDB class in jobs page
authorDavide Franco <bacula-dev@dflc.ch>
Sun, 17 Jul 2011 20:20:11 +0000 (22:20 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:24 +0000 (14:49 +0200)
gui/bacula-web/jobs.php

index 4adee0a6d4250b058baf9849a6cce3930f8f62ed..12b6bd9b8fc06e92215af32fa6d045e99d9939ba 100644 (file)
        $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