<?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_DataMap extends ORM_OSB {
	// Relationships
	protected $_belongs_to = array(
		'export_module' => array(),
		'module' => array(),
	);

	public function list_itemsnoexport(Model $o,$emoid,$desc='title()') {
		$result = array();

		$o->select(array($this->table_name().'.id','edm'))
		->join($this->table_name(),'LEFT OUTER')
		->on($this->table_name().'.site_id','=',$o->table_name().'.site_id') // @todo This should be automatic
		->on($this->table_name().'.item_id','=',$o->table_name().'.id')
		->on('export_module_id','=',$emoid)
		->where($o->table_name().'.status','=',TRUE)
		->having('edm','=',NULL);

		foreach ($o->find_all() as $object)
			$result[$object->id] = $object->resolve($desc);

		return $result;
	}
}
?>
