<?php defined('SYSPATH') or die('No direct access allowed.');

/**
 *
 * @package    PTA
 * @subpackage Database
 * @category   Models
 * @author     Deon George
 * @copyright  (c) 2010 phpTSMadmin Development Team
 * @license    http://phptsmadmin.sf.net/license.html
 */
class Model_DB extends ORM_TSM {
	protected $_table_name = 'DB';
	protected $_primary_key = 'DATABASE_NAME';
	protected $_sorting = array(
		'DATABASE_NAME'=>'ASC',
	);

        protected $_display_filters = array(
		'FREE_PAGES'=>array(
			array('number_format',array(':value',0)),
		),
		'FREE_SPACE_MB'=>array(
			array('number_format',array(':value',0)),
		),
		'LAST_REORG'=>array(
			array('ORM_TSM::date',array(':value','d-M H:i')),
		),
		'LAST_BACKUP_DATE'=>array(
			array('ORM_TSM::date',array(':value','d-M H:i')),
		),
		'TOTAL_BUFF_REQ'=>array(
			array('number_format',array(':value',0)),
		),
		'TOT_FILE_SYSTEM_MB'=>array(
			array('number_format',array(':value',0)),
		),
		'TOTAL_PAGES'=>array(
			array('number_format',array(':value',0)),
		),
		'USED_DB_SPACE_MB'=>array(
			array('number_format',array(':value',0)),
		),
		'USABLE_PAGES'=>array(
			array('number_format',array(':value',0)),
		),
		'USED_PAGES'=>array(
			array('number_format',array(':value',0)),
		),
	);

	public function backups() {
		return ORM::factory('VOLHISTORY')->where('TYPE','IN',Kohana::$config->load('config')->tsmdbtypes)->find_all();
	}

	public function vols() {
		return ORM::factory('DBSPACE')->find_all();
	}
}
?>
