// Last 15 used volumes
- $vol_list = array();
-
- $query = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job ";
- $query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId ";
- $query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId ";
- $query .= "ORDER BY Job.JobId DESC ";
- $query .= "LIMIT 10 ";
+ $last_volumes = array();
- try {
- $result = $dbSql->db_link->runQuery($query);
- foreach($result->fetchall() as $vol)
- $vol_list[] = $vol;
+ try{
+ $result = $dbSql->db_link->runQuery( "SELECT Media.MediaId,Media.Volumename, Media.Lastwritten, Media.VolStatus FROM Media ORDER BY Media.Lastwritten DESC LIMIT 10" );
+
+ foreach( $result->fetchAll() as $volume ) {
+ $query = "SELECT COUNT(*) as jobs_count FROM JobMedia WHERE JobMedia.MediaId = '" . $volume['mediaid'] . "'";
+ $jobs_by_vol = $dbSql->db_link->runQuery($query);
+ $jobs_by_vol = $jobs_by_vol->fetchAll();
+ $volume['jobs_count'] = $jobs_by_vol[0]['jobs_count'];
+ $last_volumes[] = $volume;
+ }
}catch(PDOException $e) {
CDBError::raiseError($e);
}
- $dbSql->tpl->assign( 'volume_list', $vol_list );
+ $dbSql->tpl->assign( 'volumes_list', $last_volumes );
// Render template
$dbSql->tpl->display('index.tpl');
</div>
</div> <!-- end div box -->
- <div class="box">
+ <div class="box" border=1>
<p class="title">Last used volumes</p>
<table>
<tr>
<td class="tbl_header">Last written</td>
<td class="tbl_header">Job Id</td>
</tr>
- {foreach from=$volume_list item=vol}
+ {foreach from=$volumes_list item=vol}
<tr>
<td>{$vol.volumename}</td>
<td>{$vol.volstatus}</td>
<td>{$vol.lastwritten}</td>
- <td>{$vol.jobid}</td>
+ <td><b>{$vol.jobs_count}</b></td>
</tr>
{/foreach}
</table>