-// generaldata.tpl & last_run_report.tpl (last24bytes)
-$client = $dbSql->link->query("select count(*) from Client")
- or die ("Error query: 1");
-$totalfiles = $dbSql->link->query("select count(FilenameId) from Filename")
- or die ("Error query: 2");
-if ( $dbSql->driver == "mysql")
- $last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400")
- or die ("Error query: 3");
-if ( $dbSql->driver == "pgsql")
- $last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'")
- or die ("Error query: 3");
-$bytes_stored =& $dbSql->link->getOne("select SUM(VolBytes) from Media")
- or die ("Error query: 4");
-
+// generaldata.tpl & last_run_report.tpl ( Last 24 hours report )
+$last24bytes = "";
+$query = "";
+
+/*$client = $dbSql->db_link->query("select count(*) from Client")
+ or die ("Error query: 1");*/
+ $totalfiles = $dbSql->db_link->query("select count(FilenameId) from Filename") or die ("Error query: 2");
+
+ if ( PEAR::isError( $totalfiles ) ) {
+ die( "Unable to get Total Files information from catalog" . $totalfiles->getMessage() );
+ }else {
+ $tmp = $totalfiles->fetchRow();
+ $smarty->assign('files_totales',$tmp[0]);
+ }
+ $totalfiles->free();
+
+ switch( $dbSql->driver )
+ {
+ case 'mysql':
+ $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400";
+ break;
+ case 'pgsql':
+ $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'";
+ break;
+ default:
+ $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400";
+ break;
+ }
+
+ $last24bytes = $dbSql->db_link->query( $query ) or die ("Failed to get Total Job Bytes from catalog");
+
+ if ( PEAR::isError( $last24bytes ) ) {
+ die( "Unable to get Total Job Bytes from catalog" . $last24bytes->getMessage() );
+ }else {
+ $tmp = $last24bytes->fetchRow();
+ var_dump( $tmp );
+ // Transfered bytes since last 24 hours
+ $smarty->assign('bytes_totales', $dbSql->human_file_size( $tmp[0] ) );
+
+ $smarty->assign('total_jobs', $tmp[1]);
+
+ $last24bytes->free();
+ }
+