<?php
/**
 * JE GroupBuy package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2011 - 2012 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/
defined('JPATH_BASE') or die;

jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

/**
 * Supports an HTML select list of Sortby
 */
class JFormFieldPayment extends JFormFieldList
{
	/**
	 * @var		string	The form field type.
	 */
	public $type = 'payment';

	/**
	 * Method to get the field options.
	 */
	protected function getOptions()
	{
		$options		= array();
		$db				= & JFactory::getDbo();
		$query			= $db->getQuery(true);

		$query->select("element,name");
		$query->from("#__extensions");
		$query->where("folder='jegroupbuypayment'");
		$db->setQuery($query);

		$prod			= $db->loadObjectList();
		
		$options[]	= JHTML::_('select.option',  JText::_("FREE_COUPON"), JText::_("FREE_COUPON"));

		foreach ( $prod as $key=>$value ) {
			$options[]	= JHTML::_('select.option',  $value->element, $value->name);
		}

		return $options;
	}
}