<?php
/**
 * Element selector for menu entry
 *
 * @package 	CSVIVirtueMart
 * @author 		Roland Dalmulder
 * @link 		http://www.csvimproved.com
 * @copyright 	Copyright (C) 2006 - 2012 RolandD Cyber Produksi
 * @license 	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * @version 	$Id: template.php 1892 2012-02-11 11:01:09Z RolandD $
 */
 
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

class JElementTemplate extends JElement {
	
	/**
	 * Element name
	 *
	 * @access	protected
	 * @var		string
	 */
	var	$_name = 'Export template';
	
	/**
	 * Get an element 
	 * 
	 * @copyright 
	 * @author 		RolandD
	 * @todo 		Add option when no template is found
	 * @see 
	 * @access 		public
	 * @param 
	 * @return 
	 * @since 		3.0
	 */
	public function fetchElement($name, $value, $node, $control_name) {
		$db = JFactory::getDBO();
		$q = "SELECT id, name 
			FROM #__csvivirtuemart_template_settings
			WHERE type = 'export'
			AND settings LIKE ".$db->Quote('%"export_frontend":"1"%');
		$db->setQuery($q);
		$templates = $db->loadObjectList();
		return JHTML::_('select.genericlist', $templates, $control_name.'['.$name.']', '', 'id', 'name', $value, $control_name.$name);
	}
}
