Added drive to library view

This commit is contained in:
Deon George
2011-06-25 09:46:26 +10:00
parent 279eacd4ab
commit 2d7cfd3eb3
10 changed files with 144 additions and 11 deletions

View File

@@ -11,17 +11,22 @@
* @license http://phptsmadmin.sf.net/license.html
*/
class Database_TSM_Show extends Database_Result {
private $data = array();
public function __construct($result, $sql, $as_object = FALSE, array $params = NULL) {
parent::__construct($result, $sql, $as_object, $params);
$sql = strtolower($sql);
$start = FALSE;
$barcodewarn = FALSE;
foreach ($result as $line) {
if (! trim($line))
continue;
if (preg_match('/^show slots /',$sql))
if (preg_match('/^show slots /',$sql)) {
$library = strtoupper(preg_replace('/^show slots /','',$sql));
if (preg_match('/^Slot /',$line)) {
if ($start)
$this->_internal_row++;
@@ -39,10 +44,20 @@ class Database_TSM_Show extends Database_Result {
elseif (preg_match('/^barcode\s+/',$val))
$slot['barcode'] = preg_replace('/^barcode /','',$val);
$slot['library'] = preg_replace('/^show slots /','',$sql);
$slot['library'] = $library;
$this->_rows[$this->_internal_row] = new Slot($slot);
$start = TRUE;
if (! $barcodewarn AND $slot['status'] == 'Allocated' AND $slot['barcode'] == 'not present') {
SystemMessage::add(array(
'title'=>_('Missing Bar Code Labels'),
'type'=>'warning',
'body'=>sprintf(_('Some allocated slots do not have a bar code label, you may need to run "AUDIT LIBRARY %s CHECKLABEL=BARCODE"'),$library),
));
$barcodewarn = TRUE;
}
} elseif (preg_match('/busy.$/',$line)) {
SystemMessage::add(array(
'title'=>_('Library is Busy'),
@@ -51,11 +66,26 @@ class Database_TSM_Show extends Database_Result {
));
return;
} elseif (preg_match('/:/',$line)) {
$line = str_replace(' ','',$line);
list($k,$v) = explode(':',$line,2);
$this->data[$k] = $v;
} else {
}
}
}
$this->_total_rows = $this->_internal_row;
$this->_internal_row = 0;
}
public function __get($key) {
if (isset($this->data[$key]))
return $this->data[$key];
else
return NULL;
}
}
?>