]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/bacula-web/jobs.php
bacula-web: Renamed php class Utils to CUtils
[bacula/bacula] / gui / bacula-web / jobs.php
index 5d126ec7134a854e8d8fb31c7274554ef74e0ef1..665d8be8c334eb9b86dcfbedb1443a75dfe4ee94 100644 (file)
@@ -1,35 +1,34 @@
 <?php
+/* 
++-------------------------------------------------------------------------+
+| Copyright 2010-2011, Davide Franco                                             |
+|                                                                         |
+| 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_once ("paths.php");
-  require_once ($smarty_path."Smarty.class.php");
-  require_once ("bweb.inc.php");
-  require_once ("config.inc.php");  
+  include_once( 'config.inc.php' );
 
-  $smarty = new Smarty();     
   $dbSql = new Bweb();
-
-  require("lang.php");
-
-  // Smarty configuration
-  $smarty->compile_check = true;
-  $smarty->debugging = false;
-  $smarty->force_compile = true;
-
-  $smarty->template_dir = "./templates";
-  $smarty->compile_dir = "./templates_c";
-  $smarty->config_dir     = "./configs";
-  
   // Jobs list
   $query          = "";
   $last_jobs = array();
   
   // Job Status list
   $job_status = array( 'Any', 'Waiting', 'Running', 'Completed', 'Failed', 'Canceled' );
-  $smarty->assign( 'job_status', $job_status );
+  $dbSql->tpl->assign( 'job_status', $job_status );
   
   // Jobs per page
   $jobs_per_page = array( 25,50,75,100,150 );
-  $smarty->assign( 'jobs_per_page', $jobs_per_page );
+  $dbSql->tpl->assign( 'jobs_per_page', $jobs_per_page );
 
   // Global variables
   $job_level = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' );
                        $query .= "WHERE Job.JobStatus = 'R' ";
                break;
                case 'waiting':
-                       $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R') ";
+                       $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','p','C') ";
                break;
                case 'completed':
-                       $query .= "WHERE Job.JobStatus = 'T' ";
+                       $query .= "WHERE Job.JobStatus IN ('T', 'E') ";
                break;
                case 'failed':
-                       $query .= "WHERE Job.JobStatus IN ('f','E') ";
+                       $query .= "WHERE Job.JobStatus = 'f' ";
                break;
                case 'canceled':
                        $query .= "WHERE Job.JobStatus = 'A' ";
                
                // Determine icon for job status
                switch( $job['JobStatus'] ) {
-                       case 'R':
+                       case J_RUNNING:
                                $job['Job_icon'] = "running.png";
                        break;
-                       case 'T':
-                               $job['Job_icon'] = "s_ok.png";
+                       case J_COMPLETED:
+                               $job['Job_icon'] = "ok.png";
+                       break;
+                       case J_CANCELED:
+                               $job['Job_icon'] = "canceled.png";
                        break;
-                       case 'A':
-                       case 'f':
-                       case 'E':
-                               $job['Job_icon'] = "s_error.gif";
+                       case J_COMPLETED_ERROR:
+                               $job['Job_icon'] = "warning.png";
                        break;
-                       case 'F':
-                       case 'S':
-                       case 'M':
-                       case 'm':
-                       case 's':
-                       case 'j':
-                       case 'c':
-                       case 'd':
-                       case 't':
-                       case 'C':
+                       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
                        $job['Job_classe'] = 'odd';
                
                // Elapsed time for the job
-               if( $job['StartTime'] == '0000-00-00 00:00:00' )
-                       $job['elapsed_time'] = 'N/A';
-               elseif( $job['EndTime'] == '0000-00-00 00:00:00' )
-                       $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), mktime() );
-               else
-                       $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) );
-
+               $start = $job['StartTime'];
+               $end   = $job['EndTime'];
+               
+               // Job execution execution time
+               $job['elapsed_time'] = TimeUtils::Get_Elapsed_Time( $start, $end);
                // Job Level
         $job['Level'] = $job_level[ $job['Level'] ];
-               
                // Job Size
-               $job['JobBytes'] = $dbSql->human_file_size( $job['JobBytes'] );
+               $job['JobBytes'] = CUtils::Get_Human_Size( $job['JobBytes'] );
 
                array_push( $last_jobs, $job);
          }
   }
-  $smarty->assign( 'last_jobs', $last_jobs );
+  $dbSql->tpl->assign( 'last_jobs', $last_jobs );
   
   // Count jobs
   if( isset( $_POST['status'] ) )
   else
        $total_jobs = $dbSql->CountJobs( ALL );
   
-  $smarty->assign( 'total_jobs', $total_jobs );
+  $dbSql->tpl->assign( 'total_jobs', $total_jobs );
   
   // Process and display the template 
-  $smarty->display('jobs.tpl');
+  $dbSql->tpl->display('jobs.tpl');
 ?>