<?php
/**
 * Marketplace - Component Marketplace 
 * ******************************************************************
 *
 * PHP version 7.0
 *
 * @category   Component
 * @package    Joomla
 * @author     WebKul software private limited <support@webkul.com>
 * @copyright  2010 WebKul software private limited
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version    GIT:5.2
 * @filesource http://store.webkul.com
 * @link       Technical Support:  webkul.uvdesk.com
 * ******************************************************************
 */
defined('_JEXEC') or die('Restricted access');
JFormHelper::loadFieldClass('list');
jimport('joomla.form.formfield');
/**
 * JFormFieldVmCountries class
 * 
 * @category Component
 * @package  Joomla
 * @author   WebKul software private limited <support@webkul.com>
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link     Technical Support:  webkul.uvdesk.com
 */
class JFormFieldVmCountries extends JFormFieldList
{
    var $type = 'vmCountries';
    /**
     * GetInput function
     *
     * @return void
     */
    protected function getInput()
    {
        $this->multiple=true;
        return parent::getInput();
    }
    /**
     * GetOptions function
     *
     * @return void
     */
    protected function getOptions()
    {
        $options = array();
        $this->multiple=true;
        $db = JFactory::getDBO();
        $query = $db->getQuery(true);
        $query->select(
            $db->quoteName('virtuemart_country_id', 'value').
            ",".$db->quoteName('country_name', 'text')
        )
            ->from($db->quoteName('#__virtuemart_countries'))
            ->where($db->quoteName('published')."= 1")
            ->order('country_name ASC');
        $db->setQuery($query);
        
        $values = $db->loadObjectList();
        $options=array();
        $default=1;
        foreach($values as $v) :
            $options[] = JHtml::_('select.option', $v->value, $v->text);
        endforeach;
        $dropdown = JHTML::_(
            'select.genericlist',
            $options,
            'countries',
            'class="inputbox"',
            'value',
            'text',
            $default
        );
        return $dropdown;
    }
}