]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/jobs.php
4ac5305fa25a9d6c8ac3adac813082ee000ab60c
[bacula/bacula] / gui / bacula-web / jobs.php
1 <?php
2 /* 
3 +-------------------------------------------------------------------------+
4 | Copyright (C) 2004 Juan Luis Francés Jiménez                            |
5 |                                                                         |
6 | This program is free software; you can redistribute it and/or           |
7 | modify it under the terms of the GNU General Public License             |
8 | as published by the Free Software Foundation; either version 2          |
9 | of the License, or (at your option) any later version.                  |
10 |                                                                         |
11 | This program is distributed in the hope that it will be useful,         |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
14 | GNU General Public License for more details.                            |
15 +-------------------------------------------------------------------------+ 
16 */
17   session_start();
18   require ("paths.php");
19   require($smarty_path."Smarty.class.php");
20   include "classes.inc.php";
21
22   $smarty = new Smarty();     
23   $dbSql = new Bweb();
24
25   require("lang.php");
26
27   // Smarty configuration
28   $smarty->compile_check = true;
29   $smarty->debugging = false;
30   $smarty->force_compile = true;
31
32   $smarty->template_dir = "./templates";
33   $smarty->compile_dir = "./templates_c";
34   $smarty->config_dir     = "./configs";
35   
36   // Get the last 10 failed jobs
37   $query           = "";
38   $failed_jobs = array();
39   
40   switch( $dbSql->driver ) 
41   {
42         case 'mysql':
43                 $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 ";
44                 $query .= "FROM Job ";
45                 $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
46                 $query .= "WHERE Job.JobStatus = 'f' ";
47                 //$query .= "WHERE Job.EndTime BETWEEN <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 ";
48                 $query .= "ORDER BY Job.EndTime DESC ";  
49                 $query .= "LIMIT 10";
50  
51         break;
52         
53         case 'pgsql':
54                 $query  = "select (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
55                 $query .= "FROM Job ";
56                 $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
57                 $query .= "WHERE EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second' ";
58                 $query .= "ORDER BY Job.EndTime DESC";
59                 $query .= "LIMIT 10";
60         break;
61   }
62   $jobsresult = $dbSql->db_link->query( $query );
63   
64   if( PEAR::isError( $jobsresult ) ) {
65           echo "SQL query = $query <br />";
66           die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
67   }else {
68           while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
69                 array_push( $failed_jobs, $job);
70           }
71   }
72   $smarty->assign( 'failed_jobs', $failed_jobs );
73   
74   $smarty->display('jobs.tpl');
75 ?>