Beispiel #1
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);
 }
    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;
    }
Beispiel #3
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 fetchElement($name, $value, &$node, $control_name)
 {
     $db = JFactory::getDBO();
     $query = 'SELECT `virtuemart_currency_id` AS value, `currency_name` AS text
     		 FROM `#__virtuemart_currencies`
     		 WHERE `virtuemart_vendor_id` = "1"  AND `published` = "1" ORDER BY `currency_name` ASC ';
     // default value should be vendor currency
     $db->setQuery($query);
     $currencies = $db->loadObjectList();
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $vendor_id = VirtueMartModelVendor::getLoggedVendor();
     if (empty($value)) {
         $currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
         $value = $currency->virtuemart_currency_id;
     }
     return JHTML::_('select.genericlist', $currencies, $control_name . '[' . $name . '][]', $class, 'value', 'text', $value, $control_name . $name);
 }
 function display($tpl = null)
 {
     // Load the helper(s)
     $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);
 }
 /**
  * @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;
 }
Beispiel #8
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;
 }
Beispiel #9
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;
 }
 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);
 }
Beispiel #12
0
 /**
  * calculateSalesPrice
  *
  * @param $value
  * @param $tax_id: tax id
  * @return $salesPrice
  */
 protected function calculateSalesPrice($cart, $method, $cart_prices)
 {
     $value = $this->getCosts($cart, $method, $cart_prices);
     $tax_id = @$method->tax_id;
     if (!class_exists('calculationHelper')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
     }
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $vendor_id = 1;
     $vendor_currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
     $db = JFactory::getDBO();
     $calculator = calculationHelper::getInstance();
     $currency = CurrencyDisplay::getInstance();
     $value = $currency->convertCurrencyTo($vendor_currency->virtuemart_currency_id, $value);
     $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;
 }
 function display($tpl = null)
 {
     //Load helpers
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     $orderStatusModel = VmModel::getModel('orderstatus');
     $orderStates = $orderStatusModel->getOrderStatusList();
     $shippingModel = VmModel::getModel('mds');
     $curTask = JRequest::getWord('task');
     if ($curTask == 'edit') {
         $this->setLayout('order');
         VmConfig::loadJLang('com_virtuemart_shoppers', true);
         VmConfig::loadJLang('com_virtuemart_orders', true);
         // Load addl models
         $userFieldsModel = VmModel::getModel('userfields');
         $productModel = VmModel::getModel('product');
         // Get the data
         $virtuemart_order_id = JRequest::getInt('virtuemart_order_id');
         $order = $shippingModel->getOrder($virtuemart_order_id);
         $tot_parcel = 0;
         $total_weight = 0;
         $total_vol_weight = 0;
         foreach ($order['items'] as $item) {
             $quantity = 1;
             $product = $productModel->getProduct($item->virtuemart_product_id);
             while ($quantity <= $item->product_quantity) {
                 // Length coversion, mds collivery only acceps CM
                 if (strtolower($product->product_lwh_uom) != 'çm') {
                     $length = $this->converter->convert($product->product_length, strtolower($product->product_lwh_uom), 'cm', 6);
                     $width = $this->converter->convert($product->product_width, strtolower($product->product_lwh_uom), 'cm', 6);
                     $height = $this->converter->convert($product->product_height, strtolower($product->product_lwh_uom), 'cm', 6);
                 } else {
                     $length = $product->product_length;
                     $width = $product->product_width;
                     $height = $product->product_height;
                 }
                 // Weight coversion, mds collivery only acceps KG'S
                 if (strtolower($product->product_weight_uom) != 'kg') {
                     $weight = $this->converter->convert($product->product_weight, strtolower($product->product_weight_uom), 'kg', 6);
                 } else {
                     $weight = $product->product_weight;
                 }
                 $parcels[] = array("length" => str_replace(",", "", $length), "width" => str_replace(",", "", $width), "height" => str_replace(",", "", $height), "weight" => str_replace(",", "", $weight));
                 $tot_parcel += 1;
                 $quantity++;
             }
             $total_weight += $product->product_weight * $item->product_quantity;
             $total_vol_weight += $product->product_length * $item->product_quantity * ($product->product_width * $item->product_quantity) * ($product->product_height * $item->product_quantity);
         }
         $total_vweight = $total_vol_weight / 4000;
         $deliver_info = array('vol_weight' => $total_vol_weight, 'weight' => $total_weight, 'parcels' => $parcels);
         $_orderID = $order['details']['BT']->virtuemart_order_id;
         $orderbt = $order['details']['BT'];
         $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt;
         $orderbt->invoiceNumber = $shippingModel->getInvoiceNumber($orderbt->virtuemart_order_id);
         $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
         $this->assignRef('currency', $currency);
         // 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"', '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->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);
         $this->SetViewTitle('MDS Confirm Collivery', 'Edit or accept order #' . $_orderID);
         $state_name = $shippingModel->getState($orderst->virtuemart_state_id);
         $this->assignRef('state_name', $state_name);
         $this->assignRef('mds_service', $shippingModel->getService($orderst->virtuemart_shipmentmethod_id));
         $this->assignRef('package_info', $deliver_info);
         $this->assignRef('towns', $this->towns);
         $this->assignRef('addresses', $this->addresses);
         $this->assignRef('location_types', $this->location_types);
         $this->assignRef('default_address_id', $this->default_address_id);
         $this->assignRef('default_contacts', $this->default_contacts);
         $this->assignRef('mds_services', $this->mds_services);
         $this->assignRef('risk_cover', $this->risk_cover);
         $destination_towns = $this->towns;
         $selected_town = array_search($state_name, $destination_towns);
         unset($destination_towns[$selected_town]);
         $destination_suburbs = $this->collivery->getSuburbs($selected_town);
         $this->assignRef('destination_towns', $destination_towns);
         if ($orderst->mds_suburb_id != "") {
             $destination_suburb_key = $orderst->mds_suburb_id;
         } else {
             list($destination_suburb_key) = array_keys($destination_suburbs);
         }
         $this->assignRef('destination_suburb_key', $destination_suburb_key);
         $this->assignRef('first_destination_suburb', $destination_suburbs[$destination_suburb_key]);
         unset($destination_suburbs[$destination_suburb_key]);
         $this->assignRef('destination_suburbs', $destination_suburbs);
         $destination_location_types = $this->location_types;
         $this->assignRef('first_destination_location_type', $destination_location_types[$orderst->mds_location_type]);
         unset($destination_location_types[$orderst->mds_location_type]);
         $this->assignRef('destination_location_types', $destination_location_types);
     } elseif ($curTask == 'awaiting_dispatch') {
         $this->setLayout('index_dispatch');
         // Older version check
         if (preg_replace('/[^0-9]/', "", $this->vm_version) >= preg_replace('/[^0-9]/', "", '2.0.26d')) {
             $model = VmModel::getModel();
             $this->addStandardDefaultViewLists($model, 'created_on');
             $orderslist = $model->getOrdersList();
             $this->assignRef('orderstatuses', $orderStates);
             if (!class_exists('CurrencyDisplay')) {
                 require JPATH_VM_ADMINISTRATOR . 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) {
                     //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('v' . $order->virtuemart_vendor_id, $_currencies)) {
                         $_currencies['v' . $order->virtuemart_vendor_id] = CurrencyDisplay::getInstance('', $order->virtuemart_vendor_id);
                     }
                     $order->order_total = $_currencies['v' . $order->virtuemart_vendor_id]->priceDisplay($order->order_total);
                     $order->invoiceNumber = $model->getInvoiceNumber($order->virtuemart_order_id);
                 }
             }
             /* Assign the data */
             $this->assignRef('orderslist', $orderslist);
             $this->assignRef('services', $this->services);
             $pagination = $model->getPagination();
             $this->assignRef('pagination', $pagination);
             $this->SetViewTitle('MDS Confirm Collivery', 'MDS shipping awaiting confirmation');
         } else {
             // old version!
             $model = VmModel::getModel();
             $this->addStandardDefaultViewLists($model, 'created_on');
             $orderStatusModel = VmModel::getModel('orderstatus');
             $orderstates = JRequest::getWord('order_status_code', '');
             $orderslist = $model->getOrdersList();
             $this->assignRef('orderstatuses', $orderStates);
             if (!class_exists('CurrencyDisplay')) {
                 require JPATH_VM_ADMINISTRATOR . 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;
                     } elseif ($order->virtuemart_vendor_id) {
                         if (!class_exists('VirtueMartModelVendor')) {
                             require JPATH_VM_ADMINISTRATOR . 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);
                 }
             }
             /* Assign the data */
             $this->assignRef('orderslist', $orderslist);
             $this->assignRef('services', $this->services);
             $pagination = $model->getPagination();
             $this->assignRef('pagination', $pagination);
             $this->SetViewTitle('MDS Confirm Collivery', 'MDS shipping awaiting confirmation');
         }
     } elseif ($curTask == 'config') {
         $shippingModel = VmModel::getModel();
         $post = JRequest::get('post');
         if (!empty($post)) {
             // change our password
             $this->db->setQuery("UPDATE `#__mds_collivery_config` SET `password` = '" . $post['password'] . "', `username` = '" . $post['username'] . "', `risk_cover` = '" . $post['risk_cover'] . "' WHERE `id` = 1;");
             $this->db->query();
         }
         $this->setLayout('config');
         $config = $shippingModel->getConfig();
         $this->assignRef('config', $config);
         $this->SetViewTitle('MDS Collivery Config', 'Account settings & Update option');
     } elseif ($curTask == 'view') {
         $model = VmModel::getModel();
         $waybill = JRequest::getInt('waybill');
         $order = $model->getAccepted($waybill);
         $this->setLayout('view');
         $this->SetViewTitle('MDS Confirmed', 'Waybill #' . $waybill);
         $directory = preg_replace('|administrator/|i', "", JPATH_COMPONENT) . '/views/mds/tmpl/waybills/' . $waybill;
         // Do we have images of the parcels
         if ($pod = $this->collivery->getPod($waybill)) {
             if (!is_dir($directory)) {
                 mkdir($directory, 0777, true);
             }
             file_put_contents($directory . '/' . $pod['filename'], base64_decode($pod['file']));
         }
         // Do we have proof of delivery
         if ($parcels = $this->collivery->getParcelImageList($waybill)) {
             if (!is_dir($directory)) {
                 mkdir($directory, 0777, true);
             }
             foreach ($parcels as $parcel) {
                 $size = $parcel['size'];
                 $mime = $parcel['mime'];
                 $filename = $parcel['filename'];
                 $parcel_id = $parcel['parcel_id'];
                 if ($image = $this->collivery->getParcelImage($parcel_id)) {
                     file_put_contents($directory . '/' . $filename, base64_decode($image['file']));
                 }
             }
         }
         // Get our tracking information
         $tracking = $this->collivery->getStatus($waybill);
         $validation_results = json_decode($order->validation_results);
         $this->assignRef('order', $order);
         $this->assignRef('collection_address', $this->collivery->getAddress($validation_results->collivery_from));
         $this->assignRef('destination_address', $this->collivery->getAddress($validation_results->collivery_to));
         $this->assignRef('collection_contacts', $this->collivery->getContacts($validation_results->collivery_from));
         $this->assignRef('destination_contacts', $this->collivery->getContacts($validation_results->collivery_to));
         // Set our status
         if ($tracking['status_id'] == 6) {
             // change our status
             $this->db->setQuery("UPDATE `#__mds_collivery_processed` SET `status` = 0 WHERE `waybill` = " . $waybill . ";");
             $this->db->query();
         }
         $this->assignRef('tracking', $tracking);
         $this->assignRef('pod', glob($directory . "/*.{pdf,PDF}", GLOB_BRACE));
         $this->assignRef('image_list', glob($directory . "/*.{jpg,JPG,jpeg,JPEG,gif,GIF,png,PNG}", GLOB_BRACE));
         $view_waybill = 'https://quote.collivery.co.za/waybillpdf.php?wb=' . base64_encode($waybill) . '&output=I';
         $this->assignRef('view_waybill', $view_waybill);
     } elseif ($curTask == 'index') {
         $this->setLayout('index');
         $post = JRequest::get('post');
         $status = isset($post['status']) && $post['status'] != "" ? $post['status'] : 1;
         $waybill = isset($post['waybill']) && $post['waybill'] != "" ? $post['waybill'] : false;
         $model = VmModel::getModel();
         $orderslist = $model->getAcceptedList($status, $waybill);
         /* Assign the data */
         $this->assignRef('orderslist', $orderslist);
         $pagination = $model->getPagination();
         $this->assignRef('pagination', $pagination);
         $this->SetViewTitle('MDS Confirmed', 'Orders already passed to MDS Collivery');
     }
     parent::display($tpl);
 }
Beispiel #14
0
 public static function getInvoiceFeeInclTax($method, $country)
 {
     $invoice_fee = self::getInvoiceFee($method, $country);
     $invoice_tax_id = self::getInvoiceTaxId($method, $country);
     if (!class_exists('calculationHelper')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
     }
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $vendor_id = 1;
     $vendor_currency = VirtueMartModelVendor::getVendorCurrency($vendor_id);
     $db = JFactory::getDBO();
     $calculator = calculationHelper::getInstance();
     $currency = CurrencyDisplay::getInstance();
     $value = $currency->convertCurrencyTo($vendor_currency->virtuemart_currency_id, $invoice_fee);
     $taxrules = array();
     if (!empty($invoice_tax_id)) {
         $q = 'SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`="' . $invoice_tax_id . '" ';
         $db->setQuery($q);
         $taxrules = $db->loadAssocList();
     }
     if (count($taxrules) > 0) {
         $salesPrice = $calculator->roundInternal($calculator->executeCalculation($taxrules, $value));
     } else {
         $salesPrice = $value;
     }
     return $salesPrice;
 }
Beispiel #15
0
 public function insert_com_virtuemart($template, $template_folder, $componentsOptions, $componentsPostData, $toc_type)
 {
     $this->db = JFactory::getDBO();
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_joomailermailchimpintegration/models');
     $createModel = JModelLegacy::getInstance('Create', 'joomailermailchimpintegrationModel');
     $this->loadLanguageFiles();
     $response = array();
     // define abs paths for regex
     $abs_path = '$1="' . JURI::root() . '$2$3';
     $imagepath = '$1="' . JURI::root() . 'administrator/components/com_joomailermailchimpintegration/templates/' . $template_folder . '/$2$3';
     // extract the placeholder from the template
     $regex = '!<#vm_repeater#[^>]*>(.*)<#/vm_repeater#>!is';
     preg_match($regex, $template, $repeater);
     $regex = '!<#vm_products#[^>]*>(.*)<#/vm_products#>!is';
     preg_match($regex, $template, $container);
     if (isset($repeater[0])) {
         $repeater[0] = preg_replace('#(href|src)="([^:"]*)("|(?:(?:%20|\\s|[.]|\\+)[^"]*"))#i', $imagepath, $repeater[0]);
     } else {
         $response['template'] = $template;
         $response['msg'] = '<div style="border: 2px solid #ff0000; margin:15px 0 5px;padding:10px 15px 12px;">' . '<img src="' . JURI::root() . 'media/com_joomailermailchimpintegration/backend/images/warning.png" align="left"/>' . '<div style="padding-left: 45px; line-height: 28px; font-size: 14px;">' . JTEXT::_('JM_NO_VIRTUEMART_PLACEHOLDER') . '</div></div>';
         $repeater[0] = '';
         $error = true;
     }
     //If a placeholder was found start iterating through the items and insert them into
     if ($repeater[0]) {
         // convert relative to absolute image paths
         $repeater = preg_replace('#(href|src)="([^:"]*)("|(?:(?:%20|\\s|[.]|\\+)[^"]*"))#i', $imagepath, $repeater[0]);
         $repeater = str_ireplace(array('<#vm_repeater#>', '<#/vm_repeater#>'), '', $repeater);
         $selected = JRequest::getVar($this->id, NULL, 'post');
         if (count($selected)) {
             $vm_productids = array();
             $vm_productprices = array();
             $vm_productcats = array();
             for ($i = 0; $i < count($selected); $i++) {
                 $selected[$i] = explode('|', $selected[$i]);
                 $vm_productids[$i] = $selected[$i][0];
                 $vm_productprices[$i] = $selected[$i][1];
                 $vm_productcats[$i] = $selected[$i][2];
             }
         }
         $processedContent = '';
         if (count($componentsPostData)) {
             $where = '';
             foreach ($componentsPostData as $v) {
                 list($prodId, $price, $catId) = explode('|', $v['itemId']);
                 $where .= !$where ? ' AND ' : ' OR ';
                 $where .= '(' . $this->db->qn('p.virtuemart_product_id') . ' = ' . $this->db->q($prodId) . ' AND ' . $this->db->qn('pp.product_price') . ' = ' . $this->db->q($price) . ' AND ' . $this->db->qn('c.virtuemart_category_id') . ' = ' . $this->db->q($catId) . ')';
             }
             $query = $this->db->getQuery(true)->select($this->db->qn(array('p.virtuemart_product_id', 'pl.product_name', 'pl.product_s_desc', 'pl.product_desc', 'pp.product_price', 'cur.currency_code_3', 'pc.virtuemart_category_id', 'cl.category_name', 'med.file_url_thumb', 'med.file_url', 'p.virtuemart_product_id'), array('product_id', 'product_name', 'product_s_desc', 'product_desc', 'product_price', 'product_currency', 'category_id', 'category_name', 'product_thumb_image', 'product_image', 'tax_rate')))->from('#__virtuemart_products AS p')->join('INNER', '#__virtuemart_product_prices AS pp ' . 'ON (' . $this->db->qn('pp.virtuemart_product_id') . ' = ' . $this->db->qn('p.virtuemart_product_id') . ')')->join('INNER', '#__virtuemart_products_' . $this->activeLanguage() . ' AS pl ' . 'ON (' . $this->db->qn('pl.virtuemart_product_id') . ' = ' . $this->db->qn('p.virtuemart_product_id') . ')')->join('INNER', '#__virtuemart_product_categories AS pc ' . 'ON (' . $this->db->qn('pc.virtuemart_product_id') . ' = ' . $this->db->qn('p.virtuemart_product_id') . ')')->join('INNER', '#__virtuemart_categories AS c ' . 'ON (' . $this->db->qn('c.virtuemart_category_id') . ' = ' . $this->db->qn('pc.virtuemart_category_id') . ')')->join('INNER', '#__virtuemart_categories_' . $this->activeLanguage() . ' AS cl ' . 'ON (' . $this->db->qn('cl.virtuemart_category_id') . ' = ' . $this->db->qn('c.virtuemart_category_id') . ')')->join('INNER', '#__virtuemart_currencies AS cur ' . 'ON (' . $this->db->qn('cur.virtuemart_currency_id') . ' = ' . $this->db->qn('pp.product_currency') . ')')->join('LEFT', '#__virtuemart_product_medias AS m ' . 'ON (' . $this->db->qn('m.virtuemart_product_id') . ' = ' . $this->db->qn('p.virtuemart_product_id') . ')')->join('LEFT', '#__virtuemart_medias AS med ' . 'ON (' . $this->db->qn('med.virtuemart_media_id') . ' = ' . $this->db->qn('m.virtuemart_media_id') . ')')->where($this->db->qn('p.published') . ' = ' . $this->db->q(1) . $where);
             switch ($componentsOptions['vm_order']) {
                 case 'price_desc':
                     $query->order($this->db->qn('p.product_price') . ' DESC');
                     break;
                 case 'price_asc':
                     $query->order($this->db->qn('p.product_price') . ' ASC');
                     break;
                 case 'name_desc':
                     $query->order($this->db->qn('pl.product_name') . ' DESC');
                     break;
                 case 'name_asc':
                     $query->order($this->db->qn('pl.product_name') . ' ASC');
                     break;
                 case 'cat_desc':
                     $query->order($this->db->qn('cl.category_name') . ' DESC');
                     break;
                 case 'cat_asc':
                     $query->order($this->db->qn('cl.category_name') . ' ASC');
                     break;
                 case 'random':
                     $query->order('RAND()');
                     break;
             }
             /*
             $query = 'SELECT DISTINCT a.virtuemart_product_id as product_id,a.product_name,a.product_s_desc,a.product_desc,
             b.product_price, cur.currency_code_3 as product_currency,
             c.virtuemart_category_id as category_id,
             d.category_name,
             med.file_url_thumb as product_thumb_image, med.file_url as product_image,
             a.virtuemart_product_id as tax_rate
             FROM #__virtuemart_product_prices as b
             INNER JOIN #__virtuemart_products as a ON a.virtuemart_product_id = b.virtuemart_product_id
             INNER JOIN #__virtuemart_product_categories as c ON a.virtuemart_product_id = c.virtuemart_product_id
             INNER JOIN #__virtuemart_categories as d ON c.virtuemart_category_id = d.virtuemart_category_id
             INNER JOIN #__virtuemart_currencies as cur ON b.product_currency = cur.virtuemart_currency_id
             INNER JOIN #__virtuemart_product_medias as m ON a.virtuemart_product_id = m.virtuemart_product_id
             INNER JOIN #__virtuemart_medias as med ON m.virtuemart_media_id = med.virtuemart_media_id
             WHERE a.published = 1 '
             .$where
             .$order;
             */
             $this->db->setQuery($query);
             $products = $this->db->loadObjectList();
             if (count($products)) {
                 foreach ($products as $prod) {
                     $product_content = '';
                     $prod->tax_rate = 0;
                     $product_content .= $prod->product_name . '<br />';
                     if ($componentsOptions['vm_price']) {
                         require_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php';
                         require_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/models/vendor.php';
                         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_virtuemart/models');
                         $productModel = JModelLegacy::getInstance('Product', 'VirtueMartModel');
                         $prices = $productModel->getPrice($prod->product_id, 1);
                         $price = $prices['salesPrice'];
                         $currency = VirtueMartModelVendor::getVendorCurrency(1);
                         if ($componentsOptions['vm_curr_symbol']) {
                             $prod->product_currency = $currency->currency_symbol;
                         } else {
                             $prod->product_currency = $currency->currency_code_3;
                         }
                         if ($componentsOptions['vm_curr_first']) {
                             $product_content .= $prod->product_currency . ' ' . number_format($price, 2) . '<br />';
                         } else {
                             $product_content .= number_format($price, 2) . ' ' . $prod->product_currency . '<br />';
                         }
                     }
                     if ($componentsOptions['vm_img']) {
                         $product_content .= '<img src="' . $this->getThumb($prod->product_thumb_image, $prod->product_image) . '" border="0" />';
                     }
                     if ($componentsOptions['vm_link']) {
                         $link = $createModel::getSefLink(array($prod->product_id, $prod->category_id), 'com_virtuemart');
                         $product_content = '<a href="' . $link . '">' . $product_content . '</a>';
                     }
                     if ($componentsOptions['vm_short_desc']) {
                         $product_content .= '<p>' . $prod->product_s_desc . '</p>';
                     }
                     if ($componentsOptions['vm_desc']) {
                         $product_content .= '<p>' . $prod->product_desc . '</p>';
                     }
                     $processedContent .= str_ireplace('<#vm_content#>', $product_content, $repeater);
                 }
                 $processedContent = preg_replace('!<#vm_repeater#[^>]*>(.*)<#/vm_repeater#>!is', $processedContent, $container[0]);
                 $processedContent = str_ireplace(array('<#vm_repeater#>', '<#/vm_repeater#>', '<#vm_products#>', '<#/vm_products#>'), '', $processedContent);
             }
         }
         // remove tiny mce stuff like mce_src="..."
         $processedContent = preg_replace('(mce_style=".*?")', '', $processedContent);
         $processedContent = preg_replace('(mce_src=".*?")', '', $processedContent);
         $processedContent = preg_replace('(mce_href=".*?")', '', $processedContent);
         $processedContent = preg_replace('(mce_bogus=".*?")', '', $processedContent);
         // convert relative to absolute paths
         $processedContent = preg_replace('#(href|src)="([^:"]*)("|(?:(?:%20|\\s|[.]|\\+)[^"]*"))#i', $abs_path, $processedContent);
         // escape dollar signs
         $processedContent = str_ireplace('$', '\\$', $processedContent);
         // insert articles
         $template = preg_replace('!<#vm_products#>(.*)<#/vm_products#>!is', $processedContent, $template);
         // remove placeholders
         $response['template'] = str_ireplace(array('<#vm_products#>', '<#/vm_products#>'), '', $template);
     }
     return $response;
 }