<?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('JPATH_BASE') or die;
jimport('joomla.form.formfield');
/**
 * JFormFieldAsset 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 JFormFieldAsset extends JFormField
{
    protected $type = 'Asset';
    /**
     * GetInput function
     *
     * @return void
     */
    protected function getInput()
    {
        if (!class_exists('VmConfig')) {
            include_once JPATH_ADMINISTRATOR.
            '/components/com_virtuemart/helpers/config.php';
        }
        if (!class_exists('CurrencyDisplay')) {
            include_once JPATH_ADMINISTRATOR.
            '/components/com_virtuemart/helpers/currencydisplay.php';
        }
        VmConfig::loadConfig();
        $currencyObj=CurrencyDisplay::getInstance();
        $curr=$currencyObj->getSymbol();
        $doc = JFactory::getDocument();
        $doc->addScript(
            JURI::root().
            'administrator/components/com_marketplace/elements/script.js'
        );
        $doc->addStyleSheet(
            JURI::root().
            'administrator/components/com_marketplace/elements/style.css'
        );
        ?>
        <script type="text/javascript">
        jQuery(function () {
            if (jQuery('#jform_commision_option label[for=jform_commision_option0]').hasClass('btn-success')) {
                jQuery('#jform_commision').next('.add-on').html('%');
            } else {
                jQuery('#jform_commision').next('.add-on').html('<?php echo $curr;?>');
            }
            jQuery('#jform_commision_option').on('change', function () {
                if (jQuery('#jform_commision_option label[for=jform_commision_option0]').hasClass('btn-success')) {
                    jQuery('#jform_commision').next('.add-on').html('%');
                } else {
                    jQuery('#jform_commision').next('.add-on').html('<?php echo $curr;?>');
                }
            });
        });
        </script>
        <?php
        return null;
    }
}
