<?php
// $Header: /cvsroot/phptsmadmin/phpTSMadmin/htdocs/volume.inventory.php,v 1.11 2008/08/19 11:06:50 wurley Exp $

# Required Libraries
require './common.php';

# Defaults
$libraries = objectCache('libraries');
$libvolumes = objectCache('volumes');

# The following VOLUMES in the library can be checked out.
$blockTitle['innotci'] = 'Volume Inventory Summary.';
$blockBody['innotci'] = '<table class="result_table" width=100% border=0>';
$blockBody['innotci'] .= '<tr><td class="heading">Library</td><td class="heading">Slot</td><td class="heading">Barcode/Vol Name</td><td class="heading">Usage</td><td class="heading">Status/Access</td><td class="heading">Library Access</td><td class="heading">Utilisation</td><td class="heading">Reclaim</td><td class="heading">Last Read</td><td class="heading">Last Write</td></tr>';

$blockBody['innotci'] .= sprintf('<tr><td colspan=0><b>%s</b></td></tr>',_('The following volumes are in a library, but NOT checked in.'));
$counter = 0;
foreach ($libraries->libVolumes(false) as $library => $volumes) {
	foreach ($volumes as $element => $volume) {
		$blockBody['innotci'] .= sprintf('<tr class="%s"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td><td>%s%%</td><td>%s%%</td><td>%s</td><td>%s</td></tr>',
			$counter++%2 ? 'even' : 'odd',
			isset($volume->lib['name']) ? $volume->lib['name'] : 'Unknown LIB',
			isset($volume->location) ? $volume->location : $volume->lib['slot'],
			$volume->name,
			$volume->stgpool,
			$volume->status['volume'],
			$volume->access,
			isset($volume->lib['access']) ? $volume->lib['access'] : 'N/A',
			$volume->utilisation,
			$volume->reclaim,
			tsmDate($volume->last['read'],'notime'),tsmDate($volume->last['write'],'notime'));
	}
}
$blockBody['innotci'] .= '<tr><td colspan=0>&nbsp;</td></tr>';

# The following PRIMARY VOLUMES not in the library.
$blockBody['innotci'] .= sprintf('<tr><td colspan=0><b>%s</b></td></tr>',_('The following PRIMARY pool volumes are NOT checked in a library.'));
$counter = 0;
foreach ($libvolumes->primaryNotInLib() as $volume) {
	$blockBody['innotci'] .= sprintf('<tr class="%s"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td><td>%s%%</td><td>%s%%</td><td>%s</td><td>%s</td></tr>',
		$counter++%2 ? 'even' : 'odd',
		'N/A',
		isset($volume->location) ? $volume->location : 'InLIB',
		$volume->getName(),
		$volume->stgpool,
		$volume->status['volume'],
		$volume->access,
		'N/A',
		$volume->utilisation,
		$volume->reclaim,
		tsmDate($volume->last['read'],'notime'),tsmDate($volume->last['write'],'notime'));
}
$blockBody['innotci'] .= '<tr><td colspan=0>&nbsp;</td></tr>';

# The following COPY VOLUMES in the library can be checked out.
$blockBody['innotci'] .= sprintf('<tr><td colspan=0><b>%s</b></td></tr>',_('The following COPY pool volumes can be checked out of the library(s).'));
$counter = 0;
foreach ($libvolumes->libCopyVolumes(true) as $volume) {
	$blockBody['innotci'] .= sprintf('<tr class="%s"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td><td>%s%%</td><td>%s%%</td><td>%s</td><td>%s</td></tr>',
		$counter++%2 ? 'even' : 'odd',
		$volume->lib['name'],
		isset($volume->location) ? $volume->location : 'InLIB',
		$volume->getName(),
		$volume->stgpool,
		$volume->status['volume'],
		$volume->access,
		'N/A',
		$volume->utilisation,
		$volume->reclaim,
		tsmDate($volume->last['read'],'notime'),tsmDate($volume->last['write'],'notime'));
}
$blockBody['innotci'] .= '<tr><td colspan=0>&nbsp;</td></tr>';

# The following PRIMARY VOLUMES not in the library.
$blockBody['innotci'] .= sprintf('<tr><td colspan=0><b>%s</b></td></tr>',_('The following COPY pool volumes are not checked in a library.'));
$counter = 0;
foreach ($libvolumes->libCopyVolumes(false) as $volume) {
	$blockBody['innotci'] .= sprintf('<tr class="%s"><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s/%s</td><td>%s</td><td>%s%%</td><td>%s%%</td><td>%s</td><td>%s</td></tr>',
		$counter++%2 ? 'even' : 'odd',
		'N/A',
		isset($volume->location) ? $volume->location : 'InLIB',
		$volume->getName(),
		$volume->stgpool,
		$volume->status['volume'],
		$volume->access,
		'N/A',
		$volume->utilisation,
		$volume->reclaim,
		tsmDate($volume->last['read'],'notime'),tsmDate($volume->last['write'],'notime'));
}
$blockBody['innotci'] .= '</table>';

# End
render_page($blockTitle,$blockBody);
?>
