Esempio n. 1
0
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return null;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return false;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->_debug = $method->debug;
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
     }
     //$usr = & JFactory::getUser();
     $html = '';
     $usrBT = $order['details']['BT'];
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     $vendorModel = new VirtueMartModelVendor();
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $this->getPaymentCurrency($method);
     $q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
     $db =& JFactory::getDBO();
     $db->setQuery($q);
     $currency_code_3 = $db->loadResult();
     //$paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency);
     //$totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($method->payment_currency, $order['details']['BT']->order_total,false), 2);
     $totalInPaymentCurrency = round($order['details']['BT']->order_total, 2);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     $user_title = $address->title;
     $user_email = $address->email;
     $user_name = $address->first_name . ' ' . $address->last_name;
     $user_city = $address->city;
     $user_address = $address->address_1;
     $user_zip = $address->zip;
     $user_country = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_3_code');
     $msg_1 = $user_name . " Kd-nr " . $usrBT->virtuemart_user_id;
     $msg_2 = "Bestellnr " . $order['details']['BT']->order_number;
     $cont = $method->payment_uid . "|" . $method->payment_pid . "|||||" . $totalInPaymentCurrency . "|" . $currency_code_3 . "|" . $msg_1 . "|" . $msg_2 . "|" . $order['details']['BT']->order_number . "|" . $order['details']['BT']->virtuemart_paymentmethod_id . "|VM v2.1||||" . $method->payment_pas;
     $hash = md5($cont);
     $html .= '<div style="text-align: left; margin-top: 25px; margin-bottom: 25px;">';
     $html .= 'Ihre Bestellung ist bei uns eingegangen und wird umgehend von uns bearbeitet.';
     $html .= '</div>';
     // Prepare data that should be stored in the database
     $dbValues = array();
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['payment_currency'] = $method->payment_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency;
     $this->storePSPluginInternalData($dbValues);
     $new_status = 'C';
     return $this->processConfirmedOrderPaymentResponse(1, $cart, $order, $html, $dbValues['payment_name'], $new_status);
 }
Esempio n. 2
0
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order["details"]["BT"]->virtuemart_paymentmethod_id))) {
         return null;
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return false;
     }
     $this->logInfo('plgVmOnConfirmedOrderGetPaymentForm order number: ' . $order['details']['BT']->order_number, 'message');
     $lang = JFactory::getLanguage();
     $lang->load('plg_vmpayment_epay', JPATH_ADMINISTRATOR);
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
     }
     $new_status = '';
     $usrBT = $order['details']['BT'];
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     $vendorModel = new VirtueMartModelVendor();
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $this->getPaymentCurrency($method);
     $q = ' SELECT `currency_numeric_code` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
     $db =& JFactory::getDBO();
     $db->setQuery($q);
     $currency_numeric_code = $db->loadResult();
     $paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency);
     $totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($method->payment_currency, $order['details']['BT']->order_total, false), 2);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     $session = JFactory::getSession();
     $post_variables = array('merchantnumber' => $method->epay_merchant, 'instantcapture' => $method->epay_instantcapture, 'ownreceipt' => $method->epay_ownreceipt, 'group' => $method->epay_group, 'mailreceipt' => $method->epay_authmail, 'language' => $this->_getEpayLanguage(), 'orderid' => $order['details']['BT']->order_number, "amount" => $totalInPaymentCurrency * 100, "currency" => $currency_numeric_code, "accepturl" => JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id), "callbackurl" => JROUTE::_(JURI::root() . 'index.php?callback=1&option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id), "cancelurl" => JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id), "windowstate" => $method->epay_windowstate);
     $hash = md5(implode($post_variables, "") . $method->epay_md5key);
     // Prepare data that should be stored in the database
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $this->storePSPluginInternalData($dbValues);
     // add spin image
     $html = '<script type="text/javascript" src="https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/paymentwindow.js" charset="UTF-8"></script>';
     $html .= '<script type="text/javascript">';
     $html .= 'paymentwindow = new PaymentWindow({';
     foreach ($post_variables as $name => $value) {
         $html .= '\'' . $name . '\': "' . $value . '",';
     }
     $html .= '\'hash\': "' . $hash . '"';
     $html .= '});';
     $html .= '</script><input type="button" onclick="javascript: paymentwindow.open()" value="Go to payment" />';
     $html .= ' <script type="text/javascript">';
     $html .= ' paymentwindow.open();';
     $html .= ' </script>';
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = false;
     $cart->_dataValidated = false;
     $cart->setCartIntoSession();
     JRequest::setVar('html', $html);
 }
    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;
    }
Esempio n. 4
0
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->addHelperPath(VMPATH_ADMIN . DS . 'helpers');
     if (!class_exists('vmPSPlugin')) {
         require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php';
     }
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $model = VmModel::getModel();
     $layoutName = vRequest::getCmd('layout', 'default');
     $this->SetViewTitle();
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         VmConfig::loadJLang('plg_vmpsplugin', false);
         JForm::addFieldPath(VMPATH_ADMIN . DS . 'fields');
         $shipment = $model->getShipment();
         // Get the payment XML.
         $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmshipment' . DS . $shipment->shipment_element . DS . $shipment->shipment_element . '.xml');
         if (file_exists($formFile)) {
             $shipment->form = JForm::getInstance($shipment->shipment_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
             $shipment->params = new stdClass();
             $varsToPush = vmPlugin::getVarsToPushFromForm($shipment->form);
             VmTable::bindParameterableToSubField($shipment, $varsToPush);
             $shipment->form->bind($shipment->getProperties());
         } else {
             $shipment->form = null;
         }
         if (!class_exists('VmImage')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
         }
         if (!class_exists('VirtueMartModelVendor')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
         }
         $vendor_id = 1;
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $this->assignRef('vendor_currency', $currency->currency_symbol);
         if ($this->showVendors()) {
             $vendorList = ShopFunctions::renderVendorList($shipment->virtuemart_vendor_id);
             $this->assignRef('vendorList', $vendorList);
         }
         $this->pluginList = self::renderInstalledShipmentPlugins($shipment->shipment_jplugin_id);
         $this->assignRef('shipment', $shipment);
         $this->shopperGroupList = ShopFunctions::renderShopperGroupList($shipment->virtuemart_shoppergroup_ids, true);
         $this->addStandardEditViewCommands($shipment->virtuemart_shipmentmethod_id);
     } else {
         JToolBarHelper::custom('cloneshipment', 'copy', 'copy', vmText::_('COM_VIRTUEMART_SHIPMENT_CLONE'), true);
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $this->shipments = $model->getShipments();
         VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
         foreach ($this->shipments as &$data) {
             // Write the first 5 shoppergroups in the list
             $data->shipmentShoppersList = shopfunctions::renderGuiList($data->virtuemart_shoppergroup_ids, 'shoppergroups', 'shopper_group_name', 'shopper');
         }
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
 }
 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();
 }
Esempio n. 6
0
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * Okey I try now a completly new idea.
  * We make a function for every tab and the display is getting the right tabs by an own function
  * putting that in an array and after that we call the preparedataforlayoutBlub
  *
  * @author Max Milbers
  */
 function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     $model = VmModel::getModel();
     $virtuemart_vendor_id = JRequest::getInt('virtuemart_vendor_id');
     // 		if ($layoutName=='default') {
     if (empty($virtuemart_vendor_id)) {
         $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_LIST'));
         $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_LIST'));
         $vendors = $model->getVendors();
         $model->addImages($vendors);
         $this->assignRef('vendors', $vendors);
     } else {
         $vendor = $model->getVendor($virtuemart_vendor_id);
         $model->addImages($vendor);
         if (VmConfig::get('enable_content_plugin', 0)) {
             if (!class_exists('shopFunctionsF')) {
                 require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
             }
             shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_store_desc');
             shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_terms_of_service');
         }
         $this->assignRef('vendor', $vendor);
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $userId = VirtueMartModelVendor::getUserIdByVendorId($virtuemart_vendor_id);
         //$usermodel = VmModel::getModel('user');
         //$virtuemart_userinfo_id = $usermodel->getBTuserinfo_id($userId);
         //$usermodel->getVendor($virtuemart_vendor_id);
         //$userFields = $usermodel->getUserInfoInUserFields($layoutName, 'BT', $virtuemart_userinfo_id,true,true);
         //$this->assignRef('userFields', $userFields);
         if ($layoutName == 'tos') {
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_TOS'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_TOS'));
         } elseif ($layoutName == 'contact') {
             $user = JFactory::getUser();
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_CONTACT'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_CONTACT'));
             $this->assignRef('user', $user);
         } else {
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_DETAILS'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_DETAILS'));
             $this->setLayout('details');
         }
         $linkdetails = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=details&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_DETAILS') . '</a>';
         $linkcontact = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=contact&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_CONTACT') . '</a>';
         $linktos = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_TOS') . '</a>';
         //$this->assignRef('lineSeparator', $lineSeparator);
         $this->assignRef('linkdetails', $linkdetails);
         $this->assignRef('linkcontact', $linkcontact);
         $this->assignRef('linktos', $linktos);
     }
     parent::display($tpl);
 }
Esempio n. 7
0
 /**
  * Send the ask question email.
  * @author Kohl Patrick, Christopher Roussel
  */
 public function mailAskquestion()
 {
     vRequest::vmCheckToken();
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $model = tmsModel::getModel('vendor');
     $mainframe = JFactory::getApplication();
     $vars = array();
     $min = tsmConfig::get('asks_minimum_comment_length', 50) + 1;
     $max = tsmConfig::get('asks_maximum_comment_length', 2000) - 1;
     $commentSize = vRequest::getString('comment');
     if (function_exists('mb_strlen')) {
         $commentSize = mb_strlen($commentSize);
     } else {
         $commentSize = strlen($commentSize);
     }
     $validMail = filter_var(vRequest::getVar('email'), FILTER_VALIDATE_EMAIL);
     $virtuemart_vendor_id = vRequest::getInt('virtuemart_vendor_id', 1);
     if (!class_exists('VirtueMartModelVendor')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
     }
     $userId = VirtueMartModelVendor::getUserIdByVendorId($virtuemart_vendor_id);
     //$vendorUser = JFactory::getUser($userId);
     if ($commentSize < $min || $commentSize > $max || !$validMail) {
         $this->setRedirect(JRoute::_('index.php?option=com_virtuemart&view=vendor&task=contact&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE), tsmText::_('COM_VIRTUEMART_COMMENT_NOT_VALID_JS'));
         return;
     }
     $user = JFactory::getUser();
     $fromMail = vRequest::getVar('email');
     //is sanitized then
     $fromName = vRequest::getVar('name', '');
     //is sanitized then
     $fromMail = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromMail);
     $fromName = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $fromName);
     if (!empty($user->id)) {
         if (empty($fromMail)) {
             $fromMail = $user->email;
         }
         if (empty($fromName)) {
             $fromName = $user->name;
         }
     }
     $vars['user'] = array('name' => $fromName, 'email' => $fromMail);
     $VendorEmail = $model->getVendorEmail($virtuemart_vendor_id);
     $vars['vendor'] = array('vendor_store_name' => $fromName);
     if (shopFunctionsF::renderMail('vendor', $VendorEmail, $vars, 'vendor')) {
         $string = 'COM_VIRTUEMART_MAIL_SEND_SUCCESSFULLY';
     } else {
         $string = 'COM_VIRTUEMART_MAIL_NOT_SEND_SUCCESSFULLY';
     }
     $mainframe->enqueueMessage(tsmText::_($string));
     // Display it all
     $view = $this->getView('vendor', 'html');
     $view->setLayout('mail_confirmed');
     $view->display();
 }
    /**
     * @author Max Milbers
     */
    function determineStoreOwner() {
		if(!class_exists('VirtueMartModelVendor')) require(VMPATH_ADMIN.DS.'models'.DS.'vendor.php');
		$virtuemart_user_id = VirtueMartModelVendor::getUserIdByVendorId(1);
		if (isset($virtuemart_user_id) && $virtuemart_user_id > 0) {
		    $this->_user = JFactory::getUser($virtuemart_user_id);
		}
		else {
		    $this->_user = JFactory::getUser();
		}
		return $this->_user->id;
    }
Esempio n. 9
0
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers');
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     $model = VmModel::getModel();
     $layoutName = JRequest::getWord('layout', 'default');
     $this->SetViewTitle();
     $layoutName = JRequest::getWord('layout', 'default');
     if ($layoutName == 'edit') {
         $shipment = $model->getShipment();
         if (!class_exists('VmImage')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
         }
         if (!class_exists('vmParameters')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php';
         }
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $vendor_id = 1;
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $this->assignRef('vendor_currency', $currency->currency_symbol);
         if (Vmconfig::get('multix', 'none') !== 'none') {
             $vendorList = ShopFunctions::renderVendorList($shipment->virtuemart_vendor_id);
             $this->assignRef('vendorList', $vendorList);
         }
         $this->assignRef('pluginList', self::renderInstalledShipmentPlugins($shipment->shipment_jplugin_id));
         $this->assignRef('shipment', $shipment);
         $this->assignRef('shopperGroupList', ShopFunctions::renderShopperGroupList($shipment->virtuemart_shoppergroup_ids, true));
         $this->addStandardEditViewCommands($shipment->virtuemart_shipmentmethod_id);
     } else {
         JToolBarHelper::custom('cloneshipment', 'copy', 'copy', JText::_('COM_VIRTUEMART_SHIPMENT_CLONE'), true);
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $shipments = $model->getShipments();
         $this->assignRef('shipments', $shipments);
         $pagination = $model->getPagination();
         $this->assignRef('pagination', $pagination);
     }
     parent::display($tpl);
 }
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->addHelperPath(JPATH_VM_ADMINISTRATOR . '/helpers');
     $this->loadHelper('permissions');
     $this->loadHelper('vmpsplugin');
     $this->loadHelper('html');
     $model = VmModel::getModel();
     $layoutName = JRequest::getWord('layout', 'default');
     $layoutName = JRequest::getWord('layout', 'default');
     if ($layoutName == 'edit') {
         $shipment = $model->getShipment();
         $this->loadHelper('image');
         // $this->loadHelper('html');
         // $this->loadHelper('parameterparser');
         // jimport('joomla.html.pane');
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . '/models' . DS . 'vendor.php';
         }
         $vendor_id = 1;
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $this->vendor_currency = $currency->currency_symbol;
         if (Vmconfig::get('multix', 'none') !== 'none') {
             $this->vendorList = ShopFunctions::renderVendorList($shipment->virtuemart_vendor_id);
         }
         $this->pluginList = self::renderInstalledShipmentPlugins($shipment->shipment_jplugin_id);
         $this->shipment = $shipment;
         $this->shopperGroupList = ShopFunctions::renderShopperGroupList($shipment->virtuemart_shoppergroup_ids, true);
         $this->SetViewTitle('', $shipment->shipment_name);
         $this->addStandardEditViewCommands($shipment->virtuemart_shipmentmethod_id);
     } else {
         if (JRequest::getWord('format', '') === 'raw') {
             $tpl = 'results';
         } else {
             $this->SetViewTitle();
             JToolBarHelper::custom('cloneshipment', 'copy', 'copy', JText::_('COM_VIRTUEMART_SHIPMENT_CLONE'), true);
             $this->addStandardDefaultViewCommands();
             $this->installedShipments = $this->shipmentsPlgList();
         }
         $this->addStandardDefaultViewLists($model);
         $this->shipments = $model->getShipments();
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
     if ($tpl === 'results') {
         echo $this->AjaxScripts();
     }
 }
 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);
 }
Esempio n. 13
0
 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 display($tpl = null)
 {
     // Load the helper(s)
     $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers');
     $this->loadHelper('permissions');
     $this->loadHelper('vmpsplugin');
     $this->loadHelper('html');
     $model = VmModel::getModel();
     $layoutName = JRequest::getWord('layout', 'default');
     $this->SetViewTitle();
     $layoutName = JRequest::getWord('layout', 'default');
     if ($layoutName == 'edit') {
         $shipment = $model->getShipment();
         $this->loadHelper('image');
         // $this->loadHelper('html');
         $this->loadHelper('parameterparser');
         // jimport('joomla.html.pane');
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $vendor_id = 1;
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $this->assignRef('vendor_currency', $currency->currency_symbol);
         if (Vmconfig::get('multix', 'none') !== 'none') {
             $vendorList = ShopFunctions::renderVendorList($shipment->virtuemart_vendor_id);
             $this->assignRef('vendorList', $vendorList);
         }
         $this->assignRef('pluginList', self::renderInstalledShipmentPlugins($shipment->shipment_jplugin_id));
         $this->assignRef('shipment', $shipment);
         $this->assignRef('shopperGroupList', ShopFunctions::renderShopperGroupList($shipment->virtuemart_shoppergroup_ids, true));
         $this->addStandardEditViewCommands($shipment->virtuemart_shipmentmethod_id);
     } else {
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $shipments = $model->getShipments();
         $this->assignRef('shipments', $shipments);
         $pagination = $model->getPagination();
         $this->assignRef('pagination', $pagination);
     }
     parent::display($tpl);
 }
Esempio n. 15
0
 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;
     }
 }
Esempio n. 16
0
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->loadHelper('html');
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     $perm = Permissions::getInstance();
     $this->assignRef('perm', $perm);
     $model = VmModel::getModel();
     $currentUser = JFactory::getUser();
     $task = JRequest::getWord('task', 'edit');
     if ($task == 'editshop') {
         if (Vmconfig::get('multix', 'none') !== 'none') {
             //Maybe we must check here if the user is vendor and if he has an own id and else map to mainvendor.
             $userId = 0;
         } else {
             if (!class_exists('VirtueMartModelVendor')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
             }
             $userId = VirtueMartModelVendor::getUserIdByVendorId(1);
         }
         $this->SetViewTitle('STORE');
     } else {
         if ($task == 'add') {
             $userId = 0;
         } else {
             $userId = JRequest::getVar('virtuemart_user_id', 0);
             if (is_array($userId)) {
                 $userId = $userId[0];
             }
             $this->SetViewTitle('USER');
         }
     }
     $userId = $model->setId($userId);
     $layoutName = JRequest::getWord('layout', 'default');
     $layoutName = $this->getLayout();
     if ($layoutName == 'edit' || $layoutName == 'edit_shipto') {
         $editor = JFactory::getEditor();
         // Get the required helpers
         $this->loadHelper('shoppergroup');
         $this->loadHelper('image');
         //$userFieldsModel = VmModel::getModel('userfields');
         $userDetails = $model->getUser();
         if ($task == 'editshop' && $userDetails->user_is_vendor) {
             // 				$model->setCurrent();
             if (!empty($userDetails->vendor->vendor_store_name)) {
                 $this->SetViewTitle('STORE', $userDetails->vendor->vendor_store_name);
             } else {
                 $this->SetViewTitle('STORE', JText::_('COM_VIRTUEMART_NEW_VENDOR'));
             }
             $vendorid = $userDetails->virtuemart_vendor_id;
         } else {
             $vendorid = 0;
             $this->SetViewTitle('USER', $userDetails->JUser->get('name'));
         }
         $_new = $userDetails->JUser->get('id') < 1;
         $this->addStandardEditViewCommands($vendorid);
         // User details
         $_contactDetails = $model->getContactDetails();
         $_groupList = $model->getGroupList();
         if (!is_array($_groupList)) {
             $this->lists['gid'] = '<input type="hidden" name="gid" value="' . $userDetails->JUser->get('gid') . '" /><strong>' . JText::_($_groupList) . '</strong>';
         } else {
             $this->lists['gid'] = JHTML::_('select.genericlist', $_groupList, 'gid', 'size="10"', 'value', 'text', $userDetails->JUser->get('gid'));
         }
         $this->lists['canBlock'] = $currentUser->authorize('com_users', 'block user') && $userDetails->JUser->get('id') != $currentUser->get('id');
         // Can't block myself
         $this->lists['canSetMailopt'] = $currentUser->authorize('workflow', 'email_events');
         $this->lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox"', $userDetails->JUser->get('block'), 'COM_VIRTUEMART_YES', 'COM_VIRTUEMART_NO');
         $this->lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox"', $userDetails->JUser->get('sendEmail'), 'COM_VIRTUEMART_YES', 'COM_VIRTUEMART_NO');
         $this->lists['params'] = $userDetails->JUser->getParameters(true);
         // Shopper info
         $this->lists['shoppergroups'] = ShopFunctions::renderShopperGroupList($userDetails->shopper_groups, true);
         $this->lists['vendors'] = ShopFunctions::renderVendorList($userDetails->virtuemart_vendor_id);
         $this->lists['custnumber'] = $model->getCustomerNumberById($userDetails->JUser->get('id'));
         // Shipment address(es)
         $this->lists['shipTo'] = ShopFunctions::generateStAddressList($this, $model, 'addST');
         $new = false;
         if (JRequest::getInt('new', '0') === 1) {
             $new = true;
         }
         $virtuemart_userinfo_id_BT = $model->getBTuserinfo_id($userId);
         $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'BT', $virtuemart_userinfo_id_BT, false);
         $userFieldsBT = $userFieldsArray[$virtuemart_userinfo_id_BT];
         //$this->lists['perms'] = JHTML::_('select.genericlist', Permissions::getUserGroups(), 'perms', '', 'group_name', 'group_name', $userDetails->perms);
         // Load the required scripts
         if (count($userFieldsBT['scripts']) > 0) {
             foreach ($userFieldsBT['scripts'] as $_script => $_path) {
                 JHTML::script($_script, $_path);
             }
         }
         // Load the required stylesheets
         if (count($userFieldsBT['links']) > 0) {
             foreach ($userFieldsBT['links'] as $_link => $_path) {
                 JHTML::stylesheet($_link, $_path);
             }
         }
         $this->assignRef('userFieldsBT', $userFieldsBT);
         $this->assignRef('userInfoID', $virtuemart_userinfo_id_BT);
         $virtuemart_userinfo_id = JRequest::getString('virtuemart_userinfo_id', '0', '');
         $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'ST', $virtuemart_userinfo_id, false);
         if ($new) {
             $virtuemart_userinfo_id = 0;
             // 				$userFieldsST = $userFieldsArray[$virtuemart_userinfo_id];
         } else {
             // 				$userFieldsST = $userFieldsArray[$virtuemart_userinfo_id];
             // 				if(empty($virtuemart_userinfo_id)){
             // 					$virtuemart_userinfo_id = $model->getBTuserinfo_id();
             // 				}
         }
         $userFieldsST = $userFieldsArray[$virtuemart_userinfo_id];
         $this->assignRef('shipToFields', $userFieldsST);
         $this->assignRef('shipToId', $virtuemart_userinfo_id);
         $this->assignRef('new', $new);
         if (!$_new) {
             // Check for existing orders for this user
             $orders = VmModel::getModel('orders');
             $orderList = $orders->getOrdersList($userDetails->JUser->get('id'), true);
         } else {
             $orderList = null;
         }
         if (count($orderList) > 0 || !empty($userDetails->user_is_vendor)) {
             if (!class_exists('CurrencyDisplay')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
             }
             $currency = CurrencyDisplay::getInstance();
             $this->assignRef('currency', $currency);
         }
         // 			vmdebug('user $userDetails ',	$userDetails 	);
         if (!empty($userDetails->user_is_vendor)) {
             $vendorModel = VmModel::getModel('vendor');
             $vendorModel->setId($userDetails->virtuemart_vendor_id);
             $vendorModel->addImages($userDetails->vendor);
             $this->assignRef('vendor', $userDetails->vendor);
             $currencyModel = VmModel::getModel('currency');
             $_currencies = $currencyModel->getCurrencies();
             $this->assignRef('currencies', $_currencies);
         }
         $this->assignRef('userDetails', $userDetails);
         $this->assignRef('orderlist', $orderList);
         $this->assignRef('contactDetails', $_contactDetails);
         $this->assignRef('editor', $editor);
     } else {
         JToolBarHelper::divider();
         JToolBarHelper::custom('toggle.user_is_vendor.1', 'publish', '', 'COM_VIRTUEMART_USER_ISVENDOR');
         JToolBarHelper::custom('toggle.user_is_vendor.0', 'unpublish', '', 'COM_VIRTUEMART_USER_ISNOTVENDOR');
         JToolBarHelper::divider();
         JToolBarHelper::deleteList();
         JToolBarHelper::editListX();
         //This is intentionally, creating new user via BE is buggy and can be done by joomla
         //JToolBarHelper::addNewX();
         $this->addStandardDefaultViewLists($model, 'ju.id');
         $userList = $model->getUserList();
         $this->assignRef('userList', $userList);
         $pagination = $model->getPagination();
         $this->assignRef('pagination', $pagination);
         $shoppergroupmodel = VmModel::getModel('shopperGroup');
         $defaultShopperGroup = $shoppergroupmodel->getDefault(0)->shopper_group_name;
         $this->assignRef('defaultShopperGroup', $defaultShopperGroup);
     }
     parent::display($tpl);
 }
Esempio n. 17
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;
 }
Esempio n. 18
0
 function createStandardRequest($calc, $products, $sign = 1)
 {
     if (!class_exists('TaxServiceSoap')) {
         require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
     }
     if (!class_exists('DocumentType')) {
         require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
     }
     if (!class_exists('DetailLevel')) {
         require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('ServiceMode')) {
         require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('GetTaxRequest')) {
         require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php';
     }
     if (!class_exists('GetTaxResult')) {
         require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
     }
     if (!class_exists('Address')) {
         require VMAVALARA_CLASS_PATH . DS . 'Address.class.php';
     }
     if (is_object($calc)) {
         $calc = get_object_vars($calc);
     }
     $request = new GetTaxRequest();
     $origin = new Address();
     //In Virtuemart we have not differenct warehouses, but we have a shipment address
     //So when the vendor has a shipment address, we assume that it is his warehouse
     //Later we can combine products with shipment addresses for different warehouse (yehye, future music)
     //But for now we just use the BT address
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $userId = VirtueMartModelVendor::getUserIdByVendorId($calc['virtuemart_vendor_id']);
     $userModel = VmModel::getModel('user');
     $virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId);
     // this is needed to set the correct user id for the vendor when the user is logged
     $userModel->getVendor($calc['virtuemart_vendor_id']);
     $vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE);
     $vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id];
     $origin->setLine1($vendorFields['fields']['address_1']['value']);
     $origin->setLine2($vendorFields['fields']['address_2']['value']);
     $origin->setCity($vendorFields['fields']['city']['value']);
     $origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']);
     $origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']);
     $origin->setPostalCode($vendorFields['fields']['zip']['value']);
     $request->setOriginAddress($origin);
     //Address
     if (isset($this->addresses[0])) {
         $destination = $this->addresses[0];
     } else {
         return FALSE;
     }
     if (!class_exists('calculationHelper')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
     }
     $calculator = calculationHelper::getInstance();
     $request->setCurrencyCode($calculator->_currencyDisplay->_vendorCurrency_code_3);
     //CurrencyCode
     $request->setDestinationAddress($destination);
     //Address
     $request->setCompanyCode($calc['company_code']);
     // Your Company Code From the Dashboard
     $request->setDocDate(date('Y-m-d'));
     //date, checked
     $request->setCustomerCode(self::$vmadd['customer_number']);
     //string Required
     if (isset(self::$vmadd['tax_usage_type'])) {
         $request->setCustomerUsageType(self::$vmadd['tax_usage_type']);
         //string   Entity Usage
     }
     if (isset(self::$vmadd['tax_exemption_number'])) {
         $request->setExemptionNo(self::$vmadd['tax_exemption_number']);
         //string   if not using ECMS which keys on customer code
     }
     if (isset(self::$vmadd['taxOverride'])) {
         $request->setTaxOverride(self::$vmadd['taxOverride']);
         avadebug('I set tax override ', self::$vmadd['taxOverride']);
     }
     $setAllDiscounted = false;
     if (isset($products['discountAmount'])) {
         if (!empty($products['discountAmount'])) {
             //$request->setDiscount($sign * $products['discountAmount'] * (-1));            //decimal
             $request->setDiscount($sign * $products['discountAmount']);
             //decimal
             vmdebug('We sent as discount ' . $request->getDiscount());
             $setAllDiscounted = true;
         }
         unset($products['discountAmount']);
     }
     $request->setDetailLevel('Tax');
     //Summary or Document or Line or Tax or Diagnostic
     $lines = array();
     $n = 0;
     $this->_lineNumbersToCartProductId = array();
     foreach ($products as $k => $product) {
         $n++;
         $this->_lineNumbersToCartProductId[$n] = $k;
         $line = new Line();
         $line->setNo($n);
         //string  // line Number of invoice
         $line->setItemCode($product['product_sku']);
         //string
         $line->setDescription($product['product_name']);
         //product description, like in cart, atm only the name, todo add customfields
         if (!empty($product['categories'])) {
             //avadebug('AvaTax setTaxCode Product has categories !',$catNames);
             if (!class_exists('TableCategories')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'categories.php';
             }
             $db = JFactory::getDbo();
             $catTable = new TableCategories($db);
             foreach ($product['categories'] as $cat) {
                 $catTable->load($cat);
                 $catslug = $catTable->slug;
                 if (strpos($catslug, 'avatax-') !== FALSE) {
                     $taxCode = substr($catslug, 7);
                     if (!empty($taxCode)) {
                         $line->setTaxCode($taxCode);
                     } else {
                         vmError('AvaTax setTaxCode, category could not be parsed ' . $catslug);
                     }
                     break;
                 }
             }
         }
         //$line->setTaxCode("");             //string
         $line->setQty($product['amount']);
         //decimal
         $line->setAmount($sign * $product['price'] * $product['amount']);
         //decimal // TotalAmmount
         if ($setAllDiscounted or !empty($product['discount'])) {
             $line->setDiscounted(1);
         } else {
             $line->setDiscounted(0);
         }
         $line->setRevAcct("");
         //string
         $line->setRef1("");
         //string
         $line->setRef2("");
         //string
         if (isset(self::$vmadd['tax_usage_type'])) {
             $line->setCustomerUsageType(self::$vmadd['tax_usage_type']);
             //string   Entity Usage
         }
         if (isset(self::$vmadd['tax_exemption_number'])) {
             $line->setExemptionNo(self::$vmadd['tax_exemption_number']);
             //string   if not using ECMS which keys on customer code
         }
         if (isset(self::$vmadd['taxOverride'])) {
             //create new TaxOverride Object set
             //$line->setTaxOverride(self::$vmadd['taxOverride']);
         }
         $lines[] = $line;
     }
     $this->newATConfig($calc);
     $request->setLines($lines);
     return $request;
 }
Esempio n. 19
0
 /**
  * calculateSalesPrice
  * overrides default function to remove currency conversion
  * @author Zasilkovna
  */
 function calculateSalesPrice($cart, $method, $cart_prices)
 {
     $value = $this->getCosts($cart, $method, $cart_prices);
     $tax_id = @$method->tax_id;
     $vendor_id = $cart->vendorId;
     if (empty($vendor_id)) {
         $vendor_id = 1;
     }
     $vendor_currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
     $db = JFactory::getDBO();
     $calculator = calculationHelper::getInstance();
     $currency = CurrencyDisplay::getInstance();
     $taxrules = array();
     if (!empty($tax_id)) {
         $q = 'SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`="' . $tax_id . '" ';
         $db->setQuery($q);
         $taxrules = $db->loadAssocList();
     }
     if (count($taxrules) > 0) {
         $salesPrice = $calculator->roundInternal($calculator->executeCalculation($taxrules, $value));
     } else {
         $salesPrice = $value;
     }
     return $salesPrice;
 }
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * Okey I try now a completly new idea.
  * We make a function for every tab and the display is getting the right tabs by an own function
  * putting that in an array and after that we call the preparedataforlayoutBlub
  *
  * @author Max Milbers
  */
 function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     $model = VmModel::getModel();
     $virtuemart_vendor_id = JRequest::getInt('virtuemart_vendor_id');
     // 		if ($layoutName=='default') {
     if (empty($virtuemart_vendor_id)) {
         $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_LIST'));
         $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_LIST'));
         $this->vendors = $model->getVendors();
         $model->addImages($this->vendors);
     } else {
         $vendor = $model->getVendor($virtuemart_vendor_id);
         $model->addImages($vendor);
         if (VmConfig::get('enable_content_plugin', 0)) {
             // add content plugin //
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $vendor->text = $vendor->vendor_store_desc;
             $params = new JRegistry();
             if (!isset($vendor->event)) {
                 $vendor->event = new stdClass();
             }
             $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.vendor', &$vendor, &$params, 0));
             // More events for 3rd party content plugins
             // This do not disturb actual plugins, because we don't modify $vendor->text
             $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.vendor', &$vendor, &$params, 0));
             $vendor->event->afterDisplayTitle = trim(implode("\n", $res));
             $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.vendor', &$vendor, &$params, 0));
             $vendor->event->beforeDisplayContent = trim(implode("\n", $res));
             $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.vendor', &$vendor, &$params, 0));
             $vendor->event->afterDisplayContent = trim(implode("\n", $res));
             $vendor->vendor_store_desc = $vendor->text;
         }
         $this->vendor = $vendor;
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . '/models/vendor.php';
         }
         $userId = VirtueMartModelVendor::getUserIdByVendorId($virtuemart_vendor_id);
         //$usermodel = VmModel::getModel('user');
         //$virtuemart_userinfo_id = $usermodel->getBTuserinfo_id($userId);
         //$usermodel->getVendor($virtuemart_vendor_id);
         //$userFields = $usermodel->getUserInfoInUserFields($layoutName, 'BT', $virtuemart_userinfo_id,true,true);
         //$this->assignRef('userFields', $userFields);
         if ($layoutName == 'tos') {
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_TOS'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_TOS'));
         } elseif ($layoutName == 'contact') {
             $user = JFactory::getUser();
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_CONTACT'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_CONTACT'));
             $this->user = $user;
         } else {
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_DETAILS') . ' ' . $this->vendor->vendor_store_name);
             $pathway->addItem($this->vendor->vendor_store_name);
             //JText::_('COM_VIRTUEMART_VENDOR_DETAILS'));
             $this->setLayout('details');
             $productModel = VmModel::getModel('product');
             $this->products = $productModel->getProductsInCategory(0, $virtuemart_vendor_id);
             if ($this->products) {
                 $productModel->addImages($this->products, 1);
                 $currency = CurrencyDisplay::getInstance();
                 $this->currency = $currency;
                 foreach ($this->products as $product) {
                     $product->stock = $productModel->getStockIndicator($product);
                 }
                 if (!class_exists('Permissions')) {
                     require JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php';
                 }
                 $this->showBasePrice = Permissions::getInstance()->check('admin');
                 //todo add config settings
                 $this->perRow = VmConfig::get('products_per_row', 3);
                 $this->pagination = $productModel->getPagination($this->perRow);
             }
         }
         $this->linkdetails = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=details&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_DETAILS') . '</a>';
         $this->linkcontact = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=contact&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_CONTACT') . '</a>';
         $this->linktos = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_TOS') . '</a>';
     }
     parent::display($tpl);
 }
Esempio n. 21
0
	function display($tpl = null) {


		//Load helpers
		if (!class_exists('CurrencyDisplay'))
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php');

		if (!class_exists('VmHTML'))
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php');

		if(!class_exists('vmPSPlugin')) require(VMPATH_PLUGINLIBS.DS.'vmpsplugin.php');
		$orderStatusModel=VmModel::getModel('orderstatus');
		$orderStates = $orderStatusModel->getOrderStatusList();

		$this->SetViewTitle( 'ORDER');

		$orderModel = VmModel::getModel();

		$curTask = vRequest::getCmd('task');
		if ($curTask == 'edit') {
			VmConfig::loadJLang('com_virtuemart_shoppers',TRUE);
			VmConfig::loadJLang('com_virtuemart_orders', true);

			//For getOrderStatusName
			if (!class_exists('ShopFunctions'))	require(VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php');

			// Load addl models
			$userFieldsModel = VmModel::getModel('userfields');

			// Get the data
			$virtuemart_order_id = vRequest::getInt('virtuemart_order_id');
			$order = $orderModel->getOrder($virtuemart_order_id);


			$_orderID = $order['details']['BT']->virtuemart_order_id;
			$orderbt = $order['details']['BT'];
			$orderst = (array_key_exists('ST', $order['details'])) ? $order['details']['ST'] : $orderbt;
			$orderbt ->invoiceNumber = $orderModel->getInvoiceNumber($orderbt->virtuemart_order_id);

			$currency = CurrencyDisplay::getInstance('',$order['details']['BT']->virtuemart_vendor_id);

			$this->assignRef('currency', $currency);

			$_userFields = $userFieldsModel->getUserFields(
					 'account'
					, array('captcha' => true, 'delimiters' => true) // Ignore these types
					, array('delimiter_userinfo','user_is_vendor' ,'username','name','password', 'password2', 'agreed', 'address_type') // Skips
			);
			$userFieldsCart = $userFieldsModel->getUserFields(
				'cart'
				, array('captcha' => true, 'delimiters' => true) // Ignore these types
				, array('delimiter_userinfo','user_is_vendor' ,'username','password', 'password2', 'agreed', 'address_type') // Skips
			);
			$_userFields = array_merge($userFieldsCart,$_userFields);

			//Fallback for customer_note
			if(empty($orderbt->customer_note) and !empty($orderbt->oc_note)){
				$orderbt->customer_note = $orderbt->oc_note;
			}

			$userfields = $userFieldsModel->getUserFieldsFilled(
					 $_userFields
					,$orderbt
					,'BT_'
			);

			$_userFields = $userFieldsModel->getUserFields(
					 'shipment'
					, array() // Default switches
					, array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type') // Skips
			);

			$shipmentfields = $userFieldsModel->getUserFieldsFilled(
					 $_userFields
					,$orderst
					,'ST_'
			);

			// Create an array to allow orderlinestatuses to be translated
			// We'll probably want to put this somewhere in ShopFunctions...
			$_orderStatusList = array();
			foreach ($orderStates as $orderState) {
				//$_orderStatusList[$orderState->virtuemart_orderstate_id] = $orderState->order_status_name;
				//When I use update, I have to use this?
				$_orderStatusList[$orderState->order_status_code] = vmText::_($orderState->order_status_name);
			}

			$_itemStatusUpdateFields = array();
			$_itemAttributesUpdateFields = array();
			foreach($order['items'] as $_item) {
				$_itemStatusUpdateFields[$_item->virtuemart_order_item_id] = JHtml::_('select.genericlist', $orderStates, "item_id[".$_item->virtuemart_order_item_id."][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status'.$_item->virtuemart_order_item_id,true);

			}

			if(!isset($_orderStatusList[$orderbt->order_status])){
				if(empty($orderbt->order_status)){
					$orderbt->order_status = 'unknown';
				}
				$_orderStatusList[$orderbt->order_status] = vmText::_('COM_VIRTUEMART_UNKNOWN_ORDER_STATUS');
			}

			$this->lists['search'] = '';

			/* Assign the data */
			$this->assignRef('orderdetails', $order);
			$this->assignRef('orderID', $_orderID);
			$this->assignRef('userfields', $userfields);
			$this->assignRef('shipmentfields', $shipmentfields);
			$this->assignRef('orderstatuslist', $_orderStatusList);
			$this->assignRef('itemstatusupdatefields', $_itemStatusUpdateFields);
			$this->assignRef('itemattributesupdatefields', $_itemAttributesUpdateFields);
			$this->assignRef('orderbt', $orderbt);
			$this->assignRef('orderst', $orderst);
			$this->assignRef('virtuemart_shipmentmethod_id', $orderbt->virtuemart_shipmentmethod_id);

			/* Data for the Edit Status form popup */
			$_currentOrderStat = $order['details']['BT']->order_status;
			// used to update all item status in one time
			$_orderStatusSelect = JHtml::_('select.genericlist', $orderStates, 'order_status', '', 'order_status_code', 'order_status_name', $_currentOrderStat, 'order_items_status',true);
			$this->assignRef('orderStatSelect', $_orderStatusSelect);
			$this->assignRef('currentOrderStat', $_currentOrderStat);

			/* Toolbar */
			if (JVM_VERSION < 3) { $backward="back"; $list='back';} else {$backward='backward';$list='list';}
			JToolBarHelper::custom( 'prevItem', $backward,'','COM_VIRTUEMART_ITEM_PREVIOUS',false);
			JToolBarHelper::custom( 'nextItem', 'forward','','COM_VIRTUEMART_ITEM_NEXT',false);
			JToolBarHelper::divider();
			JToolBarHelper::custom( 'cancel', $list,'','COM_VIRTUEMART_ORDER_LIST_LBL',false,false);
		}
		else if ($curTask == 'editOrderItem') {
			if(!class_exists('calculationHelper')) require(VMPATH_ADMIN.DS.'helpers'.DS.'calculationh.php');

			$this->assignRef('orderstatuses', $orderStates);

			$model = VmModel::getModel();
			$orderId = vRequest::getString('orderId', '');
			$orderLineItem = vRequest::getVar('orderLineId', '');
			$this->assignRef('virtuemart_order_id', $orderId);
			$this->assignRef('virtuemart_order_item_id', $orderLineItem);

			$orderItem = $model->getOrderLineDetails($orderId, $orderLineItem);
			$this->assignRef('orderitem', $orderItem);
		}
		else {
			$this->setLayout('orders');

			$model = VmModel::getModel();
			$this->addStandardDefaultViewLists($model,'created_on');
			$orderStatusModel =VmModel::getModel('orderstatus');
			$orderstates = vRequest::getCmd('order_status_code','');
			$this->lists['state_list'] = $orderStatusModel->renderOSList($orderstates,'order_status_code',FALSE,' onchange="this.form.submit();" ');
			$orderslist = $model->getOrdersList();

			$this->assignRef('orderstatuses', $orderStates);

			if(!class_exists('CurrencyDisplay'))require(VMPATH_ADMIN.DS.'helpers'.DS.'currencydisplay.php');

			/* Apply currency This must be done per order since it's vendor specific */
			$_currencies = array(); // Save the currency data during this loop for performance reasons

			if ($orderslist) {

			    foreach ($orderslist as $virtuemart_order_id => $order) {

				    if(!empty($order->order_currency)){
					    $currency = $order->order_currency;
				    } else if($order->virtuemart_vendor_id){
					    if(!class_exists('VirtueMartModelVendor')) require(VMPATH_ADMIN.DS.'models'.DS.'vendor.php');
					    $currObj = VirtueMartModelVendor::getVendorCurrency($order->virtuemart_vendor_id);
				        $currency = $currObj->virtuemart_currency_id;
				   }
				    //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code
				    if (!array_key_exists('curr'.$currency, $_currencies)) {

					    $_currencies['curr'.$currency] = CurrencyDisplay::getInstance($currency,$order->virtuemart_vendor_id);
				    }

				    $order->order_total = $_currencies['curr'.$currency]->priceDisplay($order->order_total);
				    $order->invoiceNumber = $model->getInvoiceNumber($order->virtuemart_order_id);
			    }

			}

			//update order items button
			/*$q = 'SELECT * FROM #__virtuemart_order_items WHERE `product_discountedPriceWithoutTax` IS NULL ';
			$db = JFactory::getDBO();
			$db->setQuery($q);
			//$res = $db->loadRow();
			if(true) {
				JToolBarHelper::custom('updateCustomsOrderItems', 'new', 'new', vmText::_('COM_VIRTUEMART_REPORT_UPDATEORDERITEMS'),false);
				vmError('COM_VIRTUEMART_UPDATEORDERITEMS_WARN');
			}*/
			/*
			 * UpdateStatus removed from the toolbar; don't understand how this was intented to work but
			 * the order ID's aren't properly passed. Might be readded later; the controller needs to handle
			 * the arguments.
			 */

			/* Toolbar */
			//JToolBarHelper::customX( 'CreateOrderHead', 'new','new','New',false);
			JToolBarHelper::save('updatestatus', vmText::_('COM_VIRTUEMART_UPDATE_STATUS'));

			if ($this->canDo->get('core.admin') || $this->canDo->get('vm.orders.delete')) {
				JToolBarHelper::spacer('100');
				JToolBarHelper::deleteList();
			}

			/* Assign the data */
			$this->assignRef('orderslist', $orderslist);

			$pagination = $model->getPagination();
			$this->assignRef('pagination', $pagination);

		}
		if(JFactory::getApplication()->isSite()) {
			$bar = JToolBar::getInstance( 'toolbar' );
			$bar->appendButton( 'Link', 'back', 'COM_VIRTUEMART_LEAVE', 'index.php?option=com_virtuemart&manage=0' );
		}

		shopFunctions::checkSafePath();

		parent::display($tpl);
	}
 /**
  * The invoice fee is in the vendor currency, and should be converted to the payment currency
  *
  * @static
  * @param $method
  * @param $country
  * @return mixed
  */
 public static function getInvoiceFeeInclTax($method, $country, $cartPricesCurrency, $cartPaymentCurrency, &$display_invoice_fee, &$invoice_fee)
 {
     $method_invoice_fee = self::getInvoiceFee($method, $country);
     $invoice_tax_id = self::getInvoiceTaxId($method, $country);
     vmdebug('getInvoiceFeeInclTax', $cartPaymentCurrency, $invoice_fee);
     if (!class_exists('calculationHelper')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
     }
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VirtueMartModelVendor')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
     }
     $vendor_id = 1;
     $vendor_currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
     //$currency = CurrencyDisplay::getInstance ();
     $paymentCurrency = CurrencyDisplay::getInstance($cartPaymentCurrency);
     $invoice_fee = (double) round($paymentCurrency->convertCurrencyTo($cartPaymentCurrency, $method_invoice_fee, FALSE), 2);
     $currencyDisplay = CurrencyDisplay::getInstance($cartPricesCurrency);
     $paymentCurrency = CurrencyDisplay::getInstance($cartPaymentCurrency);
     $display_invoice_fee = $paymentCurrency->priceDisplay($method_invoice_fee, $cartPaymentCurrency);
     $currencyDisplay = CurrencyDisplay::getInstance($cartPricesCurrency);
     vmdebug('getInvoiceFeeInclTax', $cartPaymentCurrency, $invoice_fee, $invoice_tax_id, $display_invoice_fee);
     return;
 }
Esempio n. 23
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];
    }
Esempio n. 24
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;
 }
Esempio n. 25
0
 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;
 }
 /**
  * @return mixed
  */
 function _getVendorCurrencyId()
 {
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $vendor_id = 1;
     $vendor_currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
     return $vendor_currency->virtuemart_currency_id;
 }
Esempio n. 27
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];
 }
Esempio n. 28
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;
 }
Esempio n. 29
0
 /**
  * Sets the internal user id with given vendor Id
  *
  * @author Max Milbers
  * @param int $vendorId
  */
 function getVendor($vendorId = 1, $return = TRUE)
 {
     $vendorModel = VmModel::getModel('vendor');
     $userId = VirtueMartModelVendor::getUserIdByVendorId($vendorId);
     if ($userId) {
         $this->setUserId($userId);
         if ($return) {
             return $this->getUser();
         }
     } else {
         return false;
     }
 }
 function display($tpl = null)
 {
     //Load helpers
     $this->loadHelper('currencydisplay');
     $this->loadHelper('html');
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     $orderStatusModel = VmModel::getModel('orderstatus');
     $orderStates = $orderStatusModel->getOrderStatusList();
     $this->SetViewTitle('ORDER');
     $model = VmModel::getModel();
     $curTask = JRequest::getWord('task');
     if ($curTask == 'edit') {
         VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
         // Load addl models
         $userFieldsModel = VmModel::getModel('userfields');
         $productModel = VmModel::getModel('product');
         // Get the data
         $virtuemart_order_id = JRequest::getInt('virtuemart_order_id');
         $order = $model->getOrder($virtuemart_order_id);
         $this->orderID = $order['details']['BT']->virtuemart_order_id;
         $orderbt = $order['details']['BT'];
         $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt;
         $orderbt->invoiceNumber = $model->getInvoiceNumber($orderbt->virtuemart_order_id);
         $this->currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
         $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
         $this->userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt, 'BT_');
         $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type'));
         $this->shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst, 'ST_');
         // Create an array to allow orderlinestatuses to be translated
         // We'll probably want to put this somewhere in ShopFunctions...
         $_orderStatusList = array();
         foreach ($orderStates as $orderState) {
             //$_orderStatusList[$orderState->virtuemart_orderstate_id] = $orderState->order_status_name;
             //When I use update, I have to use this?
             $_orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name);
         }
         $_itemStatusUpdateFields = array();
         $_itemAttributesUpdateFields = array();
         foreach ($order['items'] as $_item) {
             $_itemStatusUpdateFields[$_item->virtuemart_order_item_id] = JHTML::_('select.genericlist', $orderStates, "item_id[" . $_item->virtuemart_order_item_id . "][order_status]", 'class="selectItemStatusCode input-medium"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->virtuemart_order_item_id, true);
         }
         if (!isset($_orderStatusList[$orderbt->order_status])) {
             if (empty($orderbt->order_status)) {
                 $orderbt->order_status = 'unknown';
             }
             $_orderStatusList[$orderbt->order_status] = JText::_('COM_VIRTUEMART_UNKNOWN_ORDER_STATUS');
         }
         /* Assign the data */
         $this->orderdetails = $order;
         $this->orderstatuslist = $_orderStatusList;
         $this->itemstatusupdatefields = $_itemStatusUpdateFields;
         $this->itemattributesupdatefields = $_itemAttributesUpdateFields;
         $this->orderbt = $orderbt;
         $this->orderst = $orderst;
         $this->virtuemart_shipmentmethod_id = $orderbt->virtuemart_shipmentmethod_id;
         /* Data for the Edit Status form popup */
         $this->currentOrderStat = $order['details']['BT']->order_status;
         // used to update all item status in one time
         $this->orderStatusSelect = JHTML::_('select.genericlist', $orderStates, 'order_status', '', 'order_status_code', 'order_status_name', $this->currentOrderStat, 'order_items_status', true);
         /* Toolbar */
         JToolBarHelper::custom('prevItem', 'backward', '', 'COM_VIRTUEMART_ITEM_PREVIOUS', false);
         JToolBarHelper::custom('nextItem', 'forward', '', 'COM_VIRTUEMART_ITEM_NEXT', false);
         JToolBarHelper::divider();
         JToolBarHelper::custom('cancel', 'cancel', 'back', 'COM_VIRTUEMART_CLOSE', false, false);
     } else {
         if ($curTask == 'editOrderItem') {
             $this->loadHelper('calculationh');
             $this->orderstatuses = $orderStates;
             $this->virtuemart_order_id = JRequest::getString('orderId', '');
             $this->virtuemart_order_item_id = JRequest::getVar('orderLineId', '');
             $this->orderItem = $model->getOrderLineDetails($this->virtuemart_order_id, $this->virtuemart_order_item_id);
         } else {
             if (JRequest::getWord('format', '') === 'raw') {
                 $tpl = 'results';
             } else {
                 /* Toolbar */
                 JToolBarHelper::save('updatestatus', JText::_('COM_VIRTUEMART_UPDATE_STATUS'));
                 JToolBarHelper::deleteList();
             }
             $this->addStandardDefaultViewLists($model, 'created_on');
             $orderStatusModel = VmModel::getModel('orderstatus');
             $orderstates = JRequest::getWord('order_status_code', '');
             $this->lists['state_list'] = $orderStatusModel->renderOSList($orderstates, 'order_status_code', FALSE, ' onchange="this.form.submit();" ');
             $orderslist = $model->getOrdersList();
             $this->orderstatuses = $orderStates;
             foreach ($orderStates as $orderState) {
                 //$_orderStatusList[$orderState->virtuemart_orderstate_id] = $orderState->order_status_name;
                 //When I use update, I have to use this?
                 $_orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name);
             }
             $this->orderStatusList = $_orderStatusList;
             $this->loadHelper('currencydisplay');
             if ($this->adminVendor > 1) {
                 $this->setLayout('vendor');
             }
             /* Apply currency This must be done per order since it's vendor specific */
             $_currencies = array();
             // Save the currency data during this loop for performance reasons
             if ($orderslist) {
                 foreach ($orderslist as $virtuemart_order_id => $order) {
                     if (!empty($order->order_currency)) {
                         $currency = $order->order_currency;
                     } else {
                         if ($order->virtuemart_vendor_id) {
                             if (!class_exists('VirtueMartModelVendor')) {
                                 require JPATH_VM_ADMINISTRATOR . '/models' . DS . 'vendor.php';
                             }
                             $currObj = VirtueMartModelVendor::getVendorCurrency($order->virtuemart_vendor_id);
                             $currency = $currObj->virtuemart_currency_id;
                         }
                     }
                     //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code
                     if (!array_key_exists('curr' . $currency, $_currencies)) {
                         $_currencies['curr' . $currency] = CurrencyDisplay::getInstance($currency, $order->virtuemart_vendor_id);
                     }
                     $order->order_total = $_currencies['curr' . $currency]->priceDisplay($order->order_total);
                     $order->invoiceNumber = $model->getInvoiceNumber($order->virtuemart_order_id);
                 }
             }
             /*
              * UpdateStatus removed from the toolbar; don't understand how this was intented to work but
              * the order ID's aren't properly passed. Might be readded later; the controller needs to handle
              * the arguments.
              */
             /* Assign the data */
             $this->orderslist = $orderslist;
             $this->pagination = $model->getPagination();
         }
     }
     shopFunctions::checkSafePath();
     parent::display($tpl);
 }