This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/application/classes/database/tsm/show.php

91 lines
2.6 KiB
PHP
Raw Normal View History

2011-06-24 01:27:21 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* TSM database show result. See [Results](/database/results) for usage and examples.
*
* @package PTA
* @subpackage TSM
* @category Query/Show
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Database_TSM_Show extends Database_Result {
2011-06-24 23:46:26 +00:00
private $data = array();
2011-06-24 01:27:21 +00:00
public function __construct($result, $sql, $as_object = FALSE, array $params = NULL) {
parent::__construct($result, $sql, $as_object, $params);
$sql = strtolower($sql);
$start = FALSE;
2011-06-24 23:46:26 +00:00
$barcodewarn = FALSE;
2011-06-24 01:27:21 +00:00
foreach ($result as $line) {
if (! trim($line))
continue;
2011-06-24 23:46:26 +00:00
if (preg_match('/^show slots /',$sql)) {
$library = strtoupper(preg_replace('/^show slots /','',$sql));
2011-06-24 01:27:21 +00:00
if (preg_match('/^Slot /',$line)) {
if ($start)
$this->_internal_row++;
$slot = array();
foreach ((preg_split('/,\s*/',$line,-1)) as $slotkey => $val)
if (preg_match('/^element number\s+/',$val))
2011-06-26 12:20:12 +00:00
$slot['element'] = (int)preg_replace('/^element number\s+/','',$val);
2011-06-24 01:27:21 +00:00
elseif (preg_match('/^Slot\s+/',$val))
$slot['slot'] = preg_replace('/^Slot\s+/','',$val);
elseif (preg_match('/^status\s+/',$val))
$slot['status'] = preg_replace('/^status\s+/','',$val);
elseif (preg_match('/^barcode value </',$val))
$slot['barcodelabel'] = preg_replace('/^barcode value <(.*)>/',"$1",$val);
elseif (preg_match('/^barcode\s+/',$val))
$slot['barcode'] = preg_replace('/^barcode /','',$val);
2011-06-24 23:46:26 +00:00
$slot['library'] = $library;
2011-06-24 01:27:21 +00:00
$this->_rows[$this->_internal_row] = new Slot($slot);
$start = TRUE;
2011-06-24 23:46:26 +00:00
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;
}
2011-06-24 01:27:21 +00:00
} elseif (preg_match('/busy.$/',$line)) {
SystemMessage::add(array(
'title'=>_('Library is Busy'),
'type'=>'info',
'body'=>_('The library appears busy at the moment.'),
));
return;
2011-06-24 23:46:26 +00:00
} elseif (preg_match('/:/',$line)) {
$line = str_replace(' ','',$line);
list($k,$v) = explode(':',$line,2);
$this->data[$k] = $v;
2011-06-24 01:27:21 +00:00
}
2011-06-24 23:46:26 +00:00
}
2011-06-24 01:27:21 +00:00
}
$this->_total_rows = $this->_internal_row;
$this->_internal_row = 0;
}
2011-06-24 23:46:26 +00:00
public function __get($key) {
if (isset($this->data[$key]))
return $this->data[$key];
else
return NULL;
}
2011-06-24 01:27:21 +00:00
}
?>