public function SetPanelSettings()
 {
     // Setup the cart values
     $total = $count = 0;
     $GLOBALS['SNIPPETS']['SideCartItems'] = '';
     if (!isset($_SESSION['CART']['ITEMS']) || empty($_SESSION['CART']['ITEMS'])) {
         $this->DontDisplay = true;
         return;
     }
     if (isset($_SESSION['CART']['ITEMS'])) {
         foreach ($_SESSION['CART']['ITEMS'] as $item) {
             $total += $item['product_price'] * $item['quantity'];
             $count += $item['quantity'];
             if (!isset($item['type']) || $item['type'] != "giftcertificate") {
                 $GLOBALS['ProductName'] = "<a href=\"" . ProdLink($item['product_name']) . "\">" . isc_html_escape($item['product_name']) . "</a>";
             } else {
                 $GLOBALS['ProductName'] = isc_html_escape($item['product_name']);
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($item['options']) && !empty($item['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($item['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($item['product_price'] * $item['quantity']);
             $GLOBALS['ProductQuantity'] = $item['quantity'];
             $GLOBALS['SNIPPETS']['SideCartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCartItem");
         }
     }
     if ($count == 1) {
         $GLOBALS['SideCartItemCount'] = GetLang('SideCartYouHave1Item');
     } else {
         $GLOBALS['SideCartItemCount'] = sprintf(GetLang('SideCartYouHaveXItems'), $count);
     }
     $GLOBALS['ISC_LANG']['SideCartTotalCost'] = sprintf(GetLang('SideCartTotalCost'), CurrencyConvertFormatPrice($total));
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     $HideCheckout = false;
     foreach (GetAvailableModules('checkout', true, true) as $module) {
         if (method_exists($module['object'], 'GetSidePanelCheckoutButton')) {
             $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetSidePanelCheckoutButton();
         }
         if ($module['object']->disableNonCartCheckoutButtons) {
             $HideCheckout = true;
         }
     }
     if ($HideCheckout) {
         $GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = '';
     } else {
         $GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SideCartContentsCheckoutLink');
     }
 }
Example #2
0
 function SetPanelSettings()
 {
     $count = 0;
     $output = "";
     $GLOBALS['SNIPPETS']['WishListItems'] = "";
     $GLOBALS['HideCompareItems'] = "none";
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     if (!isset($GLOBALS['WishListItems'])) {
         return false;
     }
     $GLOBALS['AlternateClass'] = '';
     foreach ($GLOBALS['WishListItems'] as $row) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ItemId'] = (int) $row['wishlistitemid'];
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['SNIPPETS']['WishListItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("WishListItem");
     }
 }
 public function SetPanelSettings()
 {
     $count = 0;
     $GLOBALS['SNIPPETS']['HomeSaleProducts'] = '';
     if (GetConfig('HomeNewProducts') == 0) {
         $this->DontDisplay = true;
         return;
     }
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\tWHERE p.prodsaleprice != 0 AND p.prodsaleprice < p.prodprice AND p.prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY RAND()\n\t\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, GetConfig('HomeNewProducts'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         // Determine the price of this product
         $originalPrice = CalcRealPrice(CalcProdCustomerGroupPrice($row, $row['prodprice']), 0, 0, $row['prodistaxable']);
         $GLOBALS['OriginalProductPrice'] = CurrencyConvertFormatPrice($originalPrice);
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Workout the product description
         $desc = strip_tags($row['proddesc']);
         if (isc_strlen($desc) < 120) {
             $GLOBALS['ProductSummary'] = $desc;
         } else {
             $GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "...";
         }
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['SNIPPETS']['HomeSaleProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeSaleProductsItem");
         if (!$GLOBALS['SNIPPETS']['HomeSaleProducts']) {
             $this->DontDisplay = true;
             return;
         }
     }
 }
 public function SetPanelSettings()
 {
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetRelatedProducts() != "") {
         $output = "";
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $query = "\n\t\t\t\t\tSELECT p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, i.imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid)\n\t\t\t\t\tWHERE p.prodvisible='1' AND p.productid IN (" . $GLOBALS['ISC_CLASS_PRODUCT']->GetRelatedProducts() . ") AND i.imageisthumb=1\n\t\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\t\tORDER BY prodsortorder ASC\n\t\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
             $GLOBALS['AlternateClass'] = '';
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 if ($GLOBALS['AlternateClass'] == 'Odd') {
                     $GLOBALS['AlternateClass'] = 'Even';
                 } else {
                     $GLOBALS['AlternateClass'] = 'Odd';
                 }
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 // Determine the price of this product
                 $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 $thumb = $GLOBALS['ShopPath'] . "/" . GetConfig('ImageDirectory') . "/" . isc_html_escape($row['imagefile']);
                 $GLOBALS['ProductThumb'] = '<img src="' . $thumb . '" alt="" />';
                 $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideRelatedProducts");
             }
             $GLOBALS['SNIPPETS']['SideProductsRelated'] = $output;
         } else {
             // No related products, hide the panel
             $GLOBALS['HideRelatedProductsPanel'] = "none";
             $this->DontDisplay = true;
         }
     } else {
         // No related products, hide the panel
         $GLOBALS['HideRelatedProductsPanel'] = "none";
         $this->DontDisplay = true;
     }
 }
Example #5
0
	/**
	 * Returns the URL for a product based on it's productid
	 *
	 * @param integer $productId The ID number of the product to generate the URL for
	 */
	public static function getProductUrl($productId, $returnTitle=false)
	{
		$productId = (int)$productId;
		if($productId < 1) {
			return false;
		}

		$productName = $GLOBALS['ISC_CLASS_DB']->FetchOne('select prodname from `[|PREFIX|]products` where productid=' . $productId, 'prodname');

		if(empty($productName)) {
			return false;
		}

		if($returnTitle) {
			return array('title'=>$productName, 'url'=> ProdLink($productName));
		}

		return ProdLink($productName);
	}
 public function SetPanelSettings()
 {
     $GLOBALS['AlsoBoughtProductListing'] = '';
     $query = "\n\t\t\tSELECT ordprodid\n\t\t\tFROM [|PREFIX|]order_products\n\t\t\tWHERE orderorderid IN (SELECT orderorderid FROM [|PREFIX|]order_products WHERE ordprodid='" . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "') AND ordprodid != " . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "\n\t\t\tGROUP BY ordprodid\n\t\t\tORDER BY COUNT(ordprodid) DESC\n\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 10);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $productIds = array();
     while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $productIds[] = $product['ordprodid'];
     }
     if (empty($productIds)) {
         $this->DontDisplay = true;
         return;
     }
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $query = "\n\t\t\tSELECT p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, i.imagefile, i.imageisthumb, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\tFROM [|PREFIX|]products p\n\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid AND i.imageisthumb=1)\n\t\t\tWHERE p.prodvisible='1' AND p.productid IN (" . implode(',', $productIds) . ")\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['AlsoBoughtProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductAlsoBoughtItem");
     }
     if (!$GLOBALS['AlsoBoughtProductListing']) {
         $this->DontDisplay = true;
     }
 }
 public function SetPanelSettings()
 {
     $output = "";
     // If product ratings aren't enabled then we don't even need to load anything here
     if (GetConfig('EnableProductReviews') == 0) {
         $this->DontDisplay = true;
         return;
     }
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1)\n\t\t\t\tWHERE prodvisible='1' AND prodratingtotal > 0\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY prodavgrating DESC\n\t\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
         $GLOBALS['AlternateClass'] = '';
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $GLOBALS['ProductCartQuantity'] = '';
             if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                 $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
             }
             $GLOBALS['ProductId'] = $row['productid'];
             $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
             $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
             $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
             // Determine the price of this product
             $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
             $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
             $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SidePopularProducts");
         }
         // Showing the syndication option?
         if (GetConfig('RSSPopularProducts') != 0 && GetConfig('RSSSyndicationIcons') != 0) {
             $GLOBALS['SNIPPETS']['SidePopularProductsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SidePopularProductsFeed");
         }
     } else {
         $GLOBALS['HideSidePopularProductsPanel'] = "none";
         $this->DontDisplay = true;
     }
     $GLOBALS['SNIPPETS']['SidePopularProducts'] = $output;
 }
 public function SetPanelSettings()
 {
     $_SESSION['you_save'] = 0;
     //blessen
     $GLOBALS['SNIPPETS']['CartItems'] = "";
     $count = 0;
     $subtotal = 0;
     $_SESSION['CHECKOUT'] = array();
     // Get a list of all products in the cart
     $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART');
     $product_array = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $ShowCheckoutButton = false;
     if (!empty($product_array)) {
         foreach (GetAvailableModules('checkout', true, true) as $module) {
             if (isset($module['object']->_showBothButtons) && $module['object']->_showBothButtons) {
                 $ShowCheckoutButton = true;
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } elseif (method_exists($module['object'], 'GetCheckoutButton')) {
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } else {
                 $ShowCheckoutButton = true;
             }
         }
     }
     $GLOBALS['HideMultipleAddressShipping'] = 'display: none';
     if (gzte11(ISC_MEDIUMPRINT) && $GLOBALS['ISC_CLASS_CART']->api->GetNumPhysicalProducts() > 1 && $ShowCheckoutButton && GetConfig("MultipleShippingAddresses")) {
         $GLOBALS['HideMultipleAddressShipping'] = '';
     }
     $GLOBALS['HideCheckoutButton'] = '';
     if (!$ShowCheckoutButton) {
         $GLOBALS['HideCheckoutButton'] = 'display: none';
         $GLOBALS['HideMultipleAddressShippingOr'] = 'display: none';
     }
     $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
     if (empty($wrappingOptions)) {
         $publicWrappingOptions = false;
     } else {
         $publicWrappingOptions = true;
     }
     if (!GetConfig('ShowThumbsInCart')) {
         $GLOBALS['HideThumbColumn'] = 'display: none';
         $GLOBALS['ProductNameSpan'] = 2;
     } else {
         $GLOBALS['HideThumbColumn'] = '';
         $GLOBALS['ProductNameSpan'] = 1;
     }
     $wrappingAdjustment = 0;
     $itemTotal = 0;
     foreach ($product_array as $k => $product) {
         $GLOBALS['CartItemId'] = (int) $product['cartitemid'];
         // If the item in the cart is a gift certificate, we need to show a special type of row
         if (isset($product['type']) && $product['type'] == "giftcertificate") {
             $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']);
             $GLOBALS["Quantity" . $product['quantity']] = 'selected="selected"';
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['giftamount'] * $product['quantity']);
             $itemTotal += $product['giftamount'] * $product['quantity'];
             $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate");
         } else {
             $GLOBALS['ProductLink'] = ProdLink($product['data']['prodname']);
             $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']);
             $GLOBALS['ItemId'] = (int) $product['data']['productid'];
             $GLOBALS['VariationId'] = (int) $product['variation_id'];
             $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
             //blessen
             $GLOBALS['prodretailprice'] = CurrencyConvertFormatPrice($product['data']['prodretailprice']);
             if ($product['data']['prodretailprice'] > $product['data']['prodcalculatedprice']) {
                 $_SESSION['you_save'] += ($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']) * $product['quantity'];
             }
             //$GLOBALS['saveprice'] =  CurrencyConvertFormatPrice($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']);
             //blessen
             // Should we show thumbnails in the cart?
             if (GetConfig('ShowThumbsInCart')) {
                 $GLOBALS['ProductImage'] = ImageThumb($product['data']['imagefile'], ProdLink($product['data']['prodname']));
             }
             $GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);";
             $GLOBALS['HideCartProductFields'] = 'display:none;';
             $GLOBALS['CartProductFields'] = '';
             $this->GetProductFieldDetails($product['product_fields'], $k);
             $GLOBALS['EventDate'] = '';
             if (isset($product['event_date'])) {
                 $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:10px; color:gray">(' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . ')</div>';
             }
             // Can this product be wrapped?
             $GLOBALS['GiftWrappingName'] = '';
             $GLOBALS['HideGiftWrappingAdd'] = '';
             $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
             $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
             $GLOBALS['GiftWrappingPrice'] = '';
             $GLOBALS['GiftMessagePreview'] = '';
             $GLOBALS['HideGiftMessagePreview'] = 'display: none';
             $GLOBALS['HideWrappingOptions'] = 'display: none';
             if ($product['data']['prodtype'] == PT_PHYSICAL && $product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                 $GLOBALS['HideWrappingOptions'] = '';
                 if (isset($product['wrapping'])) {
                     $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                     $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                     $GLOBALS['HideGiftWrappingEdit'] = '';
                     $GLOBALS['HideGiftWrappingPrice'] = '';
                     $wrappingAdjustment += $product['wrapping']['wrapprice'] * $product['quantity'];
                     $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                     if (isset($product['wrapping']['wrapmessage'])) {
                         if (isc_strlen($product['wrapping']['wrapmessage']) > 30) {
                             $product['wrapping']['wrapmessage'] = substr($product['wrapping']['wrapmessage'], 0, 27) . '...';
                         }
                         $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping']['wrapmessage']);
                         if ($product['wrapping']['wrapmessage']) {
                             $GLOBALS['HideGiftMessagePreview'] = '';
                         }
                     }
                 }
             }
             $subtotalPrice = 0;
             if (isset($product['discount_price'])) {
                 $subtotalPrice = $product['discount_price'];
             } else {
                 $subtotalPrice = $product['product_price'];
             }
             if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price']) {
                 $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($subtotalPrice));
             } else {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($subtotalPrice);
             }
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($subtotalPrice * $product['quantity']);
             $itemTotal += $subtotalPrice * $product['quantity'];
             // If we're using a cart quantity drop down, load that
             if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                 $GLOBALS["Quantity" . $product['quantity']] = "selected=\"selected\"";
                 if (isset($GLOBALS["Quantity0"])) {
                     $GLOBALS['QtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                 } else {
                     $GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>";
                 }
                 // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                 if ($product['quantity'] > 30) {
                     $GLOBALS["QtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['quantity']] . " value='" . $product['quantity'] . "'>" . $product['quantity'] . "</option>";
                 }
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
             } else {
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($product['options']) && !empty($product['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($product['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             //blessen
             $withoutdollar = str_replace("\$", "", $GLOBALS['prodretailprice']);
             if (intval($withoutdollar) <= 0) {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
             } else {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem1");
             }
             //blessen
             // original $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
         }
         $GLOBALS["Quantity" . $product['quantity']] = "";
     }
     if ($wrappingAdjustment > 0) {
         $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($wrappingAdjustment);
     } else {
         $GLOBALS['HideGiftWrappingTotal'] = 'display: none';
     }
     $GLOBALS['HideAdjustedTotal'] = "none";
     $GLOBALS['AdjustedCartSubTotal'] = $GLOBALS['CartSubTotal'] - $GLOBALS['CartSubTotalDiscount'];
     $GLOBALS['CartItemTotal'] = CurrencyConvertFormatPrice($itemTotal);
     $GLOBALS['SNIPPETS']['Coupons'] = '';
     $coupons = $GLOBALS['ISC_CLASS_CART']->api->GetAppliedCouponCodes();
     if (count($coupons)) {
         foreach ($coupons as $coupon) {
             $GLOBALS['CouponId'] = $coupon['couponid'];
             $GLOBALS['CouponCode'] = $coupon['couponcode'];
             // percent coupon
             if ($coupon['coupontype'] == 1) {
                 $discount = $coupon['discount'] . "%";
             } else {
                 $discount = CurrencyConvertFormatPrice($coupon['discount']);
             }
             $GLOBALS['CouponDiscount'] = $discount;
             $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon");
         }
     }
     $GLOBALS['SNIPPETS']['GiftCertificates'] = '';
     // Has the customer chosen one or more gift certificates to apply to this order? We need to show them
     if (isset($_SESSION['CART']['GIFTCERTIFICATES']) && is_array($_SESSION['CART']['GIFTCERTIFICATES'])) {
         $certificates = $_SESSION['CART']['GIFTCERTIFICATES'];
         uasort($certificates, "GiftCertificateSort");
         foreach ($certificates as $certificate) {
             $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
             $GLOBALS['GiftCertificateId'] = $certificate['giftcertid'];
             $GLOBALS['GiftCertificateBalance'] = $certificate['giftcertbalance'];
             if ($GLOBALS['GiftCertificateBalance'] > $GLOBALS['AdjustedCartSubTotal']) {
                 $GLOBALS['GiftCertificateRemaining'] = $certificate['giftcertbalance'] - $GLOBALS['AdjustedCartSubTotal'];
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'] - $GLOBALS['GiftCertificateRemaining'];
             } else {
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'];
                 $GLOBALS['GiftCertificateRemaining'] = 0;
             }
             // Subtract this amount from the adjusted total
             $GLOBALS['AdjustedCartSubTotal'] -= $GLOBALS['GiftCertificateBalance'];
             if ($GLOBALS['AdjustedCartSubTotal'] <= 0) {
                 $GLOBALS['AdjustedCartSubTotal'] = 0;
             }
             $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateBalance']);
             $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateRemaining']);
             $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($GLOBALS['CertificateAmountUsed']);
             $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartGiftCertificate");
         }
         if ($GLOBALS['SNIPPETS']['GiftCertificates']) {
             $GLOBALS['HideAdjustedTotal'] = '';
             if ($GLOBALS['AdjustedCartSubTotal'] == 0) {
                 $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
             }
         }
     }
     if ($GLOBALS['AdjustedCartSubTotal'] != $GLOBALS['CartSubTotal']) {
         $GLOBALS['HideAdjustedTotal'] = "";
         $GLOBALS['AdjustedCartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['AdjustedCartSubTotal']);
     }
     $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal']);
     $GLOBALS['CartSaveTotal'] = CurrencyConvertFormatPrice($_SESSION['you_save']);
     //blessen
     if (!gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
     }
     // Are there any products in the cart?
     if ($GLOBALS['ISC_CLASS_CART']->api->GetNumProductsInCart() == 0) {
         $GLOBALS['HideShoppingCartGrid'] = "none";
     } else {
         $GLOBALS['HideShoppingCartEmptyMessage'] = "none";
     }
 }
	private function loadProductComments($productId)
	{
		$GLOBALS['ProductId'] = $productId;

		// Are there any reviews for this product? If so, load them
		if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews() == 0) {
			$GLOBALS['NoReviews'] = GetLang('NoReviews');
		}
		else {
			// Setup paging data
			$reviewsTotal = $GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews();
			$reviewsPerPage = GetConfig('ProductReviewsPerPage');
			$pages = ceil($reviewsTotal / $reviewsPerPage);

			$revpage = 1;
			$start = 0;

			if (isset($_GET['revpage'])) {
				$revpage = (int)$_GET['revpage'];
			}

			if ($revpage < 1) {
				$revpage = 1;
			}
			elseif ($revpage > $pages) {
				$revpage = $pages;
			}

			$start = ($revpage - 1) * $reviewsPerPage;

			$GLOBALS['ProductNumReviews'] = $reviewsTotal;
			$GLOBALS['ReviewStart'] = $start + 1;
			$GLOBALS['ReviewEnd'] = $start + $reviewsPerPage;

			// do we need to show paging?
			if ($pages > 1) {
				// Form the previous and next links
				$reviewLink = ProdLink($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName());
				if($GLOBALS['EnableSEOUrls'] == 1) {
					$reviewLink .= '?revpage=';
				}
				else {
					$reviewLink .= '&revpage=';
				}

				if ($GLOBALS['ReviewEnd'] > $reviewsTotal) {
					$GLOBALS['ReviewEnd'] = $reviewsTotal;
				}

				// show a previous link
				if ($revpage > 1) {
					$GLOBALS["ReviewLink"] = $reviewLink . ($revpage - 1);
					$GLOBALS["PrevRevLink"] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewPreviousLink");
				}

				// show a next link
				if ($revpage < $pages) {
					$GLOBALS["ReviewLink"] = $reviewLink . ($revpage + 1);
					$GLOBALS["NextRevLink"] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewNextLink");
				}

				$GLOBALS['ProductReviewPaging'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewPaging");
			}

			// Load all reviews for this product
			$query = "
				SELECT *
				FROM [|PREFIX|]reviews
				WHERE revproductid='".(int)$GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()."' AND revstatus='1'
				ORDER BY revdate DESC
			";
			$query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $reviewsPerPage);
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			$GLOBALS['ProductReviews'] = "";

			$GLOBALS['AlternateReviewClass'] = '';
			$GLOBALS['ReviewNumber'] = $GLOBALS['ReviewStart'];
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$GLOBALS['ReviewRating'] = (int) $row['revrating'];
				$GLOBALS['ReviewTitle'] = isc_html_escape($row['revtitle']);
				$GLOBALS['ReviewDate'] = isc_date(GetConfig('DisplayDateFormat'), $row['revdate']);

				if ($row['revfromname'] != "") {
					$GLOBALS['ReviewName'] = isc_html_escape($row['revfromname']);
				} else {
					$GLOBALS['ReviewName'] = GetLang('Unknown');
				}

				$GLOBALS['ReviewText'] = nl2br(isc_html_escape($row['revtext']));

				$GLOBALS['ProductReviews'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewItem");
				++$GLOBALS['ReviewNumber'];
				if($GLOBALS['AlternateReviewClass']) {
					$GLOBALS['AlternateReviewClass'] = '';
				}
				else {
					$GLOBALS['AlternateReviewClass'] = 'Alt';
				}
			}

			$GLOBALS['ProductReviewList'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductReviewList");
		}

		// Is captcha enabled?
		if (GetConfig('CaptchaEnabled') == false) {
			$GLOBALS['HideReviewCaptcha'] = "none";
		}
		else {
			// Generate the captcha image
			$GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
			$GLOBALS['ISC_CLASS_CAPTCHA']->CreateSecret();
			$GLOBALS['CaptchaImage'] = $GLOBALS['ISC_CLASS_CAPTCHA']->ShowCaptcha();
		}

		$GLOBALS['ProductReviewFlashMessages'] = GetFlashMessageBoxes('reviews');

		// If we've got review data in the session then we need to show the review form
		if(!empty($_SESSION['productReviewData']['product_id'])) {
			// But only if it's for the current product
			 if($_SESSION['productReviewData']['product_id'] == $productId) {
				$GLOBALS['AutoShowReviewForm'] = 1;

				$reviewFields = array(
					'RevTitle' => 'revtitle',
					'RevText' => 'revtext',
					'RevFromName' => 'revfromname',
				);

				foreach($reviewFields as $templateVar => $field) {
					if(!empty($_SESSION['productReviewData'])) {
						$GLOBALS[$templateVar] = isc_html_escape($_SESSION['productReviewData'][$field]);
					}
				}

				if(isset($_SESSION['productReviewData']['revrating'])) {
					$GLOBALS['ReviewRating'.(int)$_SESSION['productReviewData']['revrating']] = 'selected="selected"';
				}
			}

			// Make sure we remove any review data
			unset($_SESSION['productReviewData']);
		}

		$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("product_comments");
		return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
	}
Example #10
0
		/**
		*	Show a list of items that the customer has recently viewed by browsing our site
		*/
		private function ShowRecentItems()
		{

			$viewed = "";

			if (isset($_COOKIE['RECENTLY_VIEWED_PRODUCTS'])) {
				$viewed = $_COOKIE['RECENTLY_VIEWED_PRODUCTS'];
			} else if (isset($_SESSION['RECENTLY_VIEWED_PRODUCTS'])) {
				$viewed = $_SESSION['RECENTLY_VIEWED_PRODUCTS'];
			}

			if ($viewed != "") {
				$GLOBALS['HideNoRecentItemsMessage'] = "none";
				$GLOBALS['SNIPPETS']['AccountRecentItems'] = "";

				$viewed_products = array();
				$viewed_products = explode(",", $viewed);
				foreach ($viewed_products as $k => $p) {
					$viewed_products[$k] = (int) $p;
				}

				// Reverse the array so recently viewed products appear up top
				$viewed_products = array_reverse($viewed_products);

				// Hide the compare button if there's less than 2 products
				if (GetConfig('EnableProductComparisons') == 0 || count($viewed_products) < 2) {
					$GLOBALS['HideCompareItems'] = "none";
				}

				if (!empty($viewed_products)) {
					if(!getProductReviewsEnabled()) {
						$GLOBALS['HideProductRating'] = "display: none";
					}
					$query = "
						SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL()."
						FROM [|PREFIX|]products p
						LEFT JOIN [|PREFIX|]product_images pi ON (productid=pi.imageprodid AND imageisthumb=1)
						WHERE prodvisible='1' AND productid in ('".implode("','", $viewed_products)."')
						".GetProdCustomerGroupPermissionsSQL()."
					";
					$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
					if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
						$GLOBALS['AlternateClass'] = '';
						while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
							if($GLOBALS['AlternateClass'] == 'Odd') {
								$GLOBALS['AlternateClass'] = 'Even';
							}
							else {
								$GLOBALS['AlternateClass'] = 'Odd';
							}

							$GLOBALS['ProductId'] = (int) $row['productid'];
							$GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
							$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
							$GLOBALS['ProductRating'] = (int)$row['prodavgrating'];

							// Determine the price of this product
							$GLOBALS['ProductPrice'] = '';
							if (GetConfig('ShowProductPrice') && !$row['prodhideprice']) {
								$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);
							}

							$GLOBALS['ProductThumb'] = ImageThumb($row, ProdLink($row['prodname']));

							$GLOBALS['SNIPPETS']['AccountRecentItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountRecentlyViewedProducts");
						}
					}
				}
				else {
					$GLOBALS['HideRecentItemList'] = "none";
				}
			}
			else {
				$GLOBALS['HideRecentItemList'] = "none";
			}

			$GLOBALS['CompareLink'] = CompareLink();

			// Show the list of available shipping addresses
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(GetConfig('StoreName') . " - " . GetLang('RecentlyViewedItems'));
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("account_recentitems");
			$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
		}
Example #11
0
	public function SetPanelSettings()
	{
		$GLOBALS['SNIPPETS']['SideCartItems'] = '';

		// We check $_SESSION['QUOTE'] directly here as to not
		// instantiate the quote if it doesn't already exist.
		if(!isset($_SESSION['QUOTE']) && getCustomerQuote()->getNumItems() == 0) {
			$this->DontDisplay = true;
			return;
		}

		$incTax = false;
		if(getConfig('taxDefaultTaxDisplayCart') != TAX_PRICES_DISPLAY_EXCLUSIVE) {
			$incTax = true;
		}

		$quote = getCustomerQuote();
		$items = $quote->getItems();
		foreach($items as $item) {
			if($item->getProductId()) {
				$GLOBALS['ProductName'] = "<a href=\"".ProdLink($item->getName())."\">".isc_html_escape($item->getName())."</a>";
			}
			else {
				$GLOBALS['ProductName'] = isc_html_escape($item->getName());
			}

			// Is this product a variation?
			$GLOBALS['ProductOptions'] = '';
			$options = $item->getVariationOptions();
			if(!empty($options)) {
				$GLOBALS['ProductOptions'] .= "<br /><small>(";
				$comma = '';
				foreach($options as $name => $value) {
					if(!trim($name) || !trim($value)) {
						continue;
					}
					$GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
					$comma = ', ';
				}
				$GLOBALS['ProductOptions'] .= ")</small>";
			}

			$GLOBALS['ProductPrice'] = currencyConvertFormatPrice($item->getTotal($incTax));
			$GLOBALS['ProductQuantity'] = $item->getQuantity();
			$GLOBALS['SNIPPETS']['SideCartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCartItem");
		}

		$numItems = $quote->getNumItems();
		if($numItems == 1) {
			$GLOBALS['SideCartItemCount'] = GetLang('SideCartYouHave1Item');
		} else {
			$GLOBALS['SideCartItemCount'] = sprintf(GetLang('SideCartYouHaveXItems'), $numItems);
		}

		$total = $quote->getSubTotal($incTax);
		$GLOBALS['ISC_LANG']['SideCartTotalCost'] = sprintf(GetLang('SideCartTotalCost'), CurrencyConvertFormatPrice($total));

		// Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
		$GLOBALS['AdditionalCheckoutButtons'] = '';
		$HideCheckout = false;
		foreach (GetAvailableModules('checkout', true, true) as $module) {
			if (method_exists($module['object'], 'GetSidePanelCheckoutButton')) {
				$GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetSidePanelCheckoutButton();
			}

			if ($module['object']->disableNonCartCheckoutButtons) {
				$HideCheckout = true;
			}

		}

		if ($HideCheckout) {
			$GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = '';
		} else {
			require_once ISC_BASE_PATH.'/includes/display/CartHeader.php';

			$cartPanel = getClass('ISC_CARTHEADER_PANEL');
			$cartPanel -> insertOptimizerLinkScript();
			$GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SideCartContentsCheckoutLink');
		}

	}
 /**
  *	Show all products by inventory levels
  */
 public function ProductStatsByInventoryGrid()
 {
     $GLOBALS['OrderGrid'] = "";
     // How many records per page?
     if (isset($_GET['Show'])) {
         $per_page = (int) $_GET['Show'];
     } else {
         $per_page = 20;
     }
     $GLOBALS['ProductsPerPage'] = $per_page;
     $GLOBALS["IsShowPerPage" . $per_page] = 'selected="selected"';
     // Should we limit the records returned?
     if (isset($_GET['Page'])) {
         $page = (int) $_GET['Page'];
     } else {
         $page = 1;
     }
     $GLOBALS['ProductsByInventoryCurrentPage'] = $page;
     // Workout the start and end records
     $start = $per_page * $page - $per_page;
     $end = $start + ($per_page - 1);
     // Only fetch products this user can actually see
     $vendorRestriction = $this->GetVendorRestriction();
     $vendorSql = '';
     if ($vendorRestriction !== false) {
         $vendorSql = " WHERE prodvendorid = '" . $GLOBALS['ISC_CLASS_DB']->Quote($vendorRestriction) . "'";
     }
     // How many products are there in total?
     $query = "\n\t\t\tSELECT\n\t\t\t\tCOUNT(*) AS num\n\t\t\tFROM\n\t\t\t\t[|PREFIX|]products\n\t\t\t" . $vendorRestriction;
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     $total_products = $row['num'];
     if ($total_products > 0) {
         // Workout the paging
         $num_pages = ceil($total_products / $per_page);
         $paging = sprintf(GetLang('PageXOfX'), $page, $num_pages);
         $paging .= "&nbsp;&nbsp;&nbsp;&nbsp;";
         // Is there more than one page? If so show the &laquo; to jump back to page 1
         if ($num_pages > 1) {
             $paging .= "<a href='javascript:void(0)' onclick='ChangeProductsByInventoryPage(1)'>&laquo;</a> | ";
         } else {
             $paging .= "&laquo; | ";
         }
         // Are we on page 2 or above?
         if ($page > 1) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByInventoryPage(%d)'>%s</a> | ", $page - 1, GetLang('Prev'));
         } else {
             $paging .= sprintf("%s | ", GetLang('Prev'));
         }
         for ($i = 1; $i <= $num_pages; $i++) {
             // Only output paging -5 and +5 pages from the page we're on
             if ($i >= $page - 6 && $i <= $page + 5) {
                 if ($page == $i) {
                     $paging .= sprintf("<strong>%d</strong> | ", $i);
                 } else {
                     $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByInventoryPage(%d)'>%d</a> | ", $i, $i);
                 }
             }
         }
         // Are we on page 2 or above?
         if ($page < $num_pages) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByInventoryPage(%d)'>%s</a> | ", $page + 1, GetLang('Next'));
         } else {
             $paging .= sprintf("%s | ", GetLang('Next'));
         }
         // Is there more than one page? If so show the &raquo; to go to the last page
         if ($num_pages > 1) {
             $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeProductsByInventoryPage(%d)'>&raquo;</a> | ", $num_pages);
         } else {
             $paging .= "&raquo; | ";
         }
         $paging = rtrim($paging, ' |');
         $GLOBALS['Paging'] = $paging;
         if (isset($_GET['SortOrder']) && $_GET['SortOrder'] == "desc") {
             $sortOrder = 'desc';
         } else {
             $sortOrder = 'asc';
         }
         $sortFields = array('productid', 'prodcode', 'prodname', 'prodnumviews', 'instock');
         if (isset($_GET['SortBy']) && in_array($_GET['SortBy'], $sortFields)) {
             $sortField = $_GET['SortBy'];
             SaveDefaultSortField("ProductStatsByInventory", $_REQUEST['SortBy'], $sortOrder);
         } else {
             list($sortField, $sortOrder) = GetDefaultSortField("ProductStatsByInventory", "instock", $sortOrder);
         }
         $sortLinks = array("ProductId" => "productid", "Code" => "prodcode", "Name" => "prodname", "Views" => "prodnumviews", "Stock" => "instock");
         BuildAdminSortingLinks($sortLinks, "javascript:SortProductsByInventory('%%SORTFIELD%%', '%%SORTORDER%%');", $sortField, $sortOrder);
         // Fetch the products and inventory levels for this page
         $query = "\n\t\t\t\tSELECT productid, prodcode, prodname, prodnumviews, prodinvtrack,\n\t\t\t\t\tCASE prodinvtrack\n\t\t\t\t\t\tWHEN '0' THEN\n\t\t\t\t\t\t\t-1\n\t\t\t\t\t\tWHEN '1' THEN\n\t\t\t\t\t\t\tprodcurrentinv\n\t\t\t\t\t\tWHEN '2' THEN\n\t\t\t\t\t\t\t\t(SELECT SUM(vcstock) FROM [|PREFIX|]product_variation_combinations WHERE vcproductid=productid)\n\t\t\t\t\t\tEND\n\t\t\t\t\t\tAS instock\n\t\t\t\tFROM [|PREFIX|]products\n\t\t\t\t " . $vendorSql . "\n\t\t\t\tORDER BY " . $sortField . " " . $sortOrder;
         // Add the Limit
         $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $per_page);
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 switch ($row['prodinvtrack']) {
                     case 0:
                         // Not tracking
                         $tracking_method = GetLang('NA');
                         break;
                     case 1:
                         // By product
                         $tracking_method = GetLang('StatsByProduct');
                         break;
                     case 2:
                         // By option
                         $tracking_method = GetLang('StatsByProductOption');
                         break;
                 }
                 switch ($row['instock']) {
                     case -1:
                         $stock_level = GetLang('NA');
                         $edit_link = sprintf("<span class='disabled'>%s</span>", GetLang('UpdateStockLevels'));
                         break;
                     default:
                         $stock_level = number_format($row['instock']);
                         $edit_link = sprintf("<a href='index.php?ToDo=viewProducts&amp;productId=%d' target='_blank'>%s</span>", $row['productid'], GetLang('UpdateStockLevels'));
                         if ($stock_level == 0) {
                             // Flag if zero
                             $stock_level = sprintf("<b style='color:red'>%s</strong>", $stock_level);
                         }
                 }
                 $sku = GetLang('NA');
                 if ($row['prodcode'] != '') {
                     $sku = isc_html_escape($row['prodcode']);
                 }
                 $GLOBALS['OrderGrid'] .= sprintf("\n\t\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\"> \n\t\t\t\t\t\t\t<td nowrap height=\"22\" class=\"" . $GLOBALS['SortedFieldProductIdClass'] . "\">\n\t\t\t\t\t\t\t\t%d\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"" . $GLOBALS['SortedFieldCodeClass'] . "\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"" . $GLOBALS['SortedFieldNameClass'] . "\">\n\t\t\t\t\t\t\t\t<a href='%s' target='_blank'>%s</a>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"" . $GLOBALS['SortedFieldStockClass'] . "\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t", $row['productid'], $sku, ProdLink($row['prodname']), isc_html_escape($row['prodname']), $tracking_method, $stock_level, $edit_link);
             }
         }
     } else {
         $GLOBALS['OrderGrid'] .= sprintf("\n\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t<td nowrap height=\"22\" colspan=\"6\">\n\t\t\t\t\t\t<em>%s</em>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t", GetLang('StatsNoProducts'));
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("stats.products.byinventorygrid");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
Example #13
0
 public function SetPanelSettings()
 {
     $_SESSION['you_save'] = 0;
     //blessen
     $GLOBALS['SNIPPETS']['CartItems'] = "";
     $count = 0;
     $subtotal = 0;
     $_SESSION['CHECKOUT'] = array();
     // Get a list of all products in the cart
     $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART');
     $product_array = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
     /* $cprint = print_r($product_array, true);     
        $q      = "INSERT INTO isc_orderlogs (`ordervalue`) VALUES ('$cprint')";
        $r      = $GLOBALS["ISC_CLASS_DB"]->Query($q); */
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $ShowCheckoutButton = false;
     if (!empty($product_array)) {
         foreach (GetAvailableModules('checkout', true, true) as $module) {
             if (isset($module['object']->_showBothButtons) && $module['object']->_showBothButtons) {
                 $ShowCheckoutButton = true;
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } elseif (method_exists($module['object'], 'GetCheckoutButton')) {
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } else {
                 $ShowCheckoutButton = true;
             }
         }
     }
     $GLOBALS['HideMultipleAddressShipping'] = 'display: none';
     if (gzte11(ISC_MEDIUMPRINT) && $GLOBALS['ISC_CLASS_CART']->api->GetNumPhysicalProducts() > 1 && $ShowCheckoutButton && GetConfig("MultipleShippingAddresses")) {
         $GLOBALS['HideMultipleAddressShipping'] = '';
     }
     $GLOBALS['HideCheckoutButton'] = '';
     if (!$ShowCheckoutButton) {
         $GLOBALS['HideCheckoutButton'] = 'display: none';
         $GLOBALS['HideMultipleAddressShippingOr'] = 'display: none';
     }
     $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
     if (empty($wrappingOptions)) {
         $publicWrappingOptions = false;
     } else {
         $publicWrappingOptions = true;
     }
     if (!GetConfig('ShowThumbsInCart')) {
         $GLOBALS['HideThumbColumn'] = 'display: none';
         $GLOBALS['ProductNameSpan'] = 2;
     } else {
         $GLOBALS['HideThumbColumn'] = '';
         $GLOBALS['ProductNameSpan'] = 1;
     }
     $wrappingAdjustment = 0;
     $itemTotal = 0;
     $comptotal = 0;
     # To get all the complementary product total -- Baskaran
     $compprice = 0;
     foreach ($product_array as $k => $product) {
         $GLOBALS['CartItemId'] = (int) $product['cartitemid'];
         // If the item in the cart is a gift certificate, we need to show a special type of row
         if (isset($product['type']) && $product['type'] == "giftcertificate") {
             $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']);
             $GLOBALS["Quantity" . $product['quantity']] = 'selected="selected"';
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['giftamount'] * $product['quantity']);
             $itemTotal += $product['giftamount'] * $product['quantity'];
             $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate");
         } else {
             $GLOBALS['ProductLink'] = ProdLink($product['data']['prodname']);
             $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']);
             $GLOBALS['ItemId'] = (int) $product['data']['productid'];
             $GLOBALS['VariationId'] = (int) $product['variation_id'];
             $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
             //blessen
             $GLOBALS['prodretailprice'] = CurrencyConvertFormatPrice($product['data']['prodretailprice']);
             if ($product['data']['prodretailprice'] > $product['data']['prodcalculatedprice']) {
                 $_SESSION['you_save'] += ($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']) * $product['quantity'];
             }
             //$GLOBALS['saveprice'] =  CurrencyConvertFormatPrice($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']);
             //blessen
             // Should we show thumbnails in the cart?
             if (GetConfig('ShowThumbsInCart')) {
                 $GLOBALS['ProductImage'] = ImageThumb($product['data']['imagefile'], ProdLink($product['data']['prodname']));
             }
             $GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);";
             $GLOBALS['HideCartProductFields'] = 'display:none;';
             $GLOBALS['CartProductFields'] = '';
             $this->GetProductFieldDetails($product['product_fields'], $k);
             $GLOBALS['EventDate'] = '';
             if (isset($product['event_date'])) {
                 $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:10px; color:gray">(' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . ')</div>';
             }
             // Can this product be wrapped?
             $GLOBALS['GiftWrappingName'] = '';
             $GLOBALS['HideGiftWrappingAdd'] = '';
             $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
             $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
             $GLOBALS['GiftWrappingPrice'] = '';
             $GLOBALS['GiftMessagePreview'] = '';
             $GLOBALS['HideGiftMessagePreview'] = 'display: none';
             $GLOBALS['HideWrappingOptions'] = 'display: none';
             if ($product['data']['prodtype'] == PT_PHYSICAL && $product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                 $GLOBALS['HideWrappingOptions'] = '';
                 if (isset($product['wrapping'])) {
                     $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                     $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                     $GLOBALS['HideGiftWrappingEdit'] = '';
                     $GLOBALS['HideGiftWrappingPrice'] = '';
                     $wrappingAdjustment += $product['wrapping']['wrapprice'] * $product['quantity'];
                     $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                     if (isset($product['wrapping']['wrapmessage'])) {
                         if (isc_strlen($product['wrapping']['wrapmessage']) > 30) {
                             $product['wrapping']['wrapmessage'] = substr($product['wrapping']['wrapmessage'], 0, 27) . '...';
                         }
                         $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping']['wrapmessage']);
                         if ($product['wrapping']['wrapmessage']) {
                             $GLOBALS['HideGiftMessagePreview'] = '';
                         }
                     }
                 }
             }
             $subtotalPrice = 0;
             if (isset($product['discount_price'])) {
                 $subtotalPrice = $product['discount_price'];
             } else {
                 $subtotalPrice = $product['product_price'];
             }
             $GLOBALS['ShowOnSaleImage'] = '';
             if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price'] && GetConfig('ShowOnSale')) {
                 $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($subtotalPrice));
                 if (isset($product['discount']) && isset($product['couponcode'])) {
                     $GLOBALS['ShowOnSaleImage'] = "Coupon Applied";
                 } else {
                     $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                 }
             } else {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($subtotalPrice);
             }
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($subtotalPrice * $product['quantity']);
             $itemTotal += $subtotalPrice * $product['quantity'];
             // If we're using a cart quantity drop down, load that
             if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                 $GLOBALS["Quantity" . $product['quantity']] = "selected=\"selected\"";
                 if (isset($GLOBALS["Quantity0"])) {
                     $GLOBALS['QtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                 } else {
                     $GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>";
                 }
                 // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                 if ($product['quantity'] > 30) {
                     $GLOBALS["QtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['quantity']] . " value='" . $product['quantity'] . "'>" . $product['quantity'] . "</option>";
                 }
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
             } else {
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($product['options']) && !empty($product['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($product['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             //temp script to shortern the product name
             $pid = $product['data']['productid'];
             $pcode = $product['data']['prodcode'];
             $querytemp = "SELECT prodbrandid FROM  [|PREFIX|]products where productid = " . $pid . "  ";
             $resulttemp = $GLOBALS['ISC_CLASS_DB']->Query($querytemp);
             $brand = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp);
             if ($brand['prodbrandid'] == 37) {
                 $querytemp1 = "SELECT c.catname, c.catcombine FROM [|PREFIX|]categories \tc left join [|PREFIX|]categoryassociations ca on c.categoryid = ca.categoryid  left join [|PREFIX|]products p on ca.productid = p.productid where p.productid =  '" . $pid . "' ";
                 $resulttemp1 = $GLOBALS['ISC_CLASS_DB']->Query($querytemp1);
                 $cat = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp1);
                 if ($cat['catcombine'] != "") {
                     $GLOBALS['ProductName'] = $cat['catcombine'] . " Part Number " . $pcode;
                 } else {
                     $GLOBALS['ProductName'] = $cat['catname'] . " Part Number " . $pcode;
                 }
             } else {
                 $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             }
             //temp script to shortern the product name
             //temp script to shortern the product name
             $GLOBALS['complementaryrow'] = '';
             $compitem = $product['compitem'];
             if ($compitem == 1) {
                 for ($y = 0; $y < count($product['complementary']); $y++) {
                     /* Added for to display the complementary product in the cart -- Baskaran */
                     $compproductid = $product['complementary'][$y]['comp_productid'];
                     $compmainproductid = $product['complementary'][$y]['comp_mainproductid'];
                     $mainproductid = $product['product_id'];
                     $GLOBALS['CompCartItemId'] = $y;
                     if ($mainproductid == $compmainproductid) {
                         $GLOBALS['CompProdName'] = $compprodname = isc_html_escape($product['complementary'][$y]['comp_product_name']);
                         $compsku = isc_html_escape($product['complementary'][$y]['comp_product_code']);
                         $compprice = $product['complementary'][$y]['comp_original_price'];
                         $GLOBALS['CompProductPrice'] = $comppriceformat = CurrencyConvertFormatPrice($product['complementary'][$y]['comp_original_price']);
                         $query = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT imagefile FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images i ON p.productid = i.imageprodid AND i.imageisthumb = '1' where p.productid = '{$compproductid}' AND p.prodvisible = '1' ");
                         $path = '';
                         if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($query)) {
                             $path = $row['imagefile'];
                         }
                         if ($path != '') {
                             $GLOBALS['ProdImage'] = GetConfig('ShopPath') . "/product_images/{$path}";
                         } else {
                             $GLOBALS['ProdImage'] = GetConfig('ShopPath') . "/templates/CongoWorld/images/ProductDefault.gif";
                         }
                         //Added for complementary products - By Simha..
                         // If we're using a cart quantity drop down, load that
                         if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                             $GLOBALS["CompQuantity" . $product['complementary'][$y]['quantity']] = "selected=\"selected\"";
                             if (isset($GLOBALS["Quantity0"])) {
                                 $GLOBALS['CompCartQtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                             } else {
                                 $GLOBALS['CompCartQtyOptionZero'] = "<option value='0'>0</option>";
                             }
                             // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                             if ($product['quantity'] > 30) {
                                 //Needed to be changed for the complementary
                                 $GLOBALS["CompCartQtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['complementary'][$y]['quantity']] . " value='" . $product['complementary'][$y]['quantity'] . "'>" . $product['complementary'][$y]['quantity'] . "</option>";
                             }
                             $GLOBALS['CompCartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompItemQtySelect");
                         } else {
                             $GLOBALS['CompCartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompItemQtyText");
                         }
                         //Added for complementary products Ends - By Simha..
                         $GLOBALS['CompProductTotal'] = CurrencyConvertFormatPrice($compprice * $product['complementary'][$y]['quantity']);
                         $GLOBALS['complementaryrow'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ComplementaryItem");
                         $comptotal += $compprice * $product['complementary'][$y]['quantity'];
                     }
                     $GLOBALS["CompQuantity" . $product['complementary'][$y]['quantity']] = "";
                 }
             }
             /* Code Ends */
             //$GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             //blessen
             $withoutdollar = str_replace("\$", "", $GLOBALS['prodretailprice']);
             if (intval($withoutdollar) <= 0) {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
             } else {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem1");
             }
             //blessen
             // original $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
         }
         $GLOBALS["Quantity" . $product['quantity']] = "";
     }
     if ($wrappingAdjustment > 0) {
         $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($wrappingAdjustment);
     } else {
         $GLOBALS['HideGiftWrappingTotal'] = 'display: none';
     }
     $GLOBALS['HideAdjustedTotal'] = "none";
     $GLOBALS['AdjustedCartSubTotal'] = $GLOBALS['CartSubTotal'] - $GLOBALS['CartSubTotalDiscount'];
     $itemTotal += $comptotal;
     # Baskaran
     $GLOBALS['CartItemTotal'] = CurrencyConvertFormatPrice($itemTotal);
     $GLOBALS['SNIPPETS']['Coupons'] = '';
     $coupons = $GLOBALS['ISC_CLASS_CART']->api->GetAppliedCouponCodes();
     if (count($coupons)) {
         foreach ($coupons as $coupon) {
             $GLOBALS['CouponId'] = $coupon['couponid'];
             $GLOBALS['CouponCode'] = $coupon['couponcode'];
             // percent coupon
             if ($coupon['coupontype'] == 1) {
                 $discount = $coupon['discount'] . "%";
             } else {
                 $discount = CurrencyConvertFormatPrice($coupon['discount']);
             }
             $GLOBALS['CouponDiscount'] = $discount;
             $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon");
         }
     }
     $GLOBALS['SNIPPETS']['GiftCertificates'] = '';
     // Has the customer chosen one or more gift certificates to apply to this order? We need to show them
     if (isset($_SESSION['CART']['GIFTCERTIFICATES']) && is_array($_SESSION['CART']['GIFTCERTIFICATES'])) {
         $certificates = $_SESSION['CART']['GIFTCERTIFICATES'];
         uasort($certificates, "GiftCertificateSort");
         foreach ($certificates as $certificate) {
             $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
             $GLOBALS['GiftCertificateId'] = $certificate['giftcertid'];
             $GLOBALS['GiftCertificateBalance'] = $certificate['giftcertbalance'];
             if ($GLOBALS['GiftCertificateBalance'] > $GLOBALS['AdjustedCartSubTotal']) {
                 $GLOBALS['GiftCertificateRemaining'] = $certificate['giftcertbalance'] - $GLOBALS['AdjustedCartSubTotal'];
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'] - $GLOBALS['GiftCertificateRemaining'];
             } else {
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'];
                 $GLOBALS['GiftCertificateRemaining'] = 0;
             }
             // Subtract this amount from the adjusted total
             $GLOBALS['AdjustedCartSubTotal'] -= $GLOBALS['GiftCertificateBalance'];
             if ($GLOBALS['AdjustedCartSubTotal'] <= 0) {
                 $GLOBALS['AdjustedCartSubTotal'] = 0;
             }
             $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateBalance']);
             $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateRemaining']);
             $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($GLOBALS['CertificateAmountUsed']);
             $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartGiftCertificate");
         }
         if ($GLOBALS['SNIPPETS']['GiftCertificates']) {
             $GLOBALS['HideAdjustedTotal'] = '';
             if ($GLOBALS['AdjustedCartSubTotal'] == 0) {
                 $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
             }
         }
     }
     if ($GLOBALS['AdjustedCartSubTotal'] != $GLOBALS['CartSubTotal']) {
         $GLOBALS['HideAdjustedTotal'] = "";
         $GLOBALS['AdjustedCartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['AdjustedCartSubTotal']);
     }
     //            $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal']);
     $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal'] + $comptotal);
     # To add the subtotal in the cart -- Baskaran
     $GLOBALS['CartSaveTotal'] = CurrencyConvertFormatPrice($_SESSION['you_save']);
     //blessen
     if (!gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
     }
     // Are there any products in the cart?
     if ($GLOBALS['ISC_CLASS_CART']->api->GetNumProductsInCart() == 0) {
         $GLOBALS['HideShoppingCartGrid'] = "none";
     } else {
         $GLOBALS['HideShoppingCartEmptyMessage'] = "none";
     }
 }
Example #14
0
	public function setProductGlobals($row)
	{
		if($GLOBALS['AlternateClass'] == 'Odd') {
			$GLOBALS['AlternateClass'] = 'Even';
		}
		else {
			$GLOBALS['AlternateClass'] = 'Odd';
		}

		$GLOBALS['ProductCartQuantity'] = '';
		if(isset($GLOBALS['CartQuantity'.$row['productid']])) {
			$GLOBALS['ProductCartQuantity'] = (int)$GLOBALS['CartQuantity'.$row['productid']];
		}

		$GLOBALS['ProductId'] = (int)$row['productid'];
		$GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
		$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
		$GLOBALS['ProductRating'] = (int)$row['prodavgrating'];

		// Determine the price of this product
		$GLOBALS['ProductPrice'] = '';
		if (GetConfig('ShowProductPrice') && !$row['prodhideprice']) {
			$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);
		}

		// Workout the product description
		$desc = strip_tags($row['proddesc']);

		if (isc_strlen($desc) < 120) {
			$GLOBALS['ProductSummary'] = $desc;
		} else {
			$GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "...";
		}

		$GLOBALS['ProductThumb'] = ImageThumb($row, ProdLink($row['prodname']));
		$GLOBALS['ProductDate'] = isc_date(GetConfig('DisplayDateFormat'), $row['proddateadded']);

		$GLOBALS['ProductPreOrder'] = false;
		$GLOBALS['ProductReleaseDate'] = '';
		$GLOBALS['HideProductReleaseDate'] = 'display:none';

		if ($row['prodpreorder']) {
			$GLOBALS['ProductPreOrder'] = true;
			if ($row['prodreleasedate'] && $row['prodreleasedateremove'] && time() >= (int)$row['prodreleasedate']) {
				$GLOBALS['ProductPreOrder'] = false;
			} else if ($row['prodreleasedate']) {
				$GLOBALS['ProductReleaseDate'] = GetLang('ProductListReleaseDate', array('releasedate' => isc_date(GetConfig('DisplayDateFormat'), (int)$row['prodreleasedate'])));
				$GLOBALS['HideProductReleaseDate'] = '';
			}
		}

		if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired'] == 1) {
			$GLOBALS['ProductURL'] = ProdLink($row['prodname']);
			$GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
		} else {
			$GLOBALS['ProductURL'] = CartLink($row['productid']);
			if ($GLOBALS['ProductPreOrder']) {
				$GLOBALS['ProductAddText'] = GetLang('ProductPreOrderCartLink');
			} else {
				$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
			}
		}

		if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
			$GLOBALS['HideActionAdd'] = '';
		} else {
			$GLOBALS['HideActionAdd'] = 'none';
		}


		$GLOBALS['HideProductVendorName'] = 'display: none';
		$GLOBALS['ProductVendor'] = '';
		if(GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
			$vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
			if(isset($vendorCache[$row['prodvendorid']])) {
				$GLOBALS['ProductVendor'] = '<a href="'.VendorLink($vendorCache[$row['prodvendorid']]).'">'.isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']).'</a>';
				$GLOBALS['HideProductVendorName'] = '';
			}
		}
	}
Example #15
0
	private function GetProducts()
	{
		header('Content-type: text/xml');
		echo '<?xml version="1.0"?>';
		echo '<results>';

		if(!isset($_REQUEST['searchQuery']) && !isset($_REQUEST['category']) || (isset($_REQUEST['searchQuery']) && isc_strlen($_REQUEST['searchQuery']) <= 3)) {
			echo "<error>".GetLang('DevEditLinkerEnterSearchTerms')."</error>";
		}
		else {
			$_REQUEST['category'] = array($_REQUEST['category']);
			$ResultCount = 0;
			$GLOBALS['ISC_CLASS_ADMIN_ENGINE'] = GetClass('ISC_ADMIN_ENGINE');
			$GLOBALS['ISC_CLASS_ADMIN_AUTH'] = GetClass('ISC_ADMIN_AUTH');
			$GLOBALS['ISC_CLASS_ADMIN_PRODUCT'] = GetClass('ISC_ADMIN_PRODUCT');
			$products = $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->_GetProductList(0, 'prodname', 'asc', $ResultCount, 'p.productid,p.prodname', false);

			if($ResultCount == 0) {
				if(isset($_REQUEST['searchQuery'])) {
					echo "<error>".GetLang('DevEditLinkerNoProducts')."</error>";
				}
				else {
					echo "<error>".GetLang('DevEditLinkerNoCategoryProducts')."</error>";
				}
			}
			else {
				while($product = $GLOBALS['ISC_CLASS_DB']->Fetch($products)) {
					echo sprintf('<result title="%s" icon="images/product.gif" id="%s"><![CDATA[%s]]></result>', isc_html_escape(isc_html_escape($product['prodname'])), $product['productid'], ProdLink($product['prodname']));
				}
			}
		}
		echo '</results>';
	}
 /**
  *	Build the grid that will be shown on the "Orders by Items Sold" tab
  **/
 public function OrderStatsByItemsSoldGrid()
 {
     $GLOBALS['OrderGrid'] = "";
     if (isset($_GET['From']) && isset($_GET['To'])) {
         $from_stamp = (int) $_GET['From'];
         $to_stamp = (int) $_GET['To'];
         // How many records per page?
         if (isset($_GET['Show'])) {
             $per_page = (int) $_GET['Show'];
         } else {
             $per_page = 20;
         }
         $GLOBALS['OrdersPerPage'] = $per_page;
         $GLOBALS["IsShowPerPage" . $per_page] = 'selected="selected"';
         // Should we limit the records returned?
         if (isset($_GET['Page'])) {
             $page = (int) $_GET['Page'];
         } else {
             $page = 1;
         }
         $GLOBALS['OrdersByItemsSoldCurrentPage'] = $page;
         // Workout the start and end records
         $start = $per_page * $page - $per_page;
         $end = $start + ($per_page - 1);
         // Only fetch products this user can actually see
         $vendorRestriction = $this->GetVendorRestriction();
         $vendorSql = '';
         if ($vendorRestriction !== false) {
             $vendorSql = " AND prodvendorid='" . $GLOBALS['ISC_CLASS_DB']->Quote($vendorRestriction) . "'";
         }
         // How many orders are there in total?
         $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tCOUNT(*) AS num\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]order_products\n\t\t\t\t\tINNER JOIN [|PREFIX|]orders ON orderorderid = orderid\n\t\t\t\t\tLEFT JOIN [|PREFIX|]products ON ordprodid = productid\n\t\t\t\tWHERE\n\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n\t\t\t\t\torddate >= '" . $from_stamp . "' AND\n\t\t\t\t\torddate <= '" . $to_stamp . "' AND\n\t\t\t\t\tordprodid != 0\n\t\t\t\t\t" . $vendorSql;
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         $total_orders = $row['num'];
         if ($total_orders > 0) {
             // Workout the paging
             $num_pages = ceil($total_orders / $per_page);
             $paging = sprintf(GetLang('PageXOfX'), $page, $num_pages);
             $paging .= "&nbsp;&nbsp;&nbsp;&nbsp;";
             // Is there more than one page? If so show the &laquo; to jump back to page 1
             if ($num_pages > 1) {
                 $paging .= "<a href='javascript:void(0)' onclick='ChangeOrdersByItemsSoldPage(1)'>&laquo;</a> | ";
             } else {
                 $paging .= "&laquo; | ";
             }
             // Are we on page 2 or above?
             if ($page > 1) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeOrdersByItemsSoldPage(%d)'>%s</a> | ", $page - 1, GetLang('Prev'));
             } else {
                 $paging .= sprintf("%s | ", GetLang('Prev'));
             }
             for ($i = 1; $i <= $num_pages; $i++) {
                 // Only output paging -5 and +5 pages from the page we're on
                 if ($i >= $page - 6 && $i <= $page + 5) {
                     if ($page == $i) {
                         $paging .= sprintf("<strong>%d</strong> | ", $i);
                     } else {
                         $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeOrdersByItemsSoldPage(%d)'>%d</a> | ", $i, $i);
                     }
                 }
             }
             // Are we on page 2 or above?
             if ($page < $num_pages) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeOrdersByItemsSoldPage(%d)'>%s</a> | ", $page + 1, GetLang('Next'));
             } else {
                 $paging .= sprintf("%s | ", GetLang('Next'));
             }
             // Is there more than one page? If so show the &raquo; to go to the last page
             if ($num_pages > 1) {
                 $paging .= sprintf("<a href='javascript:void(0)' onclick='ChangeOrdersByItemsSoldPage(%d)'>&raquo;</a> | ", $num_pages);
             } else {
                 $paging .= "&raquo; | ";
             }
             $paging = rtrim($paging, ' |');
             $GLOBALS['Paging'] = $paging;
             // Should we set focus to the grid?
             if (isset($_GET['FromLink']) && $_GET['FromLink'] == "true") {
                 $GLOBALS['JumpToOrdersByItemsSoldGrid'] = "<script type=\"text/javascript\">document.location.href='#ordersByItemsSoldAnchor';</script>";
             }
             if (isset($_GET['SortOrder']) && $_GET['SortOrder'] == "asc") {
                 $sortOrder = 'asc';
             } else {
                 $sortOrder = 'desc';
             }
             $sortFields = array('ordprodid', 'ordprodsku', 'ordprodname', 'numorders', 'revenue', 'numitemssold');
             if (isset($_GET['SortBy']) && in_array($_GET['SortBy'], $sortFields)) {
                 $sortField = $_GET['SortBy'];
                 SaveDefaultSortField("OrderStatsBySold", $_REQUEST['SortBy'], $sortOrder);
             } else {
                 list($sortField, $sortOrder) = GetDefaultSortField("OrderStatsBySold", "numorders", $sortOrder);
             }
             $sortLinks = array("ProductId" => "ordprodid", "Code" => "ordprodsku", "Name" => "ordprodname", "NumOrders" => "numorders", "Revenue" => "revenue", "UnitsSold" => "numitemssold");
             BuildAdminSortingLinks($sortLinks, "javascript:SortOrdersByItemsSold('%%SORTFIELD%%', '%%SORTORDER%%');", $sortField, $sortOrder);
             // Fetch the orders for this page
             $query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tordprodid,\n\t\t\t\t\t\tordprodsku,\n\t\t\t\t\t\tordprodname,\n\t\t\t\t\t\tCOUNT(DISTINCT(orderid)) AS numorders,\n\t\t\t\t\t\t(ordprodcost * SUM(ordprodqty)) AS revenue,\n\t\t\t\t\t\tSUM(ordprodqty) AS numitemssold,\n\t\t\t\t\t\tproductid\n\t\t\t\t\tFROM\n\t\t\t\t\t\t[|PREFIX|]order_products\n\t\t\t\t\t\tINNER JOIN [|PREFIX|]orders ON orderorderid = orderid\n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]products ON ordprodid = productid\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n\t\t\t\t\t\torddate >= '" . $from_stamp . "' AND\n\t\t\t\t\t\torddate <= '" . $to_stamp . "' AND\n\t\t\t\t\t\tordprodtype != 'giftcertificate' AND\n\t\t\t\t\t\tordprodid != 0\n\t\t\t\t\t\t" . $vendorSql . "\n\t\t\t\t\tGROUP BY\n\t\t\t\t\t\tordprodid DESC\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\t" . $sortField . " " . $sortOrder;
             // Add the Limit
             $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, $per_page);
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     $sku = GetLang('NA');
                     if ($row['ordprodsku']) {
                         $sku = isc_html_escape($row['ordprodsku']);
                     }
                     $prodlink = $row['ordprodname'];
                     if (!is_null($row['productid'])) {
                         $prodlink = "<a href='" . ProdLink($row['ordprodname']) . "' target='_blank'>" . isc_html_escape($row['ordprodname']) . "</a>";
                     }
                     $GLOBALS['OrderGrid'] .= sprintf("\n\t\t\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t\t\t<td nowrap height=\"22\" class=\"" . $GLOBALS['SortedFieldProductIdClass'] . "\">\n\t\t\t\t\t\t\t\t\t%d\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldCodeClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldNameClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldNumOrdersClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldUnitsSoldClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td nowrap class=\"" . $GLOBALS['SortedFieldRevenueClass'] . "\">\n\t\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t", (int) $row['ordprodid'], $sku, $prodlink, (int) $row['numorders'], (int) $row['numitemssold'], FormatPrice($row['revenue']));
                 }
             }
         } else {
             $GLOBALS['HideStatsRows'] = "none";
             $GLOBALS['OrderGrid'] .= sprintf("\n\t\t\t\t\t<tr class=\"GridRow\" onmouseover=\"this.className='GridRowOver';\" onmouseout=\"this.className='GridRow';\">\n\t\t\t\t\t\t<td nowrap height=\"22\" colspan=\"6\">\n\t\t\t\t\t\t\t<em>%s</em>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t", GetLang('StatsNoOrdersForDate'));
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("stats.orders.byitemssoldgrid");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     }
 }
 public function SetPanelSettings()
 {
     if (!gzte11(ISC_HUGEPRINT) || $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor() === false) {
         $this->DontDisplay = true;
         return false;
     }
     $vendor = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor();
     $GLOBALS['SNIPPETS']['VendorsOtherProducts'] = '';
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $query = "\n\t\t\tSELECT p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, i.imagefile, i.imageisthumb, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\tFROM [|PREFIX|]products p\n\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid AND i.imageisthumb=1)\n\t\t\tWHERE p.prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "' AND p.productid!='" . (int) $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "'\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\tORDER BY p.prodvendorfeatured DESC, RAND() DESC\n\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 9);
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $productsDone = 0;
     $hasMore = false;
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         ++$productsDone;
         if ($productsDone == 9) {
             $hasMore = true;
             break;
         }
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
             $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
             $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
         } else {
             //$GLOBALS['ProductURL'] = CartLink($row['productid']);
             $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
             //blessen
             if (intval($row['prodretailprice']) <= 0) {
                 $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
             } else {
                 $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1');
             }
             //blessen
             //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
         }
         if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
             $GLOBALS['HideActionAdd'] = '';
         } else {
             $GLOBALS['HideActionAdd'] = 'none';
         }
         $GLOBALS['SNIPPETS']['VendorsOtherProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVendorsOtherProductsItem");
     }
     if (!$GLOBALS['SNIPPETS']['VendorsOtherProducts']) {
         $this->DontDisplay = true;
     }
     $GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor);
     if ($hasMore == true) {
         $GLOBALS['HideViewAllLink'] = '';
     } else {
         $GLOBALS['HideViewAllLink'] = 'display: none';
     }
 }
Example #18
0
	private function ManageReturnsGrid(&$numReturns)
	{
		// Show a list of products in a table
		$page = 0;
		$start = 0;
		$numPages = 0;
		$GLOBALS['ReturnGrid'] = "";
		$GLOBALS['Nav'] = "";
		$catList = "";
		$max = 0;

		// Is this a custom search?
		if(isset($_GET['searchId'])) {
			$this->_customSearch = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->LoadSearch($_GET['searchId']);
			$_REQUEST = array_merge($_REQUEST, (array)$this->_customSearch['searchvars']);

			// Override custom search sort fields if we have a requested field
			if(isset($_GET['sortField'])) {
				$_REQUEST['sortField'] = $_GET['sortField'];
			}
			if(isset($_GET['sortOrder'])) {
				$_REQUEST['sortOrder'] = $_GET['sortOrder'];
			}
		}
		else if(isset($_GET['searchQuery'])) {
			$GLOBALS['Query'] = $_GET['searchQuery'];
		}

		if(isset($_REQUEST['sortOrder']) && $_REQUEST['sortOrder'] == "asc") {
			$sortOrder = "asc";
		}
		else {
			$sortOrder = "desc";
		}

		$validSortFields = array('returnid', 'retprodname', 'custname', 'retorderid', 'retdaterequested', 'retstatus');
		if(isset($_REQUEST['sortField']) && in_array($_REQUEST['sortField'], $validSortFields)) {
			$sortField = $_REQUEST['sortField'];
			SaveDefaultSortField("ManageReturns", $_REQUEST['sortField'], $sortOrder);
		}
		else {
			list($sortField, $sortOrder) = GetDefaultSortField("ManageReturns", "returnid", $sortOrder);
		}

		if(isset($_GET['page'])) {
			$page = (int)$_GET['page'];
		} else {
			$page = 1;
		}

		// Build the pagination and sort URL
		$searchURL = '';
		foreach($_GET as $k => $v) {
			if($k == "sortField" || $k == "sortOrder" || $k == "page" || $k == "new" || $k == "ToDo" || $k == "SubmitButton1" || !$v) {
				continue;
			}
			$searchURL .= sprintf("&%s=%s", $k, urlencode($v));
		}

		$sortURL = sprintf("%s&amp;sortField=%s&amp;sortOrder=%s", $searchURL, $sortField, $sortOrder);

		$GLOBALS['SortURL'] = $sortURL;

		// Limit the number of returns returned
		if ($page == 1) {
			$start = 1;
		} else {
			$start = ($page * ISC_RETURNS_PER_PAGE) - (ISC_RETURNS_PER_PAGE-1);
		}

		$start = $start-1;

		// Get the results for the query
		$returnResult = $this->_GetReturnsList($start, $sortField, $sortOrder, $numReturns);

		$numPages = ceil($numReturns / ISC_RETURNS_PER_PAGE);

		// Add the "(Page x of n)" label
		if($numReturns > ISC_RETURNS_PER_PAGE) {
			$GLOBALS['Nav'] = sprintf("(%s %d of %d) &nbsp;&nbsp;&nbsp;", GetLang('Page'), $page, $numPages);
			$GLOBALS['Nav'] .= BuildPagination($numReturns, ISC_RETURNS_PER_PAGE, $page, sprintf("index.php?ToDo=viewReturns%s", $sortURL));
		}
		else {
			$GLOBALS['Nav'] = "";
		}

		if(isset($_GET['searchQuery'])) {
			$query = $_GET['searchQuery'];
		} else {
			$query = "";
		}

		$GLOBALS['Nav'] = rtrim($GLOBALS['Nav'], ' |');
		$GLOBALS['SearchQuery'] = $query;
		$GLOBALS['SortField'] = $sortField;
		$GLOBALS['SortOrder'] = $sortOrder;

		$sortLinks = array(
			"Id" => "returnid",
			"ReturnItem" => "retprodname",
			"Order" => "retorderid",
			"Cust" => "custname",
			"Date" => "retdaterequested",
			"Status" => "retstatus"
		);
		BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewReturns&amp;".$searchURL."&amp;page=".$page, $sortField, $sortOrder);

		$GLOBALS['ReturnStatusList'] = $this->GetReturnStatusOptions();

		// Display the returns
		while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($returnResult)) {
			$GLOBALS['ReturnId'] = $row['returnid'];
			$GLOBALS['OrderId'] = $row['retorderid'];

			$GLOBALS['ProductId'] = $row['retprodid'];
			$GLOBALS['ProductLink'] = ProdLink($row['retprodname'], $row['retprodname']);
			$GLOBALS['ProdName'] = isc_html_escape($row['retprodname']);

			$GLOBALS['ReturnedProductOptions'] = '';
			if($row['retprodoptions'] != '') {
				$options = @unserialize($row['retprodoptions']);
				if(!empty($options)) {
					$GLOBALS['ReturnedProductOptions'] = "<div style=\"margin-top: 3px; padding-left: 10px;\">(";
					$comma = '';
					foreach($options as $name => $value) {
						$GLOBALS['ReturnedProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
						$comma = ', ';
					}
					$GLOBALS['ReturnedProductOptions'] .= ")</div>";
				}
			}


			$GLOBALS['ReturnQty'] = (int)$row['retprodqty'] . " x ";

			$returnAmount = $row['retprodcost'] * $row['retprodqty'];

			$GLOBALS['AmountPaid'] = FormatPrice($returnAmount);

			$GLOBALS['CustomerId'] = (int)$row['retcustomerid'];
			$GLOBALS['Customer'] = isc_html_escape($row['custname']);
			$GLOBALS['Date'] = isc_date(GetConfig('DisplayDateFormat'), $row['retdaterequested']);

			$GLOBALS['ReturnStatus'] = (int)$row['retstatus'];
			$GLOBALS['ReturnStatusDisabled'] = '';
			if($row['retstatus'] == 5) {
				//$GLOBALS['ReturnStatusDisabled'] = 'disabled="disabled"';
			}

			$GLOBALS['ReturnStatusOptions'] = $this->GetReturnStatusOptions($row['retstatus']);

			$GLOBALS['IssueCreditLink'] = '';
			if(GetConfig('ReturnCredits') && !$row['retreceivedcredit']) {
				$GLOBALS['IssueCreditLink'] = sprintf("<a href='index.php?ToDo=issueReturnCredit&amp;returnId=%d' class='Action' onclick='return ConfirmIssueCredit(\"%s\");'>%s</a>", $row['returnid'], $GLOBALS['AmountPaid'], GetLang('ReturnIssueCredit'));
			}

			// local context for this render
			$context = array(
				'return' => $row,
			);

			$GLOBALS['ReturnGrid'] .= $this->template->render('returns.manage.row.tpl', $context);
		}
		return $this->template->render('returns.manage.grid.tpl');
	}
 public function SetPanelSettings()
 {
     $count = 0;
     $output = "";
     $params = $GLOBALS['ISC_CLASS_SEARCH']->_searchterms;
     $this->searchterms = $params;
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . $params['make'];
     }
     if (isset($_REQUEST['model']) && !empty($_REQUEST['model']) && (!isset($params['model_flag']) || $params['model_flag'] != 0)) {
         $GLOBALS['MMY'] .= strtoupper($_REQUEST['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . strtoupper($params['model']);
     } else {
         if (isset($params['model'])) {
             $ext_links .= $seo_delim . "model=" . $params['model'];
         }
     }
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= strtoupper($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
       $ext_links .= $seo_delim."year=".$params['year'];                
       }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         } else {
             $selected_catg = end($params['srch_category']);
         }
         $catg_desc_qry = "select catdesc from [|PREFIX|]categories where categoryid = " . $selected_catg;
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             $catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
       $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
       /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 0) {
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $GLOBALS['AlternateClass'] = '';
         $counter = 1;
         $CurCatId = 0;
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
             /* Added by Simha to check inf prodcucts comes from different categories*/
             if (empty($params['srch_category']) || !isset($params['srch_category'])) {
                 if ($CurCatId != $row['categoryid']) {
                     $CurCatId = $row['categoryid'];
                     $map_names = array();
                     $display_names = array();
                     $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names from \n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
                     // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
                     $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
                     while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                         $map_names[$filter_row['qid']] = $filter_row['column_name'];
                         $display_names[$filter_row['qid']] = $filter_row['display_names'];
                     }
                     $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                 }
             }
             /* Added by Simha Ends */
             $GLOBALS['SearchTrackClass'] = "TrackLink";
             $imagefile = "";
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $qry_string = $_SERVER['QUERY_STRING'];
             if (isset($_GET['page'])) {
                 $page = "&page=" . $_GET['page'];
                 $qry_string = str_ireplace($page, '', $qry_string);
             }
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 if (isset($_GET['search_key'])) {
                     $qry_string = str_ireplace('&search_key=' . $_GET['search_key'], '', $qry_string);
                 }
                 if (isset($params['search_query']) && !strstr($qry_string, 'search_query=')) {
                     $qry_string .= "search_query=" . MakeURLSafe($params['search_query']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model']) && !strstr($qry_string, 'model=')) {
                     $qry_string .= "&model=" . MakeURLSafe($params['model']);
                 }
                 if (isset($params['year']) && !strstr($qry_string, 'year=')) {
                     $qry_string .= "&year=" . MakeURLSafe($params['year']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model_flag']) && !strstr($qry_string, 'model_flag=')) {
                     $qry_string .= "&model_flag=" . MakeURLSafe($params['model_flag']);
                 }
                 if (isset($params['submodel']) && !strstr($qry_string, 'submodel=')) {
                     $qry_string .= "&submodel=" . MakeURLSafe($params['submodel']);
                 }
             }
             if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
                 if (isset($params['srch_category'])) {
                     $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                     // description will be added here to show it at the top of product listing page.
                 }
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 if ($counter % 2 == 0) {
                     $GLOBALS['RowColor'] = 'grayrow';
                 } else {
                     $GLOBALS['RowColor'] = 'whiterow';
                 }
                 $counter++;
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 $GLOBALS['BrandName'] = $row['brandname'];
                 $GLOBALS['ProdCode'] = $row['prodcode'];
                 //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
                 //$GLOBALS['ProdOptions'] = $row['productoption'];
                 $GLOBALS['VehicleOptions'] = "";
                 $GLOBALS['ProdOptions'] = "";
                 foreach ($row as $key => $val) {
                     if ($val != "" && $val != "~") {
                         if (($qualifier_id = array_search($key, $map_names)) !== false) {
                             if (eregi('^vq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['VehicleOptions'] .= $key . " : " . $val . "<br>";
                             }
                             if (eregi('^pq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['ProdOptions'] .= $key . " : " . $val . "<br>";
                             }
                         }
                     }
                 }
                 if (isset($row['vehicleoption'])) {
                     $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
                 }
                 if (isset($row['productoption'])) {
                     $GLOBALS['ProdOptions'] = $row['productoption'];
                 }
                 if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
                     $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
                     if ($vq_column_title == "") {
                         $vq_column_title = "Product Name";
                     } else {
                         if ($vq_column_title != "Product Name") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 } else {
                     if ($vq_column_title == "") {
                         $vq_column_title = "Vehicle Options";
                     } else {
                         if ($vq_column_title != "Vehicle Options") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 }
                 if (empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['VehicleOptions'] = "&nbsp;";
                 }
                 if (empty($GLOBALS['ProdOptions'])) {
                     $GLOBALS['ProdOptions'] = "&nbsp;";
                 }
                 /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                     $GLOBALS['ProductLink'] .= "/refer=true" . $ext_links;
                 } else {
                     $GLOBALS['ProductLink'] .= "&refer=true" . $ext_links;
                 }
                 ### Added by Simha for onsale addition
                 // Determine the price of this product
                 //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                 $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
                 $FinalPrice = $GLOBALS['ProductPrice'];
                 $SalePrice = $row['prodsaleprice'];
                 //$DiscountAmount = $FinalPrice;
                 if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
                     $DiscountPrice = $SalePrice;
                 } else {
                     $DiscountPrice = $FinalPrice;
                     $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid']);
                 }
                 /*
                 							foreach($DiscountInfo as $DiscountInfoSub)   {  
                     if(isset($DiscountInfoSub['catids']))    {
                 								    $catids = explode(",", $DiscountInfoSub['catids']); 
                 								    foreach($catids as $catid) {
                 									    if($catid == $row['categoryid']) {
                 										    $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                 										    if ($DiscountAmount < 0) {
                 											    $DiscountAmount = 0;
                 										    }                                                                         
                 										    $DiscountPrice  = $FinalPrice - $DiscountAmount;  
                 									    } 
                 								    }  
                     }
                 							}       
                 */
                 if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice) {
                     //&& GetConfig('ShowOnSale')
                     $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
                     $GLOBALS['ProductPrice'] .= '<br>' . CurrencyConvertFormatPrice($DiscountPrice) . '';
                     $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     if (GetConfig('ShowOnSale')) {
                         $GLOBALS['ProductPrice'] .= '<br>' . $GLOBALS['ShowOnSaleImage'] . '';
                     }
                 } else {
                     $GLOBALS['ProductPrice'] = '' . CurrencyConvertFormatPrice($FinalPrice) . '';
                 }
                 ### Added by Simha Ends
                 // commented the below line by vikas
                 //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                 $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                 } else {
                     //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     //blessen
                     if (intval($row['prodretailprice']) <= 0) {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     } else {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     }
                     //blessen
                     // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                 }
                 if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                     $GLOBALS['HideActionAdd'] = '';
                 } else {
                     $GLOBALS['HideActionAdd'] = 'none';
                 }
                 $GLOBALS['HideProductVendorName'] = 'display: none';
                 $GLOBALS['ProductVendor'] = '';
                 if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                     $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                     if (isset($vendorCache[$row['prodvendorid']])) {
                         $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                         $GLOBALS['HideProductVendorName'] = '';
                     }
                 }
                 $GLOBALS['CartURL'] = CartLink($row['productid']);
                 $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
                 if ($offer == 'yes') {
                     $GLOBALS['HideOfferButton'] = 'block';
                 } else {
                     $GLOBALS['HideOfferButton'] = 'none';
                 }
                 $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
             } else {
                 if ($GLOBALS['results_page_flag'] == 0) {
                     $subcatg_link = $this->LeftCatLink($mmy_links, 'subcategory', $row['catname']);
                     $link = "<a href='" . $subcatg_link . "'>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$link}<img src='{$path}/category_images/" . $images[$j] . "'></a>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     //$GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (!empty($row['seriesname'])) {
                         $row['brandname'] .= "<br>" . $row['seriesname'];
                     }
                     if ($row['seriesids'] != "") {
                         $seriesids = str_ireplace("~", ",", $row['seriesids']);
                         $seriesids_qry = "select brandname , seriesname from isc_brand_series bs left join isc_brands b on bs.brandid = b.brandid where seriesid in (" . $seriesids . ")";
                         $seriesids_res = $GLOBALS['ISC_CLASS_DB']->Query($seriesids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($seriesids_res) > 0) {
                             while ($seriesids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesids_res)) {
                                 if (!isset($params['brand'])) {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 } else {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 }
                             }
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     if (!isset($params['category']) && (isset($params['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))) {
                         $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                         // description will be added here to show it at the top of subcatg page.
                         $content .= "<h3><a href='" . $path . "/search.php?{$qry_string}&subcategory=" . MakeURLSafe($row['catname']) . "'>" . $row['catname'] . "</a></h3>>";
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $subcatg_link . "'>" . $row['catname'] . "</a></h2>";
                     }
                     $content .= "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '') . "<br>" . $imagefile;
                     $GLOBALS['leftsidecontent'] = $content;
                     $GLOBALS['PriceRange'] = "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $content = "{$link}<img src='{$path}/templates/default/images/view.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] = $content;
                     if (IsDiscountAvailable('category', $row['categoryid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('category', $row['categoryid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                 } else {
                     $series_link = $this->LeftCatLink($mmy_links, 'series', $row['seriesname']);
                     $link = "<a href='" . $series_link . "'>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$link}<img src='{$path}/category_images/" . $images[$j] . "'></a>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     $GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (isset($row['seriesname']) && !empty($row['seriesname']) && (!isset($params['srch_category']) || isset($params['category'])) && isset($GLOBALS['BRAND_SERIES_FLAG'])) {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $GLOBALS['LeftImage'] = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif'></a>";
                         } else {
                             $GLOBALS['LeftImage'] = "{$link}<img src='{$path}/series_images/" . $row['imagefile'] . "' width='140px'></a>";
                         }
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $series_link . "'>" . $row['brandname'] . " " . $row['seriesname'] . " " . $row['parentcatname'] . "</a></h2>";
                         //"<h3>".$row['catname']."</h3>
                         $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                         $GLOBALS['RelatedBrands'] = "<ul class='featurepoints'>";
                         if (!empty($row['feature_points1'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points1'] . "</li>";
                         }
                         if (!empty($row['feature_points2'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points2'] . "</li>";
                         }
                         if (!empty($row['feature_points3'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points3'] . "</li>";
                         }
                         if (!empty($row['feature_points4'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points4'] . "</li>";
                         }
                         $GLOBALS['RelatedBrands'] .= "</ul>";
                         /*if(isset($row['brandlargefile']) && !empty($row['brandlargefile'])) {
                         			$brand_image_path = "product_images/".$row['brandlargefile'];
                         			if(file_exists($brand_image_path)) {
                         				$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandlargefile']."'>";
                         			} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         			}
                         		} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         		}*/
                     }
                     $GLOBALS['CatgDescandBrandImage'] = $row['branddescription'];
                     if ($row['subcatgids'] != "") {
                         $subcatgids = str_ireplace("~", ",", $row['subcatgids']);
                         $subcatgids_qry = "select catname from [|PREFIX|]categories where categoryid in (" . $subcatgids . ")";
                         $subcatgids_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatgids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($subcatgids_res) > 0) {
                             while ($subcatgids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatgids_res)) {
                                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                                     $GLOBALS['ProductsCount'] .= "<br><a href='" . $series_link . "/subcategory/" . MakeURLSafe(Strtolower($subcatgids_arr['catname'])) . "'>" . $subcatgids_arr['catname'] . "</a>";
                                 } else {
                                     $GLOBALS['ProductsCount'] .= "<br><a href='" . $series_link . "&subcategory=" . MakeURLSafe(Strtolower($subcatgids_arr['catname'])) . "'>" . $subcatgids_arr['catname'] . "</a>";
                                 }
                             }
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     $content .= $row['catname'] . "<br>";
                     $content .= "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $GLOBALS['leftsidecontent'] = $content;
                     $GLOBALS['PriceRange'] = "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $content = "{$link}<img src='{$path}/templates/default/images/view.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] = $content;
                     if (IsDiscountAvailable('series', $row['brandseriesid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('series', $row['brandseriesid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                     $GLOBALS['HideCompareItems'] = "none";
                 }
             }
         }
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}{$mmy_links}/orderby/prodcalculatedprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcalculatedprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             		$GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             		$GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             $GLOBALS['ProductDetails'] = "Details";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItemHeader");
         } else {
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListingMain");
         }
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
         // Showing the syndication option?
         if (GetConfig('RSSNewProducts') != 0 && GetConfig('RSSCategories') != 0 && GetConfig('RSSSyndicationIcons') != 0) {
             $GLOBALS['RSSURL'] = SearchLink($GLOBALS['ISC_CLASS_SEARCH']->GetQuery(), 0, false);
             $GLOBALS['SNIPPETS']['SearchResultsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultsFeed");
         }
     } else {
         // No search results were found
         $GLOBALS['HideSearchResults'] = "none";
         $GLOBALS['HidePanels'][] = 'SearchPageProducts';
     }
 }
Example #20
0
		/**
		* _ReplaceTokens
		* Replace the placeholder tokens with values from the database
		*
		* @param String $row The row from the CSV file
		* @param Array $Data A reference to the database row for the product
		* @return String
		*/
		private function _ReplaceTokens($Row, &$Data)
		{

			$tokens = $this->_GetTokens();

			foreach($this->_GetTokens() as $token => $val) {
				if(isset($Data[$val]) || $token == "{PRODLINK}" || $token == "{STORENAME}") {
					switch($token) {
						case "{PRODSUMMARY}": {
							$Data[$val] = $this->_Strip(strip_tags($Data[$val]));

							if(strlen($Data[$val]) > 32) {
								$Data[$val] = isc_substr($Data[$val], 0, 32) . "...";
							}

							$Data[$val] = trim($Data[$val]);
							$Data[$val] = str_replace("\n", "", $Data[$val]);
							$Data[$val] = str_replace("\r", "", $Data[$val]);
							$Data[$val] = str_replace("\t", " ", $Data[$val]);
							break;
						}
						case "{PRODPRICE}": {
							$price = getClass('ISC_TAX')->getPrice($Data[$val], $Data['tax_class_id'], getConfig('taxDefaultTaxDisplayProducts'));
							$Data[$val] = FormatPrice($price, false, true);
							break;
						}
						case "{PRODLINK}": {
							$Data[$val] = ProdLink($Data['prodname']);
							break;
						}
						case "{STORENAME}": {
							$Data[$val] = GetConfig("StoreName");
							break;
						}
					}

					// Replace the value from the row
					$Row = str_replace($token, $Data[$val], $Row);
				}
				else {
					// Replace the value with nothing
					$Row = str_replace($token, "", $Row);
				}
			}

			$Row = str_replace("{Campaign Name}", GetConfig('StoreName'), $Row);
			$Row = str_replace("{Ad Group Name}", $this->_Strip($Data['prodname']), $Row);
			$Row = str_replace("{Component Type}", "Ad", $Row);
			$Row = str_replace("{Component Status}", "On", $Row);
			$Row = str_replace("{Keyword}", "", $Row);
			$Row = str_replace("{Keyword Alt Text}", "", $Row);
			$Row = str_replace("{Keyword Custom URL}", "", $Row);
			$Row = str_replace("{Sponsored Search Bid (USD)}", "", $Row);
			$Row = str_replace("{Sponsored Search Bid Limit (USD)}", "", $Row);
			$Row = str_replace("{Sponsored Search Status}", "", $Row);
			$Row = str_replace("{Match Type}", "", $Row);
			$Row = str_replace("{Content Match Bid (USD)}", "", $Row);
			$Row = str_replace("{Content Match Bid Limit (USD)}", "", $Row);
			$Row = str_replace("{Content Match Status}", "", $Row);
			$Row = str_replace("{Ad Name}", $this->_BuildAdName($Data['prodname']), $Row);
			$Row = str_replace("{Watch List}", "", $Row);
			$Row = str_replace("{Campaign ID}", "", $Row);
			$Row = str_replace("{Campaign Description}", "", $Row);
			$Row = str_replace("{Campaign Start Date}", "", $Row);
			$Row = str_replace("{Campaign End Date}", "", $Row);
			$Row = str_replace("{Ad Group ID}", "", $Row);
			$Row = str_replace("{Ad Group: Optimize Ad Display}", "", $Row);
			$Row = str_replace("{Ad ID}", "", $Row);
			$Row = str_replace("{Keyword ID}", "", $Row);
			$Row = str_replace("{Checksum}", "", $Row);
			$Row = str_replace("{Error Message}", "", $Row);

			// Run one final trim
			$Row = trim($Row);

			// Return the row
			return $Row;
		}
Example #21
0
 public function SetPanelSettings()
 {
     $GLOBALS['ISC_CLASS_CATEGORY'] = GetClass('ISC_CATEGORY');
     // Should we hide the comparison button?
     if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() < 2) {
         $GLOBALS['HideCompareItems'] = "none";
     }
     // Load the products into the reference array
     $GLOBALS['ISC_CLASS_CATEGORY']->GetProducts($products);
     $GLOBALS['CategoryProductListing'] = "";
     if (GetConfig('ShowProductRating') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $display_mode = ucfirst(GetConfig("CategoryDisplayMode"));
     if ($display_mode == "Grid") {
         $display_mode = "";
     }
     $GLOBALS['DisplayMode'] = $display_mode;
     if ($display_mode == "List") {
         if (GetConfig('ShowAddToCartLink') && $GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() > 0) {
             $GLOBALS['HideAddButton'] = '';
         } else {
             $GLOBALS['HideAddButton'] = 'none';
         }
         $GLOBALS['ListJS'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ListCheckForm");
     }
     $GLOBALS['CompareButton'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareButton" . $display_mode);
     if ($display_mode == "List" && $GLOBALS['ISC_CLASS_CATEGORY']->GetNumPages() > 1) {
         $GLOBALS['CompareButtonTop'] = $GLOBALS['CompareButton'];
     }
     $GLOBALS['AlternateClass'] = '';
     foreach ($products as $row) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
             $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
             $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
         } else {
             //$GLOBALS['ProductURL'] = CartLink($row['productid']);
             $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
             //blessen
             if (intval($row['prodretailprice']) <= 0) {
                 $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
             } else {
                 $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1');
             }
             //blessen  1734.06
             //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
         }
         if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
             $GLOBALS['HideActionAdd'] = '';
         } else {
             $GLOBALS['HideActionAdd'] = 'none';
         }
         $GLOBALS['HideProductVendorName'] = 'display: none';
         $GLOBALS['ProductVendor'] = '';
         if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['prodvendorid']])) {
                 $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                 $GLOBALS['HideProductVendorName'] = '';
             }
         }
         // for list style
         if ($display_mode == "List") {
             // get a small chunk of the product description
             $desc = isc_substr(strip_tags($row['proddesc']), 0, 250);
             if (isc_strlen($row['proddesc']) > 250) {
                 // trim the description back to the last period or space so words aren't cut off
                 $period_pos = isc_strrpos($desc, ".");
                 $space_pos = isc_strrpos($desc, " ");
                 // find the character that we should trim back to. -1 on space pos for a space that follows a period, so we dont end up with 4 periods
                 if ($space_pos - 1 > $period_pos) {
                     $pos = $space_pos;
                 } else {
                     $pos = $period_pos;
                 }
                 $desc = isc_substr($desc, 0, $pos);
                 $desc .= "...";
             }
             $GLOBALS['ProductDescription'] = $desc;
             $GLOBALS['AddToCartQty'] = "";
             if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired']) {
                     $GLOBALS['AddToCartQty'] = '<a href="' . $GLOBALS["ProductURL"] . '">' . $GLOBALS['ProductAddText'] . "</a>";
                 } else {
                     $GLOBALS['CartItemId'] = $GLOBALS['ProductId'];
                     // If we're using a cart quantity drop down, load that
                     if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                         $GLOBALS['Quantity0'] = "selected=\"selected\"";
                         $GLOBALS['QtyOptionZero'] = '<option %%GLOBAL_Quantity0%% value="0">Quantity</option>';
                         $GLOBALS['QtySelectStyle'] = 'width: auto;';
                         $GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
                         // Otherwise, load the textbox
                     } else {
                         $GLOBALS['ProductQuantity'] = 0;
                         $GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
                     }
                 }
             }
         } else {
             $GLOBALS["CompareOnSubmit"] = "onsubmit=\"return compareProducts(config.CompareLink)\"";
         }
         $GLOBALS['CategoryProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryProductsItem" . $display_mode);
     }
     if ($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() == 0) {
         // There are no products in this category
         $GLOBALS['CategoryProductListing'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryNoProductsMessage");
         $GLOBALS['HideOtherProductsIn'] = 'none';
         $GLOBALS['ExtraCategoryClass'] = "Wide WideWithLeft";
         if ($GLOBALS['SNIPPETS']['SubCategories'] != '') {
             $GLOBALS['CategoryProductListing'] = '';
         }
         $GLOBALS['HideRightColumn'] = "none";
     } else {
         $GLOBALS['HideOtherProductsIn'] = 'block';
         $GLOBALS['OtherProductsIn'] = sprintf(GetLang('OtherProductsIn'), $GLOBALS['ISC_CLASS_CATEGORY']->GetName());
     }
 }
 public function SetPanelSettings()
 {
     $params = $GLOBALS['ISC_CLASS_ABTESTING']->_searchterms;
     $this->searchterms = $params;
     if ($GLOBALS['pagetype'] == 1) {
         return;
     }
     if ($GLOBALS['pagetype'] == 2 && isset($GLOBALS['pagecontent']) && $GLOBALS['pagecontent'] == 1) {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
         return;
     }
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() == 0) {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
         return;
     }
     $count = 0;
     $output = "";
     /* Checking the search string. If it is used in any search, will be retained. else it will not be retained - starts */
     if (isset($this->searchterms['search'])) {
         $search_str = trim(str_ireplace($this->searchterms['search_string'], "", $this->searchterms['search']));
         if ($search_str == '') {
             unset($this->searchterms['search'], $params['search']);
         } else {
             $this->searchterms['search'] = $params['search'] = $search_str;
         }
     }
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . MakeURLSafe($params['make']);
     }
     if (isset($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) {
         $GLOBALS['MMY'] .= strtoupper($params['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . MakeURLSafe($params['model']);
     }
     /*else if(isset($params['model']))
       $ext_links .= $seo_delim."model=".$params['model'];*/
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= MakeURLSafe($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
       $ext_links .= $seo_delim."year=".$params['year'];                
       }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         } else {
             $selected_catg = end($params['srch_category']);
         }
         //wirror_20100806: add selected files like pagecontenttype and customcontentid;
         $catg_desc_qry = "select pagecontenttype, customcontentid, catdesc , categoryfooter  from [|PREFIX|]categories where categoryid = " . $selected_catg;
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             $catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     if (isset($params['brand'])) {
         $brand_desc_arr = array();
         $brand_desc_qry = "select branddescription , brandfooter from [|PREFIX|]brands where brandname = '" . $params['brand'] . "'";
         $brand_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($brand_desc_res) > 0) {
             $brand_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_desc_res);
         }
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
       $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
       /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() > 0) {
         $brand_rating = 0;
         $category_rating = 0;
         if ($GLOBALS['results_page_flag'] == 1) {
             $brand_rating_qry = "select avg(revrating) as rating from [|PREFIX|]reviews r left join [|PREFIX|]products p on r.revproductid = p.productid left join [|PREFIX|]brands b on p.prodbrandid = b.brandid  where r.revstatus = 1 and b.brandname = '" . $params['brand'] . "'";
             $brand_rating_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_rating_qry);
             $brand_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($brand_rating_res);
             if (isset($brand_rating_arr['rating'])) {
                 $brand_rating = (int) $brand_rating_arr['rating'];
             }
         } else {
             if ($GLOBALS['results_page_flag'] == 0 && isset($selected_catg)) {
                 // 3rdAug2010: added the condition "isset($selected_catg)" as no need to show rating when only YMM is selected
                 // lguan_20100612: Category page mode, calculate the rating
                 $catquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT categoryid FROM [|PREFIX|]categories where catparentid = {$selected_catg}");
                 $catlistid = array();
                 while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catquery)) {
                     $catlistid[] = $catrow['categoryid'];
                 }
                 $catcountlist = implode(",", $catlistid);
                 //lguan_20100612: Changed following codes to get product rating for categories
                 if (count($catlistid) > 0) {
                     $catcountlist = $selected_catg . "," . $catcountlist;
                 }
                 $cat_rating_res = $GLOBALS['ISC_CLASS_DB']->Query("SELECT floor(SUM(p.prodratingtotal)/SUM(p.prodnumratings))AS prodavgrating FROM [|PREFIX|]categoryassociations c INNER JOIN [|PREFIX|]products p on c.productid=p.productid where c.categoryid IN ({$catcountlist})");
                 $cat_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($cat_rating_res);
                 if (isset($cat_rating_arr['prodavgrating'])) {
                     $category_rating = (int) $cat_rating_arr['prodavgrating'];
                 }
             }
         }
         /* displaying the dropdowns for YMM */
         if (!isset($params['make']) || !isset($params['year']) || !isset($params['model']) || isset($params['model_flag']) && $params['model_flag'] == 0) {
             $this->YMMSelectors($params);
         }
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $GLOBALS['AlternateClass'] = '';
         $counter = 1;
         $CurCatId = 0;
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         //wirror_code_mark_begin
         //wirror_20100809: record the searched productids
         $searchedProductIds = array();
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
             /* Added by Simha to check inf prodcucts comes from different categories*/
             if (empty($params['srch_category']) || !isset($params['srch_category'])) {
                 if ($CurCatId != $row['categoryid']) {
                     $CurCatId = $row['categoryid'];
                     $map_names = array();
                     $display_names = array();
                     $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names from \n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
                     // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
                     $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
                     while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                         $map_names[$filter_row['qid']] = $filter_row['column_name'];
                         $display_names[$filter_row['qid']] = $filter_row['display_names'];
                     }
                     $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                 }
             }
             /* Added by Simha Ends */
             $GLOBALS['SearchTrackClass'] = "TrackLink";
             $imagefile = "";
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $qry_string = $_SERVER['QUERY_STRING'];
             if (isset($_GET['page'])) {
                 $page = "&page=" . $_GET['page'];
                 $qry_string = str_ireplace($page, '', $qry_string);
             }
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 if (isset($_GET['search_key'])) {
                     $qry_string = str_ireplace('&search_key=' . $_GET['search_key'], '', $qry_string);
                 }
                 if (isset($params['search_query']) && !strstr($qry_string, 'search_query=')) {
                     $qry_string .= "search_query=" . MakeURLSafe($params['search_query']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model']) && !strstr($qry_string, 'model=')) {
                     $qry_string .= "&model=" . MakeURLSafe($params['model']);
                 }
                 if (isset($params['year']) && !strstr($qry_string, 'year=')) {
                     $qry_string .= "&year=" . MakeURLSafe($params['year']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model_flag']) && !strstr($qry_string, 'model_flag=')) {
                     $qry_string .= "&model_flag=" . MakeURLSafe($params['model_flag']);
                 }
                 if (isset($params['submodel']) && !strstr($qry_string, 'submodel=')) {
                     $qry_string .= "&submodel=" . MakeURLSafe($params['submodel']);
                 }
             }
             if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
                 break;
             }
             if ($GLOBALS['pagetype'] == 3) {
                 //wirror_mark_condition1
                 /*if( isset($params['srch_category']) )  {
                 			$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : ''; // description will be added here to show it at the top of product listing page.
                 		}*/
                 /*if(isset($params['category']) || ( !isset($params['subcategory']) && isset($params['series']) ))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                 								//$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                 								$GLOBALS['CatgBrandSeriesFooter'] = "";
                 
                 								if( ( isset($params['category']) || isset($params['subcategory']) ) && $GLOBALS['CatgDescandBrandImage'] == "" )
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 									//$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 							}
                 							else if(isset($params['srch_category']))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';	
                 								$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 								if( isset($params['series']) && $row['seriesdescription'] != "" )
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                 									//$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 								if($GLOBALS['CatgDescandBrandImage'] == '' && $GLOBALS['CatgBrandSeriesFooter'] == '' && isset($params['brand']))
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                 									//$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 							}
                 							else if(isset($params['brand']))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                 								$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 							}*/
                 /* No need to show footer description when YMM are selected */
                 /*if( isset($params['make']) || isset($params['model']) || isset($params['year']) )
                 		{
                 			$GLOBALS['CatgBrandSeriesFooter'] = "";
                 		}*/
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 if ($counter % 2 == 0) {
                     $GLOBALS['RowColor'] = 'grayrow';
                 } else {
                     $GLOBALS['RowColor'] = 'whiterow';
                 }
                 $counter++;
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 //$GLOBALS['BrandName'] = $row['brandname'];
                 /* -- The below code is added to display the brand and series logo -- */
                 $GLOBALS['BrandName'] = "";
                 $brandlogo = realpath(ISC_BASE_PATH . '/product_images/' . $row['brandimagefile']);
                 if ($row['brandimagefile'] != '' && file_exists($brandlogo)) {
                     $GLOBALS['BrandName'] .= "<img src=\"" . $GLOBALS['ShopPath'] . "/product_images/" . $row['brandimagefile'] . "\" class=\"BrandSeriesLogo\" />";
                 } else {
                     $GLOBALS['BrandName'] .= $row['brandname'];
                 }
                 $serieslogo = realpath(ISC_BASE_PATH . '/series_images/' . $row['serieslogoimage']);
                 if ($row['serieslogoimage'] != '' && file_exists($serieslogo)) {
                     $GLOBALS['BrandName'] .= "<br><img src=\"" . $GLOBALS['ShopPath'] . "/series_images/" . $row['serieslogoimage'] . "\" />";
                 } else {
                     $GLOBALS['BrandName'] .= "<br>" . $row['seriesname'];
                 }
                 /* --- ends --- */
                 $GLOBALS['ProdCode'] = $row['prodcode'];
                 //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
                 //$GLOBALS['ProdOptions'] = $row['productoption'];
                 $GLOBALS['VehicleOptions'] = "";
                 $GLOBALS['ProdOptions'] = "";
                 foreach ($row as $key => $val) {
                     if ($val != "" && $val != "~") {
                         if (($qualifier_id = array_search($key, $map_names)) !== false) {
                             if (eregi('^vq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 //$GLOBALS['VehicleOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                                 $GLOBALS['VehicleOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                             }
                             if (eregi('^pq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 //$GLOBALS['ProdOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                                 $GLOBALS['ProdOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                             }
                         }
                     }
                 }
                 if (isset($row['vehicleoption'])) {
                     $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
                 }
                 if (isset($row['productoption'])) {
                     $GLOBALS['ProdOptions'] = $row['productoption'];
                 }
                 if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
                     $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
                     if ($vq_column_title == "") {
                         $vq_column_title = "Product Name";
                     } else {
                         if ($vq_column_title != "Product Name") {
                             $vq_column_title = "Product Name / Vehicle";
                         }
                     }
                 } else {
                     if ($vq_column_title == "") {
                         $vq_column_title = "Vehicle Options";
                     } else {
                         if ($vq_column_title != "Vehicle Options") {
                             $vq_column_title = "Product Name / Vehicle";
                         }
                     }
                 }
                 if (empty($GLOBALS['ProdOptions']) && empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['ProdOptions'] = "&nbsp;";
                 }
                 if (empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['VehicleOptions'] = "&nbsp;";
                 }
                 /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                     $GLOBALS['ProductLink'] .= "/refer=true" . $ext_links;
                     if (isset($GLOBALS['SearchId'])) {
                         $GLOBALS['ProductLink'] .= '/SearchLogId/' . $GLOBALS['SearchId'];
                     }
                 } else {
                     $GLOBALS['ProductLink'] .= "&refer=true" . $ext_links;
                     if (isset($GLOBALS['SearchId'])) {
                         $GLOBALS['ProductLink'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
                     }
                 }
                 ### Added by Simha for onsale addition
                 // Determine the price of this product
                 //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                 $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
                 $FinalPrice = $GLOBALS['ProductPrice'];
                 $SalePrice = $row['prodsaleprice'];
                 //$DiscountAmount = $FinalPrice;
                 $discounttype = 0;
                 $discountname = '';
                 if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
                     $DiscountPrice = $SalePrice;
                 } else {
                     $DiscountPrice = $FinalPrice;
                     $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid'], $discounttype, $discountname);
                     /*if($discounttype == 0)    {
                           $DiscountPrice = $FinalPrice;
                       }*/
                 }
                 /*
                 							foreach($DiscountInfo as $DiscountInfoSub)   {  
                     if(isset($DiscountInfoSub['catids']))    {
                 								    $catids = explode(",", $DiscountInfoSub['catids']); 
                 								    foreach($catids as $catid) {
                 									    if($catid == $row['categoryid']) {
                 										    $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                 										    if ($DiscountAmount < 0) {
                 											    $DiscountAmount = 0;
                 										    }                                                                         
                 										    $DiscountPrice  = $FinalPrice - $DiscountAmount;  
                 									    } 
                 								    }  
                     }
                 							}       
                 */
                 if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice && $discounttype == 0) {
                     //&& GetConfig('ShowOnSale')
                     $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
                     $GLOBALS['ProductPrice'] .= '<br><div class="finalprice">' . CurrencyConvertFormatPrice($DiscountPrice) . '</div> ';
                     if (strtolower($discountname) == "clearance") {
                         $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
                     } else {
                         $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if (GetConfig('ShowOnSale')) {
                         $GLOBALS['ProductPrice'] .= '' . $GLOBALS['ShowOnSaleImage'] . '';
                     }
                 } else {
                     $GLOBALS['ProductPrice'] = '<div class="finalprice">' . CurrencyConvertFormatPrice($FinalPrice) . '</div>';
                 }
                 ### Added by Simha Ends
                 // commented the below line by vikas
                 //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                 $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                 } else {
                     //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     //blessen
                     if (intval($row['prodretailprice']) <= 0) {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     } else {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     }
                     //blessen
                     // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                 }
                 if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                     $GLOBALS['HideActionAdd'] = '';
                 } else {
                     $GLOBALS['HideActionAdd'] = 'none';
                 }
                 $GLOBALS['HideProductVendorName'] = 'display: none';
                 $GLOBALS['ProductVendor'] = '';
                 if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                     $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                     if (isset($vendorCache[$row['prodvendorid']])) {
                         $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                         $GLOBALS['HideProductVendorName'] = '';
                     }
                 }
                 $GLOBALS['CartURL'] = CartLink($row['productid']);
                 if (isset($GLOBALS['SearchId'])) {
                     $GLOBALS['CartURL'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
                 }
                 $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
                 if ($offer == 'yes') {
                     $GLOBALS['HideOfferButton'] = 'block';
                 } else {
                     $GLOBALS['HideOfferButton'] = 'none';
                 }
                 $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
             } else {
                 if ($GLOBALS['pagetype'] == 2) {
                     //wirror_mark_condition2
                     $isDynamicPage = $catg_desc_arr['pagecontenttype'] == 0 ? true : false;
                     $mmy_links_modified = $mmy_links;
                     if (!isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
                         $parentid = $GLOBALS['categories_all'][$row['categoryid']]['catparentid'];
                         if ($parentid != 0) {
                             if (isset($GLOBALS['categories_all'][$parentid])) {
                                 // if parent catg is not visible
                                 $mmy_links_modified = $mmy_links;
                             } else {
                                 $mmy_links_modified = $mmy_links;
                             }
                         } else {
                             $mmy_links_modified = $mmy_links;
                         }
                     }
                     $subcatg_link = $this->LeftCatLink($mmy_links_modified, 'subcategory', $row['catname']);
                     $link = "<a href='" . $subcatg_link . "'>";
                     $tiplink = "<a class='thickbox1' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "'  title=''><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a>";
                     $imagelink = "<a class='thickbox' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' title='' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>";
                     //$imagelink = "<a href='".$GLOBALS['ShopPath']."/catgbrand.php?categoryid=".$row['categoryid']."&url=$subcatg_link' class='thickbox' title=''>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$imagelink}<img src='{$path}/category_images/" . $images[$j] . "' alt='" . $row['catimagealt'] . "' title='" . $row['catimagealt'] . "'></a>";
                                 $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$imagelink}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                             $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     //$GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (!empty($row['seriesname'])) {
                         $row['brandname'] .= "<br>" . $row['seriesname'];
                     }
                     $GLOBALS['CatgSeriesList'] = "";
                     if ($row['seriesids'] != "") {
                         $seriesids = str_ireplace("~", ",", $row['seriesids']);
                         $seriesids_qry = "select seriesid , brandname , seriesname from isc_brand_series bs left join isc_brands b on bs.brandid = b.brandid where seriesid in (" . $seriesids . ")";
                         $seriesids_res = $GLOBALS['ISC_CLASS_DB']->Query($seriesids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($seriesids_res) > 0) {
                             while ($seriesids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesids_res)) {
                                 if ($GLOBALS['CatgSeriesList'] == "") {
                                     $GLOBALS['CatgSeriesList'] .= "<br><a href='javascript:' onclick=\"checkanimate('" . $row['categoryid'] . "')\">View Brands ></a><div id='" . $row['categoryid'] . "' style='display:block'>";
                                 } else {
                                     $GLOBALS['CatgSeriesList'] .= "<br>";
                                 }
                                 $tooltipscript = "onmouseover='createtip(" . $row['categoryid'] . $seriesids_arr['seriesid'] . ")' onmouseout='UnTip()'";
                                 if (!isset($params['brand'])) {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 } else {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 }
                                 //wirror20100728: keep the catname consistent with the displayname
                                 $GLOBALS['CatgSeriesList'] .= "<span id='span" . $row['categoryid'] . $seriesids_arr['seriesid'] . "' style='display:none'><a class='thickbox1'  href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?seriesid=" . $seriesids_arr['seriesid'] . "&catname=" . rawurlencode($row['catname']) . "&url=" . urlencode($series_link) . "' class='' ><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a></span>";
                             }
                             $GLOBALS['CatgSeriesList'] .= "</br></div>";
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     if (!isset($params['category']) && (isset($params['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))) {
                         /*$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                         		if( isset($params['make']) || isset($params['model']) || isset($params['year']) || isset($params['brand']) )
                         		{
                         			$GLOBALS['CatgBrandSeriesFooter'] = "";
                         		}*/
                         $content .= "<h3><a href='" . $path . "/search.php?{$qry_string}&subcategory=" . MakeURLSafe($row['catname']) . "'>" . $row['catname'] . "</a></h3>>";
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $subcatg_link . "' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>" . $row['catname'] . "</a></h2>";
                     }
                     /*	copy the code to outer		
                     			//lguan_20100612: Show overal product rating at category landing page
                     			if($category_rating != 0)
                     			{
                     				$GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='".$GLOBALS['TPL_PATH']."/images/IcoRating$category_rating.gif' alt='' /></h2>";
                     			}
                     			*/
                     /*$ProdStartPrice = GetStartingPrice($row['categoryid'], $row['prodcalculatedprice']);
                                            
                     		$content .= "Price starting from $".number_format($ProdStartPrice, 2, '.', '')."<br>".$imagefile;*/
                     $GLOBALS['leftsidecontent'] = $content;
                     if (number_format($row['prodminprice'], 2, '.', '') < number_format($row['prodmaxprice'], 2, '.', '')) {
                         $GLOBALS['PriceRange'] = "Price range from \$" . number_format($row['prodminprice'], 2, '.', '') . " to \$" . number_format($row['prodmaxprice'], 2, '.', '');
                     } else {
                         $GLOBALS['PriceRange'] = "Available at \$" . number_format($row['prodminprice'], 2, '.', '');
                     }
                     //lguan_20100612: Show product ratings in categories/sub-categories page
                     $GLOBALS['Rating'] = isset($row['prodavgrating']) ? $row['prodavgrating'] : 0;
                     $GLOBALS['RatingVisible'] = $GLOBALS['Rating'] == 0 ? 'display:none' : '';
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $GLOBALS['ViewDetailsImage'] = "<a href='{$path}/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' class='thickbox'><img src='{$path}/templates/default/images/fastlook_red.gif'></a> ";
                     $content = "{$link}<img src='{$path}/templates/default/images/viewproducts.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] .= $content;
                     $discountname = '';
                     if (IsDiscountAvailable('category', $row['categoryid'], $discountname)) {
                         if (strtolower($discountname) == "clearance") {
                             $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
                         } else {
                             $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                         }
                     }
                     if ($this->IsMakeAnOffer('category', $row['categoryid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['RelatedBrands'] = $row['featurepoints'];
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                 }
             }
         }
         ///wirror_code_mark_end
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //wirror_code_mark_begin
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             $path = $path . "/a-b-testing";
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}{$mmy_links}/orderby/prodfinalprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodfinalprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             		$GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             		$GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodfinalprice') {
                 $GLOBALS['ProductDetails'] .= $img;
             }
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryProductsItemHeader");
         } else {
             //lguan_20100612: Show overal product rating at category landing page
             /*if($category_rating != 0)
             		{
             			$GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='".$GLOBALS['TPL_PATH']."/images/IcoRating$category_rating.gif' alt='' /></h2>";
             		}*/
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
             if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
                 $GLOBALS['SearchLink'] = "";
                 if (isset($params['searchtext'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['searchtext']));
                 }
                 if (isset($params['search'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['search']));
                 }
                 if (isset($params['model']) && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model/" . MakeURLSafe(strtolower($params['model']));
                 }
                 if (isset($params['model_flag']) && $params['model_flag'] == 0 && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model_flag/" . MakeURLSafe(strtolower($params['model_flag']));
                 }
                 $GLOBALS['SearchResults'] = "";
                 if (isset($GLOBALS['YMMTable'])) {
                     $GLOBALS['SearchResults'] .= "<div>" . $GLOBALS['YMMTable'] . "</div>";
                 }
                 if ($_REQUEST['is_smart_search']) {
                     $GLOBALS['SearchResults'] .= '<p class="ErrorMessage">' . GetLang('SearchYourSearch') . ' <strong>"' . htmlspecialchars($GLOBALS['OriginalSearchQuery']) . '"</strong> ' . GetLang('SearchDidNotMatch') . '</p>';
                     if ($GLOBALS['OriginalSearchQuery'] == '') {
                         $GLOBALS['SearchTitle'] = '';
                     } else {
                         $GLOBALS['SearchTitle'] = " " . sprintf(GetLang('SearchResultsFor'), $GLOBALS['OriginalSearchQuery']);
                     }
                 }
                 //$GLOBALS['SearchResults'] .= "<div style='width:100%'><p class='InfoMessage'>Please choose a category or brand</p></div>";
                 $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t\t\t\t%%Panel.StaticFeaturedBrands%%";
                 $GLOBALS['HidePanels'][] = 'SearchPagingTop';
             }
         }
         $GLOBALS['SearchResults'] .= "<script type=\"text/javascript\"> \$('.focushiddendiv').css({'position':'absolute', 'margin-top':'-200px', 'display':'block'}); </script>";
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
     } else {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = "<div>" . $GLOBALS['YMMTable'] . "</div>";
         $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t%%Panel.StaticFeaturedBrands%%";
         // No search results were found
         // commented below code as need to show the favorite categories and brands as in homepage
         /*$GLOBALS['HideSearchResults'] = "none";
         		$GLOBALS['HidePanels'][] = 'SearchPageProducts';*/
     }
 }
Example #23
0
 private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms = array())
 {
     $this->_SetFeedDetails();
     $feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int) GetConfig('RSSCacheTime') * 60);
     $channel = array("title" => $feedTitle, "description" => $feedDescription, "link" => $GLOBALS['ShopPath']);
     $feed->SetChannel($channel);
     // The magical Interspire Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function
     $searchterms = BuildProductSearchTerms($searchTerms);
     $searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder);
     // Run the query
     $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int) GetConfig('RSSItemsLimit'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
     while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if (isc_strlen($product['proddesc']) > 300) {
             $product['proddesc'] = isc_substr($product['proddesc'], 0, 298) . "..";
         }
         if ($product['imagefile']) {
             $product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", ImageThumb($product['imagefile'], ProdLink($product['prodname'])), $product['proddesc']);
         }
         // Determine the price of this product
         $price = CalculateProductPrice($product);
         $price = GetLang('Price') . ": " . $price;
         if (GetConfig('ShowProductRating')) {
             $ratingImage = $GLOBALS['TPL_PATH'] . '/images/IcoRating' . (int) $product['prodavgrating'] . '.gif';
             $ratingImage = '<img src="' . $ratingImage . '" alt="" />';
         } else {
             $ratingImage = '';
         }
         $product['proddesc'] .= '<p><strong>' . $price . '</strong> ' . $ratingImage . '</p>';
         // Add the item to the feed
         $item = array("title" => $product['prodname'], "description" => $product['proddesc'], "link" => ProdLink($product['prodname']), "date" => $product['proddateadded']);
         $feed->AddItem($item);
     }
     // Send the feed to the browser
     $feed->OutputFeed();
 }
Example #24
0
/**
 * Send a low inventory warning ot the store owner when a certain product/option reaches the
 * defined low inventory level.
 *
 * @param int The product ID.
 * @param int The variation ID.
 * @param int The current (new) quantity of the item.
 * @return boolean Returns true if successful.
 */
function SendLowInventoryWarning($productId, $variationId)
{
	// Only send the emails if we have this feature enabled
	if(GetConfig('LowInventoryNotificationAddress') == '') {
		return;
	}

	// Fetch the name of this product as well as the product option
	if ($variationId > 0) {
		$query = sprintf("
			SELECT p.prodname, p.prodcurrentinv, p.prodlowinv, v.vclowstock, v.vcstock, v.vcoptionids
			FROM [|PREFIX|]products p
			LEFT JOIN [|PREFIX|]product_variation_combinations v ON (v.combinationid='%d')
			WHERE p.productid='%d'",
			$variationId, $productId
		);
	}
	else {
		$query = sprintf("SELECT prodname, prodcurrentinv, prodlowinv FROM [|PREFIX|]products WHERE productid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($productId));
	}

	$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
	$product = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
	if ($variationId > 0) {
		// Fetch out the variation
		$query = "SELECT * FROM [|PREFIX|]product_variation_options WHERE voptionid IN (".$product['vcoptionids'].")";
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		$optionName = '';
		$comma = '';
		while($option = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$optionName .= $comma.$option['voname']." :".$option['vovalue'];
			$comma = ', ';
		}
		$prodName = $product['prodname'] . " (" . $optionName . ")";
		$stock = $product['vcstock'];
		$lowStockLevel = $product['vclowstock'];
	}
	else {
		$prodName = $product['prodname'];
		$stock = $product['prodcurrentinv'];
		$lowStockLevel = $product['prodlowinv'];
	}

	$GLOBALS['ProductId'] = $productId;

	// Now we build the email
	$GLOBALS['LowInventoryWarningIntro'] = sprintf(GetLang('LowInventoryWarningIntro'), $GLOBALS['StoreName']);
	$GLOBALS['LowInventoryWarning'] = sprintf(GetLang('LowInventoryWarning'), isc_html_escape($product['prodname']));
	$GLOBALS['LowInventoryWarningProduct'] = sprintf(GetLang('LowInventoryWarningProduct'), sprintf('<a href="%s">%s</a>', ProdLink($product['prodname']), isc_html_escape($prodName)));
	$GLOBALS['LowInventoryWarningCurrentStock'] = sprintf(GetLang('LowInventoryWarningCurrentStock'), $stock);
	$GLOBALS['LowInventoryWarningNotice'] = sprintf(GetLang('LowInventoryWarningNotice'), $lowStockLevel);

	$emailTemplate = FetchEmailTemplateParser();
	$emailTemplate->SetTemplate("low_inventory_email");
	$message = $emailTemplate->ParseTemplate(true);

	// Create a new email API object to send the email
	$store_name = GetConfig('StoreName');
	$subject = sprintf(GetLang('LowInventoryWarningSubject'), isc_html_escape($product['prodname']));

	require_once(ISC_BASE_PATH . "/lib/email.php");
	$obj_email = GetEmailClass();
	$obj_email->Set('CharSet', GetConfig('CharacterSet'));
	$obj_email->From(GetConfig('AdminEmail'), $store_name);
	$obj_email->Set('Subject', $subject);
	$obj_email->AddBody("html", $message);
	$obj_email->AddRecipient(GetConfig('LowInventoryNotificationAddress'), "", "h");
	$email_result = $obj_email->Send();

	if ($email_result['success']) {
		return true;
	}
	else {
		return false;
	}
}
Example #25
0
 /**
  * Set the panel settings.
  */
 public function SetPanelSettings()
 {
     $cVendor = GetClass('ISC_VENDORS');
     $vendor = $cVendor->GetVendor();
     $GLOBALS['VendorId'] = $vendor['vendorid'];
     $GLOBALS['VendorName'] = $vendor['vendorname'];
     // Set the field we're sorting results by
     if (isset($_REQUEST['sort'])) {
         $sort = $_REQUEST['sort'];
     } else {
         $sort = '';
     }
     switch ($sort) {
         case 'newest':
             $sortField = 'p.productid DESC';
             $GLOBALS['SortNewestSelected'] = 'selected="selected"';
             break;
         case 'bestselling':
             $sortField = 'p.prodnumsold DESC';
             $GLOBALS['SortBestSellingSelected'] = 'selected="selected"';
             break;
         case 'alphaasc':
             $sortField = 'p.prodname ASC';
             $GLOBALS['SortAlphaAsc'] = 'selected="selected"';
             break;
         case 'alphadesc':
             $sortField = 'p.prodname DESC';
             $GLOBALS['SortAlphaDesc'] = 'selected="selected"';
             break;
         case 'avgcustomerreview':
             $sortField = 'prodavgrating DESC';
             $GLOBALS['SortAvgReview'] = 'selected="selected"';
             break;
         case 'priceasc':
             $sortField = 'p.prodcalculatedprice ASC';
             $GLOBALS['SortPriceAsc'] = 'selected="selected"';
             break;
         case 'pricedesc':
             $sortField = 'p.prodcalculatedprice DESC';
             $GLOBALS['SortPriceDesc'] = 'selected="selected"';
             break;
         default:
             $sortField = 'p.prodvendorfeatured DESC';
             $sort = 'featured';
             $GLOBALS['SortFeaturedSelected'] = 'selected="selected"';
             break;
     }
     // If we're viewing a certain page, fetch our starting position
     if (isset($_REQUEST['page']) && IsId($_REQUEST['page'])) {
         $page = (int) $_REQUEST['page'];
         $start = $page * GetConfig('CategoryProductsPerPage') - GetConfig('CategoryProductsPerPage');
     } else {
         $page = 1;
         $start = 0;
     }
     // Count the number of products that belong in this vendor
     $query = "\n\t\t\tSELECT COUNT(p.productid) AS numproducts\n\t\t\tFROM [|PREFIX|]products p\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\tWHERE p.prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t";
     $numProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
     $numPages = ceil($numProducts / GetConfig('CategoryProductsPerPage'));
     // Now load the actual products for this vendor
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND imageisthumb=1)\n\t\t\t\tWHERE prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t\t\tORDER BY " . $sortField . ", prodname ASC\n\t\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, GetConfig('CategoryProductsPerPage'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $GLOBALS['SNIPPETS']['VendorProducts'] = '';
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     // Should we show the compare button?
     if (GetConfig('EnableProductComparisons') == 0 || $numProducts < 2) {
         $GLOBALS['HideCompareItems'] = "none";
     } else {
         $GLOBALS['CompareLink'] = CompareLink();
     }
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Determine the price of this product
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
             $GLOBALS['ProductURL'] = ProdLink($row['prodname']);
             $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
         } else {
             $GLOBALS['ProductURL'] = CartLink($row['productid']);
             $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
         }
         if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
             $GLOBALS['HideActionAdd'] = '';
         } else {
             $GLOBALS['HideActionAdd'] = 'none';
         }
         $GLOBALS['HideProductVendorName'] = 'display: none';
         $GLOBALS['ProductVendor'] = '';
         if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['prodvendorid']])) {
                 $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                 $GLOBALS['HideProductVendorName'] = '';
             }
         }
         $GLOBALS['SNIPPETS']['VendorProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("VendorProductsItem");
     }
     // Does paging need to be shown?
     if ($numProducts > GetConfig('CategoryProductsPerPage')) {
         $GLOBALS['SNIPPETS']['PagingData'] = "";
         $numEitherSide = 5;
         $start = max($page - $numEitherSide, 1);
         $end = min($page + $numEitherSide, $numPages);
         for ($i = $start; $i <= $end; $i++) {
             if ($i == $page) {
                 $snippet = "CategoryPagingItemCurrent";
             } else {
                 $snippet = "CategoryPagingItem";
             }
             $pageData = array('page' => $i, 'sort' => $sort);
             $GLOBALS['PageLink'] = VendorProductsLink($vendor, $pageData);
             $GLOBALS['PageNumber'] = $i;
             $GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet);
         }
         // Do we need to output a "Previous" link?
         if ($page > 1) {
             $pageData = array('page' => $page - 1, 'sort' => $sort);
             $GLOBALS['PrevLink'] = VendorProductsLink($vendor, $pageData);
             $GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious");
         }
         // Do we need to output a "Next" link?
         if ($page < $numPages) {
             $pageData = array('page' => $page + 1, 'sort' => $sort);
             $GLOBALS['NextLink'] = VendorProductsLink($vendor, $pageData);
             $GLOBALS['SNIPPETS']['CategoryPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext");
         }
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPaging");
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
         $GLOBALS['SNIPPETS']['ProductPaging'] = $output;
     }
     // Parse the sort select box snippet
     if ($numProducts > 1) {
         // Parse the sort select box snippet
         if ($GLOBALS['EnableSEOUrls'] == 1 && $vendor['vendorfriendlyname']) {
             $GLOBALS['URL'] = VendorProductsLink($vendor);
         } else {
             $GLOBALS['URL'] = $GLOBALS['ShopPath'] . "/vendors.php";
             $GLOBALS['HiddenSortField'] = "<input type=\"hidden\" name=\"vendorid\" value=\"" . (int) $vendor['vendorid'] . "\" />";
             $GLOBALS['HiddenSortField'] .= "<input type=\"hidden\" name=\"action\" value=\"products\" />";
         }
         $GLOBALS['SNIPPETS']['CategorySortBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategorySortBox");
     }
 }
 public function GetProductBrandURLs()
 {
     $filesize = 50000;
     $filePrefix = 'products';
     $dynamicPagesFiles = array();
     $query = "\n\t\t\t\tSELECT brandid, brandname\n\t\t\t\tFROM [|PREFIX|]brands\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $prodQuery = sprintf("\n\t\t\t\t\t\tSELECT prodname, brandname, prodcode\n\t\t\t\t\t\tFROM [|PREFIX|]brands b, [|PREFIX|]products p\n\t\t\t\t\t\tWHERE p.prodbrandid=b.brandid AND brandid=%d\n\t\t\t\t\t\t", $row['brandid']);
         //echo "Deep query:<br/><font color=red>$prodQuery</font><br/>";
         $prodResult = $GLOBALS['ISC_CLASS_DB']->Query($prodQuery);
         $total_results = $GLOBALS['ISC_CLASS_DB']->CountResult($prodResult);
         $num_files = ceil($total_results / $filesize);
         for ($fileIndex = 0; $fileIndex < $num_files; $fileIndex++) {
             $categoryURLs = array();
             $newQuery = $prodQuery;
             $newQuery .= $GLOBALS['ISC_CLASS_DB']->AddLimit($fileIndex * $filesize, $filesize);
             $resultLimit = $GLOBALS['ISC_CLASS_DB']->Query($newQuery);
             $firstRow = true;
             $SKU = '';
             while ($rowSub = $GLOBALS['ISC_CLASS_DB']->Fetch($resultLimit)) {
                 if ($firstRow) {
                     $SKU = $rowSub['prodcode'];
                     $firstRow = false;
                 }
                 $url = ProdLink($rowSub['prodname']);
                 //$url = htmlspecialchars($url, ENT_NOQUOTES, "UTF-8");
                 array_push($categoryURLs, $url);
             }
             if ($num_files < 2) {
                 $dynamicPagesFiles[$filePrefix . '-' . preg_replace("/\\s+/", '-', strtolower($row['brandname']))] = $categoryURLs;
             } else {
                 $dynamicPagesFiles[$filePrefix . '-' . preg_replace("/\\s+/", '-', strtolower($row['brandname'])) . '-' . $SKU] = $categoryURLs;
             }
         }
     }
     return $dynamicPagesFiles;
 }
 public function EditProductStep2()
 {
     # Used to clear the HTML Editor image upload folder name Baskaran
     $_SESSION['congobrand'] = '';
     $_SESSION['congoseries'] = '';
     // Get the information from the form and add it to the database
     $prodId = (int) $_POST['productId'];
     $arrData = array();
     $arrImages = array();
     $arrVideos = array();
     //Added by Simha
     $arrUserVideos = array();
     //Added by Simha
     $arrCustomFields = array();
     $arrVariations = array();
     $err = "";
     $this->_GetProductData($prodId, $existingData);
     $this->_GetProductData(0, $arrData);
     $arrImages = $this->_GetImageData();
     $arrVideos = $this->_GetVideoData();
     //Added by Simha
     $arrUserVideos = $this->_GetUserVideoData();
     //Added by Simha
     $this->_GetCustomFieldData(0, $arrCustomFields);
     $this->_GetVariationData(0, $arrVariations);
     $this->_GetProductFieldData(0, $arrProductFields);
     //validate product fields
     $productFieldsError = $this->_ValidateProductFields($arrProductFields);
     if ($productFieldsError != '') {
         $this->EditProductStep1($productFieldsError, MSG_ERROR, true);
         return;
     }
     if ($_SERVER['CONTENT_LENGTH'] > 100 * 1024 * 1024) {
         $this->EditProductStep1("You cannot upload files with total size more than 100MB", MSG_ERROR, true);
         return;
     }
     $discount = $this->GetDiscountRulesData(0, true);
     // Does this user have permission to edit this product?
     if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $existingData['prodvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
         FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewProducts');
     }
     $downloadError = '';
     if (isset($_FILES['newdownload']) && isset($_FILES['newdownload']['tmp_name']) && $_FILES['newdownload']['tmp_name'] != '') {
         if (!$this->SaveProductDownload($downloadError)) {
             $this->EditProductStep1($downloadError, MSG_ERROR);
             return;
         }
     }
     // Does a product with the same name already exist?
     $query = "SELECT productid FROM [|PREFIX|]products WHERE lower(prodname)='" . $GLOBALS['ISC_CLASS_DB']->Quote($arrData['prodname']) . "' AND productid!='" . $prodId . "'";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $existingProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     if ($existingProduct['productid']) {
         $this->EditProductStep1(GetLang('ProductWithSameNameExists'), MSG_ERROR, true);
         return;
     }
     /* Checks whether the vendor prefix has the value -- Baskaran */
     $queryprefix = $GLOBALS['ISC_CLASS_DB']->Query("SELECT vendorprefix FROM [|PREFIX|]vendors WHERE vendorid = '" . $arrData['prodvendorid'] . "' LIMIT 0,1 ");
     $existingProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($queryprefix);
     if ($existingProduct['vendorprefix'] == '') {
         $this->EditProductStep1(GetLang('ProductWithoutVendorprefix'), MSG_ERROR, true);
         return;
     }
     /* Ends here */
     // Validate out discount rules
     if (!empty($discount) && !$this->ValidateDiscountRulesData($error)) {
         $_POST['currentTab'] = 7;
         $this->EditProductStep1($error, MSG_ERROR, true);
         return;
     }
     // Commit the values to the database
     if ($this->_CommitProduct($prodId, $arrData, $arrImages, $arrVideos, $arrUserVideos, $arrVariations, $arrCustomFields, $discount, $err, $arrProductFields)) {
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Products)) {
             // Log this action
             $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($prodId, $arrData['prodname']);
             // Save the words to the product_words table for search spelling suggestions
             $this->SaveProductWords($arrData['prodname'], $prodId, "editing");
             if (isset($_POST['addanother'])) {
                 $_GET['productId'] = $prodId;
                 $this->EditProductStep1(GetLang('ProductUpdatedSuccessfully'), MSG_SUCCESS);
             } else {
                 if (isset($_POST['addview'])) {
                     $link = ProdLink($arrData['prodname']);
                     echo "<script language=\"javascript\">\n";
                     echo "var link = \"{$link}\"\n";
                     echo "window.open(link)\n";
                     echo "window.location.href='index.php?ToDo=viewProducts';\n";
                     echo "</script>\n";
                     exit;
                 } else {
                     FlashMessage(GetLang('ProductUpdatedSuccessfully'), MSG_SUCCESS);
                     header("Location: index.php?ToDo=viewProducts");
                     exit;
                 }
             }
         } else {
             FlashMessage(GetLang('ProductUpdatedSuccessfully'), MSG_SUCCESS);
             header("Location: index.php");
             exit;
         }
     } else {
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Products)) {
             $this->ManageProducts(sprintf(GetLang('ErrProductNotUpdated'), $err), MSG_ERROR);
         } else {
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(sprintf(GetLang('ErrProductNotUpdated'), $err), MSG_ERROR);
         }
     }
 }
Example #28
0
 function DoAjaxSearch()
 {
     if (isset($_GET['search_query']) && isc_strlen($_GET['search_query']) >= 3) {
         $searchterms = BuildProductSearchTerms($_REQUEST);
         // Build the search query using our terms & the fields we want
         $searchQueries = BuildProductSearchQuery($searchterms);
         $Search_Count = $GLOBALS['ISC_CLASS_DB']->FetchOne($searchQueries['countQuery']);
         // No results?
         if ($Search_Count == 0) {
             exit;
         }
         // Add the limit
         $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5);
         $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
         while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($Search_Result)) {
             $product['imagefile'] = '';
             $products[$product['productid']] = $product;
         }
         // Fetch product images
         $productids = implode(",", array_keys($products));
         $query = sprintf("select imageprodid, imagefile from [|PREFIX|]product_images where imageprodid in (%s) and imageisthumb=2", $GLOBALS['ISC_CLASS_DB']->Quote($productids));
         $Result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($productimage = $GLOBALS['ISC_CLASS_DB']->Fetch($Result)) {
             $products[$productimage['imageprodid']]['imagefile'] = $productimage['imagefile'];
         }
         $view_all = '';
         if ($Search_Count > 5) {
             $view_all = sprintf(' view_all="%s"', $this->EscapeEntity(sprintf('<a href="%s/search.php?search_query=%s">%s &raquo;</a>', $GLOBALS['ShopPathNormal'], $_REQUEST['search_query'], GetLang('QuickSearchViewAll'))));
         }
         echo '<?xml version="1.0"?>' . "\n";
         echo sprintf('<results type="%s" result_count="%s"%s>' . "\n", GetLang('QuickSearchProducts'), $Search_Count, $view_all);
         foreach ($products as $product) {
             if ($product['imagefile']) {
                 $image = sprintf("%s/%s/%s", $GLOBALS['ShopPathNormal'], GetConfig('ImageDirectory'), $product['imagefile']);
             } else {
                 $image = GetLang('QuickSearchNoImage');
             }
             if (GetConfig('EnableProductReviews')) {
                 $ratingimg = sprintf("%s/images/IcoRating%s.gif", $GLOBALS['TPL_PATH'], (int) $product['prodavgrating']);
             } else {
                 $ratingimg = '';
             }
             echo sprintf('<result title="%s" price="%s" url="%s" image="%s" ratingimg="%s" />' . "\n", $this->EscapeEntity($product['prodname']), $this->EscapeEntity(CalculateProductPrice_retail($product)), ProdLink($product['prodname']), $this->EscapeEntity($image), $this->EscapeEntity($ratingimg));
         }
         echo "</results>\n";
     }
 }
	public function SetPanelSettings()
	{
		if(!gzte11(ISC_HUGEPRINT) || $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor() === false) {
			$this->DontDisplay = true;
			return false;
		}

		$vendor = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor();
		$GLOBALS['SNIPPETS']['VendorsOtherProducts'] = '';

		if(!getProductReviewsEnabled()) {
			$GLOBALS['HideProductRating'] = "display: none";
		}

		$query = $this->getProductQuery(
			'p.prodvendorid='.(int)$vendor['vendorid'].' AND p.productid!='.$GLOBALS['ISC_CLASS_PRODUCT']->getProductId(),
			'p.prodvendorfeatured DESC, RAND() DESC',
			10 // Select 1 more than will be shown to check if we need to show the "has more" link
		);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		$productsDone = 0;
		$hasMore = false;
		$GLOBALS['AlternateClass'] = '';
		while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			++$productsDone;
			if($productsDone == 9) {
				$hasMore = true;
				break;
			}
			if($GLOBALS['AlternateClass'] == 'Odd') {
				$GLOBALS['AlternateClass'] = 'Even';
			}
			else {
				$GLOBALS['AlternateClass'] = 'Odd';
			}

			$GLOBALS['ProductCartQuantity'] = '';
			if(isset($GLOBALS['CartQuantity'.$row['productid']])) {
				$GLOBALS['ProductCartQuantity'] = (int)$GLOBALS['CartQuantity'.$row['productid']];
			}

			$GLOBALS['ProductId'] = (int) $row['productid'];
			$GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
			$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
			$GLOBALS['ProductRating'] = (int)$row['prodavgrating'];

			// Determine the price of this product
			$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);

			$GLOBALS['ProductThumb'] = ImageThumb($row, ProdLink($row['prodname']));

			if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired'] == 1) {
				$GLOBALS['ProductURL'] = ProdLink($row['prodname']);
				$GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
			} else {
				$GLOBALS['ProductURL'] = CartLink($row['productid']);
				$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
			}

			if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
				$GLOBALS['HideActionAdd'] = '';
			} else {
				$GLOBALS['HideActionAdd'] = 'none';
			}

			$GLOBALS['SNIPPETS']['VendorsOtherProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVendorsOtherProductsItem");
		}

		if(!$GLOBALS['SNIPPETS']['VendorsOtherProducts']) {
			$this->DontDisplay = true;
		}

		$GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor);
		if($hasMore == true) {
			$GLOBALS['HideViewAllLink'] = '';
		}
		else {
			$GLOBALS['HideViewAllLink'] = 'display: none';
		}
	}
 /**
  * Display the quick view for an order
  *
  * @return void
  **/
 public function GetOrderQuickView()
 {
     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('orders');
     // Output a quick view for this order to be used on the manage orders page
     $orderId = (int) $_REQUEST['o'];
     $GLOBALS["OrderId"] = $orderId;
     // Get the details for this order from the database
     $query = "\n\t\t\t\tSELECT o.*, CONCAT(custconfirstname, ' ', custconlastname) AS custname, custconemail, custconphone, s.zonename AS shippingzonename,\n\t\t\t\t(SELECT COUNT(messageid) FROM [|PREFIX|]order_messages WHERE messageorderid=orderid AND messagestatus='unread') AS numunreadmessages\n\t\t\t\tFROM [|PREFIX|]orders o\n\t\t\t\tLEFT JOIN [|PREFIX|]customers c ON (c.customerid=o.ordcustid)\n\t\t\t\tLEFT JOIN [|PREFIX|]shipping_zones s ON (s.zoneid=o.ordshippingzoneid)\n\t\t\t\tWHERE o.orderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         // If this user is a vendor, do they have permission to acess this order?
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $row['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             exit;
         }
         $GLOBALS['OrderDate'] = isc_date("d M Y H:i:s", $row['orddate']);
         $GLOBALS['ISC_CLASS_ADMIN_ORDERS'] = GetClass('ISC_ADMIN_ORDERS');
         $GLOBALS['OrderStatusOptions'] = $GLOBALS['ISC_CLASS_ADMIN_ORDERS']->GetOrderStatusOptions($row['ordstatus']);
         $GLOBALS['TrackingNo'] = $row['ordtrackingno'];
         $GLOBALS['NumMessages'] = $row['numunreadmessages'];
         if ($row["numunreadmessages"] == 0) {
             $GLOBALS["HideMessages"] = "none";
         }
         if (!gzte11(ISC_LARGEPRINT)) {
             $GLOBALS["HideMessageItems"] = "none";
         }
         $row['custname'] = isc_html_escape(trim($row['custname']));
         $addressDetails = array('shipfirstname' => $row['ordbillfirstname'], 'shiplastname' => $row['ordbilllastname'], 'shipcompany' => $row['ordbillcompany'], 'shipaddress1' => $row['ordbillstreet1'], 'shipaddress2' => $row['ordbillstreet2'], 'shipcity' => $row['ordbillsuburb'], 'shipstate' => $row['ordbillstate'], 'shipzip' => $row['ordbillzip'], 'shipcountry' => $row['ordbillcountry'], 'countrycode' => $row['ordbillcountrycode']);
         $GLOBALS['BillingAddress'] = ISC_ADMIN_ORDERS::BuildOrderAddressDetails($addressDetails);
         $GLOBALS['BillingEmail'] = '';
         $GLOBALS['BillingPhone'] = '';
         $GLOBALS['ShippingEmail'] = '';
         $GLOBALS['ShippingPhone'] = '';
         // For the iPhone's "Map This" feature
         $GLOBALS['OneLineBillingAddress'] = trim(isc_html_escape($row['ordbillstreet1'] . ' ' . $row['ordbillstreet2'] . ' ' . $row['ordbillsuburb'] . ' ' . $row['ordbillstate'] . ' ' . $row['ordbillzip'] . ' ' . $row['ordbillcountry']));
         $GLOBALS['OneLineShippingAddress'] = trim(isc_html_escape($row['ordshipstreet1'] . ' ' . $row['ordshipstreet2'] . ' ' . $row['ordshipsuburb'] . ' ' . $row['ordshipstate'] . ' ' . $row['ordshipzip'] . ' ' . $row['ordshipcountry']));
         // This customer still exists, use their most recent email address and phone number
         if ($row['custname'] != '') {
             $GLOBALS['BillingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', urlencode($row['custconemail']), isc_html_escape($row['custconemail']));
             $GLOBALS['ShippingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', urlencode($row['custconemail']), isc_html_escape($row['custconemail']));
             if ($row['ordbillphone'] != '') {
                 $GLOBALS['BillingPhone'] = isc_html_escape($row['ordbillphone']);
             } else {
                 $GLOBALS['BillingPhone'] = isc_html_escape($row['custconphone']);
             }
             if ($row['ordshipphone'] != '') {
                 $GLOBALS['ShippingPhone'] = isc_html_escape($row['ordshipphone']);
             } else {
                 $GLOBALS['ShippingPhone'] = isc_html_escape($row['custconphone']);
             }
         } else {
             if ($row['ordbillphone'] != '' || $row['ordbillemail'] != '' || $row['ordshipphone'] != '' || $row['ordshipemail'] != '') {
                 $GLOBALS['BillingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', $row['ordbillemail'], $row['ordbillemail']);
                 $GLOBALS['BillingPhone'] = isc_html_escape($row['ordbillphone']);
                 $GLOBALS['ShippingEmail'] = sprintf('<a href="mailto:%s" target="_blank">%s</a>', $row['ordshipemail'], $row['ordshipemail']);
                 $GLOBALS['ShippingPhone'] = isc_html_escape($row['ordshipphone']);
             }
         }
         if ($GLOBALS['BillingPhone'] === '') {
             $GLOBALS['BillingPhone'] = GetLang('NA');
         }
         if ($GLOBALS['BillingEmail'] === '') {
             $GLOBALS['BillingEmail'] = GetLang('NA');
         }
         if ($GLOBALS['ShippingPhone'] === '') {
             $GLOBALS['ShippingPhone'] = GetLang('NA');
         }
         if ($GLOBALS['ShippingEmail'] === '') {
             $GLOBALS['ShippingEmail'] = GetLang('NA');
         }
         $GLOBALS['PaymentMethod'] = array();
         if ($row['orderpaymentmethod'] == '') {
             $row['orderpaymentmethod'] = "N/A";
         }
         if ($row['orderpaymentmethod'] != "storecredit" && $row['orderpaymentmethod'] != "giftcertificate") {
             if ($row['ordgatewayamount']) {
                 $row['orderpaymentmethod'] .= " (" . FormatPriceInCurrency($row['ordgatewayamount'], $row['orddefaultcurrencyid']) . ")";
             } else {
                 $row['orderpaymentmethod'] .= " (" . FormatPriceInCurrency($row['ordtotalamount'], $row['orddefaultcurrencyid']) . ")";
             }
             // Does the payment method have any extra info to show?
             $provider = null;
             $GLOBALS['ExtraInfo'] = '';
             if (GetModuleById('checkout', $provider, $row['orderpaymentmodule'])) {
                 if (method_exists($provider, "DisplayPaymentDetails")) {
                     $GLOBALS['ExtraInfo'] = $provider->DisplayPaymentDetails($row);
                 }
             }
             $GLOBALS['PaymentMethod'][] = $row['orderpaymentmethod'];
         }
         if ($row['ordstorecreditamount'] > 0) {
             $GLOBALS['PaymentMethod'][] = GetLang('PaymentStoreCredit') . " (" . FormatPriceInCurrency($row['ordstorecreditamount'], $row['orddefaultcurrencyid']) . ")";
         }
         if ($row['ordgiftcertificateamount'] > 0 && gzte11(ISC_LARGEPRINT)) {
             $GLOBALS['PaymentMethod'][] = sprintf(GetLang('PaymentGiftCertificates'), $row['orderid']) . " (" . FormatPriceInCurrency($row['ordgiftcertificateamount'], $row['orddefaultcurrencyid']) . ")";
         }
         $GLOBALS['IPAddress'] = $row['ordipaddress'];
         $GLOBALS['PaymentMethod'] = implode("<br />", $GLOBALS['PaymentMethod']);
         $GLOBALS['HideShippingZone'] = 'display: none';
         if ($row['ordpayproviderid'] != '') {
             $GLOBALS['TransactionId'] = $row['ordpayproviderid'];
         } else {
             $GLOBALS['TransactionId'] = GetLang('NA');
             $GLOBALS['HideTransactionId'] = 'display: none';
         }
         $extraArray = @unserialize($row['extrainfo']);
         $paymentMessage = '';
         if (isset($extraArray['payment_message']) && $extraArray['payment_message'] != '') {
             $paymentMessage = "<br />" . isc_html_escape($extraArray['payment_message']);
         }
         if (isset($row['ordpaymentstatus']) && $row['ordpaymentstatus'] != '') {
             $GLOBALS['PaymentStatus'] = ucfirst($row['ordpaymentstatus']) . $paymentMessage;
         } else {
             $GLOBALS['PaymentStatus'] = GetLang('NA');
             if ($paymentMessage) {
                 $GLOBALS['PaymentStatus'] .= $paymentMessage;
             } else {
                 $GLOBALS['HidePaymentStatus'] = 'display: none';
             }
         }
         $GLOBALS['CouponsUsed'] = '';
         $GLOBALS['HideCouponsUsed'] = 'display: none';
         // Get the products in the order
         $query = "SELECT o.*\n\t\t\t\t\tFROM [|PREFIX|]order_coupons o\n\t\t\t\t\tWHERE ordcouporderid='" . $orderId . "'";
         $coupons = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($coupon = $GLOBALS['ISC_CLASS_DB']->Fetch($coupons)) {
             $GLOBALS['CouponsUsed'] .= $coupon['ordcouponcode'] . ',';
             $GLOBALS['HideCouponsUsed'] = '';
         }
         // If it's a digital order then we don't need to show the shipping details
         if ($row['ordisdigital'] == 0) {
             $addressDetails = array('shipfirstname' => $row['ordshipfirstname'], 'shiplastname' => $row['ordshiplastname'], 'shipcompany' => $row['ordshipcompany'], 'shipaddress1' => $row['ordshipstreet1'], 'shipaddress2' => $row['ordshipstreet2'], 'shipcity' => $row['ordshipsuburb'], 'shipstate' => $row['ordshipstate'], 'shipzip' => $row['ordshipzip'], 'shipcountry' => $row['ordshipcountry'], 'countrycode' => $row['ordshipcountrycode']);
             $GLOBALS['ShippingAddress'] = ISC_ADMIN_ORDERS::BuildOrderAddressDetails($addressDetails);
             if ($row['ordshipmethod'] != "") {
                 $GLOBALS['ShippingMethod'] = isc_html_escape($row['ordshipmethod']);
             } else {
                 $GLOBALS['ShippingMethod'] = GetLang('NA');
             }
             if ($row['ordshippingzoneid'] != 0) {
                 $GLOBALS['HideShippingZone'] = '';
                 if ($row['shippingzonename']) {
                     $GLOBALS['ShippingZone'] = "<a href=\"index.php?ToDo=editShippingZone&amp;zoneId=" . $row['ordshippingzoneid'] . "\">" . isc_html_escape($row['shippingzonename']) . "</a>";
                     $GLOBALS['ShippingZoneNoLink'] = isc_html_escape($row['shippingzonename']);
                 } else {
                     $GLOBALS['ShippingZone'] = isc_html_escape($row['shippingzonename']);
                 }
             }
             $GLOBALS['ShippingCost'] = FormatPriceInCurrency($row['ordshipcost'], $row['orddefaultcurrencyid']);
         } else {
             $GLOBALS['HideShippingPanel'] = "none";
         }
         $GLOBALS['HideVendor'] = 'display: none';
         if (gzte11(ISC_HUGEPRINT) && $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() == 0 && $row['ordvendorid'] > 0) {
             $GLOBALS['HideVendor'] = '';
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['ordvendorid']])) {
                 $vendor = $vendorCache[$row['ordvendorid']];
                 $GLOBALS['VendorName'] = isc_html_escape($vendor['vendorname']);
                 $GLOBALS['VendorId'] = $vendor['vendorid'];
                 $GLOBALS['HideVendor'] = '';
             }
         }
         $prodFieldsArray = $GLOBALS['ISC_CLASS_ADMIN_ORDERS']->GetOrderProductFieldsData($orderId);
         // Get the products in the order
         $query = "\n\t\t\t\t\tSELECT o.*, p.prodname\n\t\t\t\t\tFROM [|PREFIX|]order_products o\n\t\t\t\t\tLEFT JOIN [|PREFIX|]products p ON (p.productid=o.ordprodid)\n\t\t\t\t\tWHERE orderorderid='" . $orderId . "'\n\t\t\t\t\tORDER BY ordprodname";
         $pResult = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $GLOBALS['ProductsTable'] = "<table width=\"95%\" align=\"center\" border=\"0\" cellspacing=0 cellpadding=0>";
         // Add a notice about the order containing only digitally downloadable products
         if ($row['ordisdigital'] == 1) {
             $GLOBALS['ProductsTable'] .= sprintf("\n\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"padding:5px; background-color:lightyellow\" width=\"100%%\" class=\"text\" colspan=\"2\">\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\">&nbsp;</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t", GetLang('DigitalOrderNotice'));
         }
         $wrappingTotal = 0;
         while ($pRow = $GLOBALS['ISC_CLASS_DB']->Fetch($pResult)) {
             $sku = "";
             if ($pRow['ordprodsku'] != "") {
                 $sku = "<br /><em>" . isc_html_escape($pRow['ordprodsku']) . "</em>";
             }
             $sStart = $sEnd = '';
             $refunded = '';
             $shippedLabel = '';
             if ($pRow['ordprodqtyshipped'] > 0) {
                 $shippedLabel = '<div class="Shipped">' . sprintf(GetLang('OrderProductsShippedX'), $pRow['ordprodqtyshipped']) . '</div>';
             }
             if ($pRow['ordprodrefunded'] > 0) {
                 if ($pRow['ordprodrefunded'] == $pRow['ordprodqty']) {
                     $sStart = "<del>";
                     $sEnd = "</del>";
                     $refunded = '<div class="Refunded">' . GetLang('OrderProductRefunded') . '</span>';
                 } else {
                     $refunded = '<div class="Refunded">' . sprintf(GetLang('OrderProductsRefundedX'), $pRow['ordprodrefunded']) . '</div>';
                 }
                 $cost = $pRow['ordprodcost'] * ($pRow['ordprodqty'] - $pRow['ordprodrefunded']);
             } else {
                 $cost = $pRow['ordprodcost'] * $pRow['ordprodqty'];
             }
             if ($pRow['prodname']) {
                 $pRow['ordprodname'] = "<a href='" . ProdLink($pRow['prodname']) . "' target='_blank'>" . isc_html_escape($pRow['ordprodname']) . "</a>";
             }
             $pOptions = '';
             if ($pRow['ordprodoptions'] != '') {
                 $options = @unserialize($pRow['ordprodoptions']);
                 if (!empty($options)) {
                     $pOptions = "<blockquote style=\"padding-left: 10px; margin: 0;\">";
                     $comma = '';
                     foreach ($options as $name => $value) {
                         $pOptions .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                         $comma = '<br />';
                     }
                     $pOptions .= "</blockquote>";
                 }
             }
             if ($pRow['ordprodwrapcost'] > 0) {
                 $wrappingTotal += $pRow['ordprodwrapcost'] * $pRow['ordprodqty'];
             }
             $giftOptions = '';
             if ($pRow['ordprodwrapname']) {
                 $giftOptions .= "<tr><td height='18' class='QuickGiftWrapping text' colspan='2'><div>";
                 $giftOptions .= GetLang('GiftWrapping') . ": " . isc_html_escape($pRow['ordprodwrapname']);
                 $giftOptions .= " [<a href='#' onclick=\"\$.iModal({type: 'ajax', url: 'remote.php?remoteSection=orders&w=viewGiftWrappingDetails&orderprodid=" . $pRow['orderprodid'] . "'}); return false;\">" . GetLang('ViewDetails') . "</a>]";
                 $giftOptions .= "</div></td></tr>";
             }
             $prodFields = '';
             if (isset($prodFieldsArray[$pRow['orderprodid']])) {
                 $prodFields = $this->GetOrderProductsFieldsRow($prodFieldsArray[$pRow['orderprodid']]);
             }
             $eventDate = '';
             if ($pRow['ordprodeventdate'] != null) {
                 $eventDate = '<tr><td style="padding:5px 0px 5px 15px;">' . $pRow['ordprodeventname'] . ': ' . isc_date('jS M Y', $pRow['ordprodeventdate']) . '</tr>';
             }
             $itemDetails = '';
             if ($shippedLabel || $refunded) {
                 $itemDetails = "<tr><td class='text' colspan='2' style='padding-left: 20px;'>";
                 $itemDetails .= $shippedLabel . $refunded;
                 $itemDetails .= '</td></tr>';
             }
             $GLOBALS['ProductsTable'] .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"padding-left:12px; padding-top:5px\" width=\"70%\" class=\"text\">" . $sStart . $pRow['ordprodqty'] . " x " . $pRow['ordprodname'] . $sEnd . $sku . $pOptions . "</td>\n\t\t\t\t\t\t\t<td class=\"text\" width=\"30%%\" align=\"right\">" . FormatPriceInCurrency($cost, $row['orddefaultcurrencyid']) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t" . $giftOptions . $eventDate . $prodFields . $itemDetails . "\n\t\t\t\t\t";
         }
         $GLOBALS['ProductsTable'] .= "<tr><td colspan='2'><hr noshade size='1'></td></tr>";
         $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('SubTotal'), FormatPriceInCurrency($row['ordsubtotal'], $row['orddefaultcurrencyid']));
         if ($wrappingTotal > 0) {
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('GiftWrapping'), FormatPriceInCurrency($wrappingTotal, $row['orddefaultcurrencyid']));
         }
         // Do we need to show a shipping cost?
         if ($row['ordshipmethod'] != "" && $row['ordshipcost'] > 0) {
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('Shipping'), FormatPriceInCurrency($row['ordshipcost'], $row['orddefaultcurrencyid']));
         }
         // Do we need to show a handling fee?
         if ($row['ordhandlingcost'] > 0) {
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", GetLang('Handling'), FormatPriceInCurrency($row['ordhandlingcost'], $row['orddefaultcurrencyid']));
         }
         if ($row['orddateshipped'] > 0) {
             $GLOBALS['ShippingDate'] = isc_date(GetConfig('DisplayDateFormat'), $row['orddateshipped']);
         } else {
             $GLOBALS['ShippingDate'] = GetLang('NA');
         }
         // Do we need to show sales tax?
         if ($row['ordtaxtotal'] > 0 && $row['ordtotalincludestax'] == 0) {
             if ($row['ordtaxname']) {
                 $taxName = isc_html_escape($row['ordtaxname']);
             } else {
                 $taxName = GetLang('SalesTax');
             }
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", $taxName, FormatPriceInCurrency($row['ordtaxtotal'], $row['orddefaultcurrencyid']));
         }
         $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='QuickTotal text' align='right'>%s:</td><td class='QuickTotal text' align='right'>%s</td></tr>", GetLang('Total'), FormatPriceInCurrency($row['ordtotalamount'], $row['orddefaultcurrencyid']));
         // Do we need to show sales tax that was already included in the totals? We show it after the order total
         if ($row['ordtaxtotal'] > 0 && $row['ordtotalincludestax'] == 1) {
             if ($row['ordtaxname']) {
                 $taxName = isc_html_escape($row['ordtaxname']);
             } else {
                 $taxName = GetLang('SalesTax');
             }
             $taxName .= ' ' . GetLang('IncludedInTotal');
             $GLOBALS['ProductsTable'] .= sprintf("<tr><td height='18' class='text' align='right'>%s:</td><td class='text' align='right'>%s</td></tr>", $taxName, FormatPrice($row['ordtaxtotal']));
         }
         if (isset($row['ordpaymentstatus'])) {
             if ($row['ordpaymentstatus'] == 'refunded' || $row['ordpaymentstatus'] == 'partially refunded') {
                 $GLOBALS['ProductsTable'] .= '<tr><td class="text" align="right" height="18">' . GetLang('Refunded') . ':</td><td class="text" align="right">' . FormatPriceInCurrency($row['ordrefundedamount'], $row['orddefaultcurrencyid']) . '</td></tr>';
             }
         }
         $GLOBALS['ProductsTable'] .= "</table>";
         $GLOBALS['OrderComments'] = '';
         if (trim($row['ordcustmessage']) != '') {
             $GLOBALS['OrderComments'] = nl2br(isc_html_escape($row['ordcustmessage']));
         } else {
             $GLOBALS['HideOrderComments'] = 'display: none';
         }
         /**
          * Order form field
          */
         $GLOBALS['HideBillingFormFields'] = '';
         $GLOBALS['HideShippingFormFields'] = '';
         $GLOBALS['BillingFormFields'] = '';
         $GLOBALS['ShippingFormFields'] = '';
         $billingFields = array();
         $shippingFields = array();
         if (gzte11(ISC_MEDIUMPRINT) && isId($row['ordformsessionid'])) {
             $billingFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData($row['ordformsessionid'], array(), FORMFIELDS_FORM_BILLING, true);
             $shippingFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData($row['ordformsessionid'], array(), FORMFIELDS_FORM_SHIPPING, true);
         }
         /**
          * Do we have the correct version?
          */
         if (!gzte11(ISC_MEDIUMPRINT)) {
             $GLOBALS['HideBillingFormFields'] = 'none';
             $GLOBALS['HideShippingFormFields'] = 'none';
             /**
              * OK, we're allow to
              */
         } else {
             /**
              * Lets do the billing first. Do we have any?
              */
             if (empty($billingFields)) {
                 $GLOBALS['HideBillingFormFields'] = 'none';
             } else {
                 $GLOBALS['BillingFormFields'] = $this->buildOrderFormFields($billingFields);
             }
             /**
              * Now the shipping
              */
             if (empty($billingFields)) {
                 $GLOBALS['HideShippingFormFields'] = 'none';
             } else {
                 $GLOBALS['ShippingFormFields'] = $this->buildOrderFormFields($shippingFields);
             }
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("order.quickview");
         $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     } else {
         echo GetLang('OrderDetailsNotFound');
     }
 }