]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Internal code improvments and Jobs number result in jobs page
authorDavide Franco <bacula-dev@dflc.ch>
Wed, 22 Dec 2010 10:44:06 +0000 (11:44 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:43:34 +0000 (14:43 +0200)
 - Added info <Jobs found> in jobs page result
 - Improved CountJobs function in bweb.inc.php (jobs number returned directly
 - Adapted CountJobs function call in index.php and jobs.php

gui/bacula-web/bweb.inc.php
gui/bacula-web/index.php
gui/bacula-web/jobs.php
gui/bacula-web/templates/jobs.tpl

index 3b5fc635c57629c55367b9499d01c97a2f59dbfd..2d584c30ce0738cc7f801a968c99747b920ee174 100644 (file)
@@ -342,36 +342,52 @@ class Bweb extends DB {
                                return $volumes;
         } // end function GetVolumeList()
                
-               public function CountJobs( $delay = LAST_DAY, $status )
+               public function CountJobs( $delay = LAST_DAY, $status = 'any' )
                {
-                       $query = "SELECT COUNT(JobId) AS job_nb FROM Job ";
+                       $query                  = "SELECT COUNT(JobId) AS job_nb FROM Job ";
+                       $where_delay    = "";
+                       $where_status   = "";
                        
                        // Interval condition for SQL query
-                       $end_date    = mktime();
-                       $start_date  = $end_date - $delay;
+                       if( $delay != ALL ) {
+                               $end_date    = mktime();
+                               $start_date  = $end_date - $delay;
                        
-                       $start_date  = date( "Y-m-d H:i:s", $start_date );
-                       $end_date    = date( "Y-m-d H:i:s", $end_date );
+                               $start_date  = date( "Y-m-d H:i:s", $start_date );
+                               $end_date    = date( "Y-m-d H:i:s", $end_date );
                        
-                       $query      .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date' ";
+                               $where_delay = "WHERE EndTime BETWEEN '$start_date' AND '$end_date' ";
+                       }
                        
-                       // Job Status for SQL query
-                       switch( $status )
-                       {
-                               case 'completed':
-                                       $query .= "AND JobStatus = 'T' ";
-                               break;
-                               case 'failed':
-                                       $query .= "AND JobStatus = 'f' ";
-                               break;
-                       } // end switch
+                       if( $status != 'any' ) {
+                               switch( $status )
+                               {
+                                       case 'completed':
+                                               $where_status = "JobStatus = 'T' ";
+                                       break;
+                                       case 'failed':
+                                               $where_status = "JobStatus = 'f' ";
+                                       break;
+                                       case 'canceled':
+                                               $where_status = "JobStatus = 'A' ";
+                                       break;
+                               } // end switch
+                       }
                        
+                       if( !empty($where_delay) )
+                               $query = $query . $where_delay . 'AND ' . $where_status;
+                       else {
+                               if( !empty($where_status) )
+                                       $query = $query . 'WHERE ' . $where_status;
+                       }
+                               
                        $jobs = $this->db_link->query( $query );
                
                        if (PEAR::isError( $jobs ) ) {
-                               die( "Unable to get last $status jobs number from catalog <br />" . $status->getMessage() );
+                               die( "Unable to get last $status jobs number from catalog <br />" . $jobs->getMessage() );
                        }else {
-                               return $jobs->fetchRow( DB_FETCHMODE_ASSOC );
+                               $jobs = $jobs->fetchRow( DB_FETCHMODE_ASSOC ); 
+                               return $jobs['job_nb'];
                        }
                }
                
index 6bc8e73d20eb02165e759b25911d053afac98d2b..cb54d310bfd5aafa725e26229eb5d501dd1b24a2 100644 (file)
@@ -100,12 +100,10 @@ $smarty->assign('pools', $dbSql->GetVolumeList() );
 //$smarty->assign( 'completed_jobs', $completed_jobs['completed_jobs'] );
 
 // Last 24 hours completed jobs number (last_run_report.tpl)
-$completed_jobs = $dbSql->CountJobs( LAST_DAY, 'completed' );
-$smarty->assign( 'completed_jobs', $completed_jobs['job_nb'] );
+$smarty->assign( 'completed_jobs', $dbSql->CountJobs( LAST_DAY, 'completed' ) );
 
 // Last 24 hours failed jobs number (last_run_report.tpl)
-$failed_jobs = $dbSql->CountJobs( LAST_DAY, 'failed' );
-$smarty->assign( 'failed_jobs', $failed_jobs['job_nb'] );
+$smarty->assign( 'failed_jobs', $dbSql->CountJobs( LAST_DAY, 'failed' ) );
 
 // Last 24 hours elapsed time (last_run_report.tpl)
 $smarty->assign( 'elapsed_jobs', $dbSql->Get_ElapsedTime_Job() );
index 07bc885a49216432b5d24b458d5f0eb8a1eaeea4..c26d85f568b7026b94416bca035730b70bae0489 100644 (file)
   }
   $smarty->assign( 'last_jobs', $last_jobs );
   
+  if( isset( $_POST['status'] ) )
+       $total_jobs = $dbSql->CountJobs( ALL, $_POST['status'] );
+  else
+       $total_jobs = $dbSql->CountJobs( ALL );
+  
+  $smarty->assign( 'total_jobs', $total_jobs );
+  
   // Process and display the template 
   $smarty->display('jobs.tpl');
 ?>
index b1d7ce8df571bb48df57515eeadc3a14d37943bf..c7b2ad77b93ecfc0d4774c7b72b8be3c49a462e2 100644 (file)
@@ -85,6 +85,9 @@
        <form action="jobs.php" method="post">
        <table class="list" border="0">
          <tr>
+           <td class="info" width="200">
+                       {$total_jobs} jobs found
+               </td>
                <td class="info" colspan="5" style="text-align: right;">
                        Jobs / Page
                        <select name="limit">