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 $running_jobs = array();
25 $query = "SELECT Job.JobId, Job.JobStatus, Status.JobStatusLong, Job.Name, Job.StartTime, Job.Level, Pool.Name AS Pool_name ";
26 $query .= "FROM Job ";
27 $query .= "JOIN Status ON Job.JobStatus = Status.JobStatus ";
28 $query .= "LEFT JOIN Pool ON Job.PoolId = Pool.PoolId ";
29 $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R')";
31 $jobsresult = $dbSql->db_link->query( $query );
33 if( PEAR::isError( $jobsresult ) ) {
34 echo "SQL query = $query <br />";
35 die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
37 while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
40 if( $job['JobStatus'] == 'R') {
41 $elapsed = mktime() - strtotime($job['StartTime']);
43 $elapsed = date( "H:i:s", $elapsed );
44 elseif( $elapsed > 86400 )
45 $elapsed = date( "d day(s) i:s", $elapsed );
47 $elapsed = date( "i:s", $elapsed );
49 $job['elapsed_time'] = $elapsed;
51 array_push( $running_jobs, $job);
55 $smarty->assign( 'running_jobs', $running_jobs );
57 // Get the last jobs list
61 switch( $dbSql->driver )
64 $query = "SELECT SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) AS elapsed, ";
67 $query = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, ";
71 $query .= "Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong ";
72 $query .= "FROM Job ";
73 $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
74 $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus ";
77 if( isset( $_POST['status'] ) ) {
78 switch( $_POST['status'] )
81 $query .= "WHERE Job.JobStatus = 'T' ";
84 $query .= "WHERE Job.JobStatus = 'f' ";
87 $query .= "WHERE Job.JobStatus = 'A' ";
92 $query .= "ORDER BY Job.EndTime DESC ";
94 // Determine how many jobs to display
95 if( isset($_POST['limit']) )
96 $query .= "LIMIT " . $_POST['limit'];
98 $query .= "LIMIT 20 ";
100 $jobsresult = $dbSql->db_link->query( $query );
102 //var_dump( $_POST );
104 if( PEAR::isError( $jobsresult ) ) {
105 echo "SQL query = $query <br />";
106 die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
108 while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
109 // Determine icon for job
110 if( $job['JobStatus'] == 'T' )
111 $job['Job_icon'] = "s_ok.gif";
113 $job['Job_icon'] = "s_error.gif";
116 if( count($last_jobs) % 2)
117 $job['Job_classe'] = 'odd';
119 array_push( $last_jobs, $job);
122 $smarty->assign( 'last_jobs', $last_jobs );
124 // Process and display the template
125 $smarty->display('jobs.tpl');