Example #1
0
 public function neworderitem()
 {
     $adminproducthelper = new adminproducthelper();
     $stockroomhelper = new rsstockroomhelper();
     $post = JRequest::get('post');
     $tmpl = "";
     if (isset($post['tmpl'])) {
         $tmpl = $post['tmpl'];
     }
     $option = JRequest::getVar('option', '', 'request', 'string');
     $cid = JRequest::getVar('cid', array(0), 'post', 'array');
     $order_item_id = JRequest::getVar('order_item_id', 0, 'post', '');
     $model = $this->getModel('order_detail');
     $orderItem = $adminproducthelper->redesignProductItem($post);
     $post['order_item'] = $orderItem;
     $product_id = $orderItem[0]->product_id;
     $finalquantity = $quantity = $orderItem[0]->quantity;
     // Check product Quantity
     if (USE_STOCKROOM == 1) {
         $currentStock = $stockroomhelper->getStockroomTotalAmount($product_id);
         if ($currentStock >= $quantity) {
             $finalquantity = (int) $quantity;
         } else {
             $finalquantity = (int) $currentStock;
         }
     }
     if ($finalquantity > 0) {
         if ($model->neworderitem($post, $finalquantity, $order_item_id)) {
             if ($order_item_id == 0) {
                 $msg = JText::_('COM_REDSHOP_ORDER_ITEM_ADDED');
             } else {
                 $msg = JText::_('COM_REDSHOP_QUANTITY_UPDATED');
             }
         } else {
             if ($order_item_id == 0) {
                 $msg = JText::_('COM_REDSHOP_ERROR_ADDING_ORDER_ITEM');
             } else {
                 $msg = JText::_('COM_REDSHOP_ERROR_UPDATING_QUANTITY');
             }
         }
     } else {
         $msg = JText::_('COM_REDSHOP_PRODUCT_OUT_OF_STOCK');
     }
     if ($tmpl) {
         $this->setRedirect('index.php?option=' . $option . '&view=order_detail&cid[]=' . $cid[0] . '&tmpl=' . $tmpl, $msg);
     } else {
         $this->setRedirect('index.php?option=' . $option . '&view=order_detail&cid[]=' . $cid[0], $msg);
     }
 }
Example #2
0
/**
 * @package     RedSHOP.Frontend
 * @subpackage  Template
 *
 * @copyright   Copyright (C) 2005 - 2013 redCOMPONENT.com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
defined('_JEXEC') or die;
JHTML::_('behavior.tooltip');
JHTMLBehavior::modal();
$objhelper = new redhelper();
$config = new Redconfiguration();
$producthelper = new producthelper();
$extraField = new extraField();
$redTemplate = new Redtemplate();
$stockroomhelper = new rsstockroomhelper();
$url = JURI::base();
$model = $this->getModel('category');
$loadCategorytemplate = $redTemplate->getTemplate('categoryproduct');
if (count($loadCategorytemplate) > 0 && $loadCategorytemplate[0]->template_desc != "") {
    $template_desc = $loadCategorytemplate[0]->template_desc;
} else {
    $template_desc = "<div><div>{print}</div>";
    $template_desc .= "<div>{filter_by_lbl}{filter_by}</div>";
    $template_desc .= "<div>{order_by_lbl}{order_by}</div>";
    $template_desc .= "<p>{category_loop_start}</p>";
    $template_desc .= "<div style='border: 1px solid;'><div id='categories'><div style='width: 200px;'>";
    $template_desc .= "<div class='category_image'>{category_thumb_image}</div><div class='category_description'>";
    $template_desc .= "<h4 class='category_title'>{category_name}</h4>{category_description}</div></div></div>";
    $template_desc .= "<div class='category_box_wrapper clearfix'>{product_loop_start}<div class='category_product_box_outside'>";
    $template_desc .= "<div class='category_box_inside'><table border='0'><tbody><tr><td>";
Example #3
0
 public function checkAttributeStockRoom($data = array(), $productData = array())
 {
     $stockroomhelper = new rsstockroomhelper();
     $newquantity = $data['quantity'];
     $attArr = $data['cart_attribute'];
     $product_preorder = $productData->preorder;
     for ($i = 0; $i < count($attArr); $i++) {
         $propArr = $attArr[$i]['attribute_childs'];
         for ($k = 0; $k < count($propArr); $k++) {
             if (USE_STOCKROOM == 1) {
                 if ($product_preorder == "global" && !ALLOW_PRE_ORDER || $product_preorder == "no" || $product_preorder == "" && !ALLOW_PRE_ORDER) {
                     $property_stock = $stockroomhelper->getStockroomTotalAmount($propArr[$k]['property_id'], "property");
                 }
                 if ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes" || $product_preorder == "" && ALLOW_PRE_ORDER) {
                     $regular_property_stock = $stockroomhelper->getStockroomTotalAmount($propArr[$k]['property_id'], "property");
                     $Preorder_property_stock = $stockroomhelper->getPreorderStockroomTotalAmount($propArr[$k]['property_id'], "property");
                     $property_stock = $regular_property_stock + $Preorder_property_stock;
                 }
                 $ownreserveStock = $stockroomhelper->getCurrentUserReservedStock($propArr[$k]['property_id'], "property");
                 if ($property_stock >= 0) {
                     if ($newquantity > $ownreserveStock && $property_stock < $newquantity - $ownreserveStock) {
                         $newquantity = $property_stock + $ownreserveStock;
                     }
                 } else {
                     $newquantity = $property_stock + $ownreserveStock;
                 }
             }
             $subpropArr = $propArr[$k]['property_childs'];
             for ($l = 0; $l < count($subpropArr); $l++) {
                 if (USE_STOCKROOM == 1) {
                     if ($product_preorder == "global" && !ALLOW_PRE_ORDER || $product_preorder == "no" || $product_preorder == "" && !ALLOW_PRE_ORDER) {
                         $subproperty_stock = $stockroomhelper->getStockroomTotalAmount($subpropArr[$l]['subproperty_id'], "subproperty");
                     }
                     if ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes" || $product_preorder == "" && ALLOW_PRE_ORDER) {
                         $regular_subproperty_stock = $stockroomhelper->getStockroomTotalAmount($subpropArr[$l]['subproperty_id'], "subproperty");
                         $preorder_subproperty_stock = $stockroomhelper->getPreorderStockroomTotalAmount($subpropArr[$l]['subproperty_id'], "subproperty");
                         $subproperty_stock = $regular_subproperty_stock + $preorder_subproperty_stock;
                     }
                     $ownreserveStock = $stockroomhelper->getCurrentUserReservedStock($propArr[$k]['property_id'], "property");
                     if ($subproperty_stock >= 0) {
                         if ($newquantity > $ownreserveStock && $subproperty_stock < $newquantity - $ownreserveStock) {
                             $newquantity = $subproperty_stock + $ownreserveStock;
                         }
                     } else {
                         $newquantity = $subproperty_stock + $ownreserveStock;
                     }
                 }
             }
         }
     }
     if ($productData->max_order_product_quantity > 0 && $productData->max_order_product_quantity < $newquantity) {
         $newquantity = $productData->max_order_product_quantity;
     }
     for ($i = 0; $i < count($attArr); $i++) {
         $propArr = $attArr[$i]['attribute_childs'];
         for ($k = 0; $k < count($propArr); $k++) {
             $stockroomhelper->addReservedStock($propArr[$k]['property_id'], $newquantity, "property");
             $subpropArr = $propArr[$k]['property_childs'];
             for ($l = 0; $l < count($subpropArr); $l++) {
                 $stockroomhelper->addReservedStock($subpropArr[$l]['subproperty_id'], $newquantity, "subproperty");
             }
         }
     }
     return $newquantity;
 }
Example #4
0
 *
 * @copyright   Copyright (C) 2005 - 2013 redCOMPONENT.com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
defined('_JEXEC') or die;
$url = JURI::base();
// Get product helper
require_once JPATH_ROOT . '/components/com_redshop/helpers/product.php';
require_once JPATH_SITE . '/components/com_redshop/helpers/extra_field.php';
$producthelper = new producthelper();
$print = $this->input->getBool('print', false);
$user = JFactory::getUser();
$pagetitle = JText::_('COM_REDSHOP_COMPARE_PRODUCTS');
$config = new Redconfiguration();
$compare = $producthelper->getCompare();
$stockroomhelper = new rsstockroomhelper();
if (PRODUCT_COMPARISON_TYPE == 'category') {
    $compare_product = $this->session->get('compare_product');
    $catid = $compare_product[0]['category_id'];
    $cid = $this->input->getInt('cid', null);
    $template_id = $producthelper->getCategoryCompareTemplate($catid);
    if ($template_id == "") {
        $compare_template = $this->redTemplate->getTemplate("compare_product", COMPARE_TEMPLATE_ID);
    } else {
        $compare_template = $this->redTemplate->getTemplate("compare_product", $template_id);
    }
} else {
    $compare_template = $this->redTemplate->getTemplate("compare_product", COMPARE_TEMPLATE_ID);
}
if (count($compare_template) > 0 && $compare_template[0]->template_desc != "") {
    $template = $compare_template[0]->template_desc;
 public function save($apply = 0)
 {
     $post = JRequest::get('post');
     $adminproducthelper = new adminproducthelper();
     $order_functions = new order_functions();
     $shippinghelper = new shipping();
     $option = JRequest::getVar('option', '', 'request', 'string');
     $cid = JRequest::getVar('cid', array(0), 'post', 'array');
     $post['order_id'] = $cid[0];
     $model = $this->getModel('addorder_detail');
     $post['order_number'] = $order_number = $order_functions->generateOrderNumber();
     $orderItem = $adminproducthelper->redesignProductItem($post);
     $post['order_item'] = $orderItem;
     // Check product Quantity
     $stocknote = '';
     if (USE_STOCKROOM == 1) {
         $stockroomhelper = new rsstockroomhelper();
         $producthelper = new producthelper();
         for ($i = 0; $i < count($orderItem); $i++) {
             $quantity = $orderItem[$i]->quantity;
             $productData = $producthelper->getProductById($orderItem[$i]->product_id);
             if ($productData->min_order_product_quantity > 0 && $productData->min_order_product_quantity > $quantity) {
                 $msg = $productData->product_name . " " . JText::_('WARNING_MSG_MINIMUM_QUANTITY');
                 $stocknote .= sprintf($msg, $productData->min_order_product_quantity) . "<br/>";
                 $quantity = $productData->min_order_product_quantity;
             }
             $currentStock = $stockroomhelper->getStockroomTotalAmount($orderItem[$i]->product_id);
             $finalquantity = $currentStock >= $quantity ? (int) $quantity : (int) $currentStock;
             if ($finalquantity > 0) {
                 if ($productData->max_order_product_quantity > 0 && $productData->max_order_product_quantity < $finalquantity) {
                     $msg = $productData->product_name . " " . JText::_('WARNING_MSG_MAXIMUM_QUANTITY') . "<br/>";
                     $stocknote .= sprintf($msg, $productData->max_order_product_quantity);
                     $finalquantity = $productData->max_order_product_quantity;
                 }
                 $orderItem[$i]->quantity = $finalquantity;
             } else {
                 $stocknote .= $productData->product_name . " " . JText::_('PRODUCT_OUT_OF_STOCK') . "<br/>";
                 unset($orderItem[$i]);
             }
         }
         $orderItem = array_merge(array(), $orderItem);
         if (count($orderItem) <= 0) {
             $msg = JText::_('PRODUCT_OUT_OF_STOCK');
             $this->setRedirect('index.php?option=' . $option . '&view=addorder_detail&user_id=' . $post['user_id'] . '&shipping_users_info_id=' . $post['shipp_users_info_id'], $msg);
             return;
         }
     }
     $order_total = $post['order_total'];
     $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $post['shipping_rate_id'])));
     if (count($order_shipping) > 4) {
         $post['order_shipping'] = $order_shipping[3];
         $order_total = $order_total + $order_shipping[3];
         $post['order_shipping_tax'] = $order_shipping[6];
     }
     $tmporder_total = $order_total;
     if (array_key_exists("issplit", $post) && $post['issplit']) {
         $tmporder_total = $order_total / 2;
     }
     $paymentmethod = $order_functions->getPaymentMethodInfo($post['payment_method_class']);
     $paymentmethod = $paymentmethod[0];
     $paymentparams = new JRegistry($paymentmethod->params);
     $paymentinfo = new stdclass();
     $post['economic_payment_terms_id'] = $paymentparams->get('economic_payment_terms_id');
     $post['economic_design_layout'] = $paymentparams->get('economic_design_layout');
     $paymentinfo->payment_price = $paymentparams->get('payment_price', '');
     $paymentinfo->is_creditcard = $post['economic_is_creditcard'] = $paymentparams->get('is_creditcard', '');
     $paymentinfo->payment_oprand = $paymentparams->get('payment_oprand', '');
     $paymentinfo->accepted_credict_card = $paymentparams->get("accepted_credict_card");
     $paymentinfo->payment_discount_is_percent = $paymentparams->get('payment_discount_is_percent', '');
     $cartHelper = new rsCartHelper();
     $subtotal = $post['order_subtotal'];
     $update_discount = 0;
     if ($post['update_discount'] > 0) {
         $update_discount = $post['update_discount'];
         if ($update_discount > $subtotal) {
             $update_discount = $subtotal;
         }
         if ($update_discount != 0) {
             $order_total = $order_total - $update_discount;
         }
     }
     $special_discount = $post['special_discount'];
     $subtotal_excl_vat = 0;
     for ($i = 0; $i < count($orderItem); $i++) {
         $subtotal_excl_vat = $subtotal_excl_vat + $orderItem[$i]->prdexclprice * $orderItem[$i]->quantity;
     }
     if (APPLY_VAT_ON_DISCOUNT) {
         $amt = $subtotal;
     } else {
         $amt = $subtotal_excl_vat;
     }
     $discount_price = $amt * $special_discount / 100;
     $post['special_discount'] = $special_discount;
     $post['special_discount_amount'] = $discount_price;
     $order_total = $order_total - $discount_price;
     if (PAYMENT_CALCULATION_ON == 'subtotal') {
         $paymentAmount = $subtotal;
     } else {
         $paymentAmount = $order_total;
     }
     $paymentMethod = $cartHelper->calculatePayment($paymentAmount, $paymentinfo, $order_total);
     $post['ship_method_id'] = urldecode(urldecode($post['shipping_rate_id']));
     $order_total = $paymentMethod[0];
     $post['user_info_id'] = $post['users_info_id'];
     $post['payment_discount'] = $paymentMethod[1];
     $post['payment_oprand'] = $paymentinfo->payment_oprand;
     $post['order_discount'] = $update_discount;
     $post['order_total'] = $order_total;
     $post['order_payment_amount'] = $tmporder_total;
     $post['order_payment_name'] = $paymentmethod->name;
     if ($apply == 1) {
         $post['order_payment_status'] = 'Unpaid';
         $post['order_status'] = 'P';
     }
     if ($row = $model->store($post)) {
         $msg = JText::_('COM_REDSHOP_ORDER_DETAIL_SAVED');
     } else {
         $msg = JText::_('COM_REDSHOP_ERROR_SAVING_ORDER_DETAIL');
     }
     if ($apply == 1) {
         $objorder = new order_functions();
         $objorder->getpaymentinformation($row, $post);
     } else {
         $this->setRedirect('index.php?option=' . $option . '&view=order', $msg . $stocknote);
     }
 }
Example #6
0
 public function gbasefeed($data)
 {
     $producthelper = new producthelper();
     $stockroomhelper = new rsstockroomhelper();
     $shippinghelper = new shipping();
     $unpublished_data = $data['unpublished_data'];
     $cid = $data['cid'];
     $url = JURI::root();
     $currency = new CurrencyHelper();
     $product_img_url = $url . 'components/com_redshop/assets/images/product/';
     $file_path = JPATH_COMPONENT_SITE . "/assets/document/gbase";
     $file_name = $file_path . "/product.xml";
     if (count($cid)) {
         $cids = implode(',', $cid);
         if ($unpublished_data == 1) {
             $query = "SELECT p.*,m.manufacturer_name FROM " . $this->_table_prefix . "product AS p " . " LEFT JOIN " . $this->_table_prefix . "manufacturer AS m" . " ON p.manufacturer_id = m.manufacturer_id" . " WHERE p.product_id IN (" . $cids . ")";
         } else {
             $query = "SELECT p.*,m.manufacturer_name FROM " . $this->_table_prefix . "product AS p " . " LEFT JOIN " . $this->_table_prefix . "manufacturer AS m" . " ON p.manufacturer_id = m.manufacturer_id" . " WHERE p.product_id IN (" . $cids . ") and p.published =1";
         }
         $this->_db->setQuery($query);
         $rs = $this->_db->loadObjectlist();
         // For shipping information
         $shippingArr = $shippinghelper->getShopperGroupDefaultShipping();
         $default_shipping = 0.0;
         $shipping_rate = $currency->convert(number_format($shippingArr['shipping_rate'], PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
         $default_shipping = count($shippingArr) > 0 ? $shipping_rate : number_format($default_shipping, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR);
         $default_shipping_country = DEFAULT_SHIPPING_COUNTRY;
         $xml_code = '<?xml version="1.0" encoding="UTF-8" ';
         $xml_code .= '<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">';
         $xml_code .= "<channel>";
         for ($i = 0; $i < count($rs); $i++) {
             // For additional images
             $additional_images = $producthelper->getAdditionMediaImage($rs[$i]->product_id, $section = "product", $mediaType = "images");
             $add_image = "";
             for ($ad = 0; $ad < 10; $ad++) {
                 if (trim($additional_images[$ad]->product_full_image) != trim($additional_images[$ad]->media_name) && trim($additional_images[$ad]->media_name) != "") {
                     $add_image .= "<g:additional_image_link>" . $product_img_url . htmlspecialchars($additional_images[$ad]->media_name, ENT_NOQUOTES, "UTF-8") . "</g:additional_image_link>";
                 }
             }
             // For getting product Category
             $category_name = $producthelper->getCategoryNameByProductId($rs[$i]->product_id);
             if (USE_STOCKROOM == 1) {
                 // For c**t attributes
                 $attributes_set = array();
                 if ($rs[$i]->attribute_set_id > 0) {
                     $attributes_set = $producthelper->getProductAttribute(0, $rs[$i]->attribute_set_id, 0, 1);
                 }
                 $attributes = $producthelper->getProductAttribute($rs[$i]->product_id);
                 $attributes = array_merge($attributes, $attributes_set);
                 $totalatt = count($attributes);
                 // Get stock details
                 $isStockExists = $stockroomhelper->isStockExists($rs[$i]->product_id);
                 if ($totalatt > 0 && !$isStockExists) {
                     $isStockExists = $stockroomhelper->isAttributeStockExists($product_id);
                 }
                 $isPreorderStockExists = $stockroomhelper->isPreorderStockExists($product_id);
                 if ($totalatt > 0 && !$isPreorderStockExists) {
                     $isPreorderStockExists = $stockroomhelper->isAttributePreorderStockExists($product_id);
                 }
                 if (!$isStockExists) {
                     $product_preorder = $rs[$i]->preorder;
                     if ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes" || $product_preorder == "" && ALLOW_PRE_ORDER) {
                         if (!$isPreorderStockExists) {
                             $product_status = JText::_('COM_REDSHOP_OUT_OF_STOCK');
                         } else {
                             $product_status = JText::_('COM_REDSHOP_PREORDER');
                         }
                     } else {
                         $product_status = JText::_('COM_REDSHOP_OUT_OF_STOCK');
                     }
                 } else {
                     $product_status = JText::_('COM_REDSHOP_AVAILABLE_FOR_ORDER');
                 }
             } else {
                 $product_status = JText::_('COM_REDSHOP_AVAILABLE_FOR_ORDER');
             }
             $product_on_sale = 0;
             if ($rs[$i]->product_on_sale == 1 && ($rs[$i]->discount_stratdate == 0 && $rs[$i]->discount_enddate == 0 || $rs[$i]->discount_stratdate <= time() && $rs[$i]->discount_enddate >= time())) {
                 $product_on_sale = 1;
             }
             // For price and vat settings
             $product_price = $rs[$i]->product_price;
             $discount_price = $rs[$i]->discount_price;
             $sale_price = $product_on_sale == 1 ? $discount_price : $product_price;
             $price_vat = $producthelper->getGoogleVatRates($rs[$i]->product_id, $product_price, USE_TAX_EXEMPT);
             $sale_price_vat = $producthelper->getGoogleVatRates($rs[$i]->product_id, $sale_price, USE_TAX_EXEMPT);
             if (DEFAULT_VAT_COUNTRY != "USA") {
                 $product_price = $rs[$i]->product_price + $price_vat;
                 $sale_price = $sale_price + $sale_price_vat;
             }
             $product_price = $currency->convert(number_format($product_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $discount_price = $currency->convert(number_format($discount_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $sale_price = $currency->convert(number_format($sale_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $price_vat = $currency->convert(number_format($price_vat, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $product_url = $url . "index.php?option=com_redshop&amp;view=product&amp;pid=" . $rs[$i]->product_id;
             $xml_code .= "\n<item>";
             $xml_code .= "\n<g:id>" . htmlspecialchars($rs[$i]->product_id, ENT_NOQUOTES, "UTF-8") . "</g:id>";
             $xml_code .= "\n<title>" . htmlspecialchars($rs[$i]->product_name, ENT_NOQUOTES, "UTF-8") . "</title>";
             $xml_code .= "\n<description>'" . htmlspecialchars($rs[$i]->product_s_desc, ENT_NOQUOTES, "UTF-8") . "'</description>";
             $xml_code .= "\n<g:product_type>'" . htmlspecialchars($category_name, ENT_NOQUOTES, "UTF-8") . "'</g:product_type>";
             $xml_code .= "\n<link>" . htmlspecialchars($product_url, ENT_NOQUOTES, "UTF-8") . "</link>";
             $xml_code .= "\n<g:image_link>" . $product_img_url . htmlspecialchars($rs[$i]->product_full_image, ENT_NOQUOTES, "UTF-8") . "</g:image_link>";
             $xml_code .= "\n<g:brand>" . htmlspecialchars($rs[$i]->manufacturer_name, ENT_NOQUOTES, "UTF-8") . "</g:brand>";
             $xml_code .= "\n<g:condition>New</g:condition>";
             $xml_code .= "\n<g:availability>" . $product_status . "</g:availability>";
             $xml_code .= "\n<g:price>" . $product_price . " " . CURRENCY_CODE . "</g:price>";
             $xml_code .= "\n<g:sale_price>" . $sale_price . " " . CURRENCY_CODE . "</g:sale_price>";
             if ($product_on_sale == 1) {
                 $discount_start_date = date("c", $rs[$i]->discount_stratdate);
                 $discount_end_date = date("c", $rs[$i]->discount_enddate);
                 $xml_code .= "\n<g:sale_price_effective_date>" . $discount_start_date . "/" . $discount_end_date . "</g:sale_price_effective_date>";
             }
             $xml_code .= "\n<g:mpn>" . htmlspecialchars($rs[$i]->product_number, ENT_NOQUOTES, "UTF-8") . "</g:mpn>";
             if (DEFAULT_VAT_COUNTRY == "USA" || DEFAULT_VAT_COUNTRY == "GBR") {
                 $xml_code .= "\n<g:delivery>\r\n\t\t\t\t\t\t<g:country>" . DEFAULT_SHIPPING_COUNTRY . "</g:country>\r\n\t\t\t\t\t    <g:price>" . $default_shipping . " " . CURRENCY_CODE . "</g:price>\r\n\t\t\t\t\t</g:delivery>";
                 if ($rs[$i]->weight != 0) {
                     $xml_code .= "\n<g:delivery_weight>" . $rs[$i]->weight . " " . DEFAULT_WEIGHT_UNIT . "</g:delivery_weight>";
                 }
             } else {
                 $xml_code .= "\n<g:shipping>\r\n\t\t\t\t\t\t<g:country>" . DEFAULT_SHIPPING_COUNTRY . "</g:country>\r\n\t\t\t\t\t    <g:price>" . $default_shipping . " " . CURRENCY_CODE . "</g:price>\r\n\t\t\t\t\t</g:shipping>";
                 if ($rs[$i]->weight != 0) {
                     $xml_code .= "\n<g:shipping_weight>" . $rs[$i]->weight . " " . DEFAULT_WEIGHT_UNIT . "</g:shipping_weight>";
                 }
             }
             if (DEFAULT_VAT_COUNTRY == "USA") {
                 $xml_code .= "\n<g:tax>\r\n\t\t\t\t\t\t\t\t   <g:country>US</g:country>\r\n\t\t\t\t\t\t\t\t   <g:rate>" . $price_vat . "</g:rate>\r\n\t\t\t\t\t\t\t  </g:tax>";
             }
             $xml_code .= "\n" . $add_image;
             $xml_code .= "\n</item>";
         }
         $xml_code .= '</channel>';
         $xml_code .= '</rss>';
         $fp = fopen($file_name, "w");
         fwrite($fp, $xml_code);
         fclose($fp);
         if (!file_exists($file_name)) {
             return false;
         } else {
             return true;
         }
     }
     return false;
 }
Example #7
0
require_once JPATH_COMPONENT_SITE . '/helpers/product.php';
$producthelper = new producthelper();
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/order.php';
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/shipping.php';
require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/stockroom.php';
global $context;
$app = JFactory::getApplication();
$order_function = new order_functions();
$config = new Redconfiguration();
$option = JRequest::getVar('option');
$filter = $app->getUserStateFromRequest($context . 'filter', 'filter', 0);
$lists = $this->lists;
$model = $this->getModel('order');
$redhelper = new redhelper();
$shippinghelper = new shipping();
$stockroomhelper = new rsstockroomhelper();
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('redshop_product');
?>

<script language="javascript" type="text/javascript">
	Joomla.submitbutton = function (pressbutton)
	{
		submitbutton(pressbutton);
	}

	submitbutton = function (pressbutton)
	{
		var form = document.adminForm;
		if (pressbutton)
		{
 public function store($data)
 {
     $extra_field = new extra_field();
     $quotationHelper = new quotationHelper();
     $producthelper = new producthelper();
     $rsCarthelper = new rsCarthelper();
     $stockroomhelper = new rsstockroomhelper();
     $extra_field->extra_field_save($data, 16, $data['user_info_id'], $data['user_email']);
     $row = $this->getTable('quotation_detail');
     if ($data['quotation_discount'] > 0) {
         $data['order_total'] = $data['order_total'] - $data['quotation_discount'] - $data['order_total'] * $data['quotation_special_discount'] / 100;
     }
     $data['quotation_number'] = $quotationHelper->generateQuotationNumber();
     $data['quotation_encrkey'] = $quotationHelper->randomQuotationEncrkey();
     $data['quotation_cdate'] = time();
     $data['quotation_mdate'] = time();
     $data['quotation_total'] = $data['order_total'];
     $data['quotation_subtotal'] = $data['order_subtotal'];
     $data['quotation_tax'] = $data['order_tax'];
     $data['quotation_ipaddress'] = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown';
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $row->quotation_status = 2;
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $quotation_item = array();
     $user_id = $row->user_id;
     $item = $data['order_item'];
     for ($i = 0; $i < count($item); $i++) {
         $product_id = $item[$i]->product_id;
         $quantity = $item[$i]->quantity;
         $product_excl_price = $item[$i]->prdexclprice;
         $product_price = $item[$i]->productprice;
         // Attribute price added
         $generateAttributeCart = $rsCarthelper->generateAttributeArray((array) $item[$i], $user_id);
         $retAttArr = $producthelper->makeAttributeCart($generateAttributeCart, $product_id, $user_id, 0, $quantity);
         $product_attribute = $retAttArr[0];
         // Accessory price
         $generateAccessoryCart = $rsCarthelper->generateAccessoryArray((array) $item[$i], $user_id);
         $retAccArr = $producthelper->makeAccessoryCart($generateAccessoryCart, $product_id, $user_id);
         $product_accessory = $retAccArr[0];
         $wrapper_price = 0;
         $wrapper_vat = 0;
         $wrapper = $producthelper->getWrapper($product_id, $item[$i]->wrapper_data);
         if (count($wrapper) > 0) {
             if ($wrapper[0]->wrapper_price > 0) {
                 $wrapper_vat = $producthelper->getProducttax($product_id, $wrapper[0]->wrapper_price, $user_id);
             }
             $wrapper_price = $wrapper[0]->wrapper_price + $wrapper_vat;
         }
         $rowitem =& $this->getTable('quotation_item_detail');
         $product = $producthelper->getProductById($product_id);
         $quotation_item[$i]->quotation_id = $row->quotation_id;
         $quotation_item[$i]->product_id = $product_id;
         $quotation_item[$i]->is_giftcard = 0;
         $quotation_item[$i]->product_name = $product->product_name;
         $quotation_item[$i]->actualitem_price = $product_price;
         $quotation_item[$i]->product_price = $product_price;
         $quotation_item[$i]->product_excl_price = $product_excl_price;
         $quotation_item[$i]->product_final_price = $product_price * $quantity;
         $quotation_item[$i]->product_attribute = $product_attribute;
         $quotation_item[$i]->product_accessory = $product_accessory;
         $quotation_item[$i]->product_wrapperid = $item[$i]->wrapper_data;
         $quotation_item[$i]->wrapper_price = $wrapper_price;
         $quotation_item[$i]->product_quantity = $quantity;
         if (!$rowitem->bind($quotation_item[$i])) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         if (!$rowitem->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // Store userfields
         $userfields = JRequest::getVar('extrafields' . $product_id);
         $userfields_id = JRequest::getVar('extrafields_id_' . $product_id);
         for ($ui = 0; $ui < count($userfields); $ui++) {
             $quotationHelper->insertQuotationUserfield($userfields_id[$ui], $rowitem->quotation_item_id, 12, $userfields[$ui]);
         }
         /** my accessory save in table start */
         if (count($generateAccessoryCart) > 0) {
             $attArr = $generateAccessoryCart;
             for ($a = 0; $a < count($attArr); $a++) {
                 $accessory_vat_price = 0;
                 $accessory_attribute = "";
                 $accessory_id = $attArr[$a]['accessory_id'];
                 $accessory_name = $attArr[$a]['accessory_name'];
                 $accessory_price = $attArr[$a]['accessory_price'];
                 $accessory_org_price = $accessory_price;
                 if ($accessory_price > 0) {
                     $accessory_vat_price = $producthelper->getProductTax($rowitem->product_id, $accessory_price, $user_id);
                 }
                 $attchildArr = $attArr[$a]['accessory_childs'];
                 for ($j = 0; $j < count($attchildArr); $j++) {
                     $attribute_id = $attchildArr[$j]['attribute_id'];
                     $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>";
                     $rowattitem =& $this->getTable('quotation_attribute_item');
                     $rowattitem->quotation_att_item_id = 0;
                     $rowattitem->quotation_item_id = $rowitem->quotation_item_id;
                     $rowattitem->section_id = $attribute_id;
                     $rowattitem->section = "attribute";
                     $rowattitem->parent_section_id = $accessory_id;
                     $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                     $rowattitem->is_accessory_att = 1;
                     if ($attribute_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $propArr = $attchildArr[$j]['attribute_childs'];
                     for ($k = 0; $k < count($propArr); $k++) {
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price'], $user_id);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>";
                         $subpropArr = $propArr[$k]['property_childs'];
                         $rowattitem =& $this->getTable('quotation_attribute_item');
                         $rowattitem->quotation_att_item_id = 0;
                         $rowattitem->quotation_item_id = $rowitem->quotation_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 1;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>";
                             $rowattitem =& $this->getTable('quotation_attribute_item');
                             $rowattitem->quotation_att_item_id = 0;
                             $rowattitem->quotation_item_id = $rowitem->quotation_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 1;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                 }
                 $accdata =& $this->getTable('accessory_detail');
                 if ($accessory_id > 0) {
                     $accdata->load($accessory_id);
                 }
                 $accProductinfo = $producthelper->getProductById($accdata->child_product_id);
                 $rowaccitem =& $this->getTable('quotation_accessory_item');
                 $rowaccitem->quotation_item_acc_id = 0;
                 $rowaccitem->quotation_item_id = $rowitem->quotation_item_id;
                 $rowaccitem->accessory_id = $accessory_id;
                 $rowaccitem->accessory_item_sku = $accProductinfo->product_number;
                 $rowaccitem->accessory_item_name = $accessory_name;
                 $rowaccitem->accessory_price = $accessory_org_price;
                 $rowaccitem->accessory_vat = $accessory_vat_price;
                 $rowaccitem->accessory_quantity = $rowitem->product_quantity;
                 $rowaccitem->accessory_item_price = $accessory_price;
                 $rowaccitem->accessory_final_price = $accessory_price * $rowitem->product_quantity;
                 $rowaccitem->accessory_attribute = $accessory_attribute;
                 if ($accessory_id > 0) {
                     if (!$rowaccitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
             }
         }
         /** my attribute save in table start */
         if (count($generateAttributeCart) > 0) {
             $attArr = $generateAttributeCart;
             for ($j = 0; $j < count($attArr); $j++) {
                 $attribute_id = $attArr[$j]['attribute_id'];
                 $rowattitem =& $this->getTable('quotation_attribute_item');
                 $rowattitem->quotation_att_item_id = 0;
                 $rowattitem->quotation_item_id = $rowitem->quotation_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $rowitem->product_id;
                 $rowattitem->section_name = $attArr[$j]['attribute_name'];
                 $rowattitem->is_accessory_att = 0;
                 if ($attribute_id > 0) {
                     if (!$rowattitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
                 $propArr = $attArr[$j]['attribute_childs'];
                 for ($k = 0; $k < count($propArr); $k++) {
                     $section_vat = 0;
                     if ($propArr[$k]['property_price'] > 0) {
                         $section_vat = $producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price'], $user_id);
                     }
                     $property_id = $propArr[$k]['property_id'];
                     /** product property STOCKROOM update start */
                     $stockroomhelper->updateStockroomQuantity($property_id, $rowitem->product_quantity, "property");
                     $rowattitem =& $this->getTable('quotation_attribute_item');
                     $rowattitem->quotation_att_item_id = 0;
                     $rowattitem->quotation_item_id = $rowitem->quotation_item_id;
                     $rowattitem->section_id = $property_id;
                     $rowattitem->section = "property";
                     $rowattitem->parent_section_id = $attribute_id;
                     $rowattitem->section_name = $propArr[$k]['property_name'];
                     $rowattitem->section_price = $propArr[$k]['property_price'];
                     $rowattitem->section_vat = $section_vat;
                     $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                     $rowattitem->is_accessory_att = 0;
                     if ($property_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $subpropArr = $propArr[$k]['property_childs'];
                     for ($l = 0; $l < count($subpropArr); $l++) {
                         $section_vat = 0;
                         if ($subpropArr[$l]['subproperty_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                         }
                         $subproperty_id = $subpropArr[$l]['subproperty_id'];
                         /** product subproperty STOCKROOM update start */
                         $stockroomhelper->updateStockroomQuantity($subproperty_id, $rowitem->product_quantity, "subproperty");
                         $rowattitem = $this->getTable('quotation_attribute_item');
                         $rowattitem->quotation_att_item_id = 0;
                         $rowattitem->quotation_item_id = $rowitem->quotation_item_id;
                         $rowattitem->section_id = $subproperty_id;
                         $rowattitem->section = "subproperty";
                         $rowattitem->parent_section_id = $property_id;
                         $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                         $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                         $rowattitem->is_accessory_att = 0;
                         if ($subproperty_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $row;
 }
Example #9
0
 public function orderplace()
 {
     $app = JFactory::getApplication();
     $redconfig = new Redconfiguration();
     $quotationHelper = new quotationHelper();
     $stockroomhelper = new rsstockroomhelper();
     $helper = new redhelper();
     $shippinghelper = new shipping();
     $order_functions = new order_functions();
     $post = JRequest::get('post');
     $option = JRequest::getVar('option', 'com_redshop');
     $Itemid = JRequest::getVar('Itemid');
     $shop_id = JRequest::getVar('shop_id');
     $gls_mobile = JRequest::getVar('gls_mobile');
     $customer_message = JRequest::getVar('rs_customer_message_ta');
     $referral_code = JRequest::getVar('txt_referral_code');
     if ($gls_mobile) {
         $shop_id = $shop_id . '###' . $gls_mobile;
     }
     $user = JFactory::getUser();
     $session = JFactory::getSession();
     $auth = $session->get('auth');
     if (!$user->id && $auth['users_info_id']) {
         $user->id = -$auth['users_info_id'];
     }
     $db = JFactory::getDbo();
     $issplit = $session->get('issplit');
     $url = JURI::root();
     // If user subscribe for the newsletter
     if (isset($post['newsletter_signup']) && $post['newsletter_signup'] == 1) {
         $this->_userhelper->newsletterSubscribe();
     }
     // If user unsubscribe for the newsletter
     if (isset($post['newsletter_signoff']) && $post['newsletter_signoff'] == 1) {
         $this->_userhelper->newsletterUnsubscribe();
     }
     $order_paymentstatus = 'Unpaid';
     $objshipping = new shipping();
     $users_info_id = JRequest::getInt('users_info_id');
     $thirdparty_email = JRequest::getVar('thirdparty_email');
     $shippingaddresses = $this->shipaddress($users_info_id);
     $billingaddresses = $this->billingaddresses();
     if (isset($shippingaddresses)) {
         $d["shippingaddress"] = $shippingaddresses;
         $d["shippingaddress"]->country_2_code = $redconfig->getCountryCode2($d["shippingaddress"]->country_code);
         $d["shippingaddress"]->state_2_code = $redconfig->getStateCode2($d["shippingaddress"]->state_code);
         $shippingaddresses->country_2_code = $d["shippingaddress"]->country_2_code;
         $shippingaddresses->state_2_code = $d["shippingaddress"]->state_2_code;
     }
     if (isset($billingaddresses)) {
         $d["billingaddress"] = $billingaddresses;
         if (isset($billingaddresses->country_code)) {
             $d["billingaddress"]->country_2_code = $redconfig->getCountryCode2($billingaddresses->country_code);
             $billingaddresses->country_2_code = $d["billingaddress"]->country_2_code;
         }
         if (isset($billingaddresses->state_code)) {
             $d["billingaddress"]->state_2_code = $redconfig->getStateCode2($billingaddresses->state_code);
             $billingaddresses->state_2_code = $d["billingaddress"]->state_2_code;
         }
     }
     $cart = $session->get('cart');
     if ($cart['idx'] < 1) {
         $msg = JText::_('COM_REDSHOP_EMPTY_CART');
         $app->Redirect('index.php?option=' . $option . '&Itemid=' . $Itemid, $msg);
     }
     $ccdata = $session->get('ccdata');
     $shipping_rate_id = '';
     if ($cart['free_shipping'] != 1) {
         $shipping_rate_id = JRequest::getVar('shipping_rate_id');
     }
     $payment_method_id = JRequest::getVar('payment_method_id');
     $ccinfo = JRequest::getVar('ccinfo');
     if ($shipping_rate_id && $cart['free_shipping'] != 1) {
         $shipArr = $this->calculateShipping($shipping_rate_id);
         $cart['shipping'] = $shipArr['order_shipping_rate'];
         $cart['shipping_vat'] = $shipArr['shipping_vat'];
     }
     $cart = $this->_carthelper->modifyDiscount($cart);
     $paymentinfo = $this->_order_functions->getPaymentMethodInfo($payment_method_id);
     $paymentinfo = $paymentinfo[0];
     $paymentparams = new JRegistry($paymentinfo->params);
     $paymentinfo = new stdclass();
     $paymentinfo->payment_price = $paymentparams->get('payment_price', '');
     $paymentinfo->payment_oprand = $paymentparams->get('payment_oprand', '');
     $paymentinfo->payment_discount_is_percent = $paymentparams->get('payment_discount_is_percent', '');
     if (PAYMENT_CALCULATION_ON == 'subtotal') {
         $paymentAmount = $cart['product_subtotal'];
     } else {
         $paymentAmount = $cart['total'];
     }
     $paymentArray = $this->_carthelper->calculatePayment($paymentAmount, $paymentinfo, $cart['total']);
     $cart['total'] = $paymentArray[0];
     $cart = $session->set('cart', $cart);
     $cart = $session->get('cart');
     $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $shipping_rate_id)));
     $order_status = 'P';
     $order_status_full = $this->_order_functions->getOrderStatusTitle('P');
     // Start code to track duplicate order number checking by parth
     $order_number = $this->getOrdernumber();
     // End code to track duplicate order number checking by parth
     $order_subtotal = $cart['product_subtotal'];
     $cdiscount = $cart['coupon_discount'];
     $order_tax = $cart['tax'];
     $d['order_tax'] = $order_tax;
     $tax_after_discount = 0;
     if (isset($cart['tax_after_discount'])) {
         $tax_after_discount = $cart['tax_after_discount'];
     }
     $odiscount = $cart['coupon_discount'] + $cart['voucher_discount'] + $cart['cart_discount'];
     $odiscount_vat = $cart['discount_vat'];
     $d["order_payment_trans_id"] = '';
     $d['discount'] = $odiscount;
     $order_total = $cart['total'];
     if ($issplit) {
         $order_total = $order_total / 2;
     }
     JRequest::setVar('order_ship', $order_shipping[3]);
     $paymentmethod = $this->_order_functions->getPaymentMethodInfo($payment_method_id);
     $paymentmethod = $paymentmethod[0];
     $mainelement = $paymentmethod->element;
     if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_banktransfer2" || $paymentmethod->element == "rs_payment_banktransfer3" || $paymentmethod->element == "rs_payment_banktransfer4" || $paymentmethod->element == "rs_payment_banktransfer5" || $paymentmethod->element == "rs_payment_cashtransfer" || $paymentmethod->element == "rs_payment_cashsale" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_eantransfer") {
         $paymentmethod = $order_functions->getPaymentMethodInfo($paymentmethod->element);
         $paymentmethod = $paymentmethod[0];
         $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml';
         $paymentparams = new JRegistry($paymentmethod->params);
         $order_main_status = $paymentparams->get('verify_status', '');
         if ($paymentmethod->element != "rs_payment_banktransfer" && $paymentmethod->element != "rs_payment_cashtransfer" && $paymentmethod->element != "rs_payment_cashsale" && $paymentmethod->element != "rs_payment_banktransfer_discount" && $paymentmethod->element != "rs_payment_eantransfer") {
             $paymentmethod->element = substr($paymentmethod->element, 0, -1);
         }
     }
     if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_cashtransfer" || $paymentmethod->element == "rs_payment_cashsale" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_eantransfer") {
         $order_status = $order_main_status;
         if ($issplit) {
             $order_paymentstatus = trim("Partial Paid");
         } else {
             $order_paymentstatus = trim("Unpaid");
         }
         $order_status_full = $this->_order_functions->getOrderStatusTitle($order_main_status);
     }
     $paymentmethod->element = $mainelement;
     $payment_amount = 0;
     if (isset($cart['payment_amount'])) {
         $payment_amount = $cart['payment_amount'];
     }
     $payment_oprand = "";
     if (isset($cart['payment_oprand'])) {
         $payment_oprand = $cart['payment_oprand'];
     }
     $xmlpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml';
     $params = new JRegistry($paymentmethod->params, $xmlpath);
     $economic_payment_terms_id = $params->get('economic_payment_terms_id');
     $economic_design_layout = $params->get('economic_design_layout');
     $is_creditcard = $params->get('is_creditcard', '');
     $is_redirected = $params->get('is_redirected', 0);
     JRequest::setVar('payment_status', $order_paymentstatus);
     $d['order_shipping'] = $order_shipping[3];
     $GLOBALS['billingaddresses'] = $billingaddresses;
     $timestamp = time();
     // Get the IP Address
     if (!empty($_SERVER['REMOTE_ADDR'])) {
         $ip = $_SERVER['REMOTE_ADDR'];
     } else {
         $ip = 'unknown';
     }
     $row = $this->getTable('order_detail');
     if (!$row->bind($post)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $shippingVatRate = 0;
     if (array_key_exists(6, $order_shipping)) {
         $shippingVatRate = $order_shipping[6];
     }
     $random_gen_enc_key = $this->_order_functions->random_gen_enc_key(35);
     $users_info_id = $billingaddresses->users_info_id;
     $row->user_id = $user->id;
     $row->order_number = $order_number;
     $row->user_info_id = $users_info_id;
     $row->order_total = $order_total;
     $row->order_subtotal = $order_subtotal;
     $row->order_tax = $order_tax;
     $row->tax_after_discount = $tax_after_discount;
     $row->order_tax_details = '';
     $row->analytics_status = 0;
     $row->order_shipping = $order_shipping[3];
     $row->order_shipping_tax = $shippingVatRate;
     $row->coupon_discount = $cdiscount;
     $row->shop_id = $shop_id;
     $row->customer_message = $customer_message;
     $row->referral_code = $referral_code;
     $db = JFactory::getDbo();
     $dispatcher = JDispatcher::getInstance();
     $order_status_log = '';
     // For credit card payment gateway page will redirect to order detail page from plugin
     if ($is_creditcard == 1 && $is_redirected == 1) {
         $redirect_ccdata = $session->set('redirect_ccdata', $ccdata);
     }
     if ($is_creditcard == 1 && $is_redirected == 0 && $cart['total'] > 0) {
         JPluginHelper::importPlugin('redshop_payment');
         $values['order_shipping'] = $d['order_shipping'];
         $values['order_number'] = $order_number;
         $values['order_tax'] = $d['order_tax'];
         $values['shippinginfo'] = $d['shippingaddress'];
         $values['billinginfo'] = $d['billingaddress'];
         $values['order_total'] = $order_total;
         $values['order_subtotal'] = $order_subtotal;
         $values["order_id"] = $order_id;
         $values['payment_plugin'] = $paymentmethod->element;
         $values['odiscount'] = $odiscount;
         $paymentResponses = $dispatcher->trigger('onPrePayment_' . $values['payment_plugin'], array($values['payment_plugin'], $values));
         $paymentResponse = $paymentResponses[0];
         if ($paymentResponse->responsestatus == "Success") {
             $d["order_payment_trans_id"] = $paymentResponse->transaction_id;
             $order_status_log = $paymentResponse->message;
             $order_status = 'C';
             $order_paymentstatus = 'Paid';
         } else {
             if ($values['payment_plugin'] != 'rs_payment_localcreditcard') {
                 $errorMsg = $paymentResponse->message;
                 $this->setError($errorMsg);
                 return false;
             }
         }
     }
     if ($order_total <= 0) {
         $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml';
         $paymentparams = new JRegistry($paymentmethod->params);
         $order_main_status = $paymentparams->get('verify_status', '');
         $order_status = $order_main_status;
         $order_paymentstatus = 'Paid';
     }
     if (USE_AS_CATALOG) {
         $order_status = 'P';
         $order_paymentstatus = 'Unpaid';
     }
     // For barcode generation
     $barcode_code = $order_functions->barcode_randon_number(12, 0);
     // End
     $row->order_discount = $odiscount;
     $row->order_discount_vat = $odiscount_vat;
     $row->payment_discount = $payment_amount;
     $row->payment_oprand = $payment_oprand;
     $row->order_status = $order_status;
     $row->order_payment_status = $order_paymentstatus;
     $row->cdate = $timestamp;
     $row->mdate = $timestamp;
     $row->ship_method_id = $shipping_rate_id;
     $row->customer_note = $post['customer_note'];
     $row->requisition_number = $post['requisition_number'];
     $row->ip_address = $ip;
     $row->encr_key = $random_gen_enc_key;
     $row->split_payment = $issplit;
     $row->discount_type = $this->discount_type;
     $row->order_id = JRequest::getVar('order_id', $row->order_id);
     $row->barcode = $barcode_code;
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         // Start code to track duplicate order number checking by parth
         $this->deleteOrdernumberTrack();
         // End code to track duplicate order number checking by parth
         return false;
     }
     // Start code to track duplicate order number checking by parth
     $this->deleteOrdernumberTrack();
     // End code to track duplicate order number checking by parth
     $order_id = $row->order_id;
     $this->coupon($cart, $order_id);
     $this->voucher($cart, $order_id);
     $query = "UPDATE `#__redshop_orders` SET discount_type = " . $db->quote($this->discount_type) . " where order_id = " . (int) $order_id;
     $db->setQuery($query);
     $db->query();
     if (SHOW_TERMS_AND_CONDITIONS == 1 && isset($post['termscondition']) && $post['termscondition'] == 1) {
         $this->_userhelper->updateUserTermsCondition($users_info_id, 1);
     }
     // Place order id in quotation table if it Quotation
     if (array_key_exists("quotation_id", $cart) && $cart['quotation_id']) {
         $quotationHelper->updateQuotationwithOrder($cart['quotation_id'], $row->order_id);
     }
     if ($row->order_status == CLICKATELL_ORDER_STATUS) {
         $helper->clickatellSMS($order_id);
     }
     $session->set('order_id', $order_id);
     // Add order status log
     $rowOrderStatus = $this->getTable('order_status_log');
     $rowOrderStatus->order_id = $order_id;
     $rowOrderStatus->order_status = $order_status;
     $rowOrderStatus->date_changed = time();
     $rowOrderStatus->customer_note = $order_status_log;
     $rowOrderStatus->store();
     $country_name = $this->_order_functions->getCountryName($billingaddresses->country_code);
     $state_name = $this->_order_functions->getStateName($billingaddresses->state_code, $billingaddresses->country_code);
     JRequest::setVar('order_id', $row->order_id);
     JRequest::setVar('order_number', $row->order_number);
     if (!isset($order_shipping[5])) {
         $order_shipping[5] = "";
     }
     if ($order_shipping[5] == 'regular') {
         $regDel = $objshipping->getRegularDelivery();
         JRequest::setVar('order_delivery', "Delivered in one instance � DELIVERY TIME: " . current($regDel) . " weeks</td>");
     } elseif ($order_shipping[5] == 'split') {
         $delArray = $objshipping->getProductDeliveryArray($shipping_rate_id);
         $splitdel = $objshipping->getSplitDelivery();
         if (count($splitdel) > 1) {
             $split1 = $splitdel[0];
             $split2 = $splitdel[1];
             $prods1 = '';
             $prods2 = '';
             for ($i = 0; $i < count($split1); $i++) {
                 $value = current($split1);
                 $deltime1 = $value;
                 $key = key($split1);
                 $product = $this->_producthelper->getProductById($key, "product_name");
                 $prods1 .= $product->product_name . ',';
                 next($split1);
             }
             for ($i = 0; $i < count($split2); $i++) {
                 $value = current($split2);
                 $deltime2 = $value;
                 $key = key($split2);
                 $product = $this->_producthelper->getProductById($key, "product_name");
                 $prods2 .= $product->product_name . ',';
                 next($split2);
             }
             $prods1 = trim($prods1, ",");
             $prods2 = trim($prods2, ",");
         }
         JRequest::setVar('order_delivery', "Delivered over two instances for " . SPLIT_DELIVERY_COST . "kr extra    DELIVERY TIME: " . $deltime1 . " Weeks for " . $prods1 . "   AND   " . $deltime2 . " Weeks for " . $prods2 . " ");
     } else {
         $delArray = $objshipping->getProductDeliveryArray($shipping_rate_id);
         $splitdel = $objshipping->getSplitDelivery();
         $split1 = $splitdel[0];
         $value = current($split1);
         $product_delivery_time = $this->_producthelper->getProductMinDeliveryTime($cart[0]['product_id']);
         JRequest::setVar('order_delivery', $product_delivery_time);
     }
     $idx = $cart['idx'];
     $product_name = "";
     $product_note = "";
     $product_price = "";
     $product_quantity = "";
     $product_total_price = "";
     for ($i = 0; $i < $idx; $i++) {
         // GiftCARD start
         $is_giftcard = 0;
         $giftcard_price = 0;
         $giftcard_name = 0;
         // GiftCARD end
         $product_id = $cart[$i]['product_id'];
         $product = $this->_producthelper->getProductById($product_id);
         $rowitem = $this->getTable('order_item_detail');
         // The redCRM product purchase price
         if ($helper->isredCRM()) {
             $crmProductHelper = new crmProductHelper();
             $crmproduct = $crmProductHelper->getProductById($product_id);
             $rowitem->product_purchase_price = $crmproduct->product_purchase_price > 0 ? $crmproduct->product_purchase_price : $crmproduct->product_price;
             $crmdata = array();
             $crmDebitorHelper = new crmDebitorHelper();
             $crmDebitorHelper_values = $crmDebitorHelper->getShippingDestination(0, 0, $shippingaddresses->users_info_id);
             if ($session->get('isredcrmuser')) {
                 $crmDebitorHelper_contact_values = $crmDebitorHelper->getContactPersons(0, 0, 0, $user->id, 0);
             } else {
                 $crmDebitorHelper_contact_values = $crmDebitorHelper->getContactPersons(0, 0, 0, 0, $crmDebitorHelper_values[0]->shipping_id);
             }
             $crmdata['order_id'] = JRequest::getVar('order_id', $row->order_id);
             $crmdata['debitor_id'] = $shippingaddresses->users_info_id;
             $crmdata['custom_status'] = '';
             $crmdata['rma_number'] = '';
             if (count($crmDebitorHelper_values) > 0) {
                 $crmdata['shipping_id'] = $crmDebitorHelper_values[0]->shipping_id;
             } else {
                 $crmdata['shipping_id'] = 0;
             }
             if (count($crmDebitorHelper_contact_values) > 0 && count($crmDebitorHelper_values) > 0) {
                 $crmdata['person_id'] = $crmDebitorHelper_contact_values[0]->person_id;
             } else {
                 $crmdata['person_id'] = 0;
             }
             $crmOrderHelper = new crmOrderHelper();
             $crmOrderHelper->storeCRMOrder($crmdata);
         }
         // End
         if (!$rowitem->bind($post)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         if ($order_shipping[5] == 'regular') {
             $rowitem->delivery_time = $regDel;
         } elseif ($order_shipping[5] == 'split') {
             $rowitem->delivery_time = $delArray[$product_id];
         } else {
             $rowitem->delivery_time = '';
         }
         if (isset($cart[$i]['giftcard_id']) && $cart[$i]['giftcard_id']) {
             $is_giftcard = 1;
         }
         // Product stockroom update
         if (!$is_giftcard) {
             $updatestock = $stockroomhelper->updateStockroomQuantity($product_id, $cart[$i]['quantity']);
             $stockroom_id_list = $updatestock['stockroom_list'];
             $stockroom_quantity_list = $updatestock['stockroom_quantity_list'];
             $rowitem->stockroom_id = $stockroom_id_list;
             $rowitem->stockroom_quantity = $stockroom_quantity_list;
         }
         // End product stockroom update
         $vals = explode('product_attributes/', $cart[$i]['hidden_attribute_cartimage']);
         if (!empty($cart[$i]['attributeImage']) && file_exists(JPATH_ROOT . '/components/com_redshop/assets/images/mergeImages/' . $cart[$i]['attributeImage'])) {
             $rowitem->attribute_image = $order_id . $cart[$i]['attributeImage'];
             $old_media = JPATH_ROOT . '/components/com_redshop/assets/images/mergeImages/' . $cart[$i]['attributeImage'];
             $new_media = JPATH_ROOT . '/components/com_redshop/assets/images/orderMergeImages' . $rowitem->attribute_image;
             copy($old_media, $new_media);
         } elseif (!empty($vals[1])) {
             $rowitem->attribute_image = $vals[1];
         }
         $wrapper_price = 0;
         if (@$cart[$i]['wrapper_id']) {
             $wrapper_price = $cart[$i]['wrapper_price'];
         }
         if ($is_giftcard == 1) {
             $giftcardData = $this->_producthelper->getGiftcardData($cart[$i]['giftcard_id']);
             $rowitem->product_id = $cart[$i]['giftcard_id'];
             $rowitem->order_item_name = $giftcardData->giftcard_name;
             $rowitem->product_item_old_price = $cart[$i]['product_price'];
         } else {
             $rowitem->product_id = $product_id;
             $rowitem->product_item_old_price = $cart[$i]['product_old_price'];
             $rowitem->supplier_id = $product->manufacturer_id;
             $rowitem->order_item_sku = $product->product_number;
             $rowitem->order_item_name = $product->product_name;
         }
         $rowitem->product_item_price = $cart[$i]['product_price'];
         $rowitem->product_quantity = $cart[$i]['quantity'];
         $rowitem->product_item_price_excl_vat = $cart[$i]['product_price_excl_vat'];
         $rowitem->product_final_price = $cart[$i]['product_price'] * $cart[$i]['quantity'];
         $rowitem->is_giftcard = $is_giftcard;
         $retAttArr = $this->_producthelper->makeAttributeCart($cart[$i]['cart_attribute'], $product_id, 0, 0, $cart[$i]['quantity']);
         $cart_attribute = $retAttArr[0];
         // For discount calc data
         $cart_calc_data = "";
         if (isset($cart[$i]['discount_calc_output'])) {
             $cart_calc_data = $cart[$i]['discount_calc_output'];
         }
         // End
         $retAccArr = $this->_producthelper->makeAccessoryCart($cart[$i]['cart_accessory'], $product_id);
         $cart_accessory = $retAccArr[0];
         $rowitem->order_id = $order_id;
         $rowitem->user_info_id = $users_info_id;
         $rowitem->order_item_currency = REDCURRENCY_SYMBOL;
         $rowitem->order_status = $order_status;
         $rowitem->cdate = $timestamp;
         $rowitem->mdate = $timestamp;
         $rowitem->product_attribute = $cart_attribute;
         $rowitem->discount_calc_data = $cart_calc_data;
         $rowitem->product_accessory = $cart_accessory;
         $rowitem->container_id = $objshipping->getProductContainerId($cart[$i]['product_id']);
         $rowitem->wrapper_price = $wrapper_price;
         if (!empty($cart[$i]['wrapper_id'])) {
             $rowitem->wrapper_id = $cart[$i]['wrapper_id'];
         }
         if (!empty($cart[$i]['reciver_email'])) {
             $rowitem->giftcard_user_email = $cart[$i]['reciver_email'];
         }
         if (!empty($cart[$i]['reciver_name'])) {
             $rowitem->giftcard_user_name = $cart[$i]['reciver_name'];
         }
         if ($this->_producthelper->checkProductDownload($rowitem->product_id)) {
             $medianame = $this->_producthelper->getProductMediaName($rowitem->product_id);
             for ($j = 0; $j < count($medianame); $j++) {
                 $product_serial_number = $this->_producthelper->getProdcutSerialNumber($rowitem->product_id);
                 $this->_producthelper->insertProductDownload($rowitem->product_id, $user->id, $rowitem->order_id, $medianame[$j]->media_name, $product_serial_number->serial_number);
             }
         }
         // Import files for plugin
         JPluginHelper::importPlugin('redshop_product');
         if (!$rowitem->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // Add plugin support
         $dispatcher->trigger('afterOrderItemSave', array($cart, $rowitem, $i));
         // End
         if (isset($cart[$i]['giftcard_id']) && $cart[$i]['giftcard_id']) {
             $section_id = 13;
         } else {
             $section_id = 12;
         }
         $this->_producthelper->insertProdcutUserfield($i, $cart, $rowitem->order_item_id, $section_id);
         // My accessory save in table start
         if (count($cart[$i]['cart_accessory']) > 0) {
             $setPropEqual = true;
             $setSubpropEqual = true;
             $attArr = $cart[$i]['cart_accessory'];
             for ($a = 0; $a < count($attArr); $a++) {
                 $accessory_vat_price = 0;
                 $accessory_attribute = "";
                 $accessory_id = $attArr[$a]['accessory_id'];
                 $accessory_name = $attArr[$a]['accessory_name'];
                 $accessory_price = $attArr[$a]['accessory_price'];
                 $accessory_quantity = $attArr[$a]['accessory_quantity'];
                 $accessory_org_price = $accessory_price;
                 if ($accessory_price > 0) {
                     $accessory_vat_price = $this->_producthelper->getProductTax($rowitem->product_id, $accessory_price);
                 }
                 $attchildArr = $attArr[$a]['accessory_childs'];
                 for ($j = 0; $j < count($attchildArr); $j++) {
                     $prooprand = array();
                     $proprice = array();
                     $attribute_id = $attchildArr[$j]['attribute_id'];
                     $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>";
                     $rowattitem = $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $attribute_id;
                     $rowattitem->section = "attribute";
                     $rowattitem->parent_section_id = $accessory_id;
                     $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                     $rowattitem->is_accessory_att = 1;
                     if ($attribute_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $propArr = $attchildArr[$j]['attribute_childs'];
                     for ($k = 0; $k < count($propArr); $k++) {
                         $prooprand[$k] = $propArr[$k]['property_oprand'];
                         $proprice[$k] = $propArr[$k]['property_price'];
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $this->_producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>";
                         $subpropArr = $propArr[$k]['property_childs'];
                         $rowattitem = $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 1;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $this->_producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>";
                             $rowattitem = $this->getTable('order_attribute_item');
                             $rowattitem->order_att_item_id = 0;
                             $rowattitem->order_item_id = $rowitem->order_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 1;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                     // FOR ACCESSORY PROPERTY AND SUBPROPERTY PRICE CALCULATION
                     if ($setPropEqual && $setSubpropEqual) {
                         $accessory_priceArr = $this->_producthelper->makeTotalPriceByOprand($accessory_price, $prooprand, $proprice);
                         $setPropEqual = $accessory_priceArr[0];
                         $accessory_price = $accessory_priceArr[1];
                     }
                     for ($t = 0; $t < count($propArr); $t++) {
                         $subprooprand = array();
                         $subproprice = array();
                         $subElementArr = $propArr[$t]['property_childs'];
                         for ($tp = 0; $tp < count($subElementArr); $tp++) {
                             $subprooprand[$tp] = $subElementArr[$tp]['subproperty_oprand'];
                             $subproprice[$tp] = $subElementArr[$tp]['subproperty_price'];
                         }
                         if ($setPropEqual && $setSubpropEqual) {
                             $accessory_priceArr = $this->_producthelper->makeTotalPriceByOprand($accessory_price, $subprooprand, $subproprice);
                             $setSubpropEqual = $accessory_priceArr[0];
                             $accessory_price = $accessory_priceArr[1];
                         }
                     }
                     // FOR ACCESSORY PROPERTY AND SUBPROPERTY PRICE CALCULATION
                 }
                 $accdata = $this->getTable('accessory_detail');
                 if ($accessory_id > 0) {
                     $accdata->load($accessory_id);
                 }
                 $accProductinfo = $this->_producthelper->getProductById($accdata->child_product_id);
                 $rowaccitem = $this->getTable('order_acc_item');
                 $rowaccitem->order_item_acc_id = 0;
                 $rowaccitem->order_item_id = $rowitem->order_item_id;
                 $rowaccitem->product_id = $accessory_id;
                 $rowaccitem->order_acc_item_sku = $accProductinfo->product_number;
                 $rowaccitem->order_acc_item_name = $accessory_name;
                 $rowaccitem->order_acc_price = $accessory_org_price;
                 $rowaccitem->order_acc_vat = $accessory_vat_price;
                 $rowaccitem->product_quantity = $accessory_quantity;
                 $rowaccitem->product_acc_item_price = $accessory_price;
                 $rowaccitem->product_acc_final_price = $accessory_price * $accessory_quantity;
                 $rowaccitem->product_attribute = $accessory_attribute;
                 if ($accessory_id > 0) {
                     if (!$rowaccitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
             }
         }
         // My attribute save in table start
         if (count($cart[$i]['cart_attribute']) > 0) {
             $attchildArr = $cart[$i]['cart_attribute'];
             for ($j = 0; $j < count($attchildArr); $j++) {
                 $attribute_id = $attchildArr[$j]['attribute_id'];
                 $rowattitem = $this->getTable('order_attribute_item');
                 $rowattitem->order_att_item_id = 0;
                 $rowattitem->order_item_id = $rowitem->order_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $rowitem->product_id;
                 $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                 $rowattitem->is_accessory_att = 0;
                 if ($attribute_id > 0) {
                     if (!$rowattitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
                 $propArr = $attchildArr[$j]['attribute_childs'];
                 if (count($propArr) > 0) {
                     for ($k = 0; $k < count($propArr); $k++) {
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         //  Product property STOCKROOM update start
                         $updatestock_att = $stockroomhelper->updateStockroomQuantity($property_id, $cart[$i]['quantity'], "property", $product_id);
                         $stockroom_att_id_list = $updatestock_att['stockroom_list'];
                         $stockroom_att_quantity_list = $updatestock_att['stockroom_quantity_list'];
                         $rowattitem = $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 0;
                         $rowattitem->stockroom_id = $stockroom_att_id_list;
                         $rowattitem->stockroom_quantity = $stockroom_att_quantity_list;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         $subpropArr = $propArr[$k]['property_childs'];
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             // Product subproperty STOCKROOM update start
                             $updatestock_subatt = $stockroomhelper->updateStockroomQuantity($subproperty_id, $cart[$i]['quantity'], "subproperty", $product_id);
                             $stockroom_subatt_id_list = $updatestock_subatt['stockroom_list'];
                             $stockroom_subatt_quantity_list = $updatestock_subatt['stockroom_quantity_list'];
                             $rowattitem = $this->getTable('order_attribute_item');
                             $rowattitem->order_att_item_id = 0;
                             $rowattitem->order_item_id = $rowitem->order_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 0;
                             $rowattitem->stockroom_id = $stockroom_subatt_id_list;
                             $rowattitem->stockroom_quantity = $stockroom_subatt_quantity_list;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Subtracting the products from the container. means decreasing stock
         if (USE_CONTAINER) {
             $this->_producthelper->updateContainerStock($product_id, $cart[$i]['quantity'], $rowitem->container_id);
         }
         // Subtracting the products from the container. means decreasing stock end
         // Store user product subscription detail
         if ($product->product_type == 'subscription') {
             $subscribe = $this->getTable('product_subscribe_detail');
             $subscription_detail = $this->_producthelper->getProductSubscriptionDetail($product_id, $cart[$i]['subscription_id']);
             $add_day = $subscription_detail->period_type == 'days' ? $subscription_detail->subscription_period : 0;
             $add_month = $subscription_detail->period_type == 'month' ? $subscription_detail->subscription_period : 0;
             $add_year = $subscription_detail->period_type == 'year' ? $subscription_detail->subscription_period : 0;
             $subscribe->order_id = $order_id;
             $subscribe->order_item_id = $rowitem->order_item_id;
             $subscribe->product_id = $product_id;
             $subscribe->subscription_id = $cart[$i]['subscription_id'];
             $subscribe->user_id = $user->id;
             $subscribe->start_date = time();
             $subscribe->end_date = mktime(0, 0, 0, date('m') + $add_month, date('d') + $add_day, date('Y') + $add_year);
             if (!$subscribe->store()) {
                 $this->setError($this->_db->getErrorMsg());
                 return false;
             }
         }
     }
     $rowpayment = $this->getTable('order_payment');
     if (!$rowpayment->bind($post)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $rowpayment->order_id = $order_id;
     $rowpayment->payment_method_id = $payment_method_id;
     if (!isset($ccdata['creditcard_code'])) {
         $ccdata['creditcard_code'] = 0;
     }
     if (!isset($ccdata['order_payment_number'])) {
         $ccdata['order_payment_number'] = 0;
     }
     if (!isset($ccdata['order_payment_expire_month'])) {
         $ccdata['order_payment_expire_month'] = 0;
     }
     if (!isset($ccdata['order_payment_expire_year'])) {
         $ccdata['order_payment_expire_year'] = 0;
     }
     $rowpayment->order_payment_code = $ccdata['creditcard_code'];
     $rowpayment->order_payment_cardname = base64_encode($ccdata['order_payment_name']);
     $rowpayment->order_payment_number = base64_encode($ccdata['order_payment_number']);
     // This is ccv code
     $rowpayment->order_payment_ccv = base64_encode($ccdata['credit_card_code']);
     $rowpayment->order_payment_amount = $order_total;
     $rowpayment->order_payment_expire = $ccdata['order_payment_expire_month'] . $ccdata['order_payment_expire_year'];
     $rowpayment->order_payment_name = $paymentmethod->name;
     $rowpayment->payment_method_class = $paymentmethod->element;
     $rowpayment->order_payment_trans_id = $d["order_payment_trans_id"];
     $rowpayment->authorize_status = "";
     if (!$rowpayment->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // For authorize status
     JPluginHelper::importPlugin('redshop_payment');
     $dispatcher = JDispatcher::getInstance();
     $data = $dispatcher->trigger('onAuthorizeStatus_' . $paymentmethod->element, array($paymentmethod->element, $order_id));
     $GLOBALS['shippingaddresses'] = $shippingaddresses;
     // Add billing Info
     $userrow = $this->getTable('user_detail');
     $userrow->load($billingaddresses->users_info_id);
     $userrow->thirdparty_email = $post['thirdparty_email'];
     $orderuserrow = $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $order_id;
     $orderuserrow->address_type = 'BT';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add shipping Info
     $userrow = $this->getTable('user_detail');
     if (isset($shippingaddresses->users_info_id)) {
         $userrow->load($shippingaddresses->users_info_id);
     }
     $orderuserrow = $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $order_id;
     $orderuserrow->address_type = 'ST';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $checkOrderStatus = 1;
     if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_banktransfer2" || $paymentmethod->element == "rs_payment_banktransfer3" || $paymentmethod->element == "rs_payment_banktransfer4" || $paymentmethod->element == "rs_payment_banktransfer5") {
         $checkOrderStatus = 0;
     }
     if (isset($cart['extrafields_values'])) {
         if (count($cart['extrafields_values']) > 0) {
             $this->_producthelper->insertPaymentShippingField($cart, $order_id, 18);
             $this->_producthelper->insertPaymentShippingField($cart, $order_id, 19);
         }
     }
     // Economic Integration start for invoice generate and book current invoice
     if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) {
         $economic = new economic();
         $economicdata['split_payment'] = $issplit;
         $economicdata['economic_payment_terms_id'] = $economic_payment_terms_id;
         $economicdata['economic_design_layout'] = $economic_design_layout;
         $economicdata['economic_is_creditcard'] = $is_creditcard;
         $payment_name = $paymentmethod->element;
         $paymentArr = explode("rs_payment_", $paymentmethod->element);
         if (count($paymentArr) > 0) {
             $payment_name = $paymentArr[1];
         }
         $economicdata['economic_payment_method'] = $payment_name;
         $invoiceHandle = $economic->createInvoiceInEconomic($row->order_id, $economicdata);
         if (ECONOMIC_INVOICE_DRAFT == 0) {
             $bookinvoicepdf = $economic->bookInvoiceInEconomic($row->order_id, $checkOrderStatus);
             if (is_file($bookinvoicepdf)) {
                 $ret = $this->_redshopMail->sendEconomicBookInvoiceMail($row->order_id, $bookinvoicepdf);
             }
         }
     }
     // End Economic
     // Send the Order mail before payment
     if (!ORDER_MAIL_AFTER || ORDER_MAIL_AFTER && $row->order_payment_status == "Paid") {
         $this->_redshopMail->sendOrderMail($row->order_id);
     } else {
         // If Order mail set to send after payment then send mail to administrator only.
         $this->_redshopMail->sendOrderMail($row->order_id, true);
     }
     if ($row->order_status == "C") {
         $this->_order_functions->SendDownload($row->order_id);
     }
     // RedCRM includes
     if ($helper->isredCRM()) {
         if (ENABLE_ITEM_TRACKING_SYSTEM) {
             // Supplier order helper object
             $crmSupplierOrderHelper = new crmSupplierOrderHelper();
             $getStatus = array();
             $getStatus['orderstatus'] = $row->order_status;
             $getStatus['paymentstatus'] = $row->order_payment_status;
             $crmSupplierOrderHelper->redSHOPOrderUpdate($row->order_id, $getStatus);
             unset($getStatus);
         }
     }
     return $row;
 }
Example #10
0
$option = 'com_redshop';
$document = JFactory::getDocument();
$document->addStyleSheet('modules/mod_redshop_products/css/products.css');
// Include redshop js file.
require_once JPATH_SITE . '/components/com_redshop/helpers/redshop.js.php';
JLoader::import('images', JPATH_ADMINISTRATOR . '/components/com_redshop/helpers');
// Lightbox Javascript
JHTML::Script('attribute.js', 'components/com_redshop/assets/js/', false);
JHTML::Script('common.js', 'components/com_redshop/assets/js/', false);
JHTML::Script('redBOX.js', 'components/com_redshop/assets/js/', false);
JHTML::Stylesheet('fetchscript.css', 'components/com_redshop/assets/css/');
$producthelper = new producthelper();
$redhelper = new redhelper();
$redTemplate = new Redtemplate();
$extraField = new extraField();
$stockroomhelper = new rsstockroomhelper();
$config = new Redconfiguration();
$module_id = "mod_" . $module->id;
echo "<div id='" . $module_id . "' class='mod_redshop_products_wrapper'>";
for ($i = 0; $i < count($rows); $i++) {
    $row = $rows[$i];
    if ($show_stockroom_status == 1) {
        $isStockExists = $stockroomhelper->isStockExists($row->product_id);
        if (!$isStockExists) {
            $isPreorderStockExists = $stockroomhelper->isPreorderStockExists($row->product_id);
        }
        if (!$isStockExists) {
            $product_preorder = $row->preorder;
            if ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes" || $product_preorder == "" && ALLOW_PRE_ORDER) {
                if (!$isPreorderStockExists) {
                    $stock_status = "<div  class='mod_product_outstock' align='center'>" . JText::_('COM_REDSHOP_OUT_OF_STOCK') . "</div>";
Example #11
0
 /**
  * After purchased order mail function
  *
  * @return void
  */
 public function after_purchased_order_mail()
 {
     $redshopMail = new redshopMail();
     $redconfig = new Redconfiguration();
     $stockroomhelper = new rsstockroomhelper();
     $db = JFactory::getDbo();
     $date = JFactory::getDate();
     $fdate = $date->toFormat('%Y-%m-%d');
     $query = "SELECT * FROM #__redshop_orders where order_payment_status ='Paid' and order_status = 'C'";
     $db->setQuery($query);
     $data = $db->loadObjectList();
     JTable::addIncludePath(JPATH_SITE . '/administrator/components/com_redshop/tables');
     foreach ($data as $mail_detail) {
         $bodytmp = "";
         $subject = "";
         $order_id = $mail_detail->order_id;
         $mailbcc = null;
         $config = JFactory::getConfig();
         $from = $config->getValue('mailfrom');
         $fromname = $config->getValue('fromname');
         $start_date = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
         $end_date = $start_date + DISCOUPON_DURATION * 23 * 59 * 59;
         $valid_end_date = $redconfig->convertDateFormat($end_date);
         $discoupon_value = DISCOUPON_PERCENT_OR_TOTAL == 0 ? REDCURRENCY_SYMBOL . " " . number_format(DISCOUPON_VALUE, 2, PRICE_SEPERATOR, THOUSAND_SEPERATOR) : ($discoupon_value = DISCOUPON_VALUE . " %");
         $sql = "SELECT CONCAT(firstname,' ',lastname) as name,user_email as email FROM  `#__redshop_order_users_info` WHERE `order_id` =  " . (int) $mail_detail->order_id . " AND `address_type` = 'BT' limit 0,1";
         $db->setQuery($sql);
         $orderuserarr = $db->loadObject();
         $sql = "SELECT coupon_left as total,coupon_code,end_date FROM  `#__redshop_coupons` WHERE `order_id` =  " . (int) $order_id . " AND coupon_left != 0 limit 0,1";
         $db->setQuery($sql);
         $couponeArr = $db->loadObject();
         if (count($couponeArr) <= 0) {
             continue;
         }
         $total = $couponeArr->total;
         $coupon_code = $couponeArr->coupon_code;
         $cend_date = $couponeArr->end_date;
         $name = "";
         $recipient = "";
         if (isset($orderuserarr)) {
             $recipient = $orderuserarr->email;
             $name = $orderuserarr->name;
         }
         if ($mail_detail->mail1_status == 0 && (DAYS_MAIL1 != 0 || DAYS_MAIL1 != '')) {
             $send_date = date("Y-m-d", $mail_detail->cdate + DAYS_MAIL1 * (60 * 60 * 24));
             $firstmail_data = $redshopMail->getMailtemplate(0, "first_mail_after_order_purchased");
             if (count($firstmail_data) > 0) {
                 $bodytmp = $firstmail_data[0]->mail_body;
                 $subject = $firstmail_data[0]->mail_subject;
                 if (trim($firstmail_data[0]->mail_bcc) != "") {
                     $mailbcc = explode(",", $firstmail_data[0]->mail_bcc);
                 }
             }
             $jpathurl = '<a href="' . JURI::root() . '">' . JURI::root() . '</a>';
             $body = str_replace("{name}", $name, $bodytmp);
             $body = str_replace("{url}", $jpathurl, $body);
             $body = str_replace("{coupon_amount}", $discoupon_value, $body);
             if ($fdate == $send_date) {
                 $better_token = md5(uniqid(mt_rand(), true));
                 $token = substr($better_token, 0, 10);
                 $body = str_replace("{coupon_code}", $token, $body);
                 $body = str_replace("{coupon_duration}", $valid_end_date, $body);
                 $sent = JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode = 1, null, $mailbcc);
                 if ($sent == 1) {
                     $couponItems = JTable::getInstance('coupon_detail', 'Table');
                     $couponItems->coupon_code = $token;
                     $couponItems->percent_or_total = DISCOUPON_PERCENT_OR_TOTAL;
                     $couponItems->coupon_value = DISCOUPON_VALUE;
                     $couponItems->start_date = $start_date;
                     $couponItems->end_date = $end_date;
                     $couponItems->coupon_type = 1;
                     $couponItems->userid = $mail_detail->user_id;
                     $couponItems->coupon_left = 1;
                     $couponItems->published = 1;
                     $couponItems->order_id = $order_id;
                     $couponItems->store();
                     $q_update = "UPDATE #__redshop_orders SET mail1_status = 1 WHERE order_id = " . $order_id;
                     $db->setQuery($q_update);
                     $db->query();
                 }
             }
         } elseif ($mail_detail->mail2_status == 0 && (DAYS_MAIL2 != 0 || DAYS_MAIL2 != '') && $total != 0) {
             $send_date = date("Y-m-d", $mail_detail->cdate + DAYS_MAIL2 * (59 * 59 * 23));
             $secmail_data = $redshopMail->getMailtemplate(0, "second_mail_after_order_purchased");
             if (count($secmail_data) > 0) {
                 $bodytmp = $secmail_data[0]->mail_body;
                 $subject = $secmail_data[0]->mail_subject;
                 if (trim($secmail_data[0]->mail_bcc) != "") {
                     $mailbcc = explode(",", $secmail_data[0]->mail_bcc);
                 }
             }
             $days = $stockroomhelper->getdatediff($cend_date, $start_date);
             $jpathurl = '<a href="' . JURI::root() . '">' . JURI::root() . '</a>';
             $body = str_replace("{name}", $name, $bodytmp);
             $body = str_replace("{url}", $jpathurl, $body);
             $body = str_replace("{coupon_amount}", $discoupon_value, $body);
             if ($days && $fdate == $send_date) {
                 $valid_end_date = $redconfig->convertDateFormat($cend_date);
                 $body = str_replace("{coupon_code}", $coupon_code, $body);
                 $body = str_replace("{coupon_duration}", $valid_end_date, $body);
                 $sent = JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode = 1, null, $mailbcc);
                 $q_update = "UPDATE #__redshop_orders SET mail2_status = 1 WHERE order_id = " . $order_id;
                 $db->setQuery($q_update);
                 $db->query();
             }
         } elseif ($mail_detail->mail3_status == 0 && (DAYS_MAIL3 != 0 || DAYS_MAIL3 != '') && $total != 0) {
             // Coupon reminder
             $thrdmail_data = $redshopMail->getMailtemplate(0, "third_mail_after_order_purchased");
             if (count($thrdmail_data) > 0) {
                 $bodytmp = $thrdmail_data[0]->mail_body;
                 $subject = $thrdmail_data[0]->mail_subject;
                 if (trim($thrdmail_data[0]->mail_bcc) != "") {
                     $mailbcc = explode(",", $thrdmail_data[0]->mail_bcc);
                 }
             }
             $send_date = date("Y-m-d", $mail_detail->cdate + DAYS_MAIL3 * (60 * 60 * 24));
             $days = $stockroomhelper->getdatediff($cend_date, $start_date);
             $jpathurl = '<a href="' . JURI::root() . '">' . JURI::root() . '</a>';
             $body = str_replace("{name}", $name, $bodytmp);
             $body = str_replace("{url}", $jpathurl, $body);
             $body = str_replace("{coupon_amount}", $discoupon_value, $body);
             if ($days && $fdate == $send_date) {
                 $valid_end_date = $redconfig->convertDateFormat($cend_date);
                 $body = str_replace("{coupon_code}", $coupon_code, $body);
                 $body = str_replace("{coupon_duration}", $valid_end_date, $body);
                 $sent = JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode = 1, null, $mailbcc);
                 $q_update = "UPDATE #__redshop_orders SET mail3_status = 1 WHERE order_id = " . $order_id;
                 $db->setQuery($q_update);
                 $db->query();
             }
         }
     }
 }
Example #12
0
 public function orderStatusUpdate($order_id, $post = array())
 {
     $helper = new redhelper();
     $stockroomhelper = new rsstockroomhelper();
     $producthelper = new producthelper();
     $newstatus = $post['order_status_all'];
     $customer_note = $post['customer_note' . $order_id];
     $isproduct = isset($post['isproduct']) ? $post['isproduct'] : 0;
     $product_id = isset($post['product_id']) ? $post['product_id'] : 0;
     $paymentstatus = $post['order_paymentstatus' . $order_id];
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_redshop/tables');
     // Add status log...
     $order_log = JTable::getInstance('order_status_log', 'Table');
     $order_log->order_id = $customer_note;
     $order_log->customer_note = $customer_note;
     $order_log->order_status = $newstatus;
     $order_log->date_changed = time();
     if (!$order_log->store()) {
         return JError::raiseWarning('', $order_log->getError());
     }
     // Changing the status of the order
     $this->updateOrderStatus($order_id, $newstatus);
     // Changing the status of the order
     if (isset($paymentstatus)) {
         $this->updateOrderPaymentStatus($order_id, $paymentstatus);
     }
     // For Consignor Label generation
     JPluginHelper::importPlugin('redshop_shippinglabel');
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger('onChangeStatusToShipped', array($order_id, $newstatus, $paymentstatus));
     // For Webpack Postdk Label Generation
     $this->createWebPacklabel($order_id, "", $newstatus, $paymentstatus);
     if (CLICKATELL_ENABLE) {
         // Changing the status of the order end
         $helper->clickatellSMS($order_id);
     }
     // If changing the status of the order then there item status need to change
     if ($isproduct != 1) {
         $this->updateOrderItemStatus($order_id, 0, $newstatus);
     }
     // If order is cancelled then, putting stock in the container from where it was dedcuted
     if ($newstatus == 'X') {
         $orderproducts = $this->getOrderItemDetail($order_id);
         for ($j = 0; $j < count($orderproducts); $j++) {
             $conid = $orderproducts[$j]->container_id;
             $prodid = $orderproducts[$j]->product_id;
             $prodqty = $orderproducts[$j]->stockroom_quantity;
             // When the order is set to "cancelled",product will return to stock
             $stockroomhelper->manageStockAmount($prodid, $prodqty, $orderproducts[$j]->stockroom_id);
             $producthelper->makeAttributeOrder($orderproducts[$j]->order_item_id, 0, $prodid, 1);
             if (USE_CONTAINER) {
                 $this->manageContainerStock($prodid, $prodqty, $conid);
             }
         }
     } elseif ($newstatus == 'RT') {
         // If any of the item from the order is returuned back then,
         // change the status of whole order and also put back to stock.
         if ($isproduct) {
             $orderproductdetail = $this->getOrderItemDetail($order_id, $product_id);
             $conid = $orderproductdetail[0]->container_id;
             $prodid = $orderproductdetail[0]->product_id;
             $prodqty = $orderproductdetail[0]->product_quantity;
             if (USE_CONTAINER) {
                 $this->manageContainerStock($prodid, $prodqty, $conid);
             }
             // Changing the status of the order item to Returned
             $this->updateOrderItemStatus($order_id, $prodid, "RT");
             // Changing the status of the order to Partially Returned
             $this->updateOrderStatus($order_id, "PRT");
         } else {
             $orderproducts = $this->getOrderItemDetail($order_id);
             for ($k = 0; $k < count($orderproducts); $k++) {
                 $conid = $orderproducts[$k]->container_id;
                 $prodid = $orderproducts[$k]->product_id;
                 $prodqty = $orderproducts[$k]->product_quantity;
                 if (USE_CONTAINER) {
                     $this->manageContainerStock($prodid, $prodqty, $conid);
                 }
             }
         }
     } elseif ($newstatus == 'RC') {
         // If any of the item from the order is reclamation back then,
         // change the status of whole order and also put back to stock.
         if ($isproduct) {
             // Changing the status of the order item to Reclamation
             $this->updateOrderItemStatus($order_id, $product_id, "RC");
             // Changing the status of the order to Partially Reclamation
             $this->updateOrderStatus($order_id, "PRC");
         } else {
             $orderproducts = $this->getOrderItemDetail($order_id);
             for ($l = 0; $l < count($orderproducts); $l++) {
                 $conid = $orderproducts[$l]->container_id;
                 $prodid = $orderproducts[$l]->product_id;
                 $prodqty = $orderproducts[$l]->product_quantity;
                 if (USE_CONTAINER) {
                     $this->manageContainerStock($prodid, $prodqty, $conid);
                 }
             }
         }
     } elseif ($newstatus == 'S') {
         if ($isproduct) {
             // Changing the status of the order item to Reclamation
             $this->updateOrderItemStatus($order_id, $product_id, "S");
             // Changing the status of the order to Partially Reclamation
             $this->updateOrderStatus($order_id, "PS");
         }
     }
     // Mail to customer of order status change
     $this->changeOrderStatusMail($order_id, $newstatus, $customer_note);
     $this->createBookInvoice($order_id, $newstatus);
     // GENERATE PDF CODE WRITE
     return true;
 }
 public function newQuotationItem($data)
 {
     $quotationHelper = new quotationHelper();
     $rsCarthelper = new rsCarthelper();
     $producthelper = new producthelper();
     $stockroomhelper = new rsstockroomhelper();
     $item = $data['quotation_item'];
     // Get Order Info
     $quotationdata = $this->getTable('quotation_detail');
     $quotationdata->load($this->_id);
     $user_id = $quotationdata->user_id;
     // Set Order Item Info
     $qitemdata = $this->getTable('quotation_item_detail');
     for ($i = 0; $i < count($item); $i++) {
         $product_id = $item[$i]->product_id;
         $quantity = $item[$i]->quantity;
         $product_excl_price = $item[$i]->prdexclprice;
         $product_price = $item[$i]->productprice;
         $product = $producthelper->getProductById($product_id);
         $generateAttributeCart = $rsCarthelper->generateAttributeArray((array) $item[$i], $user_id);
         $retAttArr = $producthelper->makeAttributeCart($generateAttributeCart, $product_id, $user_id, 0, $quantity);
         $product_attribute = $retAttArr[0];
         $generateAccessoryCart = $rsCarthelper->generateAccessoryArray((array) $item[$i], $user_id);
         $retAccArr = $producthelper->makeAccessoryCart($generateAccessoryCart, $product_id, $user_id);
         $product_accessory = $retAccArr[0];
         $wrapper_price = 0;
         $wrapper_vat = 0;
         $wrapper = $producthelper->getWrapper($product_id, $item[$i]->wrapper_data);
         if (count($wrapper) > 0) {
             if ($wrapper[0]->wrapper_price > 0) {
                 $wrapper_vat = $producthelper->getProducttax($product_id, $wrapper[0]->wrapper_price, $user_id);
             }
             $wrapper_price = $wrapper[0]->wrapper_price + $wrapper_vat;
         }
         $qitemdata =& $this->getTable('quotation_item_detail');
         $qitemdata->quotation_item_id = 0;
         $qitemdata->quotation_id = $this->_id;
         $qitemdata->product_id = $product_id;
         $qitemdata->is_giftcard = 0;
         $qitemdata->product_name = $product->product_name;
         $qitemdata->actualitem_price = $product_price;
         $qitemdata->product_price = $product_price;
         $qitemdata->product_excl_price = $product_excl_price;
         $qitemdata->product_final_price = $product_price * $quantity;
         $qitemdata->product_attribute = $product_attribute;
         $qitemdata->product_accessory = $product_accessory;
         $qitemdata->product_wrapperid = $item[$i]->wrapper_data;
         $qitemdata->wrapper_price = $wrapper_price;
         $qitemdata->product_quantity = $quantity;
         if (!$qitemdata->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         /** my accessory save in table start */
         if (count($generateAccessoryCart) > 0) {
             $attArr = $generateAccessoryCart;
             for ($a = 0; $a < count($attArr); $a++) {
                 $accessory_vat_price = 0;
                 $accessory_attribute = "";
                 $accessory_id = $attArr[$a]['accessory_id'];
                 $accessory_name = $attArr[$a]['accessory_name'];
                 $accessory_price = $attArr[$a]['accessory_price'];
                 $accessory_org_price = $accessory_price;
                 if ($accessory_price > 0) {
                     $accessory_vat_price = $producthelper->getProductTax($qitemdata->product_id, $accessory_price, $user_id);
                 }
                 $attchildArr = $attArr[$a]['accessory_childs'];
                 for ($j = 0; $j < count($attchildArr); $j++) {
                     $attribute_id = $attchildArr[$j]['attribute_id'];
                     $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>";
                     $rowattitem =& $this->getTable('quotation_attribute_item');
                     $rowattitem->quotation_att_item_id = 0;
                     $rowattitem->quotation_item_id = $qitemdata->quotation_item_id;
                     $rowattitem->section_id = $attribute_id;
                     $rowattitem->section = "attribute";
                     $rowattitem->parent_section_id = $accessory_id;
                     $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                     $rowattitem->is_accessory_att = 1;
                     if ($attribute_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $propArr = $attchildArr[$j]['attribute_childs'];
                     for ($k = 0; $k < count($propArr); $k++) {
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($qitemdata->product_id, $propArr[$k]['property_price'], $user_id);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>";
                         $subpropArr = $propArr[$k]['property_childs'];
                         $rowattitem =& $this->getTable('quotation_attribute_item');
                         $rowattitem->quotation_att_item_id = 0;
                         $rowattitem->quotation_item_id = $qitemdata->quotation_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 1;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $producthelper->getProducttax($qitemdata->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>";
                             $rowattitem =& $this->getTable('quotation_attribute_item');
                             $rowattitem->quotation_att_item_id = 0;
                             $rowattitem->quotation_item_id = $qitemdata->quotation_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 1;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                 }
                 $accdata =& $this->getTable('accessory_detail');
                 if ($accessory_id > 0) {
                     $accdata->load($accessory_id);
                 }
                 $accProductinfo = $producthelper->getProductById($accdata->child_product_id);
                 $rowaccitem =& $this->getTable('quotation_accessory_item');
                 $rowaccitem->quotation_item_acc_id = 0;
                 $rowaccitem->quotation_item_id = $qitemdata->quotation_item_id;
                 $rowaccitem->accessory_id = $accessory_id;
                 $rowaccitem->accessory_item_sku = $accProductinfo->product_number;
                 $rowaccitem->accessory_item_name = $accessory_name;
                 $rowaccitem->accessory_price = $accessory_org_price;
                 $rowaccitem->accessory_vat = $accessory_vat_price;
                 $rowaccitem->accessory_quantity = $qitemdata->product_quantity;
                 $rowaccitem->accessory_item_price = $accessory_price;
                 $rowaccitem->accessory_final_price = $accessory_price * $qitemdata->product_quantity;
                 $rowaccitem->accessory_attribute = $accessory_attribute;
                 if ($accessory_id > 0) {
                     if (!$rowaccitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
             }
         }
         /** my attribute save in table start */
         if (count($generateAttributeCart) > 0) {
             $attArr = $generateAttributeCart;
             for ($j = 0; $j < count($attArr); $j++) {
                 $attribute_id = $attArr[$j]['attribute_id'];
                 $rowattitem =& $this->getTable('quotation_attribute_item');
                 $rowattitem->quotation_att_item_id = 0;
                 $rowattitem->quotation_item_id = $qitemdata->quotation_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $qitemdata->product_id;
                 $rowattitem->section_name = $attArr[$j]['attribute_name'];
                 $rowattitem->is_accessory_att = 0;
                 if ($attribute_id > 0) {
                     if (!$rowattitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
                 $propArr = $attArr[$j]['attribute_childs'];
                 for ($k = 0; $k < count($propArr); $k++) {
                     $section_vat = 0;
                     if ($propArr[$k]['property_price'] > 0) {
                         $section_vat = $producthelper->getProducttax($qitemdata->product_id, $propArr[$k]['property_price'], $user_id);
                     }
                     $property_id = $propArr[$k]['property_id'];
                     /** product property STOCKROOM update start */
                     $updatestock = $stockroomhelper->updateStockroomQuantity($property_id, $qitemdata->product_quantity, "property");
                     $rowattitem =& $this->getTable('quotation_attribute_item');
                     $rowattitem->quotation_att_item_id = 0;
                     $rowattitem->quotation_item_id = $qitemdata->quotation_item_id;
                     $rowattitem->section_id = $property_id;
                     $rowattitem->section = "property";
                     $rowattitem->parent_section_id = $attribute_id;
                     $rowattitem->section_name = $propArr[$k]['property_name'];
                     $rowattitem->section_price = $propArr[$k]['property_price'];
                     $rowattitem->section_vat = $section_vat;
                     $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                     $rowattitem->is_accessory_att = 0;
                     if ($property_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $subpropArr = $propArr[$k]['property_childs'];
                     for ($l = 0; $l < count($subpropArr); $l++) {
                         $section_vat = 0;
                         if ($subpropArr[$l]['subproperty_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($qitemdata->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                         }
                         $subproperty_id = $subpropArr[$l]['subproperty_id'];
                         /** product subproperty STOCKROOM update start */
                         $updatestock = $stockroomhelper->updateStockroomQuantity($subproperty_id, $qitemdata->product_quantity, "subproperty");
                         $rowattitem =& $this->getTable('quotation_attribute_item');
                         $rowattitem->quotation_att_item_id = 0;
                         $rowattitem->quotation_item_id = $qitemdata->quotation_item_id;
                         $rowattitem->section_id = $subproperty_id;
                         $rowattitem->section = "subproperty";
                         $rowattitem->parent_section_id = $property_id;
                         $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                         $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                         $rowattitem->is_accessory_att = 0;
                         if ($subproperty_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
         // Store userfields
         $userfields = JRequest::getVar('extrafields' . $qitemdata->product_id);
         $userfields_id = JRequest::getVar('extrafields_id_' . $qitemdata->product_id);
         for ($ui = 0; $ui < count($userfields); $ui++) {
             $quotationHelper->insertQuotationUserfield($userfields_id[$ui], $qitemdata->quotation_item_id, 12, $userfields[$ui]);
         }
     }
     // Update Quotation Record
     $QuotationData = $this->getTable('quotation_detail');
     $QuotationData->load($this->_id);
     $QuotationTotal = 0;
     $QuotationSubTotal = 0;
     $QuotationSpDiscount = 0;
     $QuotationDiscount = 0;
     $QuotationTotDiscount = 0;
     $QuotationTax = 0;
     $quotationItems = $quotationHelper->getQuotationProduct($QuotationData->quotation_id);
     for ($q = 0; $q < count($quotationItems); $q++) {
         $QuotationSubTotal += $quotationItems[$q]->product_excl_price * $quotationItems[$q]->product_quantity;
         $QuotationTax += ($quotationItems[$q]->product_final_price - $quotationItems[$q]->product_excl_price) * $quotationItems[$q]->product_quantity;
     }
     // Deduct normal Discount
     $QuotationDiscount = $QuotationData->quotation_discount;
     // Special Discount
     $QuotationSpDiscount = $QuotationData->quotation_special_discount * ($QuotationSubTotal + $QuotationTax) / 100;
     // Total Discount
     $QuotationTotDiscount = $QuotationDiscount + $QuotationSpDiscount;
     // Count final Total
     $QuotationTotal = $QuotationSubTotal + $QuotationTax - $QuotationTotDiscount;
     $QuotationData->quotation_tax = $QuotationTax;
     $QuotationData->quotation_total = $QuotationTotal;
     $QuotationData->quotation_subtotal = $QuotationSubTotal;
     $QuotationData->quotation_mdate = time();
     if (!$QuotationData->store()) {
         return false;
     } else {
         return true;
     }
     // End
     return true;
 }
 public function store($postdata)
 {
     $redshopMail = new redshopMail();
     $order_functions = new order_functions();
     $helper = new redhelper();
     $producthelper = new producthelper();
     $rsCarthelper = new rsCarthelper();
     $shippinghelper = new shipping();
     $adminproducthelper = new adminproducthelper();
     $stockroomhelper = new rsstockroomhelper();
     // For barcode generation
     $barcode_code = $order_functions->barcode_randon_number(12, 0);
     $postdata['barcode'] = $barcode_code;
     $row = $this->getTable('order_detail');
     if (!$row->bind($postdata)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $iscrm = $helper->isredCRM();
     if ($iscrm) {
         $postdata['order_id'] = $row->order_id;
         $postdata['debitor_id'] = $postdata['user_info_id'];
         JTable::addIncludePath(REDCRM_ADMIN . '/tables');
         $crmorder =& $this->getTable('crm_order');
         if (!$crmorder->bind($postdata)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         if (!$crmorder->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // Update rma table entry
         if (ENABLE_RMA && isset($postdata['rmanotes'])) {
             $rmaInfo = $this->getTable('rma_orders');
             $rmaInfo->rma_number = $postdata['rma_number'];
             $rmaInfo->original_order_id = $postdata['main_order_id'];
             $rmaInfo->credit_note_order_id = $row->order_id;
             $rmaInfo->rma_note = $postdata['rmanotes'];
             $rmaInfo->store();
         }
         JTable::addIncludePath(REDSHOP_ADMIN . '/tables');
     }
     $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $row->ship_method_id)));
     $rowOrderStatus =& $this->getTable('order_status_log');
     $rowOrderStatus->order_id = $row->order_id;
     $rowOrderStatus->order_status = $row->order_status;
     $rowOrderStatus->date_changed = time();
     $rowOrderStatus->customer_note = $row->customer_note;
     $rowOrderStatus->store();
     $billingaddresses = $order_functions->getBillingAddress($row->user_id);
     if (isset($postdata['billisship']) && $postdata['billisship'] == 1) {
         $shippingaddresses = $billingaddresses;
     } else {
         $key = 0;
         $shippingaddresses = $order_functions->getShippingAddress($row->user_id);
         $shipp_users_info_id = isset($postdata['shipp_users_info_id']) && $postdata['shipp_users_info_id'] != 0 ? $postdata['shipp_users_info_id'] : 0;
         if ($shipp_users_info_id != 0) {
             for ($o = 0; $o < count($shippingaddresses); $o++) {
                 if ($shippingaddresses[$o]->users_info_id == $shipp_users_info_id) {
                     $key = $o;
                     break;
                 }
             }
         }
         $shippingaddresses = $shippingaddresses[$key];
     }
     // ORDER DELIVERY TIME IS REMAINING
     $user_id = $row->user_id;
     $item = $postdata['order_item'];
     for ($i = 0; $i < count($item); $i++) {
         $product_id = $item[$i]->product_id;
         $quantity = $item[$i]->quantity;
         $product_excl_price = $item[$i]->prdexclprice;
         $product_price = $item[$i]->productprice;
         // Attribute price added
         $generateAttributeCart = $rsCarthelper->generateAttributeArray((array) $item[$i], $user_id);
         $retAttArr = $producthelper->makeAttributeCart($generateAttributeCart, $product_id, $user_id, 0, $quantity);
         $product_attribute = $retAttArr[0];
         // Accessory price
         $generateAccessoryCart = $rsCarthelper->generateAccessoryArray((array) $item[$i], $user_id);
         $retAccArr = $producthelper->makeAccessoryCart($generateAccessoryCart, $product_id, $user_id);
         $product_accessory = $retAccArr[0];
         $accessory_total_price = $retAccArr[1];
         $accessory_vat_price = $retAccArr[2];
         $wrapper_price = 0;
         $wrapper_vat = 0;
         if ($item[$i]->wrapper_data != 0 && $item[$i]->wrapper_data != '') {
             $wrapper = $producthelper->getWrapper($product_id, $item[$i]->wrapper_data);
             if (count($wrapper) > 0) {
                 if ($wrapper[0]->wrapper_price > 0) {
                     $wrapper_vat = $producthelper->getProducttax($product_id, $wrapper[0]->wrapper_price, $user_id);
                 }
                 $wrapper_price = $wrapper[0]->wrapper_price + $wrapper_vat;
             }
         }
         $product = $producthelper->getProductById($product_id);
         $rowitem =& $this->getTable('order_item_detail');
         if (!$rowitem->bind($postdata)) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         // STOCKROOM update
         $updatestock = $stockroomhelper->updateStockroomQuantity($product_id, $quantity);
         $stockroom_id_list = $updatestock['stockroom_list'];
         $stockroom_quantity_list = $updatestock['stockroom_quantity_list'];
         $rowitem->stockroom_id = $stockroom_id_list;
         $rowitem->stockroom_quantity = $stockroom_quantity_list;
         $rowitem->order_item_id = 0;
         $rowitem->order_id = $row->order_id;
         $rowitem->user_info_id = $row->user_info_id;
         $rowitem->supplier_id = $product->manufacturer_id;
         $rowitem->product_id = $product_id;
         $rowitem->order_item_sku = $product->product_number;
         $rowitem->order_item_name = $product->product_name;
         $rowitem->product_quantity = $quantity;
         $rowitem->product_item_price = $product_price;
         $rowitem->product_item_price_excl_vat = $product_excl_price;
         $rowitem->product_final_price = $product_price * $quantity;
         $rowitem->order_item_currency = REDCURRENCY_SYMBOL;
         $rowitem->order_status = $row->order_status;
         $rowitem->cdate = $row->cdate;
         $rowitem->mdate = $row->cdate;
         $rowitem->product_attribute = $product_attribute;
         $rowitem->product_accessory = $product_accessory;
         $rowitem->wrapper_id = $item[$i]->wrapper_data;
         $rowitem->wrapper_price = $wrapper_price;
         $rowitem->is_giftcard = 0;
         // RedCRM product purchase price
         if ($iscrm) {
             $crmProductHelper = new crmProductHelper();
             $crmproduct = $crmProductHelper->getProductById($product_id);
             $rowitem->product_purchase_price = $crmproduct->product_purchase_price > 0 ? $crmproduct->product_purchase_price : $crmproduct->product_price;
         }
         if ($producthelper->checkProductDownload($product_id)) {
             $medianame = $producthelper->getProductMediaName($product_id);
             for ($j = 0; $j < count($medianame); $j++) {
                 $product_serial_number = $producthelper->getProdcutSerialNumber($product_id);
                 $producthelper->insertProductDownload($product_id, $user_id, $rowitem->order_id, $medianame[$j]->media_name, $product_serial_number->serial_number);
             }
         }
         if (!$rowitem->store()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         /** my accessory save in table start */
         if (count($generateAccessoryCart) > 0) {
             $attArr = $generateAccessoryCart;
             for ($a = 0; $a < count($attArr); $a++) {
                 $accessory_vat_price = 0;
                 $accessory_attribute = "";
                 $accessory_id = $attArr[$a]['accessory_id'];
                 $accessory_name = $attArr[$a]['accessory_name'];
                 $accessory_price = $attArr[$a]['accessory_price'];
                 $accessory_org_price = $accessory_price;
                 if ($accessory_price > 0) {
                     $accessory_vat_price = $producthelper->getProductTax($product_id, $accessory_price, $user_id);
                 }
                 $attchildArr = $attArr[$a]['accessory_childs'];
                 for ($j = 0; $j < count($attchildArr); $j++) {
                     $attribute_id = $attchildArr[$j]['attribute_id'];
                     $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>";
                     $rowattitem =& $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $attribute_id;
                     $rowattitem->section = "attribute";
                     $rowattitem->parent_section_id = $accessory_id;
                     $rowattitem->section_name = $attchildArr[$j]['attribute_name'];
                     $rowattitem->is_accessory_att = 1;
                     if ($attribute_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $propArr = $attchildArr[$j]['attribute_childs'];
                     for ($k = 0; $k < count($propArr); $k++) {
                         $section_vat = 0;
                         if ($propArr[$k]['property_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($product_id, $propArr[$k]['property_price'], $user_id);
                         }
                         $property_id = $propArr[$k]['property_id'];
                         $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>";
                         $subpropArr = $propArr[$k]['property_childs'];
                         $rowattitem =& $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $property_id;
                         $rowattitem->section = "property";
                         $rowattitem->parent_section_id = $attribute_id;
                         $rowattitem->section_name = $propArr[$k]['property_name'];
                         $rowattitem->section_price = $propArr[$k]['property_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                         $rowattitem->is_accessory_att = 1;
                         if ($property_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                         for ($l = 0; $l < count($subpropArr); $l++) {
                             $section_vat = 0;
                             if ($subpropArr[$l]['subproperty_price'] > 0) {
                                 $section_vat = $producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                             }
                             $subproperty_id = $subpropArr[$l]['subproperty_id'];
                             $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>";
                             $rowattitem =& $this->getTable('order_attribute_item');
                             $rowattitem->order_att_item_id = 0;
                             $rowattitem->order_item_id = $rowitem->order_item_id;
                             $rowattitem->section_id = $subproperty_id;
                             $rowattitem->section = "subproperty";
                             $rowattitem->parent_section_id = $property_id;
                             $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                             $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                             $rowattitem->section_vat = $section_vat;
                             $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                             $rowattitem->is_accessory_att = 1;
                             if ($subproperty_id > 0) {
                                 if (!$rowattitem->store()) {
                                     $this->setError($this->_db->getErrorMsg());
                                     return false;
                                 }
                             }
                         }
                     }
                 }
                 $accdata =& $this->getTable('accessory_detail');
                 if ($accessory_id > 0) {
                     $accdata->load($accessory_id);
                 }
                 $accProductinfo = $producthelper->getProductById($accdata->child_product_id);
                 $rowaccitem =& $this->getTable('order_acc_item');
                 $rowaccitem->order_item_acc_id = 0;
                 $rowaccitem->order_item_id = $rowitem->order_item_id;
                 $rowaccitem->product_id = $accessory_id;
                 $rowaccitem->order_acc_item_sku = $accProductinfo->product_number;
                 $rowaccitem->order_acc_item_name = $accessory_name;
                 $rowaccitem->order_acc_price = $accessory_org_price;
                 $rowaccitem->order_acc_vat = $accessory_vat_price;
                 $rowaccitem->product_quantity = $quantity;
                 $rowaccitem->product_acc_item_price = $accessory_price;
                 $rowaccitem->product_acc_final_price = $accessory_price * $quantity;
                 $rowaccitem->product_attribute = $accessory_attribute;
                 if ($accessory_id > 0) {
                     if (!$rowaccitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
             }
         }
         /** my attribute save in table start */
         if (count($generateAttributeCart) > 0) {
             $attArr = $generateAttributeCart;
             for ($j = 0; $j < count($attArr); $j++) {
                 $attribute_id = $attArr[$j]['attribute_id'];
                 $rowattitem =& $this->getTable('order_attribute_item');
                 $rowattitem->order_att_item_id = 0;
                 $rowattitem->order_item_id = $rowitem->order_item_id;
                 $rowattitem->section_id = $attribute_id;
                 $rowattitem->section = "attribute";
                 $rowattitem->parent_section_id = $rowitem->product_id;
                 $rowattitem->section_name = $attArr[$j]['attribute_name'];
                 $rowattitem->is_accessory_att = 0;
                 if ($attribute_id > 0) {
                     if (!$rowattitem->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                 }
                 $propArr = $attArr[$j]['attribute_childs'];
                 for ($k = 0; $k < count($propArr); $k++) {
                     $section_vat = 0;
                     if ($propArr[$k]['property_price'] > 0) {
                         $section_vat = $producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price'], $user_id);
                     }
                     $property_id = $propArr[$k]['property_id'];
                     /** product property STOCKROOM update start */
                     $updatestock = $stockroomhelper->updateStockroomQuantity($property_id, $quantity, "property");
                     $rowattitem =& $this->getTable('order_attribute_item');
                     $rowattitem->order_att_item_id = 0;
                     $rowattitem->order_item_id = $rowitem->order_item_id;
                     $rowattitem->section_id = $property_id;
                     $rowattitem->section = "property";
                     $rowattitem->parent_section_id = $attribute_id;
                     $rowattitem->section_name = $propArr[$k]['property_name'];
                     $rowattitem->section_price = $propArr[$k]['property_price'];
                     $rowattitem->section_vat = $section_vat;
                     $rowattitem->section_oprand = $propArr[$k]['property_oprand'];
                     $rowattitem->is_accessory_att = 0;
                     if ($property_id > 0) {
                         if (!$rowattitem->store()) {
                             $this->setError($this->_db->getErrorMsg());
                             return false;
                         }
                     }
                     $subpropArr = $propArr[$k]['property_childs'];
                     for ($l = 0; $l < count($subpropArr); $l++) {
                         $section_vat = 0;
                         if ($subpropArr[$l]['subproperty_price'] > 0) {
                             $section_vat = $producthelper->getProducttax($product_id, $subpropArr[$l]['subproperty_price'], $user_id);
                         }
                         $subproperty_id = $subpropArr[$l]['subproperty_id'];
                         /** product subproperty STOCKROOM update start */
                         $updatestock = $stockroomhelper->updateStockroomQuantity($subproperty_id, $quantity, "subproperty");
                         $rowattitem =& $this->getTable('order_attribute_item');
                         $rowattitem->order_att_item_id = 0;
                         $rowattitem->order_item_id = $rowitem->order_item_id;
                         $rowattitem->section_id = $subproperty_id;
                         $rowattitem->section = "subproperty";
                         $rowattitem->parent_section_id = $property_id;
                         $rowattitem->section_name = $subpropArr[$l]['subproperty_name'];
                         $rowattitem->section_price = $subpropArr[$l]['subproperty_price'];
                         $rowattitem->section_vat = $section_vat;
                         $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand'];
                         $rowattitem->is_accessory_att = 0;
                         if ($subproperty_id > 0) {
                             if (!$rowattitem->store()) {
                                 $this->setError($this->_db->getErrorMsg());
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
         //			$producthelper->insertProdcutUserfield($i,$item,$rowitem->order_item_id,12);
         if (USE_CONTAINER) {
             $producthelper->updateContainerStock($product_id, $quantity, $rowitem->container_id);
         }
         // Store userfields
         $userfields = $item[$i]->extrafieldname;
         $userfields_id = $item[$i]->extrafieldId;
         for ($ui = 0; $ui < count($userfields); $ui++) {
             $adminproducthelper->admin_insertProdcutUserfield($userfields_id[$ui], $rowitem->order_item_id, 12, $userfields[$ui]);
         }
         // redCRM RMA Transaction Entry
         if ($iscrm) {
             if (ENABLE_RMA && $rowitem->product_final_price < 0) {
                 // RMA transation log
                 if (isset($item[$i]->reason)) {
                     $rmaTrans =& $this->getTable('rma_transaction');
                     $rmaTrans->rma_transaction_id = 0;
                     $rmaTrans->rma_number = $postdata['rma_number'];
                     $rmaTrans->order_item_return_id = $rowitem->order_item_id;
                     $rmaTrans->order_item_return_reason = $item[$i]->reason;
                     $rmaTrans->order_item_return_status = $item[$i]->deposition;
                     $rmaTrans->order_item_return_action = $item[$i]->action;
                     $rmaTrans->cdate = time();
                     $rmaTrans->store();
                     if (ENABLE_ITEM_TRACKING_SYSTEM) {
                         // Manage supplier order stock
                         $crmSupplierOrderHelper = new crmSupplierOrderHelper();
                         $senddata['main_order_number'] = $postdata['main_order_number'];
                         $senddata['order_status'] = $row->order_status;
                         $senddata['product_id'] = $rowitem->product_id;
                         $senddata['property_id'] = $property_id;
                         $senddata['subproperty_id'] = $subproperty_id;
                         $senddata['deposition'] = $item[$i]->deposition;
                         $itemqty = $rowitem->product_quantity;
                         for ($r = 0; $r < $itemqty; $r++) {
                             $crmSupplierOrderHelper->manageStockAffectedRMA($senddata);
                         }
                     }
                 }
             }
         }
     }
     $rowpayment =& $this->getTable('order_payment');
     if (!$rowpayment->bind($postdata)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $rowpayment->order_id = $row->order_id;
     $rowpayment->payment_method_id = $postdata['payment_method_class'];
     $rowpayment->order_payment_amount = $row->order_total;
     $rowpayment->order_payment_name = $postdata['order_payment_name'];
     $rowpayment->payment_method_class = $postdata['payment_method_class'];
     if (!$rowpayment->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add billing Info
     $userrow =& $this->getTable('user_detail');
     $userrow->load($billingaddresses->users_info_id);
     $orderuserrow =& $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $row->order_id;
     $orderuserrow->address_type = 'BT';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Add shipping Info
     $userrow =& $this->getTable('user_detail');
     if (isset($shippingaddresses->users_info_id)) {
         $userrow->load($shippingaddresses->users_info_id);
     }
     $orderuserrow =& $this->getTable('order_user_detail');
     if (!$orderuserrow->bind($userrow)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $orderuserrow->order_id = $row->order_id;
     $orderuserrow->address_type = 'ST';
     if (!$orderuserrow->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if ($row->order_status == CLICKATELL_ORDER_STATUS) {
         $helper->clickatellSMS($row->order_id);
     }
     // Maintan supplier order stck when item tracking system is enabled
     if ($helper->isredCRM()) {
         if (ENABLE_ITEM_TRACKING_SYSTEM) {
             // Supplier order helper object
             $crmSupplierOrderHelper = new crmSupplierOrderHelper();
             $getStatus = array();
             $getStatus['orderstatus'] = $row->order_status;
             $getStatus['paymentstatus'] = $row->order_payment_status;
             $crmSupplierOrderHelper->redSHOPOrderUpdate($row->order_id, $getStatus);
             unset($getStatus);
         }
     }
     $checkOrderStatus = 1;
     if ($postdata['payment_method_class'] == "rs_payment_banktransfer" || $postdata['payment_method_class'] == "rs_payment_banktransfer_discount" || $postdata['payment_method_class'] == "rs_payment_banktransfer2" || $postdata['payment_method_class'] == "rs_payment_banktransfer3" || $postdata['payment_method_class'] == "rs_payment_banktransfer4" || $postdata['payment_method_class'] == "rs_payment_banktransfer5") {
         $checkOrderStatus = 0;
     }
     // Economic Integration start for invoice generate and book current invoice
     if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) {
         $issplit = 0;
         $economic = new economic();
         if (isset($postdata['issplit']) && $postdata['issplit'] == 1) {
             $issplit = 1;
         }
         $economicdata['split_payment'] = $issplit;
         $economicdata['economic_payment_terms_id'] = $postdata['economic_payment_terms_id'];
         $economicdata['economic_design_layout'] = $postdata['economic_design_layout'];
         $economicdata['economic_is_creditcard'] = $postdata['economic_is_creditcard'];
         $payment_name = $postdata['payment_method_class'];
         $paymentArr = explode("rs_payment_", $postdata['payment_method_class']);
         if (count($paymentArr) > 0) {
             $payment_name = $paymentArr[1];
         }
         $economicdata['economic_payment_method'] = $payment_name;
         $invoiceHandle = $economic->createInvoiceInEconomic($row->order_id, $economicdata);
         if (ECONOMIC_INVOICE_DRAFT == 0) {
             $bookinvoicepdf = $economic->bookInvoiceInEconomic($row->order_id, $checkOrderStatus);
             if (is_file($bookinvoicepdf)) {
                 $ret = $redshopMail->sendEconomicBookInvoiceMail($row->order_id, $bookinvoicepdf);
             }
         }
     }
     // ORDER MAIL SEND
     if ($postdata['task'] != "save_without_sendmail") {
         $redshopMail->sendOrderMail($row->order_id);
     }
     return $row;
 }
Example #15
0
 public function updateAttributeItem($order_item_id, $quantity = 0, $stockroom_id = 0)
 {
     $stockroomhelper = new rsstockroomhelper();
     $order_functions = new order_functions();
     $attArr = $order_functions->getOrderItemAttributeDetail($order_item_id, 0, "attribute");
     /** my attribute save in table start */
     for ($j = 0; $j < count($attArr); $j++) {
         $propArr = $order_functions->getOrderItemAttributeDetail($order_item_id, 0, "property", $attArr[$j]->section_id);
         for ($k = 0; $k < count($propArr); $k++) {
             $propitemdata = $this->getTable('order_attribute_item');
             $propitemdata->load($propArr[$k]->order_att_item_id);
             /** product property STOCKROOM update start */
             if ($quantity > 0) {
                 $stockroomhelper->manageStockAmount($propitemdata->section_id, $quantity, $propArr[$k]->stockroom_id, "property");
             } elseif ($quantity < 0) {
                 $updatestock = $stockroomhelper->updateStockroomQuantity($propitemdata->section_id, -$quantity, "property");
             }
             $subpropArr = $order_functions->getOrderItemAttributeDetail($order_item_id, 0, "subproperty", $propitemdata->section_id);
             for ($l = 0; $l < count($subpropArr); $l++) {
                 $subpropitemdata = $this->getTable('order_attribute_item');
                 $subpropitemdata->load($subpropArr[$l]->order_att_item_id);
                 if ($quantity > 0) {
                     $stockroomhelper->manageStockAmount($subpropitemdata->section_id, $quantity, $subpropArr[$l]->stockroom_id, "subproperty");
                 } elseif ($quantity < 0) {
                     $updatestock = $stockroomhelper->updateStockroomQuantity($subpropitemdata->section_id, -$quantity, "subproperty");
                 }
             }
         }
     }
     return true;
 }
Example #16
0
 /**
  * Generate product search output
  */
 public function onRSProductSearch()
 {
     if (count($this->search) > 0) {
         $app = JFactory::getApplication();
         require_once JPATH_COMPONENT . '/helpers/product.php';
         require_once JPATH_COMPONENT . '/helpers/pagination.php';
         require_once JPATH_COMPONENT . '/helpers/extra_field.php';
         require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/text_library.php';
         $dispatcher = JDispatcher::getInstance();
         $redTemplate = new Redtemplate();
         $Redconfiguration = new Redconfiguration();
         $producthelper = new producthelper();
         $extraField = new extraField();
         $texts = new text_library();
         $stockroomhelper = new rsstockroomhelper();
         $Itemid = JRequest::getInt('Itemid');
         $search_type = JRequest::getCmd('search_type');
         $cid = JRequest::getInt('category_id');
         $manisrch = $this->search;
         $manufacture_id = $manisrch[0]->manufacturer_id;
         $templateid = JRequest::getInt('templateid');
         // Cmd removes space between to words
         $keyword = JRequest::getWord('keyword');
         $layout = JRequest::getCmd('layout', 'default');
         $db = JFactory::getDbo();
         $query = 'SELECT category_name' . ' FROM #__redshop_category  ' . 'WHERE category_id=' . JRequest::getInt('cid');
         $db->setQuery($query);
         $cat_name = null;
         if ($catname_array = $db->loadObjectList()) {
             $cat_name = $catname_array[0]->category_name;
         }
         $session = JFactory::getSession();
         $model = $this->getModel('search');
         $limit = $this->limit;
         $limitstart = JRequest::getInt('limitstart', 0);
         $total = $model->_total;
         JHTML::_('behavior.tooltip');
         JHTMLBehavior::modal();
         $url = JURI::base();
         if ($this->params->get('page_title') != "") {
             $pagetitle = $this->params->get('page_title');
         } else {
             $pagetitle = JText::_('COM_REDSHOP_SEARCH');
         }
         if ($this->params->get('show_page_heading', 1)) {
             echo '<h1 class="componentheading' . $this->escape($this->params->get('pageclass_sfx')) . '">';
             echo $pagetitle;
             echo '</h1>';
         }
         echo '<div style="clear:both"></div>';
         $category_tmpl = "";
         if (count($this->templatedata) > 0 && $this->templatedata[0]->template_desc != "") {
             $template_desc = $this->templatedata[0]->template_desc;
         } else {
             $template_desc = "<div class=\"category_print\">{print}</div>\r\n<div style=\"clear: both;\"></div>\r\n<div class=\"category_main_description\">{category_main_description}</div>\r\n<p>{if subcats} {category_loop_start}</p>\r\n<div id=\"categories\">\r\n<div style=\"float: left; width: 200px;\">\r\n<div class=\"category_image\">{category_thumb_image}</div>\r\n<div class=\"category_description\">\r\n<h2 class=\"category_title\">{category_name}</h2>\r\n{category_description}</div>\r\n</div>\r\n</div>\r\n<p>{category_loop_end} {subcats end if}</p>\r\n<div style=\"clear: both;\"></div>\r\n<div id=\"category_header\">\r\n<div class=\"category_order_by\">{order_by}</div>\r\n</div>\r\n<div class=\"category_box_wrapper\">{product_loop_start}\r\n<div class=\"category_box_outside\">\r\n<div class=\"category_box_inside\">\r\n<div class=\"category_product_image\">{product_thumb_image}</div>\r\n<div class=\"category_product_title\">\r\n<h3>{product_name}</h3>\r\n</div>\r\n<div class=\"category_product_price\">{product_price}</div>\r\n<div class=\"category_product_readmore\">{read_more}</div>\r\n<div>{product_rating_summary}</div>\r\n<div class=\"category_product_addtocart\">{form_addtocart:add_to_cart1}</div>\r\n</div>\r\n</div>\r\n{product_loop_end}\r\n<div class=\"category_product_bottom\" style=\"clear: both;\"></div>\r\n</div>\r\n<div class=\"category_pagination\">{pagination}</div>";
         }
         if (strstr($template_desc, "{product_display_limit}")) {
             $endlimit = $model->getProductPerPage();
             $limit = JRequest::getInt('limit', $endlimit, '', 'int');
         }
         $template_org = $template_desc;
         $template_d1 = explode("{category_loop_start}", $template_org);
         if (count($template_d1) > 1) {
             $template_d2 = explode("{category_loop_end}", $template_d1[1]);
             if (count($template_d2) > 0) {
                 $category_tmpl = $template_d2[0];
             }
         }
         $template_org = str_replace($category_tmpl, "", $template_org);
         $template_org = str_replace("{category_loop_start}", "", $template_org);
         $template_org = str_replace("{category_loop_end}", "", $template_org);
         $print = JRequest::getInt('print');
         $p_url = @explode('?', $_SERVER['REQUEST_URI']);
         $print_tag = '';
         if ($print) {
             $print_tag = "<a onclick='window.print();' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' ><img src=" . JSYSTEM_IMAGES_PATH . "printButton.png  alt='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' /></a>";
         } else {
             $print_url = $url . "index.php?option=com_redshop&view=search&print=1&tmpl=component";
             $print_tag = "<a href='#' onclick='window.open(\"{$print_url}\",\"mywindow\",\"scrollbars=1\",\"location=1\")' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' ><img src=" . JSYSTEM_IMAGES_PATH . "printButton.png  alt='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' title='" . JText::_('COM_REDSHOP_PRINT_LBL') . "' /></a>";
         }
         $template_org = str_replace("{total_product}", count($this->search), $template_org);
         $template_org = str_replace("{total_product_lbl}", JText::_('COM_REDSHOP_TOTAL_PRODUCT'), $template_org);
         if (strstr($template_org, "{compare_product_div}")) {
             $compare_product_div = "";
             if (PRODUCT_COMPARISON_TYPE != "") {
                 $comparediv = $producthelper->makeCompareProductDiv();
                 $compareUrl = JRoute::_('index.php?option=com_redshop&view=product&layout=compare&Itemid=' . $Itemid);
                 $compare_product_div = "<form name='frmCompare' method='post' action='" . $compareUrl . "' >";
                 $compare_product_div .= "<a href='javascript:compare();' >" . JText::_('COM_REDSHOP_COMPARE') . "</a>";
                 $compare_product_div .= "<div id='divCompareProduct'>" . $comparediv . "</div>";
                 $compare_product_div .= "</form>";
             }
             $template_org = str_replace("{compare_product_div}", $compare_product_div, $template_org);
         }
         // Skip html if nosubcategory
         if (strstr($template_org, "{if subcats}")) {
             $template_d1 = explode("{if subcats}", $template_org);
             $template_d2 = explode("{subcats end if}", $template_d1[1]);
             $template_org = $template_d1[0] . $template_d2[1];
         }
         // End skip html if nosubcategory
         $template_org = str_replace("{print}", $print_tag, $template_org);
         $template_org = str_replace("{product_price_slider}", '', $template_org);
         $template_org = str_replace("{filter_by}", '', $template_org);
         $template_org = str_replace("{template_selector_category_lbl}", '', $template_org);
         $template_org = str_replace("{template_selector_category}", '', $template_org);
         $template_org = str_replace("{category_main_description}", '', $template_org);
         $template_org = str_replace("{category_main_name}", $cat_name, $template_org);
         $template_org = str_replace("{category_description}", '', $template_org);
         $template_org = str_replace("{category_short_desc}", '', $template_org);
         $template_org = str_replace("{category_name}", '', $template_org);
         $template_org = str_replace("{if subcats}", '', $template_org);
         $template_org = str_replace("{subcats end if}", '', $template_org);
         $template_org = str_replace("{category_main_thumb_image_3}", '', $template_org);
         $template_org = str_replace("{category_main_short_desc}", '', $template_org);
         $template_org = str_replace("{category_main_thumb_image_2}", '', $template_org);
         $template_org = str_replace("{category_main_thumb_image_1}", '', $template_org);
         $template_org = str_replace("{category_main_thumb_image}", '', $template_org);
         $template_org = str_replace("{attribute_price_without_vat}", '', $template_org);
         $template_org = str_replace("{redproductfinderfilter_formstart}", '', $template_org);
         $template_org = str_replace("{redproductfinderfilter:rp_myfilter}", '', $template_org);
         $template_org = str_replace("{redproductfinderfilter_formend}", '', $template_org);
         // Replace redproductfilder filter tag
         if (strstr($template_org, "{redproductfinderfilter:")) {
             $redProductFinerHelper = JPATH_SITE . "/components/com_redproductfinder/helpers/redproductfinder_helper.php";
             if (file_exists($redProductFinerHelper)) {
                 include_once $redProductFinerHelper;
                 $redproductfinder_helper = new redproductfinder_helper();
                 $hdnFields = array('texpricemin' => '0', 'texpricemax' => '0', 'manufacturer_id' => $filter_by, 'category_template' => $templateid);
                 $hide_filter_flag = false;
                 if ($this->_id) {
                     $prodctofcat = $producthelper->getProductCategory($this->_id);
                     if (empty($prodctofcat)) {
                         $hide_filter_flag = true;
                     }
                 }
                 $template_org = $redproductfinder_helper->replaceProductfinder_tag($template_org, $hdnFields, $hide_filter_flag);
             }
         }
         // Replace redproductfilder filter tag end here
         $template_d1 = explode("{product_loop_start}", $template_org);
         $template_d2 = explode("{product_loop_end}", $template_d1[1]);
         $template_tmp_desc = $template_d2[0];
         $template_desc = $template_d2[0];
         // Order By
         $order_by = "";
         $orderby_form = "<form name='orderby_form' action='' method='post' >";
         $orderby_form .= $this->lists['order_select'];
         $orderby_form .= "<input type='hidden' name='view' value='search'>\n\t\t\t<input type='hidden' name='layout' value='{$layout}'>\n\t\t\t<input type='hidden' name='keyword' value='{$keyword}'>\n\t\t\t<input type='hidden' name='category_id' value='{$cid}'>\n\t\t\t<input type='hidden' name='manufacture_id' value='{$manufacture_id}'>\n\t\t\t<input type='hidden' name='templateid' value='{$templateid}'></form>";
         if (strstr($template_desc, '{order_by}')) {
             $order_by = $orderby_form;
         }
         $extraFieldName = $extraField->getSectionFieldNameArray(1, 1, 1);
         $attribute_template = $producthelper->getAttributeTemplate($template_desc);
         $total_product = $model->_total;
         $endlimit = $this->limit;
         $start = JRequest::getInt('limitstart', 0, '', 'int');
         if (strstr($template_org, "{pagination}")) {
             if (strstr($template_org, "{product_display_limit}")) {
                 $endlimit = JRequest::getInt('limit', $endlimit, '', 'int');
             }
         } else {
             $endlimit = $model->getData();
         }
         if ($endlimit == 0) {
             $final_endlimit = $total_product;
         } else {
             $final_endlimit = $endlimit;
         }
         $tagarray = $texts->getTextLibraryTagArray();
         $data = "";
         $count_no_user_field = 0;
         for ($i = 0; $i < count($this->search); $i++) {
             $data_add = "";
             $thum_image = "";
             $pname = $Redconfiguration->maxchar($this->search[$i]->product_name, CATEGORY_PRODUCT_TITLE_MAX_CHARS, CATEGORY_PRODUCT_TITLE_END_SUFFIX);
             if ($search_type == 'product_number') {
                 $product_number = str_ireplace($keyword, "<b class='search_hightlight'>" . $keyword . "</b>", $this->search[$i]->product_number);
                 $pro_s_desc = $this->search[$i]->product_s_desc;
                 $pro_desc = $this->search[$i]->product_desc;
             } else {
                 $product_number = $this->search[$i]->product_number;
                 $pro_s_desc = $this->search[$i]->product_s_desc;
                 $pro_desc = $this->search[$i]->product_desc;
                 if (!in_array($keyword, $tagarray)) {
                     $pname = str_ireplace($keyword, "<b class='search_hightlight'>" . $keyword . "</b>", $pname);
                     $pro_s_desc = str_ireplace($keyword, "<b class='search_hightlight'>" . $keyword . "</b>", $pro_s_desc);
                     $pro_desc = str_ireplace($keyword, "<b class='search_hightlight'>" . $keyword . "</b>", $pro_desc);
                 }
             }
             $pro_s_desc = $Redconfiguration->maxchar($pro_s_desc, CATEGORY_PRODUCT_DESC_MAX_CHARS, CATEGORY_PRODUCT_DESC_END_SUFFIX);
             $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $this->search[$i]->product_id . '&Itemid=' . $Itemid);
             if (strstr($template_desc, '{product_name}')) {
                 $pname = "<a href='" . $link . "'>" . $pname . "</a>";
                 $data_add = str_replace("{product_name}", $pname, $template_desc);
             }
             if (strstr($template_desc, '{product_name_nolink}')) {
                 $data_add = str_replace("{product_name_nolink}", $pname, $template_desc);
             }
             $readmore = "<a href='" . $link . "'>" . JText::_('COM_REDSHOP_READ_MORE') . "</a>";
             $data_add = str_replace("{read_more}", $readmore, $data_add);
             $data_add = str_replace("{read_more_link}", $link, $data_add);
             // RedSHOP Product Plugin
             JPluginHelper::importPlugin('redshop_product');
             $results = $dispatcher->trigger('onPrepareProduct', array(&$data_add, &$params, $this->search[$i]));
             // End
             if (strstr($data_add, "{product_delivery_time}")) {
                 $product_delivery_time = $producthelper->getProductMinDeliveryTime($this->search[$i]->product_id);
                 if ($product_delivery_time != "") {
                     $data_add = str_replace("{delivery_time_lbl}", JText::_('DELIVERY_TIME'), $data_add);
                     $data_add = str_replace("{product_delivery_time}", $product_delivery_time, $data_add);
                 } else {
                     $data_add = str_replace("{delivery_time_lbl}", "", $data_add);
                     $data_add = str_replace("{product_delivery_time}", "", $data_add);
                 }
             }
             // Product Review/Rating
             // Fetching reviews
             $final_avgreview_data = $producthelper->getProductRating($this->search[$i]->product_id);
             // Attribute ajax chage
             $data_add = str_replace("{product_rating_summary}", $final_avgreview_data, $data_add);
             $data_add = $producthelper->getJcommentEditor($this->search[$i], $data_add);
             $data_add = $producthelper->getExtraSectionTag($extraFieldName, $this->search[$i]->product_id, "1", $data_add, 1);
             $data_add = str_replace("{product_s_desc}", $pro_s_desc, $data_add);
             $data_add = str_replace("{product_desc}", $pro_desc, $data_add);
             $data_add = str_replace("{product_id_lbl}", JText::_('COM_REDSHOP_PRODUCT_ID_LBL'), $data_add);
             $data_add = str_replace("{product_id}", $this->search[$i]->product_id, $data_add);
             $data_add = str_replace("{product_number_lbl}", JText::_('COM_REDSHOP_PRODUCT_NUMBER_LBL'), $data_add);
             $data_add = str_replace("{product_number}", $product_number, $data_add);
             /**
              * related Product List in Lightbox
              * Tag Format = {related_product_lightbox:<related_product_name>[:width][:height]}
              */
             if (strstr($data_add, '{related_product_lightbox:')) {
                 $related_product = $producthelper->getRelatedProduct($this->search[$i]->product_id);
                 $rtlnone = explode("{related_product_lightbox:", $data_add);
                 $rtlntwo = explode("}", $rtlnone[1]);
                 $rtlnthree = explode(":", $rtlntwo[0]);
                 $rtln = $rtlnthree[0];
                 $rtlnfwidth = isset($rtlnthree[1]) ? $rtlnthree[1] : "900";
                 $rtlnwidthtag = isset($rtlnthree[1]) ? ":" . $rtlnthree[1] : "";
                 $rtlnfheight = isset($rtlnthree[2]) ? $rtlnthree[2] : "600";
                 $rtlnheighttag = isset($rtlnthree[2]) ? ":" . $rtlnthree[2] : "";
                 $rtlntag = "{related_product_lightbox:{$rtln}{$rtlnwidthtag}{$rtlnheighttag}}";
                 if (count($related_product) > 0) {
                     $linktortln = JUri::root() . "index.php?option=com_redshop&view=product&pid=" . $this->search[$i]->product_id . "&tmpl=component&template=" . $rtln . "&for=rtln";
                     $rtlna = '<a class="modal" href="' . $linktortln . '" rel="{handler:\'iframe\',size:{x:' . $rtlnfwidth . ',y:' . $rtlnfheight . '}}" >' . JText::_('COM_REDSHOP_RELATED_PRODUCT_LIST_IN_LIGHTBOX') . '</a>';
                 } else {
                     $rtlna = "";
                 }
                 $data_add = str_replace($rtlntag, $rtlna, $data_add);
             }
             $data_add = $producthelper->replaceVatinfo($data_add);
             /************************************
              *  Conditional tag
              *  if product on discount : Yes
              *  {if product_on_sale} This product is on sale {product_on_sale end if} // OUTPUT : This product is on sale
              *  NO : // OUTPUT : Display blank
              ************************************/
             $data_add = $producthelper->getProductOnSaleComment($this->search[$i], $data_add);
             $data_add = $stockroomhelper->replaceStockroomAmountDetail($data_add, $this->search[$i]->product_id);
             if (strstr($data_add, "{product_thumb_image_3}")) {
                 $cimg_tag = '{product_thumb_image_3}';
                 $ch_thumb = CATEGORY_PRODUCT_THUMB_HEIGHT_3;
                 $cw_thumb = CATEGORY_PRODUCT_THUMB_WIDTH_3;
             } elseif (strstr($data_add, "{product_thumb_image_2}")) {
                 $cimg_tag = '{product_thumb_image_2}';
                 $ch_thumb = CATEGORY_PRODUCT_THUMB_HEIGHT_2;
                 $cw_thumb = CATEGORY_PRODUCT_THUMB_WIDTH_2;
             } elseif (strstr($data_add, "{product_thumb_image_1}")) {
                 $cimg_tag = '{product_thumb_image_1}';
                 $ch_thumb = CATEGORY_PRODUCT_THUMB_HEIGHT;
                 $cw_thumb = CATEGORY_PRODUCT_THUMB_WIDTH;
             } else {
                 $cimg_tag = '{product_thumb_image}';
                 $ch_thumb = CATEGORY_PRODUCT_THUMB_HEIGHT;
                 $cw_thumb = CATEGORY_PRODUCT_THUMB_WIDTH;
             }
             $hidden_thumb_image = "<input type='hidden' name='prd_main_imgwidth' id='prd_main_imgwidth' value='" . $cw_thumb . "'><input type='hidden' name='prd_main_imgheight' id='prd_main_imgheight' value='" . $ch_thumb . "'>";
             $thum_image = $producthelper->getProductImage($this->search[$i]->product_id, $link, $cw_thumb, $ch_thumb);
             $data_add = str_replace($cimg_tag, $thum_image . $hidden_thumb_image, $data_add);
             // More documents
             if (strstr($data_add, "{more_documents}")) {
                 $media_documents = $producthelper->getAdditionMediaImage($this->search[$i]->product_id, "product", "document");
                 $more_doc = '';
                 for ($m = 0; $m < count($media_documents); $m++) {
                     $alttext = $producthelper->getAltText("product", $media_documents[$m]->section_id, "", $media_documents[$m]->media_id, "document");
                     if (!$alttext) {
                         $alttext = $media_documents[$m]->media_name;
                     }
                     if (is_file(REDSHOP_FRONT_DOCUMENT_RELPATH . "product/" . $media_documents[$m]->media_name)) {
                         $downlink = JUri::root() . 'index.php?tmpl=component&option=com_redshop&view=product&pid=' . $this->search[$i]->product_id . '&task=downloadDocument&fname=' . $media_documents[$m]->media_name . '&Itemid=' . $Itemid;
                         $more_doc .= "<div><a href='" . $downlink . "' title='" . $alttext . "'>";
                         $more_doc .= $alttext;
                         $more_doc .= "</a></div>";
                     }
                 }
                 $data_add = str_replace("{more_documents}", "<span id='additional_docs" . $this->search[$i]->product_id . "'>" . $more_doc . "</span>", $data_add);
             }
             // More documents end
             /************************************************ user fields*******************************************************/
             $hidden_userfield = "";
             $returnArr = $producthelper->getProductUserfieldFromTemplate($data_add);
             $template_userfield = $returnArr[0];
             $userfieldArr = $returnArr[1];
             $count_no_user_field = 0;
             if ($template_userfield != "") {
                 $ufield = "";
                 for ($ui = 0; $ui < count($userfieldArr); $ui++) {
                     $product_userfileds = $extraField->list_all_user_fields($userfieldArr[$ui], 12, '', '', 0, $this->search[$i]->product_id);
                     $ufield .= $product_userfileds[1];
                     if ($product_userfileds[1] != "") {
                         $count_no_user_field++;
                     }
                     $data_add = str_replace('{' . $userfieldArr[$ui] . '_lbl}', $product_userfileds[0], $data_add);
                     $data_add = str_replace('{' . $userfieldArr[$ui] . '}', $product_userfileds[1], $data_add);
                 }
                 $product_userfileds_form = "<form method='post' action='' id='user_fields_form_" . $this->search[$i]->product_id . "' name='user_fields_form_" . $this->search[$i]->product_id . "'>";
                 if ($ufield != "") {
                     $data_add = str_replace("{if product_userfield}", $product_userfileds_form, $data_add);
                     $data_add = str_replace("{product_userfield end if}", "</form>", $data_add);
                 } else {
                     $data_add = str_replace("{if product_userfield}", "", $data_add);
                     $data_add = str_replace("{product_userfield end if}", "", $data_add);
                 }
             } elseif (AJAX_CART_BOX) {
                 $ajax_detail_template_desc = "";
                 $ajax_detail_template = $producthelper->getAjaxDetailboxTemplate($this->search[$i]);
                 if (count($ajax_detail_template) > 0) {
                     $ajax_detail_template_desc = $ajax_detail_template->template_desc;
                 }
                 $returnArr = $producthelper->getProductUserfieldFromTemplate($ajax_detail_template_desc);
                 $template_userfield = $returnArr[0];
                 $userfieldArr = $returnArr[1];
                 if ($template_userfield != "") {
                     $ufield = "";
                     for ($ui = 0; $ui < count($userfieldArr); $ui++) {
                         $product_userfileds = $extraField->list_all_user_fields($userfieldArr[$ui], 12, '', '', 0, $this->search[$i]->product_id);
                         $ufield .= $product_userfileds[1];
                         if ($product_userfileds[1] != "") {
                             $count_no_user_field++;
                         }
                         $template_userfield = str_replace('{' . $userfieldArr[$ui] . '_lbl}', $product_userfileds[0], $template_userfield);
                         $template_userfield = str_replace('{' . $userfieldArr[$ui] . '}', $product_userfileds[1], $template_userfield);
                     }
                     if ($ufield != "") {
                         $hidden_userfield = "<div style='display:none;'><form method='post' action='' id='user_fields_form_" . $this->search[$i]->product_id . "' name='user_fields_form_" . $this->search[$i]->product_id . "'>" . $template_userfield . "</form></div>";
                     }
                 }
             }
             $data_add = $data_add . $hidden_userfield;
             /*************** end user fields ***************/
             // ProductFinderDatepicker Extra Field Start
             $fieldArray = $extraField->getSectionFieldList(17, 0, 0);
             $data_add = $producthelper->getProductFinderDatepickerValue($data_add, $this->search[$i]->product_id, $fieldArray);
             // ProductFinderDatepicker Extra Field End
             /*
              * manufacturer data
              */
             $manufacturer_id = $this->search[$i]->manufacturer_id;
             if ($manufacturer_id != 0) {
                 $manufacturer_data = $producthelper->getSection("manufacturer", $manufacturer_id);
                 $manufacturer_link_href = JRoute::_('index.php?option=com_redshop&view=manufacturers&layout=detail&mid=' . $manufacturer_id . '&Itemid=' . $Itemid);
                 $manufacturer_name = "";
                 if (count($manufacturer_data) > 0) {
                     $manufacturer_name = $manufacturer_data->manufacturer_name;
                 }
                 $manufacturer_link = '<a href="' . $manufacturer_link_href . '" title="' . $manufacturer_name . '">' . $manufacturer_name . '</a>';
                 if (strstr($data_add, "{manufacturer_link}")) {
                     $data_add = str_replace("{manufacturer_name}", "", $data_add);
                 } else {
                     $data_add = str_replace("{manufacturer_name}", $manufacturer_name, $data_add);
                 }
                 $data_add = str_replace("{manufacturer_link}", $manufacturer_link, $data_add);
             } else {
                 $data_add = str_replace("{manufacturer_link}", "", $data_add);
                 $data_add = str_replace("{manufacturer_name}", "", $data_add);
             }
             // End
             // Replace wishlistbutton
             $data_add = $producthelper->replaceWishlistButton($this->search[$i]->product_id, $data_add);
             // Replace compare product button
             $data_add = $producthelper->replaceCompareProductsButton($this->search[$i]->product_id, 0, $data_add);
             // Checking for child products
             $childproduct = $producthelper->getChildProduct($this->search[$i]->product_id);
             if (count($childproduct) > 0) {
                 $isChilds = true;
                 $attributes = array();
             } else {
                 $isChilds = false;
                 // Get attributes
                 $attributes_set = array();
                 if ($this->search[$i]->attribute_set_id > 0) {
                     $attributes_set = $producthelper->getProductAttribute(0, $this->search[$i]->attribute_set_id, 0, 1);
                 }
                 $attributes = $producthelper->getProductAttribute($this->search[$i]->product_id);
                 $attributes = array_merge($attributes, $attributes_set);
             }
             // Product attribute  Start
             $totalatt = count($attributes);
             // Check product for not for sale
             $data_add = $producthelper->getProductNotForSaleComment($this->search[$i], $data_add, $attributes);
             $data_add = $producthelper->replaceProductInStock($this->search[$i]->product_id, $data_add, $attributes, $attribute_template);
             $data_add = $producthelper->replaceAttributeData($this->search[$i]->product_id, 0, 0, $attributes, $data_add, $attribute_template, $isChilds);
             // Cart Template
             $data_add = $producthelper->replaceCartTemplate($this->search[$i]->product_id, 0, 0, 0, $data_add, $isChilds, $userfieldArr, $totalatt, 0, $count_no_user_field, "");
             $data .= $data_add;
         }
         $app = JFactory::getApplication();
         $router = $app->getRouter();
         $getorderby = JRequest::getVar('order_by', DEFAULT_PRODUCT_ORDERING_METHOD);
         $vars = array('option' => 'com_redshop', 'view' => 'search', 'layout' => $layout, 'keyword' => $keyword, 'manufacture_id' => $manufacture_id, 'order_by' => $getorderby, 'category_id' => $cid, 'Itemid' => $Itemid, 'limit' => $limit);
         $router->setVars($vars);
         unset($vars);
         if (strstr($template_org, "{pagination}")) {
             $pagination = new redPagination($total_product, $start, $endlimit);
             $slidertag = $pagination->getPagesLinks();
             if (strstr($template_org, "{product_display_limit}")) {
                 $slidertag = "<form action='' method='post'><input type='hidden' name='keyword' value='{$keyword}'>\n\t\t\t<input type='hidden' name='category_id' value='{$cid}'>\n\t\t\t<input type='hidden' name='manufacture_id' value='{$manufacture_id}'>\n\t\t\t<input type='hidden' name='templateid' value='{$templateid}'> " . $pagination->getListFooter() . "</form>";
                 $template_org = str_replace("{product_display_limit}", $slidertag, $template_org);
                 $template_org = str_replace("{pagination}", '', $template_org);
             }
             $template_org = str_replace("{pagination}", $slidertag, $template_org);
         }
         $template_org = str_replace("{product_display_limit}", "", $template_org);
         if (strstr($template_org, "perpagelimit:")) {
             $perpage = explode('{perpagelimit:', $template_org);
             $perpage = explode('}', $perpage[1]);
             $template_org = str_replace("{perpagelimit:" . intval($perpage[0]) . "}", "", $template_org);
         }
         $template_org = str_replace("{order_by}", $orderby_form, $template_org);
         $template_org = str_replace("{order_by_lbl}", JText::_('COM_REDSHOP_SELECT_ORDER_BY'), $template_org);
         $template_org = str_replace("{filter_by_lbl}", JText::_('COM_REDSHOP_SELECT_FILTER_BY'), $template_org);
         $template_org = str_replace("{attribute_price_with_vat}", "", $template_org);
         $template_org = str_replace("{attribute_price_without_vat}", "", $template_org);
         $template_org = str_replace("{product_loop_start}", "", $template_org);
         $template_org = str_replace("{product_loop_end}", "", $template_org);
         $template_org = str_replace($template_tmp_desc, $data, $template_org);
         $template_org = str_replace("{with_vat}", "", $template_org);
         $template_org = str_replace("{without_vat}", "", $template_org);
         $template_org = $redTemplate->parseredSHOPplugin($template_org);
         $template_org = $texts->replace_texts($template_org);
         eval("?>" . $template_org . "<?php ");
     } else {
         echo "<br><h3>" . JText::_('COM_REDSHOP_MSG_SORRY_NO_RESULT_FOUND') . "</h3>";
     }
 }
Example #17
0
 public function delete($cartElement)
 {
     $stockroomhelper = new rsstockroomhelper();
     $session = JFactory::getSession();
     $cart = $session->get('cart');
     if (array_key_exists($cartElement, $cart)) {
         $stockroomhelper->deleteCartAfterEmpty($cart[$cartElement]['product_id']);
         unset($cart[$cartElement]);
         $cart = array_merge(array(), $cart);
         $Index = $cart['idx'] - 1;
         if ($Index > 0) {
             $cart['idx'] = $Index;
         } else {
             $cart = array();
             $cart['idx'] = 0;
         }
     }
     $session->set('cart', $cart);
 }
Example #18
0
 public function getproductStockStatus($product_id = 0, $totalatt = 0, $selectedpropertyId = 0, $selectedsubpropertyId = 0)
 {
     $stockroomhelper = new rsstockroomhelper();
     $producDetail = $this->getProductById($product_id);
     $product_preorder = trim($producDetail->preorder);
     $rsltdata = array();
     $rsltdata['preorder'] = 0;
     $rsltdata['preorder_stock'] = 0;
     if ($selectedpropertyId) {
         if ($selectedsubpropertyId) {
             // Count status for selected subproperty
             $stocksts = $stockroomhelper->isStockExists($selectedsubpropertyId, "subproperty");
             if (!$stocksts && ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes")) {
                 $prestocksts = $stockroomhelper->isPreorderStockExists($selectedsubpropertyId, "subproperty");
                 $rsltdata['preorder'] = 1;
                 $rsltdata['preorder_stock'] = $prestocksts;
             }
         } else {
             // Count status for selected property
             $stocksts = $stockroomhelper->isStockExists($selectedpropertyId, "property");
             if (!$stocksts && ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes")) {
                 $prestocksts = $stockroomhelper->isPreorderStockExists($selectedpropertyId, "property");
                 $rsltdata['preorder'] = 1;
                 $rsltdata['preorder_stock'] = $prestocksts;
             }
         }
     } else {
         $stocksts = $stockroomhelper->getFinalStockofProduct($product_id, $totalatt);
         if (!$stocksts && ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes")) {
             $prestocksts = $stockroomhelper->getFinalPreorderStockofProduct($product_id, $totalatt);
             $rsltdata['preorder'] = 1;
             $rsltdata['preorder_stock'] = $prestocksts;
         }
     }
     $rsltdata['regular_stock'] = $stocksts;
     return $rsltdata;
 }
Example #19
0
 *
 * @copyright   Copyright (C) 2005 - 2013 redCOMPONENT.com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
defined('_JEXEC') or die;
JHtml::_('behavior.tooltip');
JHtmlBehavior::modal();
$url = JURI::base();
$u = JURI::getInstance();
$Scheme = $u->getScheme();
$print = $this->input->getBool('print', false);
$user = JFactory::getUser();
$extraField = new extraField();
$producthelper = new producthelper();
$redshopconfig = new Redconfiguration();
$stockroomhelper = new rsstockroomhelper();
$config = new Redconfiguration();
$template = $this->template;
if (count($template) > 0 && $template->template_desc != "") {
    $template_desc = $template->template_desc;
} else {
    $template_desc = "<div id=\"produkt\">\r\n<div class=\"produkt_spacer\"></div>\r\n<div class=\"produkt_anmeldelser_opsummering\">";
    $template_desc .= "{product_rating_summary}</div>\r\n<div id=\"opsummering_wrapper\">\r\n<div id=\"opsummering_skubber\"></div>\r\n";
    $template_desc .= "<div id=\"opsummering_link\">{product_rating_summary}</div>\r\n</div>\r\n<div id=\"produkt_kasse\">\r\n";
    $template_desc .= "<div class=\"produkt_kasse_venstre\">\r\n<div class=\"produkt_kasse_billed\">{product_thumb_image}</div>\r\n";
    $template_desc .= "<div class=\"produkt_kasse_billed_flere\">{more_images}</div>\r\n<div id=\"produkt_kasse_venstre_tekst\">";
    $template_desc .= "{view_full_size_image_lbl}</div>\r\n</div>\r\n<div class=\"produkt_kasse_hoejre\">\r\n{attribute_template:attributes}";
    $template_desc .= "<div class=\"produkt_kasse_hoejre_accessory\">{accessory_template:accessory}</div>\r\n";
    $template_desc .= "<div class=\"produkt_kasse_hoejre_pris\">\r\n<div class=\"produkt_kasse_hoejre_pris_indre\" ";
    $template_desc .= "id=\"produkt_kasse_hoejre_pris_indre\">{product_price}</div>\r\n</div>\r\n<div class=\"produkt_kasse_hoejre_laegikurv\">\r\n";
    $template_desc .= "<div class=\"produkt_kasse_hoejre_laegikurv_indre\">{form_addtocart:add_to_cart2}</div>\r\n</div>\r\n";