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

/**
 * This class supports OSB exporting.
 *
 * @package    Export
 * @category   Models
 * @author     Deon George
 * @copyright  (c) 2009-2013 Open Source Billing
 * @license    http://dev.osbill.net/license.html
 */
class Model_Export extends ORM_OSB {
	// Relationships
	protected $_has_many = array(
		'export_module' => array('far_key'=>'id','xforeign_key'=>'x'),
	);

	protected $_form = array('id'=>'id','value'=>'name');

	/**
	 * Return the object of the export plugin
	 */
	public function plugin(Model_Export_Module $emo,$type='') {
		$c = Kohana::classname('Export_Plugin_'.$this->plugin);

		if (! $this->plugin OR ! class_exists($c))
			return NULL;

		$o = new $c($emo);

		return $type ? $o->$type : $o;
	}
}
?>