]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/bacula-web/jobs.php
bacula-web: Fixed typo for date function in bweb.inc.php and jobs.php
[bacula/bacula] / gui / bacula-web / jobs.php
index 4ac5305fa25a9d6c8ac3adac813082ee000ab60c..1149c9e9f2a60789406fe53cbc09127665b07003 100644 (file)
@@ -1,23 +1,9 @@
 <?php
-/* 
-+-------------------------------------------------------------------------+
-| Copyright (C) 2004 Juan Luis Francés Jiménez                            |
-|                                                                         |
-| This program is free software; you can redistribute it and/or           |
-| modify it under the terms of the GNU General Public License             |
-| as published by the Free Software Foundation; either version 2          |
-| of the License, or (at your option) any later version.                  |
-|                                                                         |
-| This program is distributed in the hope that it will be useful,         |
-| but WITHOUT ANY WARRANTY; without even the implied warranty of          |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
-| GNU General Public License for more details.                            |
-+-------------------------------------------------------------------------+ 
-*/
   session_start();
-  require ("paths.php");
-  require($smarty_path."Smarty.class.php");
-  include "classes.inc.php";
+  require_once ("paths.php");
+  require_once ($smarty_path."Smarty.class.php");
+  require_once ("bweb.inc.php");
+  require_once ("config.inc.php");  
 
   $smarty = new Smarty();     
   $dbSql = new Bweb();
        break;
        
        case 'pgsql':
-               $query  = "select (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
+               $query  = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
                $query .= "FROM Job ";
                $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
-               $query .= "WHERE EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second' ";
+               $query .= "WHERE Job.JobStatus = 'f' ";
+               //$query .= "WHERE EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second' AND ";
                $query .= "ORDER BY Job.EndTime DESC";
                $query .= "LIMIT 10";
        break;
   }
   $smarty->assign( 'failed_jobs', $failed_jobs );
   
+  // Get the last completed jobs (last 24 hours)
+  $query          = "";
+  $completed_jobs = array();
+  
+  // Interval calculation
+  $end_date   = mktime();
+  $start_date = $end_date - LAST_DAY;
+                       
+  $start_date = date( "Y-m-d H:i:s", $start_date );
+  $end_date   = date( "Y-m-d H:i:s", $end_date );
+  
+  switch( $dbSql->driver ) 
+  {
+       case 'mysql':
+               $query  = "SELECT SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) AS elapsed, Job.JobId, Job.Name AS job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS pool_name, Job.JobStatus ";
+               $query .= "FROM Job ";
+               $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
+               $query .= "WHERE Job.JobStatus = 'T' AND ";
+               $query .= "Job.EndTime BETWEEN '$start_date' AND '$end_date' ";
+               $query .= "ORDER BY Job.EndTime DESC ";  
+               
+       break;
+       
+       case 'pgsql':
+               $query  = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
+               $query .= "FROM Job ";
+               $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
+               $query .= "WHERE EndTime BETWEEN '$start_date' and '$end_date' ";
+               $query .= "ORDER BY Job.EndTime DESC";
+       break;
+  }
+
+  $jobsresult = $dbSql->db_link->query( $query );
+  
+  if( PEAR::isError( $jobsresult ) ) {
+         echo "SQL query = $query <br />";
+         die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
+  }else {
+         while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
+               array_push( $completed_jobs, $job);
+         }
+  }
+  $smarty->assign( 'completed_jobs', $completed_jobs );
+  
   $smarty->display('jobs.tpl');
 ?>