<?php
/**
 *---------------------------------------------------------------------------------------
 * @package      VP Conversion Tracking - Joomla! System Plugin
 * @subpackage   For VirtueMart 3+
 *---------------------------------------------------------------------------------------
 * @copyright    Copyright (C) 2012-2021 VirtuePlanet Services LLP. All rights reserved.
 * @license      GNU General Public License version 2 or later; see LICENSE.txt
 * @authors      Abhishek Das
 * @email        info@virtueplanet.com
 * @link         https://www.virtueplanet.com
 *---------------------------------------------------------------------------------------
*/
defined('_JEXEC') or die;

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

class JFormFieldVMPrices extends JFormFieldList
{
	public $type = 'VMPrices';

	protected function getOptions()
	{
		if(!class_exists('VmConfig'))
		{
			require(JPATH_ROOT . '/administrator/components/com_virtuemart/helpers/config.php');
		}
		
		VmConfig::loadConfig();
		VmConfig::loadJLang('com_virtuemart');
		VmConfig::loadJLang('com_virtuemart_config');

		$options = array();
		$disabled  = VmConfig::get('basePrice', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'basePrice', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_BASEPRICE'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('basePriceVariant', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'basePriceVariant', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_BASEPRICE_VAR'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('variantModification', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'variantModification', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_VARMOD'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('basePriceWithTax', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'basePriceWithTax', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_BASEPRICE_WTAX'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('salesPriceWithDiscount', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'salesPriceWithDiscount', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_SALESPRICE_WD'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('salesPrice', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'salesPrice', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_SALESPRICE'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('discountedPriceWithoutTax', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'discountedPriceWithoutTax', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_DISCPRICE_WOTAX'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('priceWithoutTax', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'priceWithoutTax', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_SALESPRICE_WOTAX'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('discountAmount', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'discountAmount', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_DISC_AMOUNT'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('taxAmount', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'taxAmount', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_TAX_AMOUNT'), 'value', 'text', $disabled);
		$disabled  = VmConfig::get('unitPrice', 0) ? false : true;
		$options[] = JHtml::_('select.option', 'unitPrice', JText::_('COM_VIRTUEMART_ADMIN_CFG_PRICE_UNITPRICE'), 'value', 'text', $disabled);

		$options = array_merge(parent::getOptions(), $options);
		return $options;
	}
}