]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/report.php
bacula-web: Modified internal php code for smarty classe instance name
[bacula/bacula] / gui / bacula-web / report.php
1 <?php
2 /* 
3 +-------------------------------------------------------------------------+
4 | Copyright (C) 2004-2005 Juan Luis Frances Jiminez                       |
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_once('paths.php');
19 include_once( 'bweb.inc.php' );
20
21 $dbSql = new Bweb();
22
23 if ( $_GET['default'] == 1) {                                                                                                   // Default params, 1 month
24         $dbSql->StartDate = strftime("%Y-%m-%d %H:%M:%S",time()-2678400);
25         $dbSql->EndDate = strftime("%Y-%m-%d %H:%M:%S",time());
26 }
27 else                                                                                                                                            // With params
28         $dbSql->PrepareDate($_GET['StartDateMonth'],$_GET['StartDateDay'],$_GET['StartDateYear'],$_GET['EndDateMonth'],$_GET['EndDateDay'],$_GET['EndDateYear']);
29         
30 $bytes = $dbSql->CalculateBytesPeriod($_GET['server'],$dbSql->StartDate,$dbSql->EndDate);
31 $files = $dbSql->CalculateFilesPeriod($_GET['server'],$dbSql->StartDate,$dbSql->EndDate);
32 $smarty->assign('startperiod',$dbSql->StartDate);
33 $smarty->assign('endperiod',$dbSql->EndDate); 
34 $smarty->assign('bytesperiod',$dbSql->human_file_size( $bytes ) );
35 $smarty->assign('filesperiod',$files);
36
37 // Array with jobs data
38 $a_jobs = array();
39 if ($dbSql->driver == "mysql")
40         $res_jobs = $dbSql->db_link->query("select *,SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) as elapsed from Job where EndTime < '$dbSql->EndDate' and EndTime > '$dbSql->StartDate' and Name='$_GET[server]' order by EndTime")
41                 or die("Error query row 50");
42 else if ($dbSql->driver == "pgsql")
43         $res_jobs = $dbSql->db_link->query("select jobid as \"JobId\",job as \"Job\",name as \"Name\",type as \"Type\",level as \"Level\",clientid as \"ClientId\",jobstatus as \"JobStatus\",schedtime as \"SchedTime\",starttime as \"StartTime\",endtime as \"EndTime\",jobtdate as \"JobtDate\",volsessionid as \"VolSessionId\",volsessiontime as \"VolSessionTime\",jobfiles as \"JobFiles\",jobbytes as \"JobBytes\",joberrors as \"JobErrors\",jobmissingfiles as \"JobMissingFiles\",poolid as \"PoolId\",filesetid as \"FilesetId\",purgedfiles as \"PurgedFiles\",hasbase,Job.EndTime::timestamp-Job.StartTime::timestamp as elapsed from Job where EndTime < '$dbSql->EndDate' and EndTime > '$dbSql->StartDate' and Name='$_GET[server]' order by EndTime")
44                 or die("Error query row 56");
45
46 while ( $tmp = $res_jobs->fetchRow(DB_FETCHMODE_ASSOC) ) {
47         $tdate = explode (":",$tmp['elapsed']);         // Temporal "workaround" ;) Fix later
48         if ( $tdate[0] > 300000 )
49                 $tmp['elapsed'] = "00:00:00";
50                 $tmp['JobBytes'] = $dbSql->human_file_size( $tmp['JobBytes'] );
51         array_push($a_jobs,$tmp);
52 }
53 $smarty->assign('jobs',$a_jobs);
54
55 // report_select.tpl
56 $res = $dbSql->db_link->query("select Name from Job group by Name");
57 $a_jobs = array();
58 while ( $tmp = $res->fetchRow() )
59         array_push($a_jobs, $tmp[0]);
60 $smarty->assign('total_name_jobs',$a_jobs);
61 $res->free();
62 $smarty->assign('time2',( (time())-2678400) );                                  // Current time - 1 month. <select> date
63
64
65
66 $dbSql->tpl->display('report.tpl');
67 ?>