3 require_once ("paths.php");
4 require_once ($smarty_path."Smarty.class.php");
5 require_once ("bweb.inc.php");
6 require_once ("config.inc.php");
8 $smarty = new Smarty();
13 // Smarty configuration
14 $smarty->compile_check = true;
15 $smarty->debugging = false;
16 $smarty->force_compile = true;
18 $smarty->template_dir = "./templates";
19 $smarty->compile_dir = "./templates_c";
20 $smarty->config_dir = "./configs";
23 $job_status = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' );
26 $running_jobs = array();
28 $query = "SELECT Job.JobId, Job.JobStatus, Status.JobStatusLong, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS Pool_name ";
29 $query .= "FROM Job ";
30 $query .= "JOIN Status ON Job.JobStatus = Status.JobStatus ";
31 $query .= "LEFT JOIN Pool ON Job.PoolId = Pool.PoolId ";
32 $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R')";
33 $query .= "ORDER BY JobId";
35 $jobsresult = $dbSql->db_link->query( $query );
37 if( PEAR::isError( $jobsresult ) ) {
38 echo "SQL query = $query <br />";
39 die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
41 while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
43 // Elapsed time for this job
45 if( $job['JobStatus'] == 'R' )
46 $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), time() );
48 $job['elapsed_time'] = 'N/A';
51 if( count($running_jobs) % 2)
52 $job['Job_classe'] = 'odd';
55 $job['Level'] = $job_status[ $job['Level'] ];
57 array_push( $running_jobs, $job);
61 $smarty->assign( 'running_jobs', $running_jobs );
63 // Get the last jobs list
67 $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong ";
68 $query .= "FROM Job ";
69 $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
70 $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus ";
73 if( isset( $_POST['status'] ) ) {
74 switch( $_POST['status'] )
77 $query .= "WHERE Job.JobStatus = 'T' ";
80 $query .= "WHERE Job.JobStatus = 'f' ";
83 $query .= "WHERE Job.JobStatus = 'A' ";
88 $query .= "ORDER BY Job.EndTime DESC ";
90 // Determine how many jobs to display
91 if( isset($_POST['limit']) )
92 $query .= "LIMIT " . $_POST['limit'];
94 $query .= "LIMIT 20 ";
96 $jobsresult = $dbSql->db_link->query( $query );
98 if( PEAR::isError( $jobsresult ) ) {
99 echo "SQL query = $query <br />";
100 die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
102 while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
103 // Determine icon for job
104 if( $job['JobStatus'] == 'T' )
105 $job['Job_icon'] = "s_ok.gif";
107 $job['Job_icon'] = "s_error.gif";
110 if( count($last_jobs) % 2)
111 $job['Job_classe'] = 'odd';
113 // Elapsed time for this job
114 $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) );
117 $job['Level'] = $job_status[ $job['Level'] ];
119 array_push( $last_jobs, $job);
122 $smarty->assign( 'last_jobs', $last_jobs );
124 if( isset( $_POST['status'] ) )
125 $total_jobs = $dbSql->CountJobs( ALL, $_POST['status'] );
127 $total_jobs = $dbSql->CountJobs( ALL );
129 $smarty->assign( 'total_jobs', $total_jobs );
131 // Process and display the template
132 $smarty->display('jobs.tpl');