/**
  * Display a list of states for a given country
  *
  * @return void
  **/
 private function GetCountryStates()
 {
     $country = $_REQUEST['c'];
     if (IsId($country)) {
         $countryId = $country;
     } else {
         $countryId = GetCountryIdByName($country);
     }
     if (isset($_REQUEST['s']) && GetStateByName($_REQUEST['s'], $countryId)) {
         $state = $_REQUEST['s'];
     } else {
         $state = '';
     }
     if (isset($_REQUEST['format']) && $_REQUEST['format'] == 'options') {
         echo GetStateListAsOptions($country, $state, false, '', '', false, true);
     } else {
         echo GetStateList((int) $country);
     }
 }
Example #2
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");
     }
 }
 /**
  * View the details for gift wrapping for a particular item.
  */
 public function ViewGiftWrappingDetails()
 {
     if (!isset($_REQUEST['orderprodid']) || !IsId($_REQUEST['orderprodid'])) {
         exit;
     }
     $query = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM [|PREFIX|]order_products\n\t\t\t\tWHERE orderprodid='" . (int) $_REQUEST['orderprodid'] . "'\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $orderProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     if (!isset($orderProduct['ordprodid']) || !$orderProduct['ordprodwrapname']) {
         exit;
     }
     $GLOBALS['ProductName'] = isc_html_escape($orderProduct['ordprodname']);
     $GLOBALS['ProductQuantity'] = $orderProduct['ordprodqty'];
     $GLOBALS['WrapName'] = isc_html_escape($orderProduct['ordprodwrapname']);
     $GLOBALS['WrapPrice'] = FormatPrice($orderProduct['ordprodwrapcost']);
     if ($orderProduct['ordprodwrapmessage']) {
         $GLOBALS['WrapMessage'] = nl2br(isc_html_escape($orderProduct['ordprodwrapmessage']));
     } else {
         $GLOBALS['HideWrapMessage'] = 'display: none';
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("order.viewwrapping");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
Example #4
0
		/**
		 * View the details for gift wrapping for a particular item.
		 */
		public function viewGiftWrappingDetailsAction()
		{
			if(!isset($_REQUEST['orderprodid']) || !IsId($_REQUEST['orderprodid'])) {
				exit;
			}

			$query = "
				SELECT *
				FROM [|PREFIX|]order_products
				WHERE orderprodid='".(int)$_REQUEST['orderprodid']."'
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$orderProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
			if(!isset($orderProduct['ordprodid']) || !$orderProduct['ordprodwrapname']) {
				exit;
			}

			$GLOBALS['ProductName'] = isc_html_escape($orderProduct['ordprodname']);
			$GLOBALS['ProductQuantity'] = $orderProduct['ordprodqty'];
			$GLOBALS['WrapName'] = isc_html_escape($orderProduct['ordprodwrapname']);

			$wrapping = $orderProduct['wrapping_cost_ex_tax'];
			if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) {
				$wrapping = $orderProduct['wrapping_cost_inc_tax'];
			}

			$GLOBALS['WrapPrice'] = FormatPrice($wrapping);
			if($orderProduct['ordprodwrapmessage']) {
				$GLOBALS['WrapMessage'] = nl2br(isc_html_escape($orderProduct['ordprodwrapmessage']));
			}
			else {
				$GLOBALS['HideWrapMessage'] = 'display: none';
			}

			$this->template->display('order.viewwrapping.tpl');
		}
Example #5
0
	private function _ImportImage($productId, $record, $index = '')
	{
		$existingImage = false;
		$imageId = 0;

		if (!empty($record['prodimageid' . $index]) && IsId($record['prodimageid' . $index])) {
			$imageId = $record['prodimageid' . $index];
			try {
				$existingImage = new ISC_PRODUCT_IMAGE((int)$imageId);
				if ($existingImage->getProductId() != $productId) {
					// the existing image doesn't belong to this product
					$existingImage = false;
				}
			}
			catch (Exception $ex) {
			}
		}
		$imageFile = $record['prodimagefile' . $index];
		$imageDescription = '';
		if (!empty($record['prodimagedescription' . $index])) {
			$imageDescription = $record['prodimagedescription' . $index];
		}
		$imageIsThumb = false;
		if (!empty($record['prodimageisthumb' . $index])) {
			$imageIsThumb = $record['prodimageisthumb' . $index];
		}
		$imageSort = -1;
		if (isset($record['prodimagesort' . $index]) && $record['prodimagesort' . $index] != '') {
			$imageSort = (int)$record['prodimagesort' . $index];
		}

		$importedImage = false;

		if (!$existingImage || $existingImage->getSourceFilePath() != $imageFile) {
			if (preg_match('#^(?P<scheme>[a-zA-Z0-9\.]+)://#i', $imageFile, $matches)) {
				// code exists in the new product image management classes to handle these imports
				$imageAdmin = new ISC_ADMIN_PRODUCT_IMAGE();

				// the filename is an external URL, import it against the calcualted product hash
				$imageAdmin->importImagesFromUrls(false, array($imageFile), $importImages, $importImageErrors, false, true);

				if (!empty($importImages)) {
					$importedImage = $importImages[0];
				}

				if (!empty($importImageErrors)) {
					// as this import works on one file only and importImagesFromWebUrls creates one error per file, can simply tack on the new error
					$importImageError = $importImageErrors[0];
					if (is_array($importImageError)) {
						$this->ImportSession['Results']['Warnings'][] = $importImageError[1];
					} else {
						$this->ImportSession['Results']['Warnings'][] = $importImageError;
					}
				}
			} else {
				// the filename is a local file
				$importImageFilePath = ISC_BASE_PATH . "/" . GetConfig('ImageDirectory') . "/import/" . $imageFile;
				if (file_exists($importImageFilePath)) {
					try {
						$importedImage = ISC_PRODUCT_IMAGE::importImage($importImageFilePath, basename($importImageFilePath), false, false, false, false);
						$productImages[] = $importedImage;
					} catch (Exception $exception) {
						$this->ImportSession['Results']['Warnings'][] = $exception->getMessage();
					}
				}
				else {
					$this->ImportSession['Results']['Warnings'][] = $record['prodname'].GetLang('ImportProductImageDoesntExist');
				}
			}
		}

		// do we have an existing image?
		if ($existingImage) {
			// assign the imported image file to our existing image
			if ($importedImage) {
				$existingImage->setSourceFilePath($importedImage->getSourceFilePath());
				$existingImage->saveToDatabase(false);
			}

			// use the existing image to set the description, thumb, sort
			$importedImage = $existingImage;
		}

		if ($importedImage) {
			$importedImage->setDescription($imageDescription);
			$importedImage->setIsThumbnail($imageIsThumb);
			if ($imageSort >= 0) {
				$importedImage->setSort($imageSort);
			}
		}

		return $importedImage;
	}
Example #6
0
 /**
  * Print one or more packing slips a shipment
  */
 private function PrintShipmentPackingSlips()
 {
     $shipments = array();
     $showShipmentSelect = false;
     // Selected a shipment to print
     if (isset($_GET['shipmentId']) && $_GET['shipmentId'] > 0) {
         $shipment = $this->GetShipmentById($_GET['shipmentId']);
         if (!is_array($shipment)) {
             exit;
         }
         $shipments = array($shipment['shipmentid']);
         $orderId = $shipment['shiporderid'];
         $showShipmentSelect = true;
     } else {
         if (isset($_GET['orderId']) && isset($_GET['shipmentId']) && $_GET['shipmentId'] == -1) {
             $query = "\n\t\t\t\tSELECT shipmentid\n\t\t\t\tFROM [|PREFIX|]shipments\n\t\t\t\tWHERE shiporderid='" . (int) $_GET['orderId'] . "'\n\t\t\t";
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             while ($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 $shipments[] = $shipment['shipmentid'];
             }
             $orderId = (int) $_GET['orderId'];
             $showShipmentSelect = true;
         } else {
             if (isset($_GET['shipments']) && is_array($_GET['shipments'])) {
                 $shipments = array_map('intval', $_GET['shipments']);
                 $orderId = null;
             } else {
                 if (isset($_GET['orderId']) && IsId($_GET['orderId'])) {
                     $orderId = (int) $_GET['orderId'];
                     $shipments = array(0);
                     $showShipmentSelect = true;
                 }
             }
         }
     }
     if ($showShipmentSelect == true && IsId($orderId)) {
         $order = GetOrder($orderId);
         $GLOBALS['ShipmentSelectOrderId'] = $order['orderid'];
         if (count($shipments) > 1) {
             $GLOBALS['AllShipmentsSelected'] = 'selected="selected"';
         }
         $GLOBALS['PackingSlipsClass'] = 'WithShipmentSelect';
         $query = "\n\t\t\t\tSELECT shipmentid, shipdate\n\t\t\t\tFROM [|PREFIX|]shipments\n\t\t\t\tWHERE shiporderid='" . (int) $_GET['orderId'] . "'\n\t\t\t\tORDER BY shipdate ASC\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $GLOBALS['ShipmentSelectOptions'] = '';
         while ($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $sel = '';
             if (count($shipments) == 1 && $shipments[0] == $shipment['shipmentid']) {
                 $sel = 'selected="selected"';
             }
             $shipmentName = GetLang('Shipment') . ' #' . $shipment['shipmentid'] . ' (' . CDate($shipment['shipdate']) . ')';
             $GLOBALS['ShipmentSelectOptions'] .= '<option value="' . $shipment['shipmentid'] . '" ' . $sel . '>' . $shipmentName . '</option>';
         }
         if ($GLOBALS['ShipmentSelectOptions']) {
             $GLOBALS['ShipmentSelect'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ShipmentSelect');
         } else {
             $GLOBALS['PackingSlipsClass'] = '';
         }
     }
     $packingSlips = '';
     foreach ($shipments as $i => $shipmentId) {
         if ($i > 0 && $packingSlips != '') {
             $packingSlips .= '<p class="PageBreak">&nbsp;</p>';
         }
         $packingSlips .= $this->GeneratePackingSlip($orderId, $shipmentId);
     }
     $GLOBALS['PackingSlips'] = $packingSlips;
     if (!$packingSlips) {
         exit;
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate('shipments.print');
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
     echo '<script type="text/javascript">window.setTimeout("window.print();", 1000);</script>';
 }
Example #7
0
	/**
	 * Print one or more packing slips a shipment
	 */
	private function PrintShipmentPackingSlips()
	{
		$shipments = array();
		$showShipmentSelect = false;

		// Selected a shipment to print
		if(isset($_GET['shipmentId']) && $_GET['shipmentId'] > 0) {
			$shipment = $this->GetShipmentById($_GET['shipmentId']);
			if(!is_array($shipment)) {
				exit;
			}
			$shipments = array($shipment['shipmentid']);
			$orderId = $shipment['shiporderid'];
			$showShipmentSelect = true;
		}
		// Printing all shipments for a specific order
		else if(isset($_GET['orderId']) && isset($_GET['shipmentId']) && $_GET['shipmentId'] == -1) {
			$query = "
				SELECT shipmentid
				FROM [|PREFIX|]shipments
				WHERE shiporderid='".(int)$_GET['orderId']."'
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			while($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$shipments[] = $shipment['shipmentid'];
			}
			$orderId = (int)$_GET['orderId'];
			$showShipmentSelect = true;
			$allShipments = true;
		}
		// Printing packing slips for one or more selected shipments
		else if(isset($_GET['shipments']) && is_array($_GET['shipments'])) {
			$shipments = array_map('intval', $_GET['shipments']);
			$orderId = null;
		}
		// Printing a packing slip for an entire order (single packing slip)
		else if(isset($_GET['orderId']) && IsId($_GET['orderId'])) {
			$orderId = (int)$_GET['orderId'];
			$shipments = array(0);
			$showShipmentSelect = true;
		}

		if($showShipmentSelect == true && IsId($orderId)) {
			$order = GetOrder($orderId, null, null, true);
			$GLOBALS['ShipmentSelectOrderId'] = $order['orderid'];

			if(!empty($allShipments)) {
				$GLOBALS['AllShipmentsSelected'] = 'selected="selected"';
			}

			$GLOBALS['PackingSlipsClass'] = 'WithShipmentSelect';

			$query = "
				SELECT shipmentid, shipdate
				FROM [|PREFIX|]shipments
				WHERE shiporderid='".(int)$_GET['orderId']."'
				ORDER BY shipdate ASC
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$GLOBALS['ShipmentSelectOptions'] = '';
			while($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$sel = '';
				if(!empty($_GET['shipmentId']) && $_GET['shipmentId'] == $shipment['shipmentid']) {
					$sel = 'selected="selected"';
				}
				$shipmentName = GetLang('Shipment').' #'.$shipment['shipmentid'].' ('.CDate($shipment['shipdate']).')';
				$GLOBALS['ShipmentSelectOptions'] .= '<option value="'.$shipment['shipmentid'].'" '.$sel.'>'.$shipmentName.'</option>';
			}
			if($GLOBALS['ShipmentSelectOptions']) {
				$GLOBALS['ShipmentSelect'] = $this->template->render('Snippets/ShipmentSelect.html');
			}
			else {
				$GLOBALS['PackingSlipsClass'] = '';
			}
		}

		// Printing shipments for a single order
		require_once ISC_BASE_PATH.'/lib/order.printing.php';
		$packingSlips = '';
		if(in_array(0, $shipments)) {
			$packingSlips = generateOrderPackingSlip($orderId);
		}
		else {
			foreach($shipments as $i => $shipmentId) {
				if($i > 0 && $packingSlips != '') {
					$packingSlips .= '<p class="PageBreak">&nbsp;</p>';
				}
				$packingSlips .= generateShipmentPackingSlip($shipmentId);
			}
		}
		$GLOBALS['PackingSlips'] = $packingSlips;
		if(!$packingSlips) {
			echo '<script type="text/javascript">alert("'.getLang('NoShipmentsForOrdersFound').'"); window.close(); </script>';
		}
		$this->template->display('shipments.print.tpl');
		echo '<script type="text/javascript">window.setTimeout("window.print();", 1000);</script>';
	}
Example #8
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.calculated_price ASC';
				$GLOBALS['SortPriceAsc'] = 'selected="selected"';
				break;
			case 'pricedesc';
				$sortField = 'p.calculated_price 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 = "
			SELECT COUNT(p.productid) AS numproducts
			FROM [|PREFIX|]products p
			".GetProdCustomerGroupPermissionsSQL()."
			WHERE p.prodvisible='1' AND p.prodvendorid='".(int)$vendor['vendorid']."'
		";
		$numProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
		$numPages = ceil($numProducts / GetConfig('CategoryProductsPerPage'));

		// Now load the actual products for this vendor
		$query = $this->getProductQuery(
			'p.prodvendorid='.(int)$vendor['vendorid'],
			$sortField.', prodname ASC',
			getConfig('CategoryProductsPerPage'),
			$start
		);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		$GLOBALS['SNIPPETS']['VendorProducts'] = '';

		if(!GetConfig('ShowProductRating')) {
			$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)) {
			$this->setProductGlobals($row);
			$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");
		}
	}
Example #9
0
 public function HandleToDo($Do)
 {
     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('brands');
     $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
     switch (isc_strtolower($Do)) {
         case "saveeditedbrand":
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Brands)) {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands");
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 $this->SaveEditedBrand();
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 die;
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
             break;
         case "editbrand":
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Brands)) {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands", GetLang('EditBrand') => "index.php?ToDo=editBrand");
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 $this->EditBrand();
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 die;
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
             break;
         case "savenewbrands":
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Add_Brands)) {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 $this->SaveNewBrands();
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 die;
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
             break;
         case "addbrand":
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Add_Brands)) {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands", GetLang('AddBrands') => "index.php?ToDo=addBrand");
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 $this->AddBrands();
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 die;
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
             break;
         case "deletebrands":
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Delete_Brands)) {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands");
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 $this->DeleteBrands();
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 die;
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
             break;
             /* Added for series -- Baskaran */
         /* Added for series -- Baskaran */
         case "addbrandseries":
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Add_Brands)) {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands", GetLang('AddSeries') => "index.php?ToDo=addbrandseries");
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 $this->AddSeries();
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 die;
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
             break;
         case "savebrandseries":
             if (isset($_POST['addanother']) == 'addanother') {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands", GetLang('AddSeries') => "index.php?ToDo=addbrandseries");
             } else {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands", GetLang('AddSeries') => "index.php?ToDo=addbrandseries");
             }
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
             $this->SaveNewSeries();
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
             die;
             break;
         case "editbrandseries":
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Brands)) {
                 if (isset($_POST['keepedit']) == 'keepedit') {
                     $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands", GetLang('EditSeries') => "index.php?ToDo=editBrandSeries");
                 } else {
                     $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands", GetLang('EditSeries') => "index.php?ToDo=editBrandSeries");
                 }
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 $this->EditSeries();
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 die;
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
             break;
         case "saveeditedbrandseries":
             if (isset($_POST['keepedit']) == 'keepedit') {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewSeries", GetLang('EditSeries') => "index.php?ToDo=editBrandSeries");
             } else {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewSeries", GetLang('EditSeries') => "index.php?ToDo=editBrandSeries");
             }
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
             $this->SaveEditedSeries();
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
             die;
             break;
         case "getbrandseriescatename":
             if (isset($_POST['categoryId']) && IsId($_POST['categoryId'])) {
                 echo $this->GetCategoryName($_POST['categoryId']);
             } else {
                 echo 'notFound';
             }
             break;
             /* Ends here */
         /* Ends here */
         default:
             if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Brands)) {
                 $GLOBALS['BreadcrumEntries'] = array(GetLang('Home') => "index.php", GetLang('Brands') => "index.php?ToDo=viewBrands");
                 if (!isset($_REQUEST['ajax'])) {
                     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintHeader();
                 }
                 $this->ManageBrands();
                 if (!isset($_REQUEST['ajax'])) {
                     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->PrintFooter();
                 }
             } else {
                 $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
             }
     }
 }