<?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
 * ******************************************************************
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
JFormHelper::loadFieldClass('list');
jimport('joomla.form.formfield');
/**
 * JFormFieldVmOrderState 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 JFormFieldVmOrderState extends JFormFieldList
{
    var $type = 'vmOrderState';
    /**
     * GetOptions function
     *
     * @return void
     */
    protected function getOptions()
    {
        VmConfig::loadJLang(
            'com_virtuemart_orders',
            true
        );
        $options = array();
        $db = JFactory::getDBO();
        /* $query = 'SELECT `order_status_code` AS value, `order_status_name` AS text
                 FROM `#__virtuemart_orderstates`
                 WHERE `virtuemart_vendor_id` = 1
                 ORDER BY `ordering` ASC '; */
        $query = $db->getQuery(true);
        $query->select(
            $db->quoteName('order_status_code', 'value').
            ','.$db->quoteName('order_status_name', 'text')
        )
            ->from($db->quoteName('#__virtuemart_orderstates'))
            ->where($db->quoteName('virtuemart_vendor_id').'= 1')
            ->order($db->quoteName('ordering').' ASC');
        $db->setQuery($query);
        $values = $db->loadObjectList();
        foreach ($values as $value) {
            $options[] = JHtml::_(
                'select.option',
                $value->value,
                vmText::_($value->text)
            );
        }
        return array_merge(parent::getOptions(), $options);;
    }

}