protected function getOptions()
    {
        $options = array();
        if (!class_exists('VirtueMartModelVendor')) {
            require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
        }
        $vendor_id = VirtueMartModelVendor::getLoggedVendor();
        // set currency_id to logged vendor
        if (empty($this->value)) {
            $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
            $this->value = $currency->virtuemart_currency_id;
        }
        // why not logged vendor? shared is missing
        $db = JFactory::getDBO();
        $query = 'SELECT `virtuemart_currency_id` AS value, `currency_name` AS text
			FROM `#__virtuemart_currencies`
			WHERE `virtuemart_vendor_id` = "1"  AND `published` = "1" ORDER BY `currency_name` ASC ';
        // default value should be vendor currency
        $db->setQuery($query);
        $values = $db->loadObjectList();
        foreach ($values as $v) {
            $options[] = JHtml::_('select.option', $v->value, $v->text);
        }
        // Merge any additional options in the XML definition.
        $options = array_merge(parent::getOptions(), $options);
        return $options;
    }
 public function getCurrencyCode($currency_id)
 {
     $vendorId = VirtueMartModelVendor::getLoggedVendor();
     $db = JFactory::getDBO();
     $q = 'SELECT   `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`=' . $currency_id;
     $db->setQuery($q);
     return $db->loadResult();
 }
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->loadHelper('html');
     // get necessary models
     $model = VmModel::getModel('manufacturer');
     $categoryModel = VmModel::getModel('manufacturercategories');
     $layoutName = JRequest::getWord('layout', 'default');
     if ($layoutName == 'edit') {
         $manufacturer = $model->getManufacturer();
         $model->addImages($manufacturer);
         $this->manufacturer = $manufacturer;
         /* Process the images */
         $mediaModel = VmModel::getModel('media');
         $mediaModel->setId($manufacturer->virtuemart_media_id);
         $image = $mediaModel->getFile('manufacturer', 'image');
         $manufacturerCategories = $categoryModel->getManufacturerCategories(false, true);
         $this->manufacturerCategories = $manufacturerCategories;
         $this->SetViewTitle('', $manufacturer->mf_name);
         $this->addStandardEditViewCommands($manufacturer->virtuemart_manufacturer_id);
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . '/models' . DS . 'vendor.php';
         }
         $virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor();
         $this->virtuemart_vendor_id = $virtuemart_vendor_id;
     } else {
         if (JRequest::getWord('format', '') === 'raw') {
             $tpl = 'results';
         } else {
             $this->SetViewTitle();
             $this->addStandardDefaultViewCommands();
         }
         $mainframe = JFactory::getApplication();
         $categoryFilter = $categoryModel->getCategoryFilter();
         $this->addStandardDefaultViewLists($model, 'mf_name');
         $this->manufacturers = $model->getManufacturers();
         $this->pagination = $model->getPagination();
         $virtuemart_manufacturercategories_id = $mainframe->getUserStateFromRequest('com_virtuemart.virtuemart_manufacturercategories_id', 'virtuemart_manufacturercategories_id', 0, 'int');
         $this->lists['virtuemart_manufacturercategories_id'] = JHTML::_('select.genericlist', $categoryFilter, 'virtuemart_manufacturercategories_id', ' onChange="Joomla.ajaxSearch(this); return false;" ', 'value', 'text', $virtuemart_manufacturercategories_id);
     }
     parent::display($tpl);
     if ($tpl === 'results') {
         echo $this->AjaxScripts();
     }
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     $db = JFactory::getDBO();
     $query = 'SELECT `virtuemart_currency_id` AS value, `currency_name` AS text
     		 FROM `#__virtuemart_currencies`
     		 WHERE `virtuemart_vendor_id` = "1"  AND `published` = "1" ORDER BY `currency_name` ASC ';
     // default value should be vendor currency
     $db->setQuery($query);
     $currencies = $db->loadObjectList();
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $vendor_id = VirtueMartModelVendor::getLoggedVendor();
     if (empty($value)) {
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $value = $currency->virtuemart_currency_id;
     }
     return JHTML::_('select.genericlist', $currencies, $control_name . '[' . $name . '][]', $class, 'value', 'text', $value, $control_name . $name);
 }
 function display($tpl = null)
 {
     // Load the helper(s)
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     // get necessary models
     $model = VmModel::getModel('manufacturer');
     $categoryModel = VmModel::getModel('manufacturercategories');
     $this->SetViewTitle();
     $layoutName = JRequest::getWord('layout', 'default');
     if ($layoutName == 'edit') {
         $manufacturer = $model->getManufacturer();
         $isNew = $manufacturer->virtuemart_manufacturer_id < 1;
         $model->addImages($manufacturer);
         $this->assignRef('manufacturer', $manufacturer);
         /* Process the images */
         $mediaModel = VmModel::getModel('media');
         $mediaModel->setId($manufacturer->virtuemart_media_id);
         $image = $mediaModel->getFile('manufacturer', 'image');
         $manufacturerCategories = $categoryModel->getManufacturerCategories(false, true);
         $this->assignRef('manufacturerCategories', $manufacturerCategories);
         $this->addStandardEditViewCommands($manufacturer->virtuemart_manufacturer_id);
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor();
         $this->assignRef('virtuemart_vendor_id', $virtuemart_vendor_id);
     } else {
         $mainframe = JFactory::getApplication();
         $categoryFilter = $categoryModel->getCategoryFilter();
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model, 'mf_name');
         $manufacturers = $model->getManufacturers();
         $this->assignRef('manufacturers', $manufacturers);
         $pagination = $model->getPagination();
         $this->assignRef('pagination', $pagination);
         $virtuemart_manufacturercategories_id = $mainframe->getUserStateFromRequest('com_virtuemart.virtuemart_manufacturercategories_id', 'virtuemart_manufacturercategories_id', 0, 'int');
         $this->lists['virtuemart_manufacturercategories_id'] = JHTML::_('select.genericlist', $categoryFilter, 'virtuemart_manufacturercategories_id', 'class="inputbox" onchange="this.form.submit()"', 'value', 'text', $virtuemart_manufacturercategories_id);
     }
     parent::display($tpl);
 }
 function onDisplayEditBECustom($virtuemart_custom_id, &$customPlugin)
 {
     //if($this->plugin = $this->selectedThisByMethodId($this->_psType,$virtuemart_custom_id)){
     if ($this->plugin = $this->selectedThisByMethodId($virtuemart_custom_id)) {
         if (empty($this->plugin)) {
             $this->plugin->custom_jplugin_id = null;
             return $this->plugin;
         }
         //Must use here the table to get valid params
         $this->plugin = $this->getVmPluginMethod($this->plugin->virtuemart_custom_id);
         if (empty($this->plugin->virtuemart_vendor_id)) {
             if (!class_exists('VirtueMartModelVendor')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
             }
             $this->plugin->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor();
         }
         $customPlugin = $this->plugin;
         //   		return $this->plugin;
         return true;
     }
 }
Exemple #7
0
 /**
  *
  * @author Max Milbers
  *
  */
 public function getData($id = 0)
 {
     if ($id != 0) {
         $this->_id = (int) $id;
     }
     if (empty($this->_cache[$this->_id])) {
         $this->_cache[$this->_id] = $this->getTable($this->_maintablename);
         $this->_cache[$this->_id]->load($this->_id);
         //just an idea
         if (isset($this->_cache[$this->_id]->virtuemart_vendor_id) && empty($this->_data->virtuemart_vendor_id)) {
             if (!class_exists('VirtueMartModelVendor')) {
                 require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
             }
             $this->_cache[$this->_id]->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor();
         }
     }
     return $this->_cache[$this->_id];
 }
 public function store(&$data)
 {
     if (!empty($data['params'])) {
         foreach ($data['params'] as $k => $v) {
             $data[$k] = $v;
         }
     }
     if (empty($data['virtuemart_vendor_id'])) {
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor();
     } else {
         $data['virtuemart_vendor_id'] = (int) $data['virtuemart_vendor_id'];
     }
     // missing string FIX, Bad way ?
     if (JVM_VERSION === 1) {
         $tb = '#__plugins';
         $ext_id = 'id';
     } else {
         $tb = '#__extensions';
         $ext_id = 'extension_id';
     }
     $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['custom_jplugin_id'] . '"';
     $this->_db->setQuery($q);
     $data['custom_element'] = $this->_db->loadResult();
     // 		vmdebug('store custom',$data);
     $table = $this->getTable('customs');
     if (isset($data['custom_jplugin_id'])) {
         vmdebug('$data store custom', $data);
         JPluginHelper::importPlugin('vmcustom');
         $dispatcher = JDispatcher::getInstance();
         // 			$retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsCustom',array($data['custom_value'],$data['custom_jplugin_id'],&$table));
         $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsCustom', array($data['custom_element'], $data['custom_jplugin_id'], &$table));
     }
     $table->bindChecknStore($data);
     $errors = $table->getErrors();
     if (!empty($errors)) {
         foreach ($errors as $error) {
             vmError($error);
         }
     }
     JPluginHelper::importPlugin('vmcustom');
     $dispatcher = JDispatcher::getInstance();
     $error = $dispatcher->trigger('plgVmOnStoreInstallPluginTable', array('custom', $data));
     return $table->virtuemart_custom_id;
 }
Exemple #9
0
 /**
  * Bind the post data to the shipment tables and save it
  *
  * @author Max Milbers
  * @return boolean True is the save was successful, false otherwise.
  */
 public function store(&$data)
 {
     if ($data) {
         $data = (array) $data;
     }
     if (!empty($data['params'])) {
         foreach ($data['params'] as $k => $v) {
             $data[$k] = $v;
         }
     }
     if (empty($data['virtuemart_vendor_id'])) {
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor();
     } else {
         $data['virtuemart_vendor_id'] = (int) $data['virtuemart_vendor_id'];
     }
     $tb = '#__extensions';
     $ext_id = 'extension_id';
     $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['shipment_jplugin_id'] . '"';
     $db = JFactory::getDBO();
     $db->setQuery($q);
     $data['shipment_element'] = $db->loadResult();
     $table = $this->getTable('shipmentmethods');
     if (isset($data['shipment_jplugin_id'])) {
         JPluginHelper::importPlugin('vmshipment');
         $dispatcher = JDispatcher::getInstance();
         //bad trigger, we should just give it data, so that the plugins itself can check the data to be stored
         //so this trigger is now deprecated and will be deleted in vm2.2
         $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsShipment', array($data['shipment_element'], $data['shipment_jplugin_id'], &$table));
         $retValue = $dispatcher->trigger('plgVmSetOnTablePluginShipment', array(&$data, &$table));
     }
     $table->bindChecknStore($data);
     $errors = $table->getErrors();
     foreach ($errors as $error) {
         vmError($error);
     }
     $xrefTable = $this->getTable('shipmentmethod_shoppergroups');
     $xrefTable->bindChecknStore($data);
     $errors = $xrefTable->getErrors();
     foreach ($errors as $error) {
         vmError($error);
     }
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmshipment');
     //Add a hook here for other shipment methods, checking the data of the choosed plugin
     $dispatcher = JDispatcher::getInstance();
     $retValues = $dispatcher->trigger('plgVmOnStoreInstallShipmentPluginTable', array($data['shipment_jplugin_id']));
     return $table->virtuemart_shipmentmethod_id;
 }
Exemple #10
0
    function getVendorAcceptedCurrrenciesList($vendorId = 0)
    {
        static $currencies = array();
        if ($vendorId === 0) {
            $multix = Vmconfig::get('multix', 'none');
            if (strpos($multix, 'payment') !== FALSE) {
                if (!class_exists('VirtueMartModelVendor')) {
                    require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
                }
                $vendorId = VirtueMartModelVendor::getLoggedVendor();
            } else {
                $vendorId = 1;
            }
        }
        if (!isset($currencies[$vendorId])) {
            $db = JFactory::getDbo();
            $q = 'SELECT `vendor_accepted_currencies`, `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id`=' . $vendorId;
            $db->setQuery($q);
            $vendor_currency = $db->loadAssoc();
            if (!$vendor_currency['vendor_accepted_currencies']) {
                $vendor_currency['vendor_accepted_currencies'] = $vendor_currency['vendor_currency'];
                vmWarn('No accepted currencies defined');
                if (empty($vendor_currency['vendor_accepted_currencies'])) {
                    $uri = JFactory::getURI();
                    $link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=user&task=editshop';
                    vmWarn(vmText::sprintf('COM_VIRTUEMART_CONF_WARN_NO_CURRENCY_DEFINED', '<a href="' . $link . '">' . $link . '</a>'));
                    $currencies[$vendorId] = false;
                    return $currencies[$vendorId];
                }
            }
            $q = 'SELECT `virtuemart_currency_id`,CONCAT_WS(" ",`currency_name`,`currency_symbol`) as currency_txt
					FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id` IN (' . $vendor_currency['vendor_accepted_currencies'] . ')';
            if ($vendorId != 1) {
                $q .= ' AND (`virtuemart_vendor_id` = "' . $vendorId . '" OR `shared`="1")';
            }
            $q .= '	AND published = "1"
					ORDER BY `ordering`,`currency_name`';
            $db->setQuery($q);
            $currencies[$vendorId] = $db->loadObjectList();
        }
        return $currencies[$vendorId];
    }
Exemple #11
0
 /**
  * Bind the post data to the shipment tables and save it
  *
  * @author Max Milbers
  * @return boolean True is the save was successful, false otherwise.
  */
 public function store(&$data)
 {
     //$data = JRequest::get('post');
     if ($data) {
         $data = (array) $data;
     }
     // 		vmdebug('store',$data);
     if (!empty($data['params'])) {
         foreach ($data['params'] as $k => $v) {
             $data[$k] = $v;
         }
     }
     if (empty($data['virtuemart_vendor_id'])) {
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor();
     } else {
         $data['virtuemart_vendor_id'] = (int) $data['virtuemart_vendor_id'];
     }
     // missing string FIX, Bad way ?
     if (JVM_VERSION === 1) {
         $tb = '#__plugins';
         $ext_id = 'id';
     } else {
         $tb = '#__extensions';
         $ext_id = 'extension_id';
     }
     $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['shipment_jplugin_id'] . '"';
     $this->_db->setQuery($q);
     $data['shipment_element'] = $this->_db->loadResult();
     $table = $this->getTable('shipmentmethods');
     if (isset($data['shipment_jplugin_id'])) {
         JPluginHelper::importPlugin('vmshipment');
         $dispatcher = JDispatcher::getInstance();
         $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsShipment', array($data['shipment_element'], $data['shipment_jplugin_id'], &$table));
     }
     $table->bindChecknStore($data);
     $errors = $table->getErrors();
     foreach ($errors as $error) {
         vmError($error);
     }
     $xrefTable = $this->getTable('shipmentmethod_shoppergroups');
     $xrefTable->bindChecknStore($data);
     $errors = $xrefTable->getErrors();
     foreach ($errors as $error) {
         vmError($error);
     }
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmshipment');
     //Add a hook here for other shipment methods, checking the data of the choosed plugin
     $dispatcher = JDispatcher::getInstance();
     $retValues = $dispatcher->trigger('plgVmOnStoreInstallShipmentPluginTable', array($data['shipment_jplugin_id']));
     return $table->virtuemart_shipmentmethod_id;
 }
Exemple #12
0
 public function store(&$data)
 {
     if (!empty($data['params'])) {
         foreach ($data['params'] as $k => $v) {
             $data[$k] = $v;
         }
     }
     //I think this is obsolete, note by Max
     if (empty($data['virtuemart_vendor_id'])) {
         if (!class_exists('VirtueMartModelVendor')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
         }
         $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor();
     } else {
         $data['virtuemart_vendor_id'] = (int) $data['virtuemart_vendor_id'];
     }
     if (isset($data['custom_jplugin_id'])) {
         $tb = '#__extensions';
         $ext_id = 'extension_id';
         $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['custom_jplugin_id'] . '"';
         $db = JFactory::getDBO();
         $db->setQuery($q);
         $data['custom_element'] = $db->loadResult();
         $q = 'UPDATE `#__extensions` SET `enabled`= 1 WHERE `extension_id` = "' . $data['custom_jplugin_id'] . '"';
         $db->setQuery($q);
         $db->execute();
     }
     $table = $this->getTable('customs');
     $table->field_type = $data['field_type'];
     $table->custom_element = $data['custom_element'];
     $table->custom_jplugin_id = $data['custom_jplugin_id'];
     $table->_xParams = 'custom_params';
     if (!empty($data['is_input'])) {
         if (empty($data['layout_pos'])) {
             $data['layout_pos'] = 'addtocart';
         }
     }
     //We are in the custom and so the table contains the field_type, else not!!
     self::setParameterableByFieldType($table, $table->field_type);
     $table->bindChecknStore($data);
     JPluginHelper::importPlugin('vmcustom');
     $dispatcher = JDispatcher::getInstance();
     $error = $dispatcher->trigger('plgVmOnStoreInstallPluginTable', array('custom', $data, $table));
     return $table->virtuemart_custom_id;
 }
Exemple #13
0
 /**
  *
  * @author Max Milbers
  *
  */
 public function getData()
 {
     if (empty($this->_data)) {
         $this->_data = $this->getTable($this->_maintablename);
         $this->_data->load($this->_id);
         //just an idea
         if (isset($this->_data->virtuemart_vendor_id) && empty($this->_data->virtuemart_vendor_id)) {
             if (!class_exists('VirtueMartModelVendor')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
             }
             $this->_data->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor();
         }
     }
     return $this->_data;
 }
Exemple #14
0
 /**
  * Bind the post data to the paymentmethod tables and save it
  *
  * @author Max Milbers
  * @return boolean True is the save was successful, false otherwise.
  */
 public function store(&$data)
 {
     if ($data) {
         $data = (array) $data;
     }
     if (!empty($data['params'])) {
         foreach ($data['params'] as $k => $v) {
             $data[$k] = $v;
         }
     }
     if (empty($data['virtuemart_vendor_id'])) {
         if (!class_exists('VirtueMartModelVendor')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
         }
         $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor();
     }
     $table = $this->getTable('paymentmethods');
     if (isset($data['payment_jplugin_id'])) {
         $q = 'SELECT `element` FROM `#__extensions` WHERE `extension_id` = "' . $data['payment_jplugin_id'] . '"';
         $db = JFactory::getDBO();
         $db->setQuery($q);
         $data['payment_element'] = $db->loadResult();
         $q = 'UPDATE `#__extensions` SET `enabled`= 1 WHERE `extension_id` = "' . $data['payment_jplugin_id'] . '"';
         $db->setQuery($q);
         $db->execute();
         JPluginHelper::importPlugin('vmpayment');
         $dispatcher = JDispatcher::getInstance();
         $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsPayment', array($data['payment_element'], $data['payment_jplugin_id'], &$table));
     }
     $table->bindChecknStore($data);
     $xrefTable = $this->getTable('paymentmethod_shoppergroups');
     $xrefTable->bindChecknStore($data);
     if (!class_exists('vmPSPlugin')) {
         require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmpayment');
     //Add a hook here for other shipment methods, checking the data of the choosed plugin
     $dispatcher = JDispatcher::getInstance();
     $retValues = $dispatcher->trigger('plgVmOnStoreInstallPaymentPluginTable', array($data['payment_jplugin_id']));
     return $table->virtuemart_paymentmethod_id;
 }
Exemple #15
0
 public function store(&$data)
 {
     if (!vmAccess::manager('custom.edit')) {
         vmWarn('Insufficient permission to edit custom');
         return false;
     }
     if (!empty($data['params'])) {
         foreach ($data['params'] as $k => $v) {
             $data[$k] = $v;
         }
     }
     //I think this is obsolete, note by Max
     if (empty($data['virtuemart_vendor_id'])) {
         if (!class_exists('VirtueMartModelVendor')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
         }
         $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor();
     } else {
         $data['virtuemart_vendor_id'] = (int) $data['virtuemart_vendor_id'];
     }
     $table = $this->getTable('customs');
     if (!empty($data['custom_jplugin_id'])) {
         $tb = '#__extensions';
         $ext_id = 'extension_id';
         $db = JFactory::getDBO();
         $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['custom_jplugin_id'] . '"';
         $db->setQuery($q);
         $cElement = $db->loadResult();
         if (empty($cElement)) {
             if (!empty($data['virtuemart_custom_id'])) {
                 $table->load($data['virtuemart_custom_id']);
                 $cElement = $table->custom_element;
             } else {
                 if (!empty($data['custom_element'])) {
                     $cElement = $data['custom_element'];
                 }
             }
             $q = 'SELECT * FROM `' . $tb . '` WHERE `element` = "' . $cElement . '" ';
             $db->setQuery($q);
             if ($jids = $db->loadAssocList()) {
                 $newJid = 0;
                 foreach ($jids as $jid) {
                     $newJid = $jid[$ext_id];
                     if ($jid['enabled'] == 1 and $jid['state'] == 0) {
                         break;
                     }
                 }
                 vmdebug('Available entries ', $newJid, $jids);
                 if (!empty($newJid)) {
                     $q = 'UPDATE `#__virtuemart_customs` SET `custom_jplugin_id`="' . $jid . '" WHERE `custom_jplugin_id` = "' . $data['custom_jplugin_id'] . '"';
                     $db->setQuery($q);
                     $db->execute();
                     $data['custom_jplugin_id'] = $newJid;
                     vmInfo('Old Plugin id was not available, updated entries with ' . $ext_id . ' = ' . $newJid . ' found for the same element');
                 }
             } else {
                 vmWarn('could not load custom_element for plugin, testing if current custom_jplugin_id is still available ' . $q);
             }
         }
         if (!empty($cElement)) {
             $data['custom_element'] = $cElement;
         }
         $q = 'UPDATE `#__extensions` SET `enabled`= 1, `state` = 0 WHERE `extension_id` = "' . $data['custom_jplugin_id'] . '"';
         $db->setQuery($q);
         $db->execute();
     }
     $table->field_type = $data['field_type'];
     if ($table->field_type == 'C') {
         //vmInfo();
         //$data['is_cart_attribute'] = 1;
     }
     $table->custom_element = $data['custom_element'];
     $table->custom_jplugin_id = $data['custom_jplugin_id'];
     $table->_xParams = 'custom_params';
     if (!empty($data['is_input'])) {
         if (empty($data['layout_pos'])) {
             $data['layout_pos'] = 'addtocart';
         }
     }
     //We are in the custom and so the table contains the field_type, else not!!
     self::setParameterableByFieldType($table, $table->field_type);
     if (empty($data['virtuemart_custom_id']) and !vmAccess::manager('custom.create')) {
         vmWarn('Insufficient permission to create custom');
         return false;
     }
     $table->bindChecknStore($data);
     JPluginHelper::importPlugin('vmcustom');
     $dispatcher = JDispatcher::getInstance();
     $error = $dispatcher->trigger('plgVmOnStoreInstallPluginTable', array('custom', $data, $table));
     return $table->virtuemart_custom_id;
 }
 /**
  * Bind the post data to the paymentmethod tables and save it
  *
  * @author Max Milbers
  * @return boolean True is the save was successful, false otherwise.
  */
 public function store(&$data)
 {
     if ($data) {
         $data = (array) $data;
     }
     if (!vmAccess::manager('paymentmethod.edit')) {
         vmWarn('Insufficient permissions to store paymentmethod');
         return false;
     } else {
         if (empty($data['virtuemart_payment_id']) and !vmAccess::manager('paymentmethod.create')) {
             vmWarn('Insufficient permission to create paymentmethod');
             return false;
         }
     }
     if (!empty($data['params'])) {
         foreach ($data['params'] as $k => $v) {
             $data[$k] = $v;
         }
     }
     if (empty($data['virtuemart_vendor_id'])) {
         if (!class_exists('VirtueMartModelVendor')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
         }
         $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor();
     }
     $tCon = array('min_amount', 'max_amount', 'cost_per_transaction', 'cost_min_transaction', 'cost_percent_total');
     foreach ($tCon as $f) {
         if (!empty($data[$f])) {
             $data[$f] = str_replace(array(',', ' '), array('.', ''), $data[$f]);
         }
     }
     $table = $this->getTable('paymentmethods');
     if (isset($data['payment_jplugin_id'])) {
         $q = 'SELECT `element` FROM `#__extensions` WHERE `extension_id` = "' . $data['payment_jplugin_id'] . '"';
         $db = JFactory::getDBO();
         $db->setQuery($q);
         $data['payment_element'] = $db->loadResult();
         $q = 'UPDATE `#__extensions` SET `enabled`= 1 WHERE `extension_id` = "' . $data['payment_jplugin_id'] . '"';
         $db->setQuery($q);
         $db->execute();
         JPluginHelper::importPlugin('vmpayment');
         $dispatcher = JDispatcher::getInstance();
         $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsPayment', array($data['payment_element'], $data['payment_jplugin_id'], &$table));
         $retValue = $dispatcher->trigger('plgVmSetOnTablePluginPayment', array(&$data, &$table));
     }
     $table->bindChecknStore($data);
     $xrefTable = $this->getTable('paymentmethod_shoppergroups');
     $xrefTable->bindChecknStore($data);
     if (!class_exists('vmPSPlugin')) {
         require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmpayment');
     //Add a hook here for other payment methods, checking the data of the choosed plugin
     $dispatcher = JDispatcher::getInstance();
     $retValues = $dispatcher->trigger('plgVmOnStoreInstallPaymentPluginTable', array($data['payment_jplugin_id']));
     return $table->virtuemart_paymentmethod_id;
 }