Beispiel #1
0
 function display($tpl = null)
 {
     //Load helpers
     $this->loadHelper('currencydisplay');
     $this->loadHelper('html');
     // Get the data
     $model = VmModel::getModel('product');
     // Create filter
     $this->addStandardDefaultViewLists($model);
     $inventorylist = $model->getProductListing(false, false);
     $pagination = $model->getPagination();
     $this->assignRef('pagination', $pagination);
     // Apply currency
     $currencydisplay = CurrencyDisplay::getInstance();
     foreach ($inventorylist as $virtuemart_product_id => $product) {
         //TODO oculd be interesting to show the price for each product, and all stored ones $product->product_in_stock
         $product->product_instock_value = $currencydisplay->priceDisplay($product->product_price, '', $product->product_in_stock, false);
         $product->product_price_display = $currencydisplay->priceDisplay($product->product_price, '', 1, false);
         $product->weigth_unit_display = ShopFunctions::renderWeightUnit($product->product_weight_uom);
     }
     $this->assignRef('inventorylist', $inventorylist);
     $options = array();
     $options[] = JHTML::_('select.option', '', JText::_('COM_VIRTUEMART_DISPLAY_STOCK') . ':');
     $options[] = JHTML::_('select.option', 'stocklow', JText::_('COM_VIRTUEMART_STOCK_LEVEL_LOW'));
     $options[] = JHTML::_('select.option', 'stockout', JText::_('COM_VIRTUEMART_STOCK_LEVEL_OUT'));
     $this->lists['stockfilter'] = JHTML::_('select.genericlist', $options, 'search_type', 'onChange="document.adminForm.submit(); return false;"', 'value', 'text', JRequest::getVar('search_type'));
     $this->lists['filter_product'] = JRequest::getVar('filter_product');
     // $this->assignRef('lists', $lists);
     /* Toolbar */
     $this->SetViewTitle('PRODUCT_INVENTORY');
     JToolBarHelper::publish();
     JToolBarHelper::unpublish();
     parent::display($tpl);
 }
Beispiel #2
0
 /**
  * Render the view
  */
 function display($tpl = null)
 {
     // Load the helper(s)
     $this->loadHelper('html');
     $this->loadHelper('html');
     $this->loadHelper('currencydisplay');
     $this->loadHelper('reportFunctions');
     $model = VmModel::getModel();
     // $config		= JFactory::getConfig();
     // $tzoffset	= $config->getValue('config.offset');
     JRequest::setvar('task', '');
     // set period
     //$date_presets = $model->getDatePresets();
     $this->SetViewTitle('REPORT');
     $myCurrencyDisplay = CurrencyDisplay::getInstance();
     $this->addStandardDefaultViewLists($model);
     $revenueBasic = $model->getRevenue();
     if ($revenueBasic) {
         $totalReport['revenueTotal_brutto'] = $totalReport['revenueTotal_netto'] = $totalReport['number_of_ordersTotal'] = $totalReport['itemsSoldTotal'] = 0;
         foreach ($revenueBasic as &$j) {
             vmdebug('VirtuemartViewReport revenue', $j);
             $totalReport['revenueTotal_netto'] += $j['order_subtotal_netto'];
             $totalReport['revenueTotal_brutto'] += $j['order_subtotal_brutto'];
             $totalReport['number_of_ordersTotal'] += $j['count_order_id'];
             $j['order_subtotal_netto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_netto']);
             $j['order_subtotal_brutto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_brutto']);
             $j['product_quantity'] = $model->getItemsByRevenue($j);
             $totalReport['itemsSoldTotal'] += $j['product_quantity'];
         }
         $totalReport['revenueTotal_netto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_netto']);
         $totalReport['revenueTotal_brutto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_brutto']);
         // if ( 'product_quantity'==JRequest::getWord('filter_order')) {
         // foreach ($revenueBasic as $key => $row) {
         // $created_on[] =$row['created_on'];
         // $intervals[] =$row['intervals'];
         // $itemsSold[] =$row['product_quantity'];
         // $number_of_orders[] =$row['count_order_id'];
         // $revenue[] =$row['revenue'];
         // }
         // if (JRequest::getWord('filter_order_Dir') == 'desc') array_multisort($itemsSold, SORT_DESC,$revenueBasic);
         // else array_multisort($itemsSold, SORT_ASC,$revenueBasic);
         // }
     }
     $this->assignRef('report', $revenueBasic);
     $this->assignRef('totalReport', $totalReport);
     //$itemsSold = $model->getItemsSold($revenueBasic);
     //$this->assignRef('itemsSold', $itemsSold);
     // I tihnk is to use in a different layout such as product solds
     // PATRICK K.
     // $productList = $model->getOrderItems();
     // $this->assignRef('productList', $productList);
     $this->lists['select_date'] = $model->renderDateSelectList();
     $this->lists['state_list'] = $model->renderOrderstatesList();
     $this->lists['intervals'] = $model->renderIntervalsList();
     $this->assignRef('from_period', $model->from_period);
     $this->assignRef('until_period', $model->until_period);
     $pagination = $model->getPagination();
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
 function 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);
 }
Beispiel #4
0
    JLoader::import('product', JPATH_ADMINISTRATOR . '/components/com_virtuemart/models');
}
if (!class_exists('VmModel')) {
    require JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/vmmodel.php';
}
abstract class modNSSP2VMHelper
{
    public static function getList($params, $count)
    {
        $productModel = VmModel::getModel('Product');
        $products = $productModel->getProductListing($params->get('vmordering', 'latest'), $count, true, true, false, true, $params->get('vmcat', NULL));
        $productModel->addImages($products);
        $currency = CurrencyDisplay::getInstance();
        if (count($products)) {
            foreach ($products as $item) {
                $author =& JFactory::getUser($item->created_by);
                $item->created = $item->created_on;
                $item->author = $author->name;
                $item->hits = $item->hits;
                $item->category = $item->category_name;
                $item->cat_link = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $item->virtuemart_category_id);
                $item->image = $item->images[0]->file_url;
                $item->title = $item->product_name;
                $item->introtext = $item->product_s_desc;
                $item->price = round($item->prices['salesPrice'], 2) . $currency->getSymbol();
                $item->addtocart = self::addtocart($item);
	function plgVmOnDisplayProductVariantFE($field,&$idx,&$group) {
		// default return if it's not this plugin
		 if ($field->custom_element != $this->_name) return '';
		$this->parseCustomParams($field);
		$options = explode(',', $field->custom_drop);
		$class='';
		$selects= array();
		if(!class_exists('CurrencyDisplay')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'currencydisplay.php');
		$currency = CurrencyDisplay::getInstance();
		foreach ($options as $valuesWithPrice) {
			$valueWithPrice = explode('|', $valuesWithPrice);

			if ( isset ($valueWithPrice[1]) ) {
				$op = $valueWithPrice[1][0];
				$price = substr($valueWithPrice[1], 1) ;
				$text = $valueWithPrice[0].' ('.$op.$currency->priceDisplay((float)$price).')';
			} else {
				$text = $valueWithPrice[0] ;
			}
			$selects[] = array('value' =>$valueWithPrice[0], 'text' => $text );
		}
// 		vmdebug('plgVmOnDisplayProductVariantFE',$field,$idx,$group);
		$html = JHTML::_('select.genericlist', $selects,'customPlugin['.$field->virtuemart_customfield_id.']['.$this->_name.'][custom_drop]','','value','text',$selects[0],false,true);
		$group->display .= $html;
		return true;
    }
 /**
  * @param $total
  */
 public function setTotal($total)
 {
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . '/helpers/currencydisplay.php';
     }
     $this->total = vmPSPlugin::getAmountValueInCurrency($total, $this->_method->payment_currency);
     $cd = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
 }
Beispiel #7
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);
 }
Beispiel #8
0
 public function display($tpl = null)
 {
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     $session = JFactory::getSession();
     $cmp = $session->get('compare', '');
     $listpid = explode(",", $cmp);
     if (empty($cmp)) {
         $valid = 0;
         $this->assignRef('valid', $valid);
         //$app =& JFactory::getApplication();
         //$app->enqueueMessage('Your Wishlist is Empty Please Add any product to Wishlist', 'error');
         //$app->redirect('index.php');
         //exit;
     } else {
         $valid = 1;
         $this->assignRef('valid', $valid);
         $this->assignRef('wids', $wids);
         $productModel = VmModel::getModel('product');
         $products = $productModel->getProducts($listpid);
         //echo "<pre>";
         //print_r($wishlist);
         //exit;
         $productModel->addImages($products, 1);
         $this->assignRef('products', $products);
         foreach ($products as $product) {
             $product->stock = $productModel->getStockIndicator($product);
         }
         $show_prices = VmConfig::get('show_prices', 1);
         if ($show_prices == '1') {
             if (!class_exists('calculationHelper')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
             }
         }
         $this->assignRef('show_prices', $show_prices);
         if (!class_exists('Permissions')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
         }
         $showBasePrice = Permissions::getInstance()->check('admin');
         //todo add config settings
         $this->assignRef('showBasePrice', $showBasePrice);
         $currency = CurrencyDisplay::getInstance();
         $this->assignRef('currency', $currency);
         $pagination = $productModel->getPagination(3);
         $this->assignRef('vmPagination', $pagination);
         /*** rating ***/
         $ratingModel = VmModel::getModel('ratings');
         $showRating = $ratingModel->showRating($product->virtuemart_product_id);
         $this->assignRef('showRating', $showRating);
         if ($showRating) {
             $vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id);
             $this->assignRef('vote', $vote);
             $rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
             $this->assignRef('rating', $rating);
         }
     }
     parent::display($tpl);
 }
Beispiel #9
0
 /**
  * Check if the given coupon code exists, is (still) valid and valid for the total order amount
  * @param string $_code Coupon code
  * @param float $_billTotal Total amount for the order
  * @author Oscar van Eijk
  * @author Max Milbers
  * @return string Empty when the code is valid, otherwise the error message
  */
 public static function ValidateCouponCode($_code, $_billTotal)
 {
     if (empty($_code) or $_code == vmText::_('COM_VIRTUEMART_COUPON_CODE_ENTER')) {
         return '';
     }
     $couponData = 0;
     JPluginHelper::importPlugin('vmcoupon');
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('plgVmValidateCouponCode', array($_code, $_billTotal));
     if (!empty($returnValues)) {
         foreach ($returnValues as $returnValue) {
             if ($returnValue !== null) {
                 //Take a look on this seyi, I am not sure about that, but it should work at least simular note by Max
                 return $returnValue;
             }
         }
     }
     if (empty($couponData)) {
         $_db = JFactory::getDBO();
         $_q = 'SELECT IFNULL( NOW() >= `coupon_start_date` OR `coupon_start_date`="0000-00-00 00:00:00" , 1 ) AS started
 				, `coupon_start_date`
 				,  IFNULL (`coupon_expiry_date`!="0000-00-00 00:00:00" and NOW() > `coupon_expiry_date`,0) AS `ended`
 				, `coupon_expiry_date`
 				, `coupon_value_valid`
 				, `coupon_used`
 				FROM `#__virtuemart_coupons`
 				WHERE `coupon_code` = "' . $_db->escape($_code) . '"';
         $_db->setQuery($_q);
         $couponData = $_db->loadObject();
     }
     if (!$couponData) {
         return vmText::_('COM_VIRTUEMART_COUPON_CODE_INVALID');
     }
     if ($couponData->coupon_used) {
         $session = JFactory::getSession();
         $session_id = $session->getId();
         if ($couponData->coupon_used != $session_id) {
             return vmText::_('COM_VIRTUEMART_COUPON_CODE_INVALID');
         }
     }
     if (!$couponData->started) {
         return vmText::_('COM_VIRTUEMART_COUPON_CODE_NOTYET') . $couponData->coupon_start_date;
     }
     if ($couponData->ended) {
         self::RemoveCoupon($_code, true);
         return vmText::_('COM_VIRTUEMART_COUPON_CODE_EXPIRED');
     }
     if ($_billTotal < $couponData->coupon_value_valid) {
         if (!class_exists('CurrencyDisplay')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
         }
         $currency = CurrencyDisplay::getInstance();
         $coupon_value_valid = $currency->priceDisplay($couponData->coupon_value_valid);
         return vmText::_('COM_VIRTUEMART_COUPON_CODE_TOOLOW') . " " . $coupon_value_valid;
     }
     return '';
 }
 /**
  * @param $total
  */
 public function setTotal($total)
 {
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     // $this->total = vmPSPlugin::getAmountValueInCurrency($total, $this->_method->payment_currency);
     $this->total = $total;
     $cd = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
 }
Beispiel #11
0
 public function _autocomplete($search_category_id, $search_name, $params)
 {
     VmConfig::loadJLang('com_virtuemart', true);
     VmConfig::loadConfig();
     $list = array();
     $limitation = (int) $params->get('limit', 8);
     $source_group = null;
     $catids = $search_category_id == 0 ? 0 : $search_category_id;
     $query = ' * , pp.product_price FROM `#__virtuemart_products_en_gb` p LEFT JOIN #__virtuemart_product_prices pp ON p.virtuemart_product_id = pp.virtuemart_product_id';
     if ($search_category_id != 0) {
         $query .= " LEFT JOIN `#__virtuemart_product_categories` pc ON (p.virtuemart_product_id = pc.virtuemart_product_id) WHERE pc.virtuemart_category_id = " . $search_category_id . " AND p.product_name LIKE '%" . $search_name . "%'";
     } else {
         $query .= " WHERE p.product_name LIKE '%" . $search_name . "%'";
     }
     //$source_group = null;
     $productModel = VmModel::getModel('Product');
     //$productModel = new VirtuemartModelProductExtend();
     $items = $productModel->exeSortSearchListQuery(0, $query, '', '', '', '', '', $limitation);
     if ($limitation == 0) {
         $productModel->_noLimit = true;
     } else {
         $productModel->_noLimit = false;
     }
     //$productModel->addImages($items,1);
     $ratingModel = VmModel::getModel('ratings');
     $small_image_config = array('type' => $params->get('imgcfg_type'), 'width' => $params->get('imgcfg_width'), 'height' => $params->get('imgcfg_height'), 'quality' => 90, 'function' => $params->get('imgcfg_function') == 'none' ? null : 'resize', 'function_mode' => $params->get('imgcfg_function') == 'none' ? null : substr($params->get('imgcfg_function'), 7), 'transparency' => $params->get('imgcfg_transparency', 1) ? true : false, 'background' => $params->get('imgcfg_background'));
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     foreach ($items as $item) {
         $virtuemart_product_id = $item->virtuemart_product_id;
         $quantity = 1;
         $product_info = $productModel->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity);
         $productModel->addImages($product_info);
         $item_img = VmSearchProHelper::getVmImage($product_info, $params);
         $image = VmSearchProHelper::imageTag($item_img, $small_image_config);
         $salesPrice = "";
         $discountAmount = "";
         if (!empty($product_info->prices['salesPrice'])) {
             $salesPrice = $currency->createPriceDiv('salesPrice', JText::_("SALES_PRICE"), $product_info->prices, false, false, 1.0);
         }
         if (!empty($product_info->prices['discountAmount'])) {
             $discountAmount = $currency->createPriceDiv('discountAmount', JText::_("DISCOUNT_AMOUNT"), $product_info->prices, false, false, 1.0);
         }
         $list[] = array('name' => $item->product_name, 'product_id' => $item->virtuemart_product_id, 'salesPrice' => $salesPrice, 'discountAmount' => $discountAmount, 'image' => $image, 'link' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $product_info->virtuemart_category_id . '&virtuemart_product_id=' . $product_info->virtuemart_product_id . '&keyword=' . $search_name . ''), 'category_name' => $product_info->category_name);
     }
     die(json_encode($list));
 }
Beispiel #12
0
 function display($tpl = null)
 {
     if (!class_exists('VmImage')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
     }
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     $model = VmModel::getModel('virtuemart');
     $nbrCustomers = $model->getTotalCustomers();
     $this->assignRef('nbrCustomers', $nbrCustomers);
     $nbrActiveProducts = $model->getTotalActiveProducts();
     $this->assignRef('nbrActiveProducts', $nbrActiveProducts);
     $nbrInActiveProducts = $model->getTotalInActiveProducts();
     $this->assignRef('nbrInActiveProducts', $nbrInActiveProducts);
     $nbrFeaturedProducts = $model->getTotalFeaturedProducts();
     $this->assignRef('nbrFeaturedProducts', $nbrFeaturedProducts);
     $ordersByStatus = $model->getTotalOrdersByStatus();
     $this->assignRef('ordersByStatus', $ordersByStatus);
     $recentOrders = $model->getRecentOrders();
     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
     foreach ($recentOrders 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);
     }
     $this->assignRef('recentOrders', $recentOrders);
     $recentCustomers = $model->getRecentCustomers();
     $this->assignRef('recentCustomers', $recentCustomers);
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . '/helpers/shopfunctions.php';
     }
     $extensionsFeed = ShopFunctions::getExtensionsRssFeed();
     $this->assignRef('extensionsFeed', $extensionsFeed);
     $virtuemartFeed = ShopFunctions::getVirtueMartRssFeed();
     $this->assignRef('virtuemartFeed', $virtuemartFeed);
     // Options button.
     // if ( !JVM_VERSION===1) {
     // if (JFactory::getUser()->authorise('core.admin', 'com_virtuemart')) {
     // JToolBarHelper::preferences('com_virtuemart');
     // }
     // }
     parent::display($tpl);
 }
Beispiel #13
0
 function display($tpl = null)
 {
     // Get data from the model
     $rows =& $this->get('Data');
     $pagination =& $this->get('Pagination');
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     JToolBarHelper::title(JText::_('COM_VMCOUPONS_STATISTICS'), 'generic.png');
     // push data into the template
     $this->assignRef('rows', $rows);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('currency', $currency);
     parent::display($tpl);
 }
Beispiel #14
0
 function prepare(&$products)
 {
     // Get user
     $user = JFactory::getUser();
     // Get null date
     $db = JFactory::getDBO();
     $nullDate = $db->getNullDate();
     // Get trash state
     $mainframe = JFactory::getApplication();
     $option = JRequest::getCmd('option');
     $view = JRequest::getCmd('view');
     $trash = $mainframe->getUserStateFromRequest("{$option}.{$view}.trash", 'trash', -1, 'int');
     // Require Virtuemart classes for price display
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php';
     $currency = CurrencyDisplay::getInstance();
     // Cast the input to array
     if (!is_array($products)) {
         $rows = array($products);
     } else {
         $rows = $products;
     }
     // Prepare the products
     foreach ($rows as $key => $product) {
         $product->parity = $key % 2;
         $product->key = $key + 1;
         $product->checkout = JHTML::_('grid.checkedout', $product, $key);
         $product->price = $currency->priceDisplay($product->price, (int) $product->currency, true);
         $product->featuredToggler = K2martHTMLHelper::stateToggler($product, $key, 'featured', array('K2MART_FEATURED', 'K2MART_NOT_FEATURED'), array('K2MART_REMOVE_FEATURED_FLAG', 'K2MART_FLAG_AS_FEATURED'));
         $product->publishedToggler = K2martHTMLHelper::stateToggler($product, $key, 'published', array('K2MART_PUBLISHED', 'K2MART_UNPUBLISHED'), array('K2MART_UNPUBLISH', 'K2MART_PUBLISH'));
         if (JTable::isCheckedOut($user->get('id'), $product->checked_out) || $trash == 1) {
             $product->link = false;
             $product->featuredToggler = strip_tags($product->featuredToggler, '<img>');
             $product->publishedToggler = strip_tags($product->publishedToggler, '<img>');
         } else {
             $product->link = JRoute::_('index.php?option=com_k2&view=item&cid=' . $product->id);
         }
         $product->categoryLink = JRoute::_('index.php?option=com_k2&view=category&cid=' . $product->catid);
         if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $product->id) . '_XL.jpg')) {
             $product->image = JURI::root(true) . '/media/k2/items/cache/' . md5("Image" . $product->id) . '_XL.jpg';
         } else {
             $product->image = false;
         }
         $product->created = JHTML::_('date', $product->created);
         $product->modified = $product->modified == $nullDate ? JText::_('K2MART_NEVER') : JHTML::_('date', $product->modified);
     }
 }
 /**
  * Check if the given coupon code exists, is (still) valid and valid for the total order amount
  * @param string $_code Coupon code
  * @param float $_billTotal Total amount for the order
  * @author Oscar van Eijk
  * @author Max Milbers
  * @return string Empty when the code is valid, otherwise the error message
  */
 public static function ValidateCouponCode($_code, $_billTotal)
 {
     $couponData = 0;
     JPluginHelper::importPlugin('vmcoupon');
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('plgVmValidateCouponCode', array($_code, $_billTotal));
     if (!empty($returnValues)) {
         foreach ($returnValues as $returnValue) {
             if ($returnValue !== null) {
                 //Take a look on this seyi, I am not sure about that, but it should work at least simular note by Max
                 return $returnValue;
             }
         }
     }
     if (empty($couponData)) {
         $_db = JFactory::getDBO();
         $_q = 'SELECT IF( NOW() >= `coupon_start_date` , 1, 0 ) AS started ' . ', `coupon_start_date` ' . ', IFNULL( 0, IF( NOW() > `coupon_expiry_date`, 1, 0 )) AS ended ' . ', `coupon_value_valid` ' . 'FROM `#__virtuemart_coupons` ' . 'WHERE `coupon_code` = "' . $_db->escape($_code) . '"';
         $_db->setQuery($_q);
         $couponData = $_db->loadObject();
     }
     if (!$couponData) {
         return JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID');
     }
     if (!$couponData->started) {
         return JText::_('COM_VIRTUEMART_COUPON_CODE_NOTYET') . $couponData->coupon_start_date;
     }
     if ($couponData->ended) {
         self::RemoveCoupon($_code, true);
         return JText::_('COM_VIRTUEMART_COUPON_CODE_EXPIRED');
     }
     if ($_billTotal < $couponData->coupon_value_valid) {
         JLoader::register('CurrencyDisplay', JPATH_VM_ADMINISTRATOR . '/helpers/currencydisplay.php');
         $currency = CurrencyDisplay::getInstance();
         $coupon_value_valid = $currency->priceDisplay($couponData->coupon_value_valid);
         return JText::_('COM_VIRTUEMART_COUPON_CODE_TOOLOW') . " " . $coupon_value_valid;
     }
     return '';
 }
Beispiel #16
0
 function display($tpl = null)
 {
     // Get data from the model
     $rows =& $this->get('Data');
     $pagination =& $this->get('Pagination');
     $totalcoupons =& $this->get('Total');
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     JToolBarHelper::title(JText::_('COM_VMCOUPONS_GENERATED_COUPON_MANAGER'), 'generic.png');
     JToolBarHelper::publishList('publishgenerated');
     JToolBarHelper::unpublishList('unpublishgenerated');
     JToolBarHelper::editListX('editgenerated');
     JToolBarHelper::divider();
     JToolBarHelper::deleteList('', 'deletegenerated', 'Delete');
     JToolBarHelper::spacer();
     // push data into the template
     $this->assignRef('rows', $rows);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('totalcoupons', $totalcoupons);
     $this->assignRef('currency', $currency);
     parent::display($tpl);
 }
 function display($tpl = null)
 {
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     $app = JFactory::getApplication();
     // Load the helper(s)
     if (JFactory::getUser()->authorise('core.admin', 'com_virtuemart')) {
         if ($app->isadmin()) {
             JToolBarHelper::preferences('com_virtuemart');
         }
     }
     $this->loadHelper('image');
     JToolBarHelper::title(JText::_('COM_VIRTUEMART'), 'home');
     $model = VmModel::getModel('virtuemart');
     $this->nbrCustomers = $model->getTotalCustomers();
     $this->nbrActiveProducts = $model->getTotalActiveProducts();
     $this->nbrInActiveProducts = $model->getTotalInActiveProducts();
     $this->nbrFeaturedProducts = $model->getTotalFeaturedProducts();
     $this->ordersByStatus = $model->getTotalOrdersByStatus();
     $recentOrders = $model->getRecentOrders();
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . '/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
     foreach ($recentOrders 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);
     }
     $this->recentOrders = $recentOrders;
     $this->recentCustomers = $model->getRecentCustomers();
     parent::display($tpl);
 }
Beispiel #18
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';
     }
     // Get the data
     $model = VmModel::getModel('product');
     // Create filter
     $this->addStandardDefaultViewLists($model);
     $this->inventorylist = $model->getProductListing();
     $this->pagination = $model->getPagination();
     // Apply currency
     $currencydisplay = CurrencyDisplay::getInstance();
     foreach ($this->inventorylist as $virtuemart_product_id => $product) {
         //TODO oculd be interesting to show the price for each product, and all stored ones $product->product_in_stock
         $price = isset($product->allPrices[$product->selectedPrice]['product_price']) ? $product->allPrices[$product->selectedPrice]['product_price'] : 0;
         $product->product_instock_value = $currencydisplay->priceDisplay($price, '', $product->product_in_stock, false);
         $product->product_price_display = $currencydisplay->priceDisplay($price, '', 1, false);
         $product->weigth_unit_display = ShopFunctions::renderWeightUnit($product->product_weight_uom);
     }
     $options = array();
     $options[] = JHtml::_('select.option', '', vmText::_('COM_VIRTUEMART_DISPLAY_STOCK') . ':');
     $options[] = JHtml::_('select.option', 'stocklow', vmText::_('COM_VIRTUEMART_STOCK_LEVEL_LOW'));
     $options[] = JHtml::_('select.option', 'stockout', vmText::_('COM_VIRTUEMART_STOCK_LEVEL_OUT'));
     $this->lists['stockfilter'] = JHtml::_('select.genericlist', $options, 'search_type', 'onChange="document.adminForm.submit(); return false;"', 'value', 'text', vRequest::getVar('search_type'));
     $this->lists['filter_product'] = vRequest::getVar('filter_product');
     /* Toolbar */
     $this->SetViewTitle('PRODUCT_INVENTORY');
     JToolBarHelper::publish();
     JToolBarHelper::unpublish();
     parent::display($tpl);
 }
Beispiel #19
0
 /**
  * @param $cart
  * @param $order
  * @return bool|null
  */
 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';
     }
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     if (!class_exists('TableVendors')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'vendors.php';
     }
     $vendorModel = VmModel::getModel('Vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $vendorModel->addImages($vendor, 1);
     $this->getPaymentCurrency($method);
     $email_currency = $this->getEmailCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $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);
     if ($totalInPaymentCurrency <= 0) {
         vmInfo(JText::_('VMPAYMENT_PAYPAL_PAYMENT_AMOUNT_INCORRECT'));
         return FALSE;
     }
     $merchant_email = $this->_getMerchantEmail($method);
     if (empty($merchant_email)) {
         vmInfo(JText::_('VMPAYMENT_PAYPAL_MERCHANT_EMAIL_NOT_SET'));
         return FALSE;
     }
     $quantity = 0;
     foreach ($cart->products as $key => $product) {
         $quantity = $quantity + $product->quantity;
     }
     $post_variables = array('cmd' => '_ext-enter', 'redirect_cmd' => '_xclick', 'upload' => '1', 'business' => $merchant_email, 'receiver_email' => $merchant_email, 'order_number' => $order['details']['BT']->order_number, "invoice" => $order['details']['BT']->order_number, 'custom' => $return_context, 'item_name' => JText::_('VMPAYMENT_PAYPAL_ORDER_NUMBER') . ': ' . $order['details']['BT']->order_number, "amount" => $totalInPaymentCurrency, "currency_code" => $currency_code_3, "address_override" => isset($method->address_override) ? $method->address_override : 0, "first_name" => $address->first_name, "last_name" => $address->last_name, "address1" => $address->address_1, "address2" => isset($address->address_2) ? $address->address_2 : '', "zip" => $address->zip, "city" => $address->city, "state" => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : '', "country" => ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'), "email" => $order['details']['BT']->email, "night_phone_b" => $address->phone_1, "return" => substr(JURI::root(false, ''), 0, -1) . JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid'), false), "notify_url" => substr(JURI::root(false, ''), 0, -1) . JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component', false), "cancel_return" => substr(JURI::root(false, ''), 0, -1) . JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid'), false), "ipn_test" => $method->debug, "rm" => '2', "bn" => "VirtueMart_Cart_PPA", "image_url" => JURI::root() . $vendor->images[0]->file_url, "no_shipping" => isset($method->no_shipping) ? $method->no_shipping : 0, "no_note" => "1");
     /*
      $i = 1;
      foreach ($cart->products as $key => $product) {
      $post_variables["item_name_" . $i] = substr(strip_tags($product->product_name), 0, 127);
      $post_variables["item_number_" . $i] = $i;
      $post_variables["amount_" . $i] = $cart->pricesUnformatted[$key]['salesPrice'];
      $post_variables["quantity_" . $i] = $product->quantity;
      $i++;
      }
      if ($cart->pricesUnformatted ['shipmentValue']) {
      $post_variables["item_name_" . $i] = JText::_('VMPAYMENT_PAYPAL_SHIPMENT_PRICE');
      $post_variables["item_number_" . $i] = $i;
      $post_variables["amount_" . $i] = $cart->pricesUnformatted ['shipmentValue'];
      $post_variables["quantity_" . $i] = 1;
      $i++;
      }
      if ($cart->pricesUnformatted ['paymentValue']) {
      $post_variables["item_name_" . $i] = JText::_('VMPAYMENT_PAYPAL_PAYMENT_PRICE');
      $post_variables["item_number_" . $i] = $i;
      $post_variables["amount_" . $i] = $cart->pricesUnformatted ['paymentValue'];
      $post_variables["quantity_" . $i] = 1;
      $i++;
      }
      if (!empty($order->cart->coupon)) {
      $post_variables["discount_amount_cart"] = $cart->pricesUnformatted['discountAmount'];
      }
     */
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['paypal_custom'] = $return_context;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $method->payment_currency;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency;
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $url = $this->_getPaypalUrlHttps($method);
     // add spin image
     $html = '<html><head><title>Redirection</title></head><body><div style="margin: auto; text-align: center;">';
     $html .= '<form action="' . "https://" . $url . '" method="post" name="vm_paypal_form"  accept-charset="UTF-8">';
     $html .= '<input type="submit"  value="' . JText::_('VMPAYMENT_PAYPAL_REDIRECT_MESSAGE') . '" />';
     $html .= '<input type="hidden" name="charset" value="utf-8">';
     foreach ($post_variables as $name => $value) {
         $html .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
     }
     $html .= '</form>';
     $html .= ' <script type="text/javascript">';
     $html .= ' document.vm_paypal_form.submit();';
     $html .= ' </script></body></html>';
     // 	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);
     /*
     
      $qstring = '?';
      foreach ($post_variables AS $k => $v) {
      $qstring .= ( empty($qstring) ? '' : '&')
      . urlencode($k) . '=' . urlencode($v);
      }
      // we can display the logo, or do the redirect
      $mainframe = JFactory::getApplication();
      $mainframe->redirect("https://" . $url . $qstring);
     
     
      return false; // don't delete the cart, don't send email
     */
 }
Beispiel #20
0
 public function display($tpl = NULL)
 {
     $show_prices = VmConfig::get('show_prices', 1);
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
         }
     }
     $doc = JFactory::getDocument();
     if (!class_exists('VmImage')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
     }
     $productModel = VmModel::getModel('product');
     $categoryId = JRequest::getInt('virtuemart_category_id', false);
     $feed_show_prices = VmConfig::get('feed_cat_show_prices', 0);
     $feed_show_images = VmConfig::get('feed_cat_show_images', 0);
     $feed_show_description = VmConfig::get('feed_cat_show_description', 0);
     $feed_description_type = VmConfig::get('feed_cat_description_type', 'product_s_desc');
     $feed_max_text_length = VmConfig::get('feed_cat_max_text_length', 0);
     // Load the products in the given category
     $products = $productModel->getProductsInCategory($categoryId);
     if ($feed_show_images == 1) {
         $productModel->addImages($products, 1);
     }
     if ($products && $feed_show_prices == 1) {
         $currency = CurrencyDisplay::getInstance();
     }
     foreach ($products as $product) {
         $title = $this->escape($product->product_name);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         $description = "";
         if ($feed_show_images == 1) {
             $effect = " ";
             $return = true;
             $withDescr = false;
             $absUrl = true;
             $description = $product->images[0]->displayMediaThumb('style="margin-right: 10px; margin-bottom: 10px; float: left;"', false, $effect, $return, $withDescr, $absUrl);
         }
         if ($feed_show_description == 1) {
             if ($feed_description_type == 'product_s_desc') {
                 $description .= $product->product_s_desc;
             } else {
                 if ($feed_max_text_length > 0) {
                     $description .= shopFunctionsF::limitStringByWord($product->product_desc, $feed_max_text_length);
                 } else {
                     $description .= $product->product_desc;
                 }
             }
         }
         if ($feed_show_prices == 1 and $show_prices == 1) {
             $description .= $currency->createPriceDiv('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $product->prices);
             if (round($product->prices['basePriceWithTax'], $currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
                 $description .= '<span class="price-crossed" >' . $currency->createPriceDiv('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</span>";
             }
             if (round($product->prices['salesPriceWithDiscount'], $currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
                 $description .= $currency->createPriceDiv('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
             }
             $description .= $currency->createPriceDiv('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
             $description .= $currency->createPriceDiv('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
             $description .= $currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
             $description .= $currency->createPriceDiv('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $product->prices);
             $unitPriceDescription = JText::sprintf('COM_VIRTUEMART_PRODUCT_UNITPRICE', $product->product_unit);
             $description .= $currency->createPriceDiv('unitPrice', $unitPriceDescription, $product->prices);
         }
         if ($feed_description_type == 'product_s_desc' or $feed_max_text_length > 0) {
             $description .= '<p class="feed-readmore"><a target="_blank" href ="' . rtrim(JURI::base(), "/") . str_replace(' ', '%20', $product->link) . '">' . JText::_('COM_VIRTUEMART_FEED_READMORE') . '</a></p>';
         }
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $product->link;
         $item->date = $product->created_on;
         $item->description = '<div class="feed-description">' . $description . '</div>';
         $item->category = $categoryId;
         $doc->addItem($item);
     }
 }
    /**
     * This shows the plugin for choosing in the payment list of the checkout process.
     *
     * @author Valerie Cartan Isaksen
     */
    function plgVmDisplayListFEPayment(VirtueMartCart $cart, $selected = 0, &$htmlIn)
    {
        if ($this->getPluginMethods($cart->vendorId) === 0) {
            if (empty($this->_name)) {
                $app = JFactory::getApplication();
                $app->enqueueMessage(vmText::_('COM_VIRTUEMART_CART_NO_' . strtoupper($this->_psType)));
                return false;
            } else {
                return false;
            }
        }
        $htmla = array();
        $html = '';
        $logo = '';
        VmConfig::loadJLang('com_virtuemart');
        $currency = CurrencyDisplay::getInstance();
        $showallform = true;
        foreach ($this->methods as $this->_currentMethod) {
            if ($this->checkConditions($cart, $this->_currentMethod, $cart->pricesUnformatted)) {
                if (isset($this->_currentMethod->cost_method)) {
                    $cost_method = $this->_currentMethod->cost_method;
                } else {
                    $cost_method = true;
                }
                $cartPrices = $cart->cartPrices;
                $methodSalesPrice = $this->setCartPrices($cart, $cartPrices, $this->_currentMethod, $cost_method);
                $logo = $this->displayLogoKlarna('listfe');
                $payment_cost = '';
                if ($methodSalesPrice) {
                    $payment_cost = $currency->priceDisplay($methodSalesPrice);
                }
                if ($selected == $this->_currentMethod->virtuemart_paymentmethod_id) {
                    $checked = 'checked="checked"';
                } else {
                    $checked = '';
                }
                if ($cart->virtuemart_paymentmethod_id == $this->_currentMethod->virtuemart_paymentmethod_id) {
                    $showallform = false;
                }
                $html = $this->renderByLayout('display_payment', array('plugin' => $this->_currentMethod, 'checked' => $checked, 'payment_logo' => $logo, 'payment_tooltip' => empty($this->_currentMethod->payment_logo_display_tooltip) ? false : $this->_currentMethod->payment_logo_display_tooltip, 'payment_cost' => $payment_cost, 'showallform' => $showallform));
                $htmla[] = $html;
            }
        }
        if ($showallform) {
            $js = '
	jQuery(document).ready(function( $ ) {
		      $("#checkoutForm").show();
		      $(".billto-shipto").show();
		      $("#com-form-login").show();

	});
	';
            vmJsApi::addJScript('vm.showallform', $js);
        }
        if (!empty($htmla)) {
            $htmlIn[] = $htmla;
        }
        return true;
    }
Beispiel #22
0
 private function getTotalInPaymentCurrency()
 {
     if (empty($this->cart->virtuemart_paymentmethod_id)) {
         return null;
     }
     if (!$this->cart->paymentCurrency or $this->cart->paymentCurrency == $this->cart->pricesCurrency) {
         return null;
     }
     $paymentCurrency = CurrencyDisplay::getInstance($this->cart->paymentCurrency);
     $totalInPaymentCurrency = $paymentCurrency->priceDisplay($this->cart->cartPrices['billTotal'], $this->cart->paymentCurrency);
     $currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
     return $totalInPaymentCurrency;
 }
Beispiel #23
0
	function plgVmOnPaymentResponseReceived(&$html) {

		if (!class_exists('VirtueMartCart')) {
			require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
		}
		if (!class_exists('shopFunctionsF')) {
			require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
		}
		if (!class_exists('VirtueMartModelOrders')) {
			require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php');
		}
		VmConfig::loadJLang('com_virtuemart_orders',TRUE);

		// the payment itself should send the parameter needed.
		$virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
		$expresscheckout = JRequest::getVar('expresscheckout', '');
		if ($expresscheckout) {
			return;

		}
		$order_number = JRequest::getString('on', 0);
		$vendorId = 0;
		if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
			return NULL;
		}

		if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
			return NULL;
		}
		if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) {
			return '';
		}
		$payment_name = $this->renderPluginName($this->_currentMethod);
		$payment = end($payments);

		VmConfig::loadJLang('com_virtuemart');
		$orderModel = VmModel::getModel('orders');
		$order = $orderModel->getOrder($virtuemart_order_id);
		// to do: this
vmdebug('plgVmOnPaymentResponseReceived',$payment );
		if (!class_exists('CurrencyDisplay'))
			require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php');
		$currency = CurrencyDisplay::getInstance('',$order['details']['BT']->virtuemart_vendor_id);

		if ($payment->paypal_fullresponse) {
			$paypal_data = json_decode($payment->paypal_fullresponse);
			$success = ($paypal_data->payment_status == 'Completed' or $paypal_data->payment_status == 'Pending');
		} else {
			$success=false;
		}

		$html = $this->renderByLayout($this->_currentMethod->paypalproduct . 'response', array("success" => $success,
		                                                                                      "payment_name" => $payment_name,
		                                                                                      "payment" => $paypal_data,
		                                                                                      "order" => $order,
		                                                                                      "currency" => $currency,
		                                                                                 ));

		//We delete the old stuff
		// get the correct cart / session
		$cart = VirtueMartCart::getCart();
		$cart->emptyCart();
		return TRUE;
	}
Beispiel #24
0
 /**
  * Write the order header record
  *
  * @author Oscar van Eijk
  * @param object $_cart The cart data
  * @param object $_usr User object
  * @param array $_prices Price data
  * @return integer The new ordernumber
  */
 private function _createOrder($_cart, $_usr, $_prices)
 {
     //		TODO We need tablefields for the new values:
     //		Shipment:
     //		$_prices['shipmentValue']		w/out tax
     //		$_prices['shipmentTax']			Tax
     //		$_prices['salesPriceShipment']	Total
     //
     //		Payment:
     //		$_prices['paymentValue']		w/out tax
     //		$_prices['paymentTax']			Tax
     //		$_prices['paymentDiscount']		Discount
     //		$_prices['salesPricePayment']	Total
     $_orderData = new stdClass();
     $_orderData->virtuemart_order_id = null;
     $_orderData->virtuemart_user_id = $_usr->get('id');
     $_orderData->virtuemart_vendor_id = $_cart->vendorId;
     //Note as long we do not have an extra table only storing addresses, the virtuemart_userinfo_id is not needed.
     //The virtuemart_userinfo_id is just the id of a stored address and is only necessary in the user maintance view or for choosing addresses.
     //the saved order should be an snapshot with plain data written in it.
     //		$_orderData->virtuemart_userinfo_id = 'TODO'; // $_cart['BT']['virtuemart_userinfo_id']; // TODO; Add it in the cart... but where is this used? Obsolete?
     $_orderData->order_total = $_prices['billTotal'];
     $_orderData->order_salesPrice = $_prices['salesPrice'];
     $_orderData->order_billTaxAmount = $_prices['billTaxAmount'];
     $_orderData->order_billDiscountAmount = $_prices['billDiscountAmount'];
     $_orderData->order_discountAmount = $_prices['discountAmount'];
     $_orderData->order_subtotal = $_prices['priceWithoutTax'];
     $_orderData->order_tax = $_prices['taxAmount'];
     $_orderData->order_shipment = $_prices['shipmentValue'];
     $_orderData->order_shipment_tax = $_prices['shipmentTax'];
     $_orderData->order_payment = $_prices['paymentValue'];
     $_orderData->order_payment_tax = $_prices['paymentTax'];
     if (!empty($_cart->couponCode)) {
         $_orderData->coupon_code = $_cart->couponCode;
         $_orderData->coupon_discount = $_prices['salesPriceCoupon'];
     }
     $_orderData->order_discount = $_prices['discountAmount'];
     // discount order_items
     $_orderData->order_status = 'P';
     if (isset($_cart->pricesCurrency)) {
         $_orderData->user_currency_id = $_cart->pricesCurrency;
         //$this->getCurrencyIsoCode($_cart->pricesCurrency);
         $currency = CurrencyDisplay::getInstance();
         if (!empty($currency->exchangeRateShopper)) {
             $_orderData->user_currency_rate = $currency->exchangeRateShopper;
         } else {
             $_orderData->user_currency_rate = 1.0;
         }
     }
     $_orderData->order_currency = $this->getVendorCurrencyId($_orderData->virtuemart_vendor_id);
     $_orderData->virtuemart_paymentmethod_id = $_cart->virtuemart_paymentmethod_id;
     $_orderData->virtuemart_shipmentmethod_id = $_cart->virtuemart_shipmentmethod_id;
     $_filter = JFilterInput::getInstance(array('br', 'i', 'em', 'b', 'strong'), array(), 0, 0, 1);
     $_orderData->customer_note = $_filter->clean($_cart->customer_comment);
     //	$_orderData->ip_address = $_SERVER['REMOTE_ADDR'];
     $_orderData->ip_address = $_SERVER['HTTP_X_REAL_IP'];
     $_orderData->order_number = '';
     JPluginHelper::importPlugin('vmshopper');
     $dispatcher = JDispatcher::getInstance();
     $plg_datas = $dispatcher->trigger('plgVmOnUserOrder', array(&$_orderData));
     foreach ($plg_datas as $plg_data) {
         // 				$data = array_merge($plg_data,$data);
     }
     if (empty($_orderData->order_number)) {
         $_orderData->order_number = $this->generateOrderNumber($_usr->get('id'), 4, $_orderData->virtuemart_vendor_id);
     }
     if (empty($_orderData->order_pass)) {
         $_orderData->order_pass = '******' . substr(md5((string) time() . rand(1, 1000) . $_orderData->order_number), 0, 5);
     }
     $orderTable = $this->getTable('orders');
     $orderTable->bindChecknStore($_orderData);
     $errors = $orderTable->getErrors();
     foreach ($errors as $error) {
         vmError($error);
     }
     $db = JFactory::getDBO();
     $_orderID = $db->insertid();
     if (!empty($_cart->couponCode)) {
         //set the virtuemart_order_id in the Request for 3rd party coupon components (by Seyi and Max)
         JRequest::setVar('virtuemart_order_id', $_orderData->virtuemart_order_id);
         // If a gift coupon was used, remove it now
         CouponHelper::RemoveCoupon($_cart->couponCode);
     }
     // the order number is saved into the session to make sure that the correct cart is emptied with the payment notification
     $_cart->order_number = $_orderData->order_number;
     $_cart->setCartIntoSession();
     return $_orderID;
 }
Beispiel #25
0
    function display($tpl = null)
    {
        if (!class_exists('VmImage')) {
            require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
        }
        tsmConfig::loadJLang('com_tsmart_orders', TRUE);
        if (JFactory::getApplication()->isSite()) {
            $bar = JToolBar::getInstance('toolbar');
            $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0');
        }
        $layout = $this->getLayout();
        if ($this->manager('report')) {
            vmSetStartTime('report');
            $model = tmsModel::getModel('tsmart');
            $nbrCustomers = $model->getTotalCustomers();
            $this->nbrCustomers = $nbrCustomers;
            $nbrActiveProducts = $model->getTotalActiveProducts();
            $this->nbrActiveProducts = $nbrActiveProducts;
            $nbrInActiveProducts = $model->getTotalInActiveProducts();
            $this->nbrInActiveProducts = $nbrInActiveProducts;
            $nbrFeaturedProducts = $model->getTotalFeaturedProducts();
            $this->nbrFeaturedProducts = $nbrFeaturedProducts;
            $ordersByStatus = $model->getTotalOrdersByStatus();
            $this->ordersByStatus = $ordersByStatus;
            $recentOrders = $model->getRecentOrders();
            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
            foreach ($recentOrders as $tsmart_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->tsmart_vendor_id, $_currencies)) {
                    $_currencies['v' . $order->tsmart_vendor_id] = CurrencyDisplay::getInstance('', $order->tsmart_vendor_id);
                }
                $order->order_total = $_currencies['v' . $order->tsmart_vendor_id]->priceDisplay($order->order_total);
            }
            $this->recentOrders = $recentOrders;
            $recentCustomers = $model->getRecentCustomers();
            $this->recentCustomers = $recentCustomers;
            $reportModel = tmsModel::getModel('report');
            vRequest::setvar('task', '');
            $myCurrencyDisplay = CurrencyDisplay::getInstance();
            $revenueBasic = $reportModel->getRevenue(60, true);
            $this->report = $revenueBasic['report'];
            vmJsApi::addJScript("jsapi", "//google.com/jsapi", false, false, '');
            vmJsApi::addJScript('vm.stats_chart', $revenueBasic['js'], false, true);
            vmTime('Created report', 'report');
        }
        //if($layout=='default'){
        $j = 'jQuery("#feed").ready(function(){
				var datas = "";
				vmSiteurl = "' . JURI::root() . '"
				jQuery.ajax({
						type: "GET",
						async: true,
						cache: false,
						dataType: "json",
						url: vmSiteurl + "index.php?option=com_tsmart&view=tsmart&task=feed",
						data: datas,
						dataType: "html"
					})
					.done(function( data ) {
						jQuery("#feed").append(data);
					});
				})';
        vmJsApi::addJScript('getFeed', $j, false, true);
        //}
        self::showACLPref($this);
        parent::display($tpl);
    }
 /**
  * Reimplementation of vmPaymentPlugin::plgVmOnConfirmedOrder()
  *
  * @link http://www.authorize.net/support/AIM_guide.pdf
  * Credit Cards Test Numbers
  * Visa Test Account           4007000000027
  * Amex Test Account           370000000000002
  * Master Card Test Account    6011000000000012
  * Discover Test Account       5424000000000015
  * @author Valerie Isaksen
  */
 function plgVmConfirmedOrder(VirtueMartCart $cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $this->setInConfirmOrder($cart);
     $usrBT = $order['details']['BT'];
     $usrST = isset($order['details']['ST']) ? $order['details']['ST'] : '';
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $payment_currency_id = shopFunctions::getCurrencyIDByName(self::AUTHORIZE_DEFAULT_PAYMENT_CURRENCY);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $payment_currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     // Set up data
     $formdata = array();
     $formdata = array_merge($this->_setHeader(), $formdata);
     $formdata = array_merge($this->_setResponseConfiguration(), $formdata);
     $formdata = array_merge($this->_setBillingInformation($usrBT), $formdata);
     if (!empty($usrST)) {
         $formdata = array_merge($this->_setShippingInformation($usrST), $formdata);
     }
     $formdata = array_merge($this->_setTransactionData($order['details']['BT'], $totalInPaymentCurrency['value']), $formdata);
     $formdata = array_merge($this->_setMerchantData(), $formdata);
     // prepare the array to post
     $poststring = '';
     foreach ($formdata as $key => $val) {
         $poststring .= urlencode($key) . "=" . urlencode($val) . "&";
     }
     $poststring = rtrim($poststring, "& ");
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_method_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['return_context'] = $return_context;
     $dbValues['payment_name'] = parent::renderPluginName($this->_currentMethod);
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['payment_currency'] = $payment_currency_id;
     $this->debugLog("before store", "plgVmConfirmedOrder", 'debug');
     $this->storePSPluginInternalData($dbValues);
     // send a request
     $response = $this->_sendRequest($poststring);
     $this->debugLog($response, "plgVmConfirmedOrder", 'debug');
     $authnet_values = array();
     // to check the values???
     // evaluate the response
     $html = $this->_handleResponse($response, $authnet_values, $order, $dbValues['payment_name']);
     if ($this->error) {
         $new_status = $this->_currentMethod->payment_declined_status;
         $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
         return;
         // will not process the order
     } else {
         if ($this->approved) {
             $this->_clearAuthorizeNetSession();
             $new_status = $this->_currentMethod->payment_approved_status;
         } else {
             if ($this->declined) {
                 vRequest::setVar('html', $html);
                 $new_status = $this->_currentMethod->payment_declined_status;
                 $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
                 return;
             } else {
                 if ($this->held) {
                     $this->_clearAuthorizeNetSession();
                     $new_status = $this->_currentMethod->payment_held_status;
                 }
             }
         }
     }
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $new_status;
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
 }
Beispiel #27
0
 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';
     }
     // Load addl models
     $orderModel = VmModel::getModel();
     $userFieldsModel = VmModel::getModel('userfields');
     $productModel = VmModel::getModel('product');
     /* Get the data */
     $virtuemart_order_id = vRequest::getvar('virtuemart_order_id');
     $order = $orderModel->getOrder($virtuemart_order_id);
     //$order = $this->get('Order');
     $orderNumber = $order['details']['BT']->virtuemart_order_number;
     $orderbt = $order['details']['BT'];
     $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt;
     $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
     $this->assignRef('currency', $currency);
     $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'email', 'password', 'password2', 'agreed', 'address_type'));
     $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt);
     $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type'));
     $shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst);
     // Create an array to allow orderlinestatuses to be translated
     // We'll probably want to put this somewhere in ShopFunctions...
     $_orderStats = $this->get('OrderStatusList');
     $_orderStatusList = array();
     foreach ($_orderStats as $orderState) {
         $_orderStatusList[$orderState->order_status_code] = vmText::_($orderState->order_status_name);
     }
     /*foreach($order['items'] as $_item) {
     			if (!empty($_item->product_attribute)) {
     				$_attribs = preg_split('/\s?<br\s*\/?>\s?/i', $_item->product_attribute);
     
     				$product = $productModel->getProduct($_item->virtuemart_product_id);
     				$_productAttributes = array();
     				$_prodAttribs = explode(';', $product->attribute);
     				foreach ($_prodAttribs as $_pAttr) {
     					$_list = explode(',', $_pAttr);
     					$_name = array_shift($_list);
     					$_productAttributes[$_item->virtuemart_order_item_id][$_name] = array();
     					foreach ($_list as $_opt) {
     						$_optObj = new stdClass();
     						$_optObj->option = $_opt;
     						$_productAttributes[$_item->virtuemart_order_item_id][$_name][] = $_optObj;
     					}
     				}
     			}
     		}*/
     //$_shipmentInfo = ShopFunctions::getShipmentRateDetails($orderbt->virtuemart_shipmentmethod_id);
     /* Assign the data */
     $this->assignRef('orderdetails', $order);
     $this->assignRef('orderNumber', $orderNumber);
     $this->assignRef('userfields', $userfields);
     $this->assignRef('shipmentfields', $shipmentfields);
     $this->assignRef('orderstatuslist', $_orderStatusList);
     $this->assignRef('orderbt', $orderbt);
     $this->assignRef('orderst', $orderst);
     $this->assignRef('virtuemart_shipmentmethod_id', $orderbt->virtuemart_shipmentmethod_id);
     error_reporting(0);
     parent::display($tpl);
 }
Beispiel #28
0
	public function displayExtraPluginInfo () {
		$extraInfo = '';
		if ($this->_method->payment_type == '_xclick-auto-billing' && $this->customerData->getVar('autobilling_max_amount')) {
			$cd = CurrencyDisplay::getInstance($this->_method->payment_currency);
			$extraInfo .= '<br/>';
			$extraInfo .= vmText::_('VMPAYMENT_PAYPAL_PAYMENT_BILLING_MAX_AMOUNT') . ': ' . $cd->priceDisplay($this->customerData->getVar('autobilling_max_amount'));
		}
		if ($this->_method->payment_type == '_xclick-subscriptions') {
			$extraInfo .= '<br /><span class="vmpayment_cardinfo">';
			$extraInfo .= $this->getRecurringProfileDesc();
			$extraInfo .= '</span>';
		}
		if ($this->_method->payment_type == '_xclick-payment-plan') {
			$extraInfo .= '<br /><span class="vmpayment_cardinfo">';
			$extraInfo .= $this->getPaymentPlanDesc();
			$extraInfo .= '</span>';
		}

		return $extraInfo;
	}
 private function handle3DSRequest()
 {
     $realexInterface = $this->initRealexInterface(false);
     $cart = VirtueMartCart::getCart();
     $realexInterface->setCart($cart, false);
     $saved_cc_selected = $this->customerData->getVar('saved_cc_selected');
     $realvault = false;
     if ($saved_cc_selected > 0) {
         $realvault = $realexInterface->getStoredCCsData($saved_cc_selected);
         $realvault->cc_cvv_realvault = $this->customerData->getVar('cc_cvv_realvault');
         $this->customerData->saveCustomerRealVaultData((array) $realvault);
     }
     if (!($payments = $this->getDatasByOrderId($realexInterface->order['details']['BT']->virtuemart_order_id))) {
         $this->redirectToCart();
         return FALSE;
     }
     $dcc_payment = $realexInterface->getTransactionData($payments, array($realexInterface::REQUEST_TYPE_DCCRATE, $realexInterface::REQUEST_TYPE_REALVAULT_DCCRATE));
     if ($dcc_payment) {
         $xml_dcc_payment = simplexml_load_string($dcc_payment->realex_hpp_api_fullresponse);
     } else {
         $xml_dcc_payment = NULL;
     }
     $response3DSVerifysig = $realexInterface->request3DSVerifysig($realvault);
     $realexInterface->manageResponse3DSVerifysig($response3DSVerifysig);
     $eci = $realexInterface->getEciFrom3DSVerifysig($response3DSVerifysig, $this->_currentMethod->require_liability);
     $xml_response3DSVerifysig = simplexml_load_string($response3DSVerifysig);
     if ($eci !== false) {
         $xml_response3DSVerifysig->threedsecure->eci = $eci;
         if ($realvault) {
             $response = $realexInterface->requestReceiptIn($realvault, $xml_dcc_payment, $xml_response3DSVerifysig);
         } else {
             $response = $realexInterface->requestAuth($xml_dcc_payment, $xml_response3DSVerifysig);
         }
         $realexInterface->manageResponseRequestAuth($response);
         $xml_response = simplexml_load_string($response);
         $success = $realexInterface->isResponseSuccess($xml_response);
     } else {
         $success = false;
     }
     $order_history = array();
     $redirectToCart = false;
     if ($success) {
         $userfield = $realexInterface->handleCardStorage($saved_cc_selected);
         $realexInterface->storeNewPayment($userfield);
         $status = $this->_currentMethod->status_success;
         $amountValue = vmPSPlugin::getAmountInCurrency($realexInterface->order['details']['BT']->order_total, $realexInterface->order['details']['BT']->order_currency);
         $currencyDisplay = CurrencyDisplay::getInstance($realexInterface->cart->pricesCurrency);
         $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CONFIRMED', $amountValue['display'], $realexInterface->order['details']['BT']->order_number);
         if (isset($xml_response->dccinfo) and isset($xml_response->dccinfo->cardholderrate)) {
             $order_history['comments'] .= "<br />";
             if ($xml_response->dccinfo->cardholderrate != 1.0) {
                 $order_history['comments'] .= vmText::sprintf('VMPAYMENT_REALEX_HPP_API_DCC_PAY_OWN_CURRENCY_CHARGED', $this->getCardHolderAmount($xml_response->dccinfo->merchantamount), $xml_response->dccinfo->merchantcurrency, $this->getCardHolderAmount($xml_response->dccinfo->cardholderamount), $xml_response->dccinfo->cardholdercurrency);
             } else {
                 $order_history['comments'] .= vmText::sprintf('VMPAYMENT_REALEX_HPP_API_DCC_PAY_MERCHANT_CURRENCY', $this->getCardHolderAmount($xml_response->dccinfo->merchantamount), $xml_response->dccinfo->merchantcurrency);
             }
             $order_history['comments'] .= "<br />";
         } else {
         }
     } else {
         $msgToShopper = '';
         $status = $this->_currentMethod->status_canceled;
         if ($realexInterface->isResponseDeclined($xml_response3DSVerifysig)) {
             $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_DECLINED', $realexInterface->order['details']['BT']->order_number);
             $msgToShopper = $xml_response3DSVerifysig->message;
         } elseif ($realexInterface->isResponseWrongPhrase($xml_response3DSVerifysig)) {
             $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CANCELLED', $realexInterface->order['details']['BT']->order_number);
             $msgToShopper = $xml_response3DSVerifysig->message;
         } elseif ($realexInterface->isResponseAlreadyProcessed($xml_response3DSVerifysig)) {
             $order_history['comments'] = $xml_response3DSVerifysig->message;
             $msgToShopper = $xml_response3DSVerifysig->message;
             // log this response, but do not change the order status
             $status = $realexInterface->order['details']['BT']->order_status;
             /* } elseif ($xml_response and $realexInterface->isResponseInvalidPaymentDetails($xml_response)) {
             
             					$order_history['comments'] =$xml_response->message;
             					if ($realvault) {
             						$accountURL=JRoute::_('index.php?option=com_virtuemart&view=user&layout=edit');
             						$msgToShopper=vmText::sprintf('VMPAYMENT_REALEX_HPP_API_INVALID_PAYMENT_DETAILS_REALVAULT',$xml_response->message, $accountURL);
             					} else {
             						$msgToShopper=vmText::sprintf('VMPAYMENT_REALEX_HPP_API_INVALID_PAYMENT_DETAILS',$xml_response->message);
             					}
             	*/
         } else {
             $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CANCELLED', $realexInterface->order['details']['BT']->order_number);
         }
         $redirectToCart = true;
     }
     $order_history['customer_notified'] = true;
     $order_history['order_status'] = $status;
     //	$this->updateOrderStatus($realexInterface->order, $redirectToCart);
     $modelOrder = VmModel::getModel('orders');
     $modelOrder->updateStatusForOneOrder($realexInterface->order['details']['BT']->virtuemart_order_id, $order_history, false);
     /*
     		$payments = $this->getDatasByOrderId($realexInterface->order['details']['BT']->virtuemart_order_id);
     
     		$html = $realexInterface->getResponseHTML($payments);
     		$this->customerData->clear();
     		$cart = VirtueMartCart::getCart();
     		$cart->emptyCart();
     		vRequest::setVar('display_title', false);
     		vRequest::setVar('html', $html);
     		echo $html;
     */
     //$html = $realexInterface->getResponseHTML($payments);
     if ($redirectToCart) {
         $this->redirectToCart($msgToShopper);
     } else {
         $this->customerData->clear();
         $cart = VirtueMartCart::getCart();
         $cart->emptyCart();
         $submit_url = JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=' . $this->_currentMethod->virtuemart_paymentmethod_id . '&on=' . $realexInterface->order['details']['BT']->order_number . '&Itemid=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', '');
         $app = JFactory::getApplication();
         $app->redirect(JRoute::_($submit_url));
     }
     return true;
 }
Beispiel #30
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 = tmsModel::getModel('orderstatus');
     $orderStates = $orderStatusModel->getOrderStatusList(true);
     $this->SetViewTitle('ORDER');
     $orderModel = tmsModel::getModel();
     $curTask = vRequest::getCmd('task');
     if ($curTask == 'edit') {
         tsmConfig::loadJLang('com_tsmart_shoppers', TRUE);
         tsmConfig::loadJLang('com_tsmart_orders', true);
         //For getOrderStatusName
         if (!class_exists('ShopFunctions')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php';
         }
         // Load addl models
         $userFieldsModel = tmsModel::getModel('userfields');
         // Get the data
         $tsmart_order_id = vRequest::getInt('tsmart_order_id');
         $order = $orderModel->getOrder($tsmart_order_id);
         if (empty($order['details'])) {
             JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=orders', tsmText::_('com_tsmart_ORDER_NOTFOUND'));
         }
         $_orderID = $order['details']['BT']->tsmart_order_id;
         $orderbt = $order['details']['BT'];
         $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt;
         $orderbt->invoiceNumber = $orderModel->getInvoiceNumber($orderbt->tsmart_order_id);
         $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->tsmart_vendor_id);
         $this->assignRef('currency', $currency);
         $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'name', 'password', 'password2', 'agreed', 'address_type'));
         $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
         $_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(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type'));
         $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->tsmart_orderstate_id] = $orderState->order_status_name;
             //When I use update, I have to use this?
             $_orderStatusList[$orderState->order_status_code] = tsmText::_($orderState->order_status_name);
         }
         $_itemStatusUpdateFields = array();
         $_itemAttributesUpdateFields = array();
         foreach ($order['items'] as $_item) {
             $_itemStatusUpdateFields[$_item->tsmart_order_item_id] = JHtml::_('select.genericlist', $orderStates, "item_id[" . $_item->tsmart_order_item_id . "][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->tsmart_order_item_id, true);
         }
         if (!isset($_orderStatusList[$orderbt->order_status])) {
             if (empty($orderbt->order_status)) {
                 $orderbt->order_status = 'unknown';
             }
             $_orderStatusList[$orderbt->order_status] = tsmText::_('com_tsmart_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('tsmart_shipmentmethod_id', $orderbt->tsmart_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', 'style="width:100px;"', '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_tsmart_ITEM_PREVIOUS', false);
         JToolBarHelper::custom('nextItem', 'forward', '', 'com_tsmart_ITEM_NEXT', false);
         JToolBarHelper::divider();
         JToolBarHelper::custom('cancel', $list, '', 'com_tsmart_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 = tmsModel::getModel();
             $orderId = vRequest::getString('orderId', '');
             $orderLineItem = vRequest::getVar('orderLineId', '');
             $this->assignRef('tsmart_order_id', $orderId);
             $this->assignRef('tsmart_order_item_id', $orderLineItem);
             $orderItem = $model->getOrderLineDetails($orderId, $orderLineItem);
             $this->assignRef('orderitem', $orderItem);
         } else {
             $this->setLayout('orders');
             $model = tmsModel::getModel();
             $this->addStandardDefaultViewLists($model, 'created_on');
             $orderStatusModel = tmsModel::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 $tsmart_order_id => $order) {
                     if (!empty($order->order_currency)) {
                         $currency = $order->order_currency;
                     } else {
                         if ($order->tsmart_vendor_id) {
                             if (!class_exists('tsmartModelVendor')) {
                                 require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
                             }
                             $currObj = tsmartModelVendor::getVendorCurrency($order->tsmart_vendor_id);
                             $currency = $currObj->tsmart_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->tsmart_vendor_id);
                     }
                     $order->order_total = $_currencies['curr' . $currency]->priceDisplay($order->order_total);
                     $order->invoiceNumber = $model->getInvoiceNumber($order->tsmart_order_id);
                 }
             }
             //update order items button
             /*$q = 'SELECT * FROM #__tsmart_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_tsmart_REPORT_UPDATEORDERITEMS'),false);
             			vmError('com_tsmart_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', tsmText::_('com_tsmart_UPDATE_STATUS'));
             if (vmAccess::manager('orders.delete')) {
                 JToolBarHelper::spacer('80');
                 JToolBarHelper::deleteList();
             }
             /* Assign the data */
             $this->assignRef('orderslist', $orderslist);
             $this->pagination = $model->getPagination();
         }
     }
     if (JFactory::getApplication()->isSite()) {
         $bar = JToolBar::getInstance('toolbar');
         $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0');
     }
     shopFunctions::checkSafePath();
     parent::display($tpl);
 }