/** * Render the view */ function display($tpl = null) { // Load the helper(s) $this->loadHelper('html'); $this->loadHelper('html'); $this->loadHelper('currencydisplay'); $this->loadHelper('reportFunctions'); $model = VmModel::getModel(); // $config = JFactory::getConfig(); // $tzoffset = $config->getValue('config.offset'); JRequest::setvar('task', ''); // set period //$date_presets = $model->getDatePresets(); $this->SetViewTitle('REPORT'); $myCurrencyDisplay = CurrencyDisplay::getInstance(); $this->addStandardDefaultViewLists($model); $revenueBasic = $model->getRevenue(); if ($revenueBasic) { $totalReport['revenueTotal_brutto'] = $totalReport['revenueTotal_netto'] = $totalReport['number_of_ordersTotal'] = $totalReport['itemsSoldTotal'] = 0; foreach ($revenueBasic as &$j) { vmdebug('VirtuemartViewReport revenue', $j); $totalReport['revenueTotal_netto'] += $j['order_subtotal_netto']; $totalReport['revenueTotal_brutto'] += $j['order_subtotal_brutto']; $totalReport['number_of_ordersTotal'] += $j['count_order_id']; $j['order_subtotal_netto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_netto']); $j['order_subtotal_brutto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_brutto']); $j['product_quantity'] = $model->getItemsByRevenue($j); $totalReport['itemsSoldTotal'] += $j['product_quantity']; } $totalReport['revenueTotal_netto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_netto']); $totalReport['revenueTotal_brutto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_brutto']); // if ( 'product_quantity'==JRequest::getWord('filter_order')) { // foreach ($revenueBasic as $key => $row) { // $created_on[] =$row['created_on']; // $intervals[] =$row['intervals']; // $itemsSold[] =$row['product_quantity']; // $number_of_orders[] =$row['count_order_id']; // $revenue[] =$row['revenue']; // } // if (JRequest::getWord('filter_order_Dir') == 'desc') array_multisort($itemsSold, SORT_DESC,$revenueBasic); // else array_multisort($itemsSold, SORT_ASC,$revenueBasic); // } } $this->assignRef('report', $revenueBasic); $this->assignRef('totalReport', $totalReport); //$itemsSold = $model->getItemsSold($revenueBasic); //$this->assignRef('itemsSold', $itemsSold); // I tihnk is to use in a different layout such as product solds // PATRICK K. // $productList = $model->getOrderItems(); // $this->assignRef('productList', $productList); $this->lists['select_date'] = $model->renderDateSelectList(); $this->lists['state_list'] = $model->renderOrderstatesList(); $this->lists['intervals'] = $model->renderIntervalsList(); $this->assignRef('from_period', $model->from_period); $this->assignRef('until_period', $model->until_period); $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); parent::display($tpl); }
function convert($amountA, $currA = '', $currB = '', $a2rC = true, $relatedCurrency = 'EUR') { // cache subfolder(group) 'convertECB', cache method: callback $cache = JFactory::getCache('convertECB', 'callback'); // save configured lifetime @($lifetime = $cache->lifetime); $cache->setLifeTime(86400 / 4); // check 4 time per day // save cache conf $conf = JFactory::getConfig(); // check if cache is enabled in configuration $cacheactive = $conf->getValue('config.caching'); $cache->setCaching(1); //enable caching $globalCurrencyConverter = $cache->call(array('convertECB', 'getSetExchangeRates'), $this->document_address); // revert configuration $cache->setCaching($cacheactive); if (!$globalCurrencyConverter) { vmdebug('convert convert No $globalCurrencyConverter convert ' . $amountA); return $amountA; } else { $valA = isset($globalCurrencyConverter[$currA]) ? $globalCurrencyConverter[$currA] : 1.0; $valB = isset($globalCurrencyConverter[$currB]) ? $globalCurrencyConverter[$currB] : 1.0; $val = (double) $amountA * $valB / (double) $valA; // $val = $amountA * $valB / $valA; // vmdebug('convert convert in: '.$amountA.' out: '.$val); return $val; } }
function save($data = 0) { $fileModel = VmModel::getModel('media'); //Now we try to determine to which this media should be long to $data = array_merge(vRequest::getRequest(), vRequest::get('media')); //$data['file_title'] = vRequest::getVar('file_title','','post','STRING',JREQUEST_ALLOWHTML); $data['file_description'] = vRequest::getHtml('media[file_description]', ''); /*$data['media_action'] = vRequest::getCmd('media[media_action]'); $data['media_attributes'] = vRequest::getCmd('media[media_attributes]'); $data['file_type'] = vRequest::getCmd('media[file_type]');*/ if (empty($data['file_type'])) { $data['file_type'] = $data['media_attributes']; } vmdebug('my media in controller save media', $data); $msg = ''; if ($id = $fileModel->store($data)) { $msg = vmText::_('COM_VIRTUEMART_FILE_SAVED_SUCCESS'); } $cmd = vRequest::getCmd('task'); if ($cmd == 'apply') { $redirection = 'index.php?option=com_virtuemart&view=media&task=edit&virtuemart_media_id=' . $id; } else { $redirection = 'index.php?option=com_virtuemart&view=media'; } $this->setRedirect($redirection, $msg); }
/** * @return string */ public function getVmPluginCreateTableSQL () { $db = JFactory::getDBO(); $query = 'SHOW TABLES LIKE "%' . str_replace('#__', '', $this->_tablename) . '"'; $db->setQuery($query); $result = $db->loadResult(); $app = JFactory::getApplication(); $tablesFields = 0; if ($result) { $SQLfields = $this->getTableSQLFields(); $loggablefields = $this->getTableSQLLoggablefields(); $tablesFields = array_merge($SQLfields, $loggablefields); $update[$this->_tablename] = array($tablesFields, array(), array()); vmdebug(get_class($this) . ':: VirtueMart2 update ' . $this->_tablename); if (!class_exists('GenericTableUpdater')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'tableupdater.php'); } $updater = new GenericTableUpdater(); $updater->updateMyVmTables($update); // return FALSE; //TODO enable this, when using vm version higher than 2.0.8F } else { return $this->createTableSQL('Userfield Realex Realvault Table', $tablesFields); } }
/** * Records in this table do not need to exist, so we might need to create a record even * if the primary key is set. Therefore we need to overload the store() function. * * @author Max Milbers * @see libraries/joomla/database/JTable#store($updateNulls) */ public function store($updateNulls = false) { $this->setLoggableFieldsForStore(); $this->storeParams(); $tblKey = $this->_tbl_key; $pKey = $this->_pkey; if($tblKey == $pKey){ vmdebug('VmTableData '.get_class($this). ' need not to be a vmtabledata $tblKey == $pKey'); $res = false; if(!empty($this->$tblKey)){ $_qry = 'SELECT `'.$this->_tbl_key.'` ' . 'FROM `'.$this->_tbl.'` ' . 'WHERE `'.$this->_tbl_key.'` = "' . $this->$tblKey.'" '; $this->_db->setQuery($_qry); $res = $this->_db->loadResult(); } if($res){ $returnCode = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); } else { $returnCode = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); } } else { if(!empty($this->$pKey)){ $_qry = 'SELECT `'.$this->_tbl_key.'` ' . 'FROM `'.$this->_tbl.'` ' . 'WHERE `'.$this->_pkey.'` = "' . $this->$pKey.'" '; $this->_db->setQuery($_qry); //Yes, overwriting $this->$tblKey is correct ! $this->$tblKey = $this->_db->loadResult(); } if ( !empty($this->$tblKey) ) { $returnCode = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); } else { $returnCode = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); } } //reset Params if(isset($this->_tmpParams)){ foreach($this->_tmpParams as $k => $v){ $this->$k = $v; } } $this->_tmpParams = false; if (!$returnCode) { vmError(get_class($this) . '::store failed - ' . $this->_db->getErrorMsg()); return false; } else { return true; } }
/** * Validates the user info record fields. * * @author RickG, RolandD, Max Milbers * @return boolean True if the table buffer is contains valid data, false otherwise. */ public function check() { if ($this->address_type == 'BT' or $this->address_type == 'ST') { if ($this->address_type == 'ST' and empty($this->address_type_name)) { $this->address_type_name = 'Delivery Address ' . rand(1, 9); vmWarn('Table userinfos check failed: address_type ' . $this->address_type . ' without name, autogenerated ' . $this->address_type_name, 'check failed: ST has no name, autogenerated ' . $this->address_type_name); //return false; } } else { vmError('Table userinfos check failed: Unknown address_type ' . $this->address_type, 'check failed: Unknown address_type '); vmdebug('Table userinfos check failed: Unknown address_type ' . $this->address_type . ' virtuemart_user_id ' . $this->virtuemart_user_id . ' name ' . $this->name); return false; } if (!empty($this->virtuemart_userinfo_id)) { $this->virtuemart_userinfo_id = (int) $this->virtuemart_userinfo_id; if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } if (!Permissions::getInstance()->check("admin")) { $q = "SELECT virtuemart_user_id\n\t\t\t\t\t\t\t\t\t\tFROM #__virtuemart_userinfos\n\t\t\t\t\t\t\t\t\t\tWHERE virtuemart_userinfo_id = " . $this->virtuemart_userinfo_id; $this->_db->setQuery($q); $total = $this->_db->loadResultArray(); if (count($total) > 0) { $userId = JFactory::getUser()->id; if ($total[0] != $userId) { vmError('Hacking attempt uid check, you got logged'); echo 'Hacking attempt uid check, you got logged'; return false; } } } //return parent::check(); } else { if (empty($this->address_type)) { $this->address_type = 'BT'; } /* Check if a record exists */ $q = "SELECT virtuemart_userinfo_id\n\t\t\tFROM #__virtuemart_userinfos\n\t\t\tWHERE virtuemart_user_id = " . $this->virtuemart_user_id . "\n\t\t\tAND address_type = " . $this->_db->Quote($this->address_type); if ($this->address_type != 'BT') { $q .= " AND address_type_name = " . $this->_db->Quote($this->address_type_name); } $this->_db->setQuery($q); $total = $this->_db->loadResultArray(); if (count($total) > 0) { $this->virtuemart_userinfo_id = (int) $total[0]; } else { $this->virtuemart_userinfo_id = 0; //md5(uniqid($this->virtuemart_user_id)); } } if (empty($this->virtuemart_user_id)) { $user = JFactory::getUser(); if (!empty($user->id)) { $this->virtuemart_user_id = $user->id; } } return parent::check(); }
function displayErrors($errors) { foreach ($errors as $error) { vmError(vmText::sprintf('VMPAYMENT_ubrir_ERROR_FROM', $error['message'], $error['field'], $error['code'])); vmInfo(vmText::sprintf('VMPAYMENT_ubrir_ERROR_FROM', $error['message'], $error['field'], $error['code'])); if ($error['message'] == 401) { vmdebug('check you payment parameters: custom_id, project_id, api key'); } } }
function display($tpl = null) { $db = JFactory::getDBO(); if ($field = vRequest::getVar('field')) { if (strpos($field, 'plugin') !== false) { JForm::addFieldPath(JPATH_VM_ADMINISTRATOR . DS . 'fields'); $table = '#__extensions'; $field = substr($field, 6); $q = 'SELECT `params`,`element`,`type` FROM `' . $table . '` WHERE `element` = "' . $field . '"'; $db->setQuery($q); $this->userField = $db->loadObject(); //$this->userField->element = substr($this->userField->type, 6); if (!class_exists('vmPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmplugin.php'; } vmPlugin::loadJLang('plg_vmuserfield_' . $this->userField->element, 'vmuserfield', $this->userField->element); $path = JPATH_ROOT . DS . 'plugins' . DS . 'vmuserfield' . DS . $this->userField->element . DS . $this->userField->element . '.xml'; // Get the payment XML. $formFile = JPath::clean($path); if (file_exists($formFile)) { if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } if (!class_exists('VmTable')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtable.php'; } $this->userField->form = JForm::getInstance($this->userField->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $this->userField->params = new stdClass(); $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm'); /* $this->userField->params->userfield_params = $this->userField->params; VmTable::bindParameterable($this->userField->params,'userfield_params',$varsToPush);*/ if (empty($this->userField->userfield_params)) { $this->userField->userfield_params = ''; } $this->userField->params->userfield_params = $this->userField->userfield_params; VmTable::bindParameterable($this->userField->params, 'userfield_params', $varsToPush); $this->userField->form->bind($this->userField); } else { $this->userField->form = false; vmdebug('renderUserfieldPlugin could not find xml for ' . $this->userField->type . ' at ' . $path); } //vmdebug('renderUserfieldPlugin ',$this->userField->form); if ($this->userField->form) { $form = $this->userField->form; ob_start(); include JPATH_VM_ADMINISTRATOR . DS . 'fields' . DS . 'formrenderer.php'; $body = ob_get_contents(); ob_end_clean(); echo $body; } } } jExit(); }
/** * Validates the user info record fields. * * @author RickG, RolandD, Max Milbers * @return boolean True if the table buffer is contains valid data, false otherwise. */ public function check() { if ($this->address_type == 'BT' or $this->address_type == 'ST') { if ($this->address_type == 'ST' and empty($this->address_type_name)) { $this->address_type_name = 'Delivery Address ' . rand(1, 9); vmWarn('Table userinfos check failed: address_type ' . $this->address_type . ' without name, autogenerated ' . $this->address_type_name, 'check failed: ST has no name, autogenerated ' . $this->address_type_name); } } else { vmError('Table userinfos check failed: Unknown address_type ' . $this->address_type, 'check failed: Unknown address_type '); vmdebug('Table userinfos check failed: Unknown address_type ' . $this->address_type . ' virtuemart_user_id ' . $this->virtuemart_user_id . ' name ' . $this->name); return false; } if (!empty($this->virtuemart_userinfo_id)) { $this->virtuemart_userinfo_id = (int) $this->virtuemart_userinfo_id; $user = JFactory::getUser(); if (!$user->authorise('core.admin', 'com_virtuemart')) { $q = "SELECT virtuemart_user_id\n\t\t\t\t\t\t\t\t\t\tFROM #__virtuemart_userinfos\n\t\t\t\t\t\t\t\t\t\tWHERE virtuemart_userinfo_id = " . $this->virtuemart_userinfo_id; $this->_db->setQuery($q); $total = $this->_db->loadColumn(); if (count($total) > 0) { $userId = JFactory::getUser()->id; if ($total[0] != $userId) { vmError('Hacking attempt uid check, you got logged'); echo 'Hacking attempt uid check, you got logged'; return false; } } } //return parent::check(); } else { if (empty($this->address_type)) { $this->address_type = 'BT'; } /* Check if a record exists */ $q = "SELECT virtuemart_userinfo_id\n\t\t\tFROM #__virtuemart_userinfos\n\t\t\tWHERE virtuemart_user_id = " . $this->virtuemart_user_id . "\n\t\t\tAND address_type = " . $this->_db->Quote($this->address_type); if ($this->address_type != 'BT') { $q .= " AND address_type_name = " . $this->_db->Quote($this->address_type_name); } $this->_db->setQuery($q); $total = $this->_db->loadColumn(); if (count($total) > 0) { $this->virtuemart_userinfo_id = (int) $total[0]; } else { $this->virtuemart_userinfo_id = 0; //md5(uniqid($this->virtuemart_user_id)); } } if (empty($this->virtuemart_user_id)) { $user = JFactory::getUser(); if (!empty($user->id)) { $this->virtuemart_user_id = $user->id; } } return parent::check(); }
function display($tpl = null) { $db = JFactory::getDBO(); if ($virtuemart_media_id = vRequest::getInt('virtuemart_media_id')) { //$db = JFactory::getDBO(); $query = 'SELECT `file_url`,`file_title` FROM `#__virtuemart_medias` where `virtuemart_media_id`=' . $virtuemart_media_id; $db->setQuery($query); $json = $db->loadObject(); if (isset($json->file_url)) { $json->file_url = JURI::root() . $json->file_url; $json->msg = 'OK'; echo json_encode($json); } else { $json->msg = '<b>' . vmText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '</b>'; echo json_encode($json); } } elseif ($custom_jplugin_id = vRequest::getInt('custom_jplugin_id')) { $table = '#__extensions'; $ext_id = 'extension_id'; $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $ext_id . '` = "' . $custom_jplugin_id . '"'; $db->setQuery($q); $this->jCustom = $db->loadObject(); $customModel = VmModel::getModel('custom'); $this->custom = $customModel->getCustom(); // Get the payment XML. $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmcustom' . DS . $this->jCustom->element . DS . $this->jCustom->element . '.xml'); if (file_exists($formFile)) { VmConfig::loadJLang('plg_vmpsplugin', false); if (!class_exists('vmPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmplugin.php'; } $filename = 'plg_vmcustom_' . $this->jCustom->element; vmPlugin::loadJLang($filename, 'vmcustom', $this->jCustom->element); $this->custom = VmModel::getModel('custom')->getCustom(); $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm'); $this->custom->form = JForm::getInstance($this->jCustom->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $this->custom->params = new stdClass(); foreach ($varsToPush as $k => $field) { if (strpos($k, '_') != 0) { $this->custom->params->{$k} = $field[0]; } } $this->custom->form->bind($this->custom->getProperties()); $form = $this->custom->form; include VMPATH_ADMIN . DS . 'fields' . DS . 'formrenderer.php'; echo '<input type="hidden" value="' . $this->jCustom->element . '" name="custom_value">'; } else { $this->custom->form = null; //VmConfig::$echoDebug = 1; vmdebug('File does not exist ' . $formFile); } } jExit(); }
function removeAddressST() { $virtuemart_userinfo_id = vRequest::getInt('virtuemart_userinfo_id'); $virtuemart_user_id = vRequest::getInt('virtuemart_user_id'); //Lets do it dirty for now $userModel = VmModel::getModel('user'); vmdebug('removeAddressST', $virtuemart_user_id, $virtuemart_userinfo_id); $userModel->setId($virtuemart_user_id[0]); $userModel->removeAddress($virtuemart_userinfo_id); $layout = vRequest::getCmd('layout', 'edit'); $this->setRedirect('index.php?option=com_virtuemart&view=user&task=edit&virtuemart_user_id[]=' . $virtuemart_user_id[0]); }
/** * Construct a proxy for Avalara's Address Web Service using the default URL as coded in the class or programatically set. * * <b>Example:</b> * <pre> * $port = new AddressServiceSoap(); * $port->ping(); * </pre> * * @see AvalaraSoapClient * @see TaxServiceSoap */ public function __construct($configurationName = 'Default', $config = 0) { if (empty($config)) { vmdebug('AddressServiceSoap ' . $configurationName); $config = new ATConfig($configurationName); } if (!class_exists('DynamicSoapClient')) { require VMAVALARA_CLASS_PATH . '/DynamicSoapClient.class.php'; } $this->client = new DynamicSoapClient($config->addressWSDL, array('location' => $config->url . $config->addressService, 'trace' => $config->trace, 'classmap' => AddressServiceSoap::$classmap), $config); //$this->client->__getTypes(); }
/** * @param $cData */ public function __construct($cData) { $this->path = JPATH_VMKLARNAPLUGIN . '/klarna/'; if (!class_exists('ShopFunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } $this->cData = $cData; //$this->currencyId = ShopFunctions::getCurrencyIDByName($this->cData['currency_code']); vmdebug('klarna_productPrice', $this->cData); try { $this->klarna_virtuemart = new Klarna_virtuemart(); $this->klarna_virtuemart->config($this->cData['eid'], $this->cData['secret'], $this->cData['country'], $this->cData['language'], $this->cData['currency'], $this->cData['mode'], VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), FALSE); } catch (Exception $e) { vmDebug('klarna_productPrice', $e->getMessage(), $this->cData); unset($this->klarna); } }
/** * @author Max Milbers */ function setStoreOwner($userId=-1) { $allowInsert=FALSE; if($userId===-1){ $allowInsert = TRUE; $userId = 0; } if (empty($userId)) { $userId = $this->determineStoreOwner(); vmdebug('setStoreOwner $userId = '.$userId.' by determineStoreOwner'); } $db = JFactory::getDBO(); $db->setQuery('SELECT * FROM `#__virtuemart_vmusers` WHERE `virtuemart_user_id`= "' . $userId . '" '); $oldUserId = $db->loadResult(); if (!empty($oldUserId) and !empty($userId)) { $db->setQuery( 'UPDATE `#__virtuemart_vmusers` SET `virtuemart_vendor_id` = "0", `user_is_vendor` = "0" WHERE `virtuemart_vendor_id` ="1" '); if ($db->execute() == false ) { vmWarn( 'UPDATE __vmusers failed for virtuemart_user_id '.$userId); return false; } $db->setQuery( 'UPDATE `#__virtuemart_vmusers` SET `virtuemart_vendor_id` = "1", `user_is_vendor` = "1" WHERE `virtuemart_user_id` ="'.$userId.'" '); if ($db->execute() === false ) { vmWarn( 'UPDATE __vmusers failed for virtuemart_user_id '.$userId); return false; } else { vmInfo('setStoreOwner VmUser updated new main vendor has user id '.$userId); } } else if($allowInsert){ $db->setQuery('INSERT `#__virtuemart_vmusers` (`virtuemart_user_id`, `user_is_vendor`, `virtuemart_vendor_id`) VALUES ("' . $userId . '", "1","1")'); if ($db->execute() === false ) { vmWarn( 'setStoreOwner was not possible to execute INSERT __vmusers for virtuemart_user_id '.$userId); return false; } else { vmInfo('setStoreOwner VmUser inserted new main vendor has user id '.$userId); } } return $userId; }
/** * Renders sublayouts * * @author Max Milbers * @param $name * @param int $viewData viewdata for the rendered sublayout, do not remove * @return string */ public function renderVmSubLayout($name = 0, $viewData = 0) { if ($name === 0) { $name = $this->_name; } $lPath = self::getVmSubLayoutPath($name); if ($lPath) { if ($viewData !== 0 and is_array($viewData)) { foreach ($viewData as $k => $v) { if ('_' != substr($k, 0, 1) and !isset($this->{$k})) { $this->{$k} = $v; } } } ob_start(); include $lPath; return ob_get_clean(); } else { vmdebug('renderVmSubLayout layout not found ' . $name); } }
/** * Delete all calcs selected * * @author Max Milbers * @param array $cids categories to remove * @return boolean if the item remove was successful */ public function remove($cids) { JRequest::checkToken() or jexit( 'Invalid Token, in remove category'); $table = $this->getTable($this->_maintablename); $cat = $this->getTable('calc_categories'); $sgrp = $this->getTable('calc_shoppergroups'); $countries = $this->getTable('calc_countries'); $states = $this->getTable('calc_states'); $ok = true; foreach($cids as $id) { $id = (int)$id; vmdebug('remove '.$id); if (!$table->delete($id)) { vmError(get_class( $this ).'::remove '.$id.' '.$table->getError()); $ok = false; } if (!$cat->delete($id)) { vmError(get_class( $this ).'::remove '.$id.' '.$cat->getError()); $ok = false; } if (!$sgrp->delete($id)) { vmError(get_class( $this ).'::remove '.$id.' '.$sgrp->getError()); $ok = false; } if (!$countries->delete($id)) { vmError(get_class( $this ).'::remove '.$id.' '.$countries->getError()); $ok = false; } if (!$states->delete($id)) { vmError(get_class( $this ).'::remove '.$id.' '.$states->getError()); $ok = false; } // if(!class_exists('vmPSPlugin')) require(JPATH_VM_PLUGINS.DS.'vmpsplugin.php'); JPluginHelper::importPlugin('vmcalculation'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmDeleteCalculationRow', array( $id)); } return $ok; }
} if (!empty($productfile->file_is_forSale)) { echo vmText::_('COM_VIRTUEMART_FOR_SALE'); } ?> </td> <!-- Preview --> <td> <?php if (file_exists($fullSizeFilenamePath)) { echo $productfile->displayMediaThumb(); } else { $file_url = $productfile->theme_url . 'assets/images/vmgeneral/' . VmConfig::get('no_image_found'); $file_alt = vmText::_('COM_VIRTUEMART_NO_IMAGE_SET') . ' ' . $productfile->file_description; vmdebug('check path $file_url', $file_url); echo $productfile->displayIt($file_url, $file_alt, '', false); } ?> </td> <!-- File title --> <td><?php echo $productfile->file_name; ?> </td> <!-- File extension --> <td style="overflow:hidden;"><span class="vmicon vmicon-16-ext_<?php echo $productfile->file_extension; ?> "></span><?php
/** * * @author Max Milbers */ function getUserInfoInUserFields($layoutName, $type, $uid, $cart = true, $isVendor = false) { // if(!class_exists('VirtueMartModelUserfields')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'userfields.php' ); // $userFieldsModel = new VirtuemartModelUserfields(); $userFieldsModel = VmModel::getModel('userfields'); $prepareUserFields = $userFieldsModel->getUserFieldsFor($layoutName, $type); if ($type == 'ST') { $preFix = 'shipto_'; } else { $preFix = ''; } /* * JUser or $this->_id is the logged user */ if (!empty($this->_data->JUser)) { $JUser = $this->_data->JUser; } else { $JUser = JUser::getInstance($this->_id); } $data = null; $userFields = array(); if (!empty($uid)) { $dataT = $this->getTable('userinfos'); $data = $dataT->load($uid); if ($data->virtuemart_user_id !== 0 and !$isVendor) { $user = JFactory::getUser(); if (!($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart'))) { if ($data->virtuemart_user_id != $this->_id) { vmError('Hacking attempt loading userinfo, you got logged'); echo 'Hacking attempt loading userinfo, you got logged'; return false; } } } if ($data->address_type != 'ST') { $BTuid = $uid; $data->name = $JUser->name; $data->email = $JUser->email; $data->username = $JUser->username; $data->address_type = 'BT'; } vmdebug('getUserInfoInUserFields !$uid', $data->name); } else { vmdebug('getUserInfoInUserFields case empty $uid'); //New Address is filled here with the data of the cart (we are in the userview) if ($cart) { if (!class_exists('VirtueMartCart')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); $adType = $type . 'address'; if (empty($cart->{$adType})) { $data = $cart->{$type}; if (empty($data)) { $data = array(); } if ($JUser) { if (empty($data['name'])) { $data['name'] = $JUser->name; } if (empty($data['email'])) { $data['email'] = $JUser->email; } if (empty($data['username'])) { $data['username'] = $JUser->username; } if (empty($data['virtuemart_user_id'])) { $data['virtuemart_user_id'] = $JUser->id; } } $data = (object) $data; } } else { if ($JUser) { if (empty($data['name'])) { $data['name'] = $JUser->name; } if (empty($data['email'])) { $data['email'] = $JUser->email; } if (empty($data['username'])) { $data['username'] = $JUser->username; } if (empty($data['virtuemart_user_id'])) { $data['virtuemart_user_id'] = $JUser->id; } $data = (object) $data; } } } if (empty($data)) { vmdebug('getUserInfoInUserFields $data empty', $uid, $data); $cart = VirtueMartCart::getCart(); $data = $cart->BT; } $userFields[$uid] = $userFieldsModel->getUserFieldsFilled($prepareUserFields, $data, $preFix); return $userFields; }
/** * Add, change or drop userfields * * @param string $_act Action: ADD, DROP or CHANGE (synonyms available, see the switch cases) * @param string $_col Column name * @param string $_type fieldtype * @param string $_col2 Second Column name * @return boolean True on success * @author Oscar van Eijk * * stAn - note: i disabled deleting of user data when a column (shopper field) is deleted. If a deletion of specific user or order is needed, it can be done separatedly * The column if not set with $_col2 will be renamed to ORIGINALNAME_DELETED_{timestamp()} and depending on mysql version it's definition will change */ function _modifyColumn($_act, $_col, $_type = '', $_col2 = '') { $_sql = 'ALTER TABLE `' . $this->_tbl . '` '; $_check_act = strtoupper(substr($_act, 0, 3)); //Check if a column is there //$columns = $this->_db->getTableColumns($this->_tbl); $columns = $this->showFullColumns('Field', 'Type', false); $res = array_key_exists($_col, $columns); if ($_check_act != 'ADD' and $_check_act != 'CRE') { if (!$res) { vmdebug('_modifyColumn Command was ' . $_check_act . ' column does not exist, changed to ADD'); $_check_act = 'ADD'; } } else { if ($res) { vmdebug('_modifyColumn Command was ' . $_check_act . ' column already exists, changed to MOD'); $_check_act = 'UPD'; } } switch ($_check_act) { case 'ADD': case 'CRE': // Create $_sql .= "ADD {$_col} {$_type} "; break; case 'DRO': // Drop // Drop case 'DEL': // Delete //stAn, i strongly do not recommend to delete customer information only because a field was deleted if (empty($_col2)) { $_col2 = $_col . '_DELETED_' . time(); vmInfo('Be aware the column of table ' . $this->_tbl . ' is not deleted, only renamed to ' . $_col2); } if (!$this->isMysql51Plus()) { if (empty($_type)) { $_type = 'TEXT CHARACTER SET utf8'; } } // NOT NULL not allowed for deleted columns //$t_type = str_ireplace(' NOT ', '', $_type); $_sql .= "CHANGE {$_col} {$_col2} {$_type} "; //was: $_sql .= "DROP $_col "; break; case 'MOD': // Modify // Modify case 'UPD': // Update // Update case 'CHA': // Change if (empty($col2)) { $_col2 = $_col; } // change type only $_sql .= "CHANGE {$_col} {$_col2} {$_type} "; break; } $this->_db->setQuery($_sql); $this->_db->execute(); if ($this->_db->getErrorNum() != 0) { vmError(get_class($this) . '::modify table - ' . $this->_db->getErrorMsg() . '<br /> values: action ' . $_act . ', columname: ' . $_col . ', type: ' . $_type . ', columname2: ' . $_col2); return false; } vmdebug('_modifyColumn executed successfully ' . $_sql); return true; }
public function updateCustomsOrderItems() { $q = 'SELECT `product_attribute` FROM `#__virtuemart_order_items` LIMIT '; $do = true; $db = JFactory::getDbo(); $start = 0; $hunk = 1000; while ($do) { $db->setQuery($q . $start . ',' . $hunk); $items = $db->loadColumn(); if (!$items) { vmdebug('updateCustomsOrderItems Reached end after ' . $start / $hunk . ' loops'); break; } //The stored result in vm2.0.14 looks like this {"48":{"textinput":{"comment":"test"}}} //{"96":"18"} download plugin // 46 is virtuemart_customfield_id //{"46":" <span class=\"costumTitle\">Cap Size<\/span><span class=\"costumValue\" >S<\/span>","110":{"istraxx_customsize":{"invala":"10","invalb":"10"}}} //and now {"32":[{"invala":"100"}]} foreach ($items as $field) { if (strpos($field, '{') !== FALSE) { $jsField = json_decode($field); $fieldProps = get_object_vars($jsField); vmdebug('updateCustomsOrderItems', $fieldProps); $nJsField = array(); foreach ($fieldProps as $k => $props) { if (is_object($props)) { $props = (array) $props; foreach ($props as $ke => $prop) { if (!is_numeric($ke)) { vmdebug('Found old param style', $ke, $prop); if (is_object($prop)) { $prop = (array) $prop; $nJsField[$k] = $prop; /*foreach($prop as $name => $propvalue){ $nJsField[$k][$name] = $propvalue; }*/ } } else { //$nJsField[$k][$name] = $prop; } } } else { if (is_numeric($k) and is_numeric($props)) { $nJsField[$props] = $k; } else { $nJsField[$k] = $props; } } } $nJsField = vmJsApi::safe_json_encode($nJsField); vmdebug('updateCustomsOrderItems json $field encoded', $field, $nJsField); } else { vmdebug('updateCustomsOrderItems $field', $field); } } if (count($items) < $hunk) { vmdebug('Reached end'); break; } $start += $hunk; } // Create the view object $view = $this->getView('orders', 'html'); $view->display(); }
function renderPluginName($method, $where = 'checkout') { $display_logos = ""; if (!class_exists('RealexHelperCustomerData')) { require VMPATH_ROOT . 'plugins' . DS . 'vmpayment' . DS . 'realex_hpp_api' . DS . 'realex_hpp_api' . DS . 'helpers' . DS . 'customerdata.php'; } $this->_currentMethod = $method; $realexInterface = $this->_loadRealexInterface(); if ($realexInterface == NULL) { vmdebug('renderPluginName', $method); return; } $realexInterface->getCustomerData(); $extraInfo = ''; if ($realexInterface->customerData->getVar('selected_method') == $method->virtuemart_paymentmethod_id) { //$extraInfo = $realexInterface->getExtraPluginInfo(); //$extraInfo['cc_number'] =$realexInterface->cc_mask($extraInfo['cc_number']); } $logos = $method->payment_logos; if (!empty($logos)) { $display_logos = $this->displayLogos($logos) . ' '; } $payment_name = $method->payment_name; $html = $this->renderByLayout('render_pluginname', array('where' => $where, 'shop_mode' => $method->shop_mode, 'virtuemart_paymentmethod_id' => $method->virtuemart_paymentmethod_id, 'logo' => $display_logos, 'payment_name' => $payment_name, 'extraInfo' => $extraInfo, 'payment_description' => $method->payment_desc)); $html = $this->rmspace($html); return $html; }
function plgVmOnPaymentResponseReceived(&$html) { if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } if (!class_exists('shopFunctionsF')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'); } if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } VmConfig::loadJLang('com_virtuemart_orders',TRUE); // the payment itself should send the parameter needed. $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0); $expresscheckout = JRequest::getVar('expresscheckout', ''); if ($expresscheckout) { return; } $order_number = JRequest::getString('on', 0); $vendorId = 0; if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->_currentMethod->payment_element)) { return NULL; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) { return NULL; } if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) { return ''; } $payment_name = $this->renderPluginName($this->_currentMethod); $payment = end($payments); VmConfig::loadJLang('com_virtuemart'); $orderModel = VmModel::getModel('orders'); $order = $orderModel->getOrder($virtuemart_order_id); // to do: this vmdebug('plgVmOnPaymentResponseReceived',$payment ); if (!class_exists('CurrencyDisplay')) require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'); $currency = CurrencyDisplay::getInstance('',$order['details']['BT']->virtuemart_vendor_id); if ($payment->paypal_fullresponse) { $paypal_data = json_decode($payment->paypal_fullresponse); $success = ($paypal_data->payment_status == 'Completed' or $paypal_data->payment_status == 'Pending'); } else { $success=false; } $html = $this->renderByLayout($this->_currentMethod->paypalproduct . 'response', array("success" => $success, "payment_name" => $payment_name, "payment" => $paypal_data, "order" => $order, "currency" => $currency, )); //We delete the old stuff // get the correct cart / session $cart = VirtueMartCart::getCart(); $cart->emptyCart(); return TRUE; }
function createInvoiceNumber($orderDetails, &$invoiceNumber) { $orderDetails = (array) $orderDetails; $db = JFactory::getDBO(); if (!isset($orderDetails['virtuemart_order_id'])) { vmWarn('createInvoiceNumber $orderDetails has no virtuemart_order_id ', $orderDetails); vmdebug('createInvoiceNumber $orderDetails has no virtuemart_order_id ', $orderDetails); } $q = 'SELECT * FROM `#__virtuemart_invoices` WHERE `virtuemart_order_id`= "' . $orderDetails['virtuemart_order_id'] . '" '; // AND `order_status` = "'.$orderDetails->order_status.'" '; $db->setQuery($q); $result = $db->loadAssoc(); // vmdebug('my createInvoiceNumber $q '.$q,$result); if (!class_exists('ShopFunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } if (!$result or empty($result['invoice_number'])) { $data['virtuemart_order_id'] = $orderDetails['virtuemart_order_id']; $data['order_status'] = $orderDetails['order_status']; $data['virtuemart_vendor_id'] = $orderDetails['virtuemart_vendor_id']; JPluginHelper::importPlugin('vmshopper'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); // plugin returns invoice number, 0 if it does not want an invoice number to be created by Vm $plg_datas = $dispatcher->trigger('plgVmOnUserInvoice', array($orderDetails, &$data)); foreach ($plg_datas as $plg_data) { // $data = array_merge($plg_data,$data); } if (!isset($data['invoice_number'])) { // check the default configuration $orderstatusForInvoice = VmConfig::get('inv_os', array()); if (!is_array($orderstatusForInvoice)) { $orderstatusForInvoice = array($orderstatusForInvoice); } //for backward compatibility 2.0.8e $pdfInvoice = (int) VmConfig::get('pdf_invoice', 0); // backwards compatible $force_create_invoice = JRequest::getInt('create_invoice', 0); // florian : added if pdf invoice are enabled if (in_array($orderDetails['order_status'], $orderstatusForInvoice) or $pdfInvoice == 1 or $force_create_invoice == 1) { $q = 'SELECT COUNT(1) FROM `#__virtuemart_invoices` WHERE `virtuemart_vendor_id`= "' . $orderDetails['virtuemart_vendor_id'] . '" '; // AND `order_status` = "'.$orderDetails->order_status.'" '; $db->setQuery($q); $count = $db->loadResult() + 1; if (empty($data['invoice_number'])) { //$variable_fixed=sprintf("%05s",$num_rows); $date = date("Y-m-d"); // $date = JFactory::getDate()->toMySQL(); $data['invoice_number'] = str_replace('-', '', substr($date, 2, 8)) . substr(md5($orderDetails['order_number'] . $orderDetails['order_status']), 0, 3) . '0' . $count; } } else { return false; } } $table = $this->getTable('invoices'); $table->bindChecknStore($data); $invoiceNumber = array($table->invoice_number, $table->created_on); } elseif (ShopFunctions::InvoiceNumberReserved($result['invoice_number'])) { $invoiceNumber = array($result['invoice_number'], $result['created_on']); return true; } else { $invoiceNumber = array($result['invoice_number'], $result['created_on']); } return true; }
/** * @author Max Milbers * @param unknown_type $tablename * @param unknown_type $fields * @param unknown_type $command */ public function alterColumns($tablename, $fields, $reCreatePrimary) { $after = ' FIRST'; $dropped = 0; $altered = 0; $added = 0; $this->_app = JFactory::getApplication(); $demandFieldNames = array(); foreach ($fields as $i => $line) { $demandFieldNames[] = $i; } $query = 'SHOW FULL COLUMNS FROM `' . $tablename . '` '; //$q = 'SHOW CREATE TABLE '.$this->_tbl; $this->_db->setQuery($query); $fullColumns = $this->_db->loadObjectList(); $columns = $this->_db->loadColumn(0); //vmdebug('alterColumns',$fullColumns); //Attention user_infos is not in here, because it an contain customised fields. #__virtuemart_order_userinfos #__virtuemart_userinfos //This is currently not working as intended, because the config is not deleted before, it is better to create an extra command for this, when we need it later $upDelCols = (int) VmConfig::get('updelcols', 0); if ($upDelCols == 1 and !($tablename == $this->_prefix . 'virtuemart_userfields' or $tablename == $this->_prefix . 'virtuemart_userinfos' or $tablename == $this->_prefix . 'virtuemart_order_userinfos')) { foreach ($columns as $fieldname) { if (!in_array($fieldname, $demandFieldNames)) { $query = 'ALTER TABLE `' . $tablename . '` DROP COLUMN `' . $fieldname . '` '; $action = 'DROP'; $dropped++; $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->_app->enqueueMessage('alterTable ' . $action . ' ' . $tablename . '.' . $fieldname . ' :' . $this->_db->getErrorMsg()); } } } } foreach ($fields as $fieldname => $alterCommand) { if (microtime(true) - $this->starttime >= $this->maxScriptTime) { vmWarn('alterColumns alterKey not finished, please rise execution time and update tables again'); return false; } $query = ''; $action = ''; if (empty($alterCommand)) { vmdebug('empty alter command ' . $fieldname); continue; } // we remove the auto_increment, to be free to set the primary key if (strpos($alterCommand, 'AUTO_INCREMENT') !== false and $reCreatePrimary) { $alterCommand = str_replace('AUTO_INCREMENT', '', $alterCommand); } if (in_array($fieldname, $columns)) { $key = array_search($fieldname, $columns); $oldColumn = $this->reCreateColumnByTableAttributes($fullColumns[$key]); //Attention, we give for a primary the auto_increment back, so we cant decide if a key is used as primary, //but has no auto increment, so wie alter it anytime if (strpos($alterCommand, 'AUTO_INCREMENT') !== false and $reCreatePrimary) { $query = 'ALTER TABLE `' . $tablename . '` CHANGE COLUMN `' . $fieldname . '` `' . $fieldname . '` ' . $alterCommand; $action = 'CHANGE'; $altered++; // vmdebug('$fieldname just auto '.$fieldname,$alterCommand,$oldColumn); } else { // while (strpos($oldColumn,' ')){ // str_replace(' ', ' ', $oldColumn); // } while (strpos($alterCommand, ' ')) { $alterCommand = str_replace(' ', ' ', trim($alterCommand)); } // str_replace(' ', ' ', $alterCommand); // $compare = strcasecmp( $oldColumn, $alterCommand); // $compare = strcasecmp( $oldColumn, $alterCommand); // if (!empty($compare)) { $oldColumn = strtoupper($oldColumn); $alterCommand = strtoupper(trim($alterCommand)); // vmdebug('reCreateColumnByTableAttributes ',$fullColumns[$key]); if ($oldColumn != $alterCommand) { $query = 'ALTER TABLE `' . $tablename . '` CHANGE COLUMN `' . $fieldname . '` `' . $fieldname . '` ' . $alterCommand . $after; $action = 'CHANGE'; $altered++; vmdebug($tablename . ' Alter field ' . $fieldname . ' oldcolumn ', $oldColumn, $alterCommand); // vmdebug('Alter field new column ',$fullColumns[$key]); // vmdebug('Alter field new column '.$this->reCreateColumnByTableAttributes($fullColumns[$key])); //,$fullColumns[$key]); } } } else { $query = 'ALTER TABLE `' . $tablename . '` ADD ' . $fieldname . ' ' . $alterCommand . ' ' . $after; $action = 'ADD'; $added++; // vmdebug('$fieldname '.$fieldname); } if (!empty($query)) { $this->_db->setQuery($query); $err = $this->_db->getErrorMsg(); if (!$this->_db->execute() or !empty($err)) { vmError('alterTable ' . $action . ' ' . $tablename . '.' . $fieldname . ' : ' . $err); } else { vmInfo('alterTable ' . $action . ' ' . $tablename . '.' . $fieldname . ' : ' . $query); } } $after = ' AFTER `' . $fieldname . '`'; } if ($dropped != 0 or $altered != 0 or $added != 0) { $this->_app->enqueueMessage('Table updated: Tablename ' . $tablename . ' dropped: ' . $dropped . ' altered: ' . $altered . ' added: ' . $added); $err = $this->_db->getErrorMsg(); if (!empty($err)) { vmError('Tableupdater updating table ' . $tablename . ' throws error ' . $err); } } return true; }
/** * This is the actions which take place, when a product gets stored * * @param string $type atm valid 'product' * @param array $data form data * @param int $id virtuemart_product_id */ function OnStoreProduct($data, $plugin_param) { if (key($plugin_param) !== $this->_name) { return; } $key = key($plugin_param); $plugin_param[$key]['virtuemart_product_id'] = $data['virtuemart_product_id']; vmdebug('plgData', $plugin_param[$key]); // $this->id = $this->getIdForCustomIdProduct($data['virtuemart_product_id'],$plugin_param[$key]['virtuemart_custom_id']); $this->storePluginInternalDataProduct($plugin_param[$key], 'id', $data['virtuemart_product_id']); }
/** * Checks if user is admin or has vendorId=1, * if superadmin, but not a vendor it gives back vendorId=1 (single vendor, but multiuser administrated) * * @author Mattheo Vicini * @author Max Milbers */ public static function isSuperVendor($adminId = 0) { if (!isset(self::$_virtuemart_vendor_id[$adminId])) { if (empty($adminId)) { $user = JFactory::getUser(); } else { $user = JFactory::getUser($adminId); } if (!empty($user->id)) { $q = 'SELECT `virtuemart_vendor_id` FROM `#__virtuemart_vmusers` `au` WHERE `au`.`virtuemart_user_id`="' . $user->id . '" AND `au`.`user_is_vendor` = "1" '; $db = JFactory::getDbo(); $db->setQuery($q); $virtuemart_vendor_id = $db->loadResult(); if ($virtuemart_vendor_id) { self::$_virtuemart_vendor_id[$adminId] = $virtuemart_vendor_id; } else { if ($user->authorise('core.admin', 'com_virtuemart') or self::get('multix', 'none') == 'none' and $user->authorise('core.manage', 'com_virtuemart')) { self::$_virtuemart_vendor_id[$adminId] = 1; } } } else { self::$_virtuemart_vendor_id[$adminId] = 0; vmdebug('Not a vendor'); } } return self::$_virtuemart_vendor_id[$adminId]; }
/** * Build the Payment params */ public function getCheapestMonthlyCost($cart = NULL, $cData) { if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('KlarnaAPI')) { require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnaapi.php'; } if (!isset($this->klarna) || !$this->klarna instanceof Klarna_virtuemart) { return NULL; } $display_fee = 0; $billTotalInCountryCurrency = 0; if (isset($cart->pricesUnformatted['billTotal'])) { $billTotalInCountryCurrency = KlarnaHandler::convertPrice($cart->pricesUnformatted['billTotal'], $cData['vendor_currency'], $cData['virtuemart_currency_id'], $cart->pricesCurrency); } if ($billTotalInCountryCurrency <= 0) { return NULL; } $aTypes = array(KlarnaPClass::ACCOUNT, KlarnaPClass::CAMPAIGN); $kCheckout = new KlarnaAPI($this->country, $this->lang, 'part', $billTotalInCountryCurrency, KlarnaFlags::CHECKOUT_PAGE, $this->klarna, $aTypes, JPATH_VMKLARNAPLUGIN); KlarnaHandler::getCheapestPclass($kCheckout, $cheapest, $minimum); vmdebug('getCheapestMonthlyCost', $cart->pricesUnformatted['billTotal'], $billTotalInCountryCurrency, $cheapest, $minimum); if ($billTotalInCountryCurrency < $minimum) { return NULL; } if (!class_exists('VirtueMartModelCurrency')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php'; } $sFee = $kCheckout->getPresentableValuta($cheapest); return $sFee; }
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; }
function addStandardEditViewCommandsNoValidate($id = 0, $object = null) { $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart')); if (!class_exists('JToolBarHelper')) { require JPATH_ADMINISTRATOR . DS . 'includes' . DS . 'toolbar.php'; } JToolBarHelper::divider(); if (vmAccess::manager($view . '.edit')) { JToolBarHelper::save(); JToolBarHelper::apply(); } JToolBarHelper::cancel(); //self::showHelp(); //self::showACLPref($view); if ($view != 'shipmentmethod' and $view != 'paymentmethod' and $view != 'media') { $validate = true; } else { $validate = false; } $this->addJsJoomlaSubmitButtonNoValidate($validate); $editView = vRequest::getCmd('view', vRequest::getCmd('controller', '')); $params = JComponentHelper::getParams('com_languages'); $selectedLangue = $params->get('site', 'en-GB'); $this->lang = strtolower(strtr($selectedLangue, '-', '_')); // Get all the published languages defined in Language manager > Content $allLanguages = JLanguageHelper::getLanguages(); foreach ($allLanguages as $jlang) { $languagesByCode[$jlang->lang_code] = $jlang; } // only add if ID and view not null if ($editView and $id and count(tsmConfig::get('active_languages')) > 1) { if ($editView == 'user') { $editView = 'vendor'; } jimport('joomla.language.helper'); $this->lang = vRequest::getVar('vmlang', $this->lang); // list of languages installed in #__extensions (may be more than the ones in the Language manager > Content if the user did not added them) $languages = JLanguageHelper::createLanguageList($selectedLangue, constant('VMPATH_ROOT'), true); $activeVmLangs = tsmConfig::get('active_languages'); $flagCss = ""; foreach ($languages as $k => &$joomlaLang) { if (!in_array($joomlaLang['value'], $activeVmLangs)) { unset($languages[$k]); } else { $key = $joomlaLang['value']; if (!isset($languagesByCode[$key])) { $img = substr($key, 0, 2); //We try a fallback vmdebug('com_tsmart_MISSING_FLAG', $img, $joomlaLang['text']); } else { $img = $languagesByCode[$key]->image; } $image_flag = VMPATH_ROOT . "/media/mod_languages/images/" . $img . ".gif"; $image_flag_url = JURI::root() . "media/mod_languages/images/" . $img . ".gif"; if (!file_exists($image_flag)) { vmerror(tsmText::sprintf('com_tsmart_MISSING_FLAG', $image_flag, $joomlaLang['text'])); } else { $flagCss .= "td.flag-" . $key . ",.flag-" . $key . "{background: url( " . $image_flag_url . ") no-repeat 0 0; padding-left:20px !important;}\n"; } } } JFactory::getDocument()->addStyleDeclaration($flagCss); $this->langList = JHtml::_('select.genericlist', $languages, 'vmlang', 'class="inputbox" style="width:176px;"', 'value', 'text', $selectedLangue, 'vmlang'); if ($editView == 'product') { $productModel = tmsModel::getModel('product'); $childproducts = $productModel->getProductChilds($id) ? $productModel->getProductChilds($id) : ''; } $token = vRequest::getFormToken(); $j = ' jQuery(function($) { var oldflag = ""; $("select#vmlang").chosen().change(function() { langCode = $(this).find("option:selected").val(); flagClass = "flag-"+langCode; jQuery.ajax({ type: "GET", cache: false, dataType: "json", url: "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $id . '&editView=' . $editView . '&' . $token . '=1", }).done( function(data) { var items = []; var theForm = document.forms["adminForm"]; if(typeof theForm.vmlang==="undefined"){ var input = document.createElement("input"); input.type = "hidden"; input.name = "vmlang"; input.value = langCode; theForm.appendChild(input); } else { theForm.vmlang.value = langCode; } if (data.fields !== "error" ) { if (data.structure == "empty") alert(data.msg); $.each(data.fields , function(key, val) { cible = jQuery("#"+key); if (oldflag !== "") cible.parent().removeClass(oldflag) var tmce_ver = 0; if(typeof window.tinyMCE!=="undefined"){ var tmce_ver=window.tinyMCE.majorVersion; } if (tmce_ver>="4") { if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) { tinyMCE.get(key).execCommand("mceSetContent", false,val); cible.val(val); } else if (data.structure !== "empty") cible.val(val); } else { if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) { tinyMCE.execInstanceCommand(key,"mceSetContent",false,val); cible.val(val); } else if (data.structure !== "empty") cible.val(val); } }); } else alert(data.msg);'; if ($editView == 'product' && !empty($childproducts)) { foreach ($childproducts as $child) { $j .= 'jQuery.ajax({ type: "GET", cache: false, dataType: "json", url: "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $child->tsmart_product_id . '&editView=' . $editView . '&' . $token . '=1", }).done( // $.getJSON( "index.php?option=com_tsmart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $child->tsmart_product_id . '&editView=' . $editView . '&' . $token . '=1" , function(data) { cible = jQuery("#child' . $child->tsmart_product_id . 'product_name"); if (oldflag !== "") cible.parent().removeClass(oldflag) cible.parent().addClass(flagClass); cible.val(data.fields.product_name); jQuery("#child' . $child->tsmart_product_id . 'slug").val(data.fields["slug"]); } ) '; } } $j .= 'oldflag = flagClass ; } ) }); })'; vmJsApi::addJScript('vmlang', $j); } else { $jlang = JFactory::getLanguage(); $langs = $jlang->getKnownLanguages(); $defautName = $selectedLangue; $flagImg = $selectedLangue; if (isset($languagesByCode[$selectedLangue])) { $defautName = $langs[$selectedLangue]['name']; $flagImg = JHtml::_('image', 'mod_languages/' . $languagesByCode[$selectedLangue]->image . '.gif', $languagesByCode[$selectedLangue]->title_native, array('title' => $languagesByCode[$selectedLangue]->title_native), true); } else { vmWarn(tsmText::sprintf('com_tsmart_MISSING_FLAG', $selectedLangue, $selectedLangue)); } $this->langList = '<input name ="vmlang" type="hidden" value="' . $selectedLangue . '" >' . $flagImg . ' <b> ' . $defautName . '</b>'; } if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0'); } }
/** * toggle (0/1) a field * or invert by $val for multi IDS; * @author Patrick Kohl * @param string $field the field to toggle * @param string $postName the name of id Post (Primary Key in table Class constructor) */ function toggle($field, $val = NULL, $cidname = 0, $tablename = 0, $view = false) { if ($view and !vmAccess::manager($view . '.edit.state')) { return false; } $ok = true; if (!in_array($field, $this->_togglesName)) { vmdebug('vmModel function toggle, field ' . $field . ' is not in white list'); return false; } if ($tablename === 0) { $tablename = $this->_maintablename; } if ($cidname === 0) { $cidname = $this->_cidName; } $table = $this->getTable($tablename); $ids = vRequest::getInt($cidname, vRequest::getInt('cid', array())); foreach ($ids as $id) { $table->load((int) $id); if (!$table->toggle($field, $val)) { vmError(get_class($this) . '::toggle ' . $id); $ok = false; } } return $ok; }