Example #1
0
function CurrencyFormatNumber($price, $currency)
{
    $arCurFormat = CCurrencyLang::GetCurrencyFormat($currency);
    if (!isset($arCurFormat["DECIMALS"])) {
        $arCurFormat["DECIMALS"] = 2;
    }
    $arCurFormat["DECIMALS"] = IntVal($arCurFormat["DECIMALS"]);
    if (!isset($arCurFormat["DEC_POINT"])) {
        $arCurFormat["DEC_POINT"] = ".";
    }
    if (!empty($arCurFormat["THOUSANDS_VARIANT"])) {
        if ($arCurFormat["THOUSANDS_VARIANT"] == "N") {
            $arCurFormat["THOUSANDS_SEP"] = "";
        } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "D") {
            $arCurFormat["THOUSANDS_SEP"] = ".";
        } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "C") {
            $arCurFormat["THOUSANDS_SEP"] = ",";
        } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "S") {
            $arCurFormat["THOUSANDS_SEP"] = chr(32);
        } elseif ($arCurFormat["THOUSANDS_VARIANT"] == "B") {
            $arCurFormat["THOUSANDS_SEP"] = chr(32);
        }
    }
    if (!isset($arCurFormat["FORMAT_STRING"])) {
        $arCurFormat["FORMAT_STRING"] = "#";
    }
    $price = number_format($price, $arCurFormat["DECIMALS"], $arCurFormat["DEC_POINT"], $arCurFormat["THOUSANDS_SEP"]);
    if ($arCurFormat["THOUSANDS_VARIANT"] == "B") {
        $num = str_replace(" ", " ", $num);
    }
    $price = str_replace(',', '.', $price);
    return $price;
}
Example #2
0
				while($arItem = $dbItem->Fetch())
					echo "<b>"."<a href=\"".CIBlock::GetAdminElementEditLink($arItem["IBLOCK_ID"], $arItem["ID"], array(
						"find_section_section" => $arItem["IBLOCK_SECTION_ID"],
						'WF' => 'Y',
					))."\">".htmlspecialcharsbx($arItem["NAME"])."</a></b> (".GetMessage("NEWO_PRODUCTS_NA").")<br />";
			}
			echo EndNote();
		}
		?>
		<script type="text/javascript">
			var arProduct = [];
			var arProductEditCountProps = [];
			var countProduct = 0;
		</script>
		<?
		$arCurFormat = CCurrencyLang::GetCurrencyFormat($str_CURRENCY);
		$CURRENCY_FORMAT = trim(str_replace("#", '', $arCurFormat["FORMAT_STRING"]));
		$ORDER_TOTAL_PRICE = 0;
		$ORDER_PRICE_WITH_DISCOUNT = 0;
		$productCountAll = 0;
		$productWeight = 0;
		$arFilterRecommended = array();
		$WEIGHT_UNIT = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', "", $LID));
		$WEIGHT_KOEF = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, $LID));

		$QUANTITY_FACTORIAL = COption::GetOptionString('sale', 'QUANTITY_FACTORIAL', "N");
		if (!isset($QUANTITY_FACTORIAL) OR $QUANTITY_FACTORIAL == "")
			$QUANTITY_FACTORIAL = 'N';

		//edit form props
		$formTemplate = '
Example #3
0
function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
	if (!\Bitrix\Main\Loader::includeModule("catalog"))
		return array();

	$arParams = array();

	$productId = (int)$productId;
	if ($productId <= 0)
	{
		return $arParams;
	}
	$iblockId = (int)CIBlockElement::GetIBlockByID($productId);
	if ($iblockId <= 0)
	{
		return $arParams;
	}

	$arSku2Parent = array();
	$arElementId = array();

	$arElementId[] = $productId;
	$arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
	if ($arParent)
	{
		$arElementId[] = $arParent["ID"];
		$arSku2Parent[$productId] = $arParent["ID"];
	}

	$arPropertyInfo = array();
	$userColumns = (string)$userColumns;
	$arUserColumns = ($userColumns != '') ? explode(",", $userColumns) : array();
	foreach ($arUserColumns as $key => $column)
	{
		if (strncmp($column, 'PROPERTY_', 9) != 0)
		{
			unset($arUserColumns[$key]);
		}
		else
		{
			$propertyCode = substr($column, 9);
			if ($propertyCode == '')
			{
				unset($arUserColumns[$key]);
				continue;
			}
			$dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
			if ($arPropData = $dbres->GetNext())
				$arPropertyInfo[$column] = $arPropData;
		}
	}

	$arSelect = array_merge(
		array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"),
		$arUserColumns
	);

	$arProductData = getProductProps($arElementId, $arSelect);

	$defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);

	if (!empty($arProductData))
	{
		$arElementInfo = array();
		foreach ($arProductData as $elemId => &$arElement)
		{
			foreach ($arElement as $key => $value)
			{
				if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE")
				{
					$columnCode = str_replace("_VALUE", "", $key);
					$arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
				}
			}
		}
		unset($arElement);

		if (isset($arProductData[$productId]))
			$arElementInfo = $arProductData[$productId];

		if (isset( $arSku2Parent[$productId]))
			$arParent = $arProductData[$arSku2Parent[$productId]];

		if (!empty($arSku2Parent)) // if sku element doesn't have value of some property - we'll show parent element value instead
		{
			foreach ($arUserColumns as $field)
			{
				$fieldVal = $field."_VALUE";
				$parentId = $arSku2Parent[$productId];

				if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0))
					&& (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) // can be array or string
				{
					$arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
				}
			}
			if (strpos($arElementInfo["~XML_ID"], '#') === false)
			{
				$arElementInfo["~XML_ID"] = $arParent['~XML_ID'].'#'.$arElementInfo["~XML_ID"];
			}
		}

		$arElementInfo["MODULE"] = "catalog";
		$arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";

		$arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];

		if ($arElementInfo["IBLOCK_ID"] > 0)
		{
			$arElementInfo["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array(
				"find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"],
				'WF' => 'Y',
			));
		}

		$arBuyerGroups = CUser::GetUserGroup($userId);

		// price
		$arPrice = CCatalogProduct::GetOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
		$currentPrice = $arPrice["DISCOUNT_PRICE"];
		$arElementInfo["PRICE"] = $currentPrice;
		$arElementInfo["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
		$arElementInfo["DISCOUNT_PRICE"] = $arPrice["PRICE"]["PRICE"] - $arPrice["DISCOUNT_PRICE"];
		$currentTotalPrice = ($arElementInfo["PRICE"] + $arElementInfo["DISCOUNT_PRICE"]);
		$discountPercent = 0;
		if ($arElementInfo["DISCOUNT_PRICE"] > 0)
			$discountPercent = intval(($arElementInfo["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);

		$rsProducts = CCatalogProduct::GetList(
			array(),
			array('ID' => $productId),
			false,
			false,
			array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI')
		);
		if (!($arProduct = $rsProducts->Fetch()))
		{
			return array();
		}
		$balance = floatval($arProduct["QUANTITY"]);

		// sku props
		$arSkuData = array();
		$arProps[] = array(
			"NAME" => "Catalog XML_ID",
			"CODE" => "CATALOG.XML_ID",
			"VALUE" => $arElementInfo['~IBLOCK_XML_ID']
		);
		$arSkuProperty = CSaleProduct::GetProductSkuProps($productId, '', true);
		if (!empty($arSkuProperty))
		{
			foreach ($arSkuProperty as &$val)
			{
				$arSkuData[] = array(
					'NAME' => $val['NAME'],
					'VALUE' => $val['VALUE'],
					'CODE' => $val['CODE']
				);
			}
			unset($val);
		}
		$arSkuData[] = array(
			"NAME" => "Product XML_ID",
			"CODE" => "PRODUCT.XML_ID",
			"VALUE" => $arElementInfo["~XML_ID"]
		);

		// currency
		$arCurFormat = CCurrencyLang::GetCurrencyFormat($arElementInfo["CURRENCY"]);
		$priceValutaFormat = str_replace("#", "", $arCurFormat["FORMAT_STRING"]);

		$arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];

		// measure
		$arElementInfo["MEASURE_TEXT"] = "";
		if ((int)$arProduct["MEASURE"] > 0)
		{
			$dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
			if ($arMeasure = $dbMeasure->Fetch())
				$arElementInfo["MEASURE_TEXT"] = ($arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"]);
		}
		if ($arElementInfo["MEASURE_TEXT"] == '')
		{
			$arElementInfo["MEASURE_TEXT"] = ($defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"]);
		}


		// ratio
		$arElementInfo["RATIO"] = 1;
		$dbratio = CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
		if ($arRatio = $dbratio->Fetch())
			$arElementInfo["RATIO"] = $arRatio["RATIO"];

		// image
		if ($arElementInfo["PREVIEW_PICTURE"] > 0)
			$imgCode = $arElementInfo["PREVIEW_PICTURE"];
		elseif ($arElementInfo["DETAIL_PICTURE"] > 0)
			$imgCode = $arElementInfo["DETAIL_PICTURE"];

		if ($imgCode == "" && count($arParent) > 0)
		{
			if ($arParent["PREVIEW_PICTURE"] > 0)
				$imgCode = $arParent["PREVIEW_PICTURE"];
			elseif ($arParent["DETAIL_PICTURE"] > 0)
				$imgCode = $arParent["DETAIL_PICTURE"];
		}

		if ($imgCode > 0)
		{
			$arFile = CFile::GetFileArray($imgCode);
			$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
			if (is_array($arImgProduct))
				$imgUrl = $arImgProduct["src"];
		}

		$arSetInfo = array();
		$arStores = array();

		/** @var $productProvider IBXSaleProductProvider */
		if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"])))
		{
			// get set items if it is set
			if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET)
			{
				if (method_exists($productProvider, "GetSetItems"))
				{
					$arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);

					if ($tmpId == "")
						$tmpId = randString(7);

					if (!empty($arSets))
					{
						foreach ($arSets as $arSetData)
						{
							foreach ($arSetData["ITEMS"] as $setItem)
							{
								$arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call

								// re-define some fields with set data values
								$arSetItemParams["id"] = $setItem["PRODUCT_ID"];
								$arSetItemParams["name"] = $setItem["NAME"];
								$arSetItemParams["module"] = $setItem["MODULE"];
								$arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
								$arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
								$arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
								$arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
								$arSetItemParams["productType"] = $setItem["TYPE"];
								$arSetItemParams["weight"] = $setItem["WEIGHT"];
								$arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
								$arSetItemParams["setItems"] = "";

								$arSetItemParams["setParentId"] = $productId."_tmp".$tmpId;
								$arSetItemParams["isSetItem"] = "Y";
								$arSetItemParams["isSetParent"] = "N";

								$arSetInfo[] = $arSetItemParams;
							}
						}
					}
				}
			}

			// get stores
			$storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID)); // with exact SITE_ID or SITE_ID = NULL

			if ($storeCount > 0)
			{
				if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID)))
					$arStores = $arProductStore;
			}
		}

		$currentTotalPrice = (float)$currentTotalPrice;
		// params array
		$arParams["id"] = $productId;
		$arParams["name"] = $arElementInfo["~NAME"];
		$arParams["url"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
		$arParams["urlEdit"] = $arElementInfo["EDIT_PAGE_URL"];
		$arParams["urlImg"] = $imgUrl;
		$arParams["price"] = floatval($arElementInfo["PRICE"]);
		$arParams["priceBase"] = $currentTotalPrice;
		$arParams["priceBaseFormat"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], false);
		$arParams["priceFormated"] = CCurrencyLang::CurrencyFormat(floatval($arElementInfo["PRICE"]), $arElementInfo["CURRENCY"], false);
		$arParams["valutaFormat"] = $priceValutaFormat;
		$arParams["dimensions"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
		$arParams["priceDiscount"] = floatval($arElementInfo["DISCOUNT_PRICE"]);
		$arParams["priceTotalFormated"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], true);
		$arParams["discountPercent"] = $discountPercent;
		$arParams["summaFormated"] = CCurrencyLang::CurrencyFormat($arElementInfo["PRICE"], $arElementInfo["CURRENCY"], false);
		$arParams["quantity"] = $quantity;
		$arParams["module"] = $arElementInfo["MODULE"];
		$arParams["currency"] = $arElementInfo["CURRENCY"];
		$arParams["weight"] = $arElementInfo["WEIGHT"];
		$arParams["vatRate"] = $arPrice["PRICE"]["VAT_RATE"];
		$arParams["priceType"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
		$arParams["balance"] = $balance;
		$arParams["notes"] = (is_array($arPrice["PRICE"]) && array_key_exists("CATALOG_GROUP_NAME", $arPrice["PRICE"])) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "";
		$arParams["catalogXmlID"] = $arElementInfo["~IBLOCK_XML_ID"];
		$arParams["productXmlID"] = $arElementInfo["~XML_ID"];
		$arParams["callback"] = "";
		$arParams["orderCallback"] = "";
		$arParams["cancelCallback"] = "";
		$arParams["payCallback"] = "";
		$arParams["productProviderClass"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
		$arParams["skuProps"] = $arSkuData;
		$arParams["measureText"] = $arElementInfo["MEASURE_TEXT"];
		$arParams["ratio"] = $arElementInfo["RATIO"];
		$arParams["barcodeMulti"] = $arProduct["BARCODE_MULTI"];

		$arParams["productType"] = empty($arSetInfo) ? "" : CSaleBasket::TYPE_SET;
		$arParams["setParentId"] = empty($arSetInfo) ? "" : $productId."_tmp".$tmpId;

		$arParams["setItems"] = $arSetInfo;
		$arParams["isSetItem"] = "N";
		$arParams["isSetParent"] = empty($arSetInfo) ? "N" : "Y";

		$arParams["stores"] = empty($arSetInfo) ? $arStores : array();
		$arParams["productPropsValues"] = $arElementInfo; // along with other information also contains values of properties with correct keys (after getProductProps)
	}

	return $arParams;
}
Example #4
0
				$tabControl->BeginCustomField("orders_list", GetMessage("SOD_ORDER"));
				?>
				<tr>
					<td colspan="2" valign="top">
						<!-- //? -->
						<table  id="BASKET_TABLE" cellpadding="3" cellspacing="1" border="0" width="100%" class="internal">

						<tr class="heading">
							<?php 
echo getColumnsHeaders($arUserColumns, "detail", false);
?>
						</tr>
						<?
						$bXmlId = COption::GetOptionString("sale", "show_order_product_xml_id", "N");
						$arCurFormat = CCurrencyLang::GetCurrencyFormat($arOrder["CURRENCY"]);
						$CURRENCY_FORMAT = trim(str_replace("#", '', $arCurFormat["FORMAT_STRING"]));
						$ORDER_TOTAL_PRICE = 0;
						$ORDER_TOTAL_WEIGHT = 0;
						$arFilterRecomendet = array();
						$arBasketProps = array();

						$bUseCatalog = (CModule::IncludeModule("catalog")) ? true : false;
						$bUseIblock = (CModule::IncludeModule("iblock")) ? true : false;

						$arBasketItems = getMeasures($arBasketItems);

						if(!empty($arBasketId))
						{
							//select props from basket
							$arPropsFilter = array("BASKET_ID" => $arBasketId);
Example #5
0
	public static function GetFormatDescription($currency)
	{
		$boolAdminSection = (defined('ADMIN_SECTION') && ADMIN_SECTION === true);
		$currency = (string)$currency;

		if (!isset(self::$arCurrencyFormat[$currency]))
		{
			$arCurFormat = CCurrencyLang::GetCurrencyFormat($currency);
			if ($arCurFormat === false)
			{
				$arCurFormat = self::$arDefaultValues;
			}
			else
			{
				if (!isset($arCurFormat['DECIMALS']))
					$arCurFormat['DECIMALS'] = self::$arDefaultValues['DECIMALS'];
				$arCurFormat['DECIMALS'] = (int)$arCurFormat['DECIMALS'];
				if (!isset($arCurFormat['DEC_POINT']))
					$arCurFormat['DEC_POINT'] = self::$arDefaultValues['DEC_POINT'];
				if (!empty($arCurFormat['THOUSANDS_VARIANT']) && isset(self::$arSeparators[$arCurFormat['THOUSANDS_VARIANT']]))
				{
					$arCurFormat['THOUSANDS_SEP'] = self::$arSeparators[$arCurFormat['THOUSANDS_VARIANT']];
				}
				elseif (!isset($arCurFormat['THOUSANDS_SEP']))
				{
					$arCurFormat['THOUSANDS_SEP'] = self::$arDefaultValues['THOUSANDS_SEP'];
				}
				if (!isset($arCurFormat['FORMAT_STRING']))
				{
					$arCurFormat['FORMAT_STRING'] = self::$arDefaultValues['FORMAT_STRING'];
				}
				elseif ($boolAdminSection)
				{
					$arCurFormat["FORMAT_STRING"] = strip_tags(preg_replace(
						'#<script[^>]*?>.*?</script[^>]*?>#is',
						'',
						$arCurFormat["FORMAT_STRING"]
					));
				}
				if (!isset($arCurFormat['HIDE_ZERO']) || empty($arCurFormat['HIDE_ZERO']))
					$arCurFormat['HIDE_ZERO'] = self::$arDefaultValues['HIDE_ZERO'];
			}
			self::$arCurrencyFormat[$currency] = $arCurFormat;
		}
		else
		{
			$arCurFormat = self::$arCurrencyFormat[$currency];
		}
		return $arCurFormat;
	}
Example #6
0
 /**
  * get sku for product.
  *
  * @param integer $USER_ID				User.
  * @param string  $LID					Site.
  * @param integer $PRODUCT_ID			Product id.
  * @param string  $PRODUCT_NAME			Product name.
  * @param string CURRENCY				Currency.
  * @param array $arProduct				Iblock list.
  * @return array|false
  */
 function GetProductSku($USER_ID, $LID, $PRODUCT_ID, $PRODUCT_NAME = '', $CURRENCY = '', $arProduct = array())
 {
     $USER_ID = (int) $USER_ID;
     $PRODUCT_ID = (int) $PRODUCT_ID;
     if ($PRODUCT_ID <= 0) {
         return false;
     }
     $LID = trim($LID);
     if ($LID == '') {
         return false;
     }
     $PRODUCT_NAME = trim($PRODUCT_NAME);
     $arResult = array();
     $arOffers = array();
     static $arCacheGroups = array();
     if (!is_set($arCacheGroups[$USER_ID])) {
         $arCacheGroups[$USER_ID] = CUser::GetUserGroup($USER_ID);
     }
     $arGroups = $arCacheGroups[$USER_ID];
     if (empty($arProduct)) {
         $arProduct = CSaleProduct::GetProductListIblockInfo(array($PRODUCT_ID));
     }
     static $arOffersIblock = array();
     if (!is_set($arOffersIblock[$arProduct["IBLOCK_ID"]])) {
         $mxResult = CCatalogSKU::GetInfoByProductIBlock($arProduct["IBLOCK_ID"]);
         if (is_array($mxResult)) {
             $arOffersIblock[$arProduct["IBLOCK_ID"]] = $mxResult["IBLOCK_ID"];
         }
     }
     if ($arOffersIblock[$arProduct["IBLOCK_ID"]] > 0) {
         static $arCacheOfferProperties = array();
         if (!is_set($arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]])) {
             $dbOfferProperties = CIBlock::GetProperties($arOffersIblock[$arProduct["IBLOCK_ID"]], array(), array("!XML_ID" => "CML2_LINK"));
             while ($arOfferProperties = $dbOfferProperties->Fetch()) {
                 $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]][] = $arOfferProperties;
             }
         }
         $arOfferProperties = $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]];
         $arIblockOfferProps = array();
         $arIblockOfferPropsFilter = array();
         if (is_array($arOfferProperties)) {
             foreach ($arOfferProperties as $val) {
                 $arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]);
                 $arIblockOfferPropsFilter[] = $val["CODE"];
             }
         }
         $arOffers = CIBlockPriceTools::GetOffersArray($arProduct["IBLOCK_ID"], $PRODUCT_ID, array("ID" => "DESC"), array("NAME"), $arIblockOfferPropsFilter, 0, array(), 1, array(), $USER_ID, $LID);
         $arSku = array();
         $minItemPrice = 0;
         $minItemPriceFormat = "";
         $arSkuId = array();
         $arImgSku = array();
         foreach ($arOffers as $arOffer) {
             $arSkuId[] = $arOffer['ID'];
         }
         if (!empty($arSkuId)) {
             $res = CIBlockElement::GetList(array(), array("ID" => $arSkuId), false, false, array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL"));
             while ($arOfferImg = $res->GetNext()) {
                 $arImgSku[$arOfferImg["ID"]] = $arOfferImg;
             }
         }
         foreach ($arOffers as $arOffer) {
             $arPrice = CCatalogProduct::GetOptimalPrice($arOffer['ID'], 1, $arGroups, "N", array(), $LID);
             if (empty($arPrice)) {
                 break;
             } elseif (strlen($CURRENCY) > 0) {
                 $arPrice["PRICE"]["PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);
                 if ($arPrice["DISCOUNT_PRICE"] > 0) {
                     $arPrice["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);
                 }
                 $arPrice["PRICE"]["CURRENCY"] = $CURRENCY;
             }
             $arSkuTmp = array();
             $arOffer["CAN_BUY"] = "N";
             $arCatalogProduct = CCatalogProduct::GetByID($arOffer['ID']);
             if (!empty($arCatalogProduct)) {
                 if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
                     $arOffer["CAN_BUY"] = "N";
                 } else {
                     $arOffer["CAN_BUY"] = "Y";
                 }
             }
             $arSkuTmp["ImageUrl"] = '';
             if ($arOffer["CAN_BUY"] == "Y") {
                 $productImg = "";
                 if (isset($arImgSku[$arOffer['ID']]) && !empty($arImgSku[$arOffer['ID']])) {
                     if ('' == $PRODUCT_NAME) {
                         $PRODUCT_NAME = $arImgSku[$arOffer['ID']]["~NAME"];
                     }
                     if ($arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"] != "") {
                         $productImg = $arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"];
                     } elseif ($arImgSku[$arOffer['ID']]["DETAIL_PICTURE"] != "") {
                         $productImg = $arImgSku[$arOffer['ID']]["DETAIL_PICTURE"];
                     }
                     if ($productImg == "") {
                         if ($arProduct["PREVIEW_PICTURE"] != "") {
                             $productImg = $arProduct["PREVIEW_PICTURE"];
                         } elseif ($arProduct["DETAIL_PICTURE"] != "") {
                             $productImg = $arProduct["DETAIL_PICTURE"];
                         }
                     }
                     if ($productImg != "") {
                         $arFile = CFile::GetFileArray($productImg);
                         $productImg = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                         $arSkuTmp["ImageUrl"] = $productImg["src"];
                     }
                 }
             }
             if ($minItemPrice === 0 || $arPrice["DISCOUNT_PRICE"] < $minItemPrice) {
                 $minItemPrice = $arPrice["DISCOUNT_PRICE"];
                 $minItemPriceFormat = SaleFormatCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"]);
             }
             foreach ($arIblockOfferProps as $arCode) {
                 if (array_key_exists($arCode["CODE"], $arOffer["PROPERTIES"])) {
                     if (is_array($arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"])) {
                         $arSkuTmp[] = implode("/", $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"]);
                     } else {
                         $arSkuTmp[] = $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"];
                     }
                 }
             }
             if (!empty($arCatalogProduct)) {
                 $arSkuTmp["BALANCE"] = $arCatalogProduct["QUANTITY"];
                 $arSkuTmp["WEIGHT"] = $arCatalogProduct["WEIGHT"];
                 $arSkuTmp["BARCODE_MULTI"] = $arCatalogProduct["BARCODE_MULTI"];
             } else {
                 $arSkuTmp["BALANCE"] = 0;
                 $arSkuTmp["WEIGHT"] = 0;
                 $arSkuTmp["BARCODE_MULTI"] = 'N';
             }
             $urlEdit = CIBlock::GetAdminElementEditLink($arOffer["IBLOCK_ID"], $arOffer['ID'], array('find_section_section' => 0, 'WF' => 'Y'));
             $discountPercent = 0;
             $arSkuTmp["USER_ID"] = $USER_ID;
             $arSkuTmp["ID"] = $arOffer["ID"];
             $arSkuTmp["NAME"] = CUtil::JSEscape($arOffer["NAME"]);
             $arSkuTmp["PRODUCT_NAME"] = CUtil::JSEscape($PRODUCT_NAME);
             $arSkuTmp["PRODUCT_ID"] = $PRODUCT_ID;
             $arSkuTmp["LID"] = CUtil::JSEscape($LID);
             $arSkuTmp["MIN_PRICE"] = $minItemPriceFormat;
             $arSkuTmp["URL_EDIT"] = $urlEdit;
             $arSkuTmp["DISCOUNT_PRICE"] = '';
             $arSkuTmp["DISCOUNT_PRICE_FORMATED"] = '';
             $arSkuTmp["PRICE"] = $arPrice["PRICE"]["PRICE"];
             $arSkuTmp["PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], false);
             $arPriceType = GetCatalogGroup($arPrice["PRICE"]["CATALOG_GROUP_ID"]);
             $arSkuTmp["PRICE_TYPE"] = $arPriceType["NAME_LANG"];
             $arSkuTmp["VAT_RATE"] = $arPrice["PRICE"]["VAT_RATE"];
             if (count($arPrice["DISCOUNT"]) > 0) {
                 $discountPercent = IntVal($arPrice["DISCOUNT"]["VALUE"]);
                 $arSkuTmp["DISCOUNT_PRICE"] = $arPrice["DISCOUNT_PRICE"];
                 $arSkuTmp["DISCOUNT_PRICE_FORMATED"] = CCurrencyLang::CurrencyFormat($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], false);
             }
             $arCurFormat = CCurrencyLang::GetCurrencyFormat($arPrice["PRICE"]["CURRENCY"]);
             $arSkuTmp["VALUTA_FORMAT"] = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
             $arSkuTmp["DISCOUNT_PERCENT"] = $discountPercent;
             $arSkuTmp["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
             $arSkuTmp["CAN_BUY"] = $arOffer["CAN_BUY"];
             $arSku[] = $arSkuTmp;
         }
         if ((!is_array($arIblockOfferProps) || empty($arIblockOfferProps)) && is_array($arSku) && !empty($arSku)) {
             $arIblockOfferProps[0] = array("CODE" => "TITLE", "NAME" => GetMessage("SKU_TITLE"));
             foreach ($arSku as $key => $val) {
                 $arSku[$key][0] = $val["NAME"];
             }
         }
         $arResult["SKU_ELEMENTS"] = $arSku;
         $arResult["SKU_PROPERTIES"] = $arIblockOfferProps;
         $arResult["OFFERS_IBLOCK_ID"] = $arOffersIblock[$arProduct["IBLOCK_ID"]];
     }
     //if OFFERS_IBLOCK_ID > 0
     return $arResult;
 }
Example #7
0
    }
    $pdf->Ln();
}
/*
$pdf->Write(15, CSalePdf::prepareToPdf(sprintf(
	"Грузополучатель: %s ИНН %s, %s",
	CSalePaySystemAction::GetParamValue("BUYER_NAME", false),
	CSalePaySystemAction::GetParamValue("BUYER_INN", false),
	CSalePaySystemAction::GetParamValue("BUYER_ADDRESS", false)
)));
$pdf->Ln();
*/
// Список товаров
$dbBasket = CSaleBasket::GetList(array("DATE_INSERT" => "ASC", "NAME" => "ASC"), array("ORDER_ID" => $ORDER_ID), false, false, array("ID", "PRICE", "CURRENCY", "QUANTITY", "NAME", "VAT_RATE", "MEASURE_NAME"));
if ($arBasket = $dbBasket->Fetch()) {
    $arCurFormat = CCurrencyLang::GetCurrencyFormat($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"]);
    $currency = trim(str_replace('#', '', $arCurFormat['FORMAT_STRING']));
    $arColsCaption = array(1 => CSalePdf::prepareToPdf('№'), CSalePdf::prepareToPdf('Наименование товара'), CSalePdf::prepareToPdf('Кол-во'), CSalePdf::prepareToPdf('Ед.'), CSalePdf::prepareToPdf('Цена, ' . $currency), CSalePdf::prepareToPdf('Ставка НДС'), CSalePdf::prepareToPdf('Сумма, ' . $currency));
    $arCells = array();
    $arProps = array();
    $arRowsWidth = array(1 => 0, 0, 0, 0, 0, 0, 0);
    for ($i = 1; $i <= 7; $i++) {
        $arRowsWidth[$i] = max($arRowsWidth[$i], $pdf->GetStringWidth($arColsCaption[$i]));
    }
    $n = 0;
    $sum = 0.0;
    $vat = 0;
    do {
        // props in product basket
        $arProdProps = array();
        $dbBasketProps = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "DESC"), array("BASKET_ID" => $arBasket["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")), false, false, array("ID", "BASKET_ID", "NAME", "VALUE", "CODE", "SORT"));
Example #8
0
 public static function ConvertMoney($sum, $srcCurrencyID, $dstCurrencyID, $srcExchRate = -1)
 {
     $sum = doubleval($sum);
     if (!CModule::IncludeModule('currency')) {
         return $sum;
     }
     $srcCurrencyID = self::NormalizeCurrencyID($srcCurrencyID);
     $dstCurrencyID = self::NormalizeCurrencyID($dstCurrencyID);
     $srcExchRate = doubleval($srcExchRate);
     if ($sum === 0.0 || $srcCurrencyID === $dstCurrencyID) {
         return $sum;
     }
     $result = 0;
     if ($srcExchRate < 0) {
         // Use default exchenge rate
         $result = CCurrencyRates::ConvertCurrency($sum, $srcCurrencyID, $dstCurrencyID);
     } else {
         // Convert source currency to base and convert base currency to destination
         $result = CCurrencyRates::ConvertCurrency(doubleval($sum * $srcExchRate), self::GetBaseCurrencyID(), $dstCurrencyID);
     }
     $decimals = 2;
     $formatInfo = CCurrencyLang::GetCurrencyFormat($dstCurrencyID);
     if (isset($formatInfo['DECIMALS'])) {
         $decimals = intval($formatInfo['DECIMALS']);
     }
     $result = round($result, $decimals);
     return $result;
 }
         }
         $currentDiscount = roundEx($currentDiscount, CATALOG_VALUE_PRECISION);
         if ($arPrice["DISCOUNT"]["VALUE_TYPE"] == "S") {
             $currentPrice = $currentDiscount;
         } else {
             $currentPrice = $currentPrice - $currentDiscount;
         }
     }
     $vatRate = $arPrice["PRICE"]["VAT_RATE"];
     $fieldValue = FormatCurrency($currentPrice, $arPrice["PRICE"]["CURRENCY"]);
     if (DoubleVal($nearestQuantity) != DoubleVal($QUANTITY)) {
         $fieldValue .= str_replace("#CNT#", $nearestQuantity, GetMessage("SOPS_PRICE1"));
     }
 }
 if (strlen($BASE_LANG_CURR) <= 0) {
     $arCurFormat = CCurrencyLang::GetCurrencyFormat($arPrice["PRICE"]["CURRENCY"]);
     $priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
 }
 $row->AddField("PRICE", $fieldValue);
 $arCatalogProduct = CCatalogProduct::GetByID($arItems["ID"]);
 $balance = FloatVal($arCatalogProduct["QUANTITY"]);
 $row->AddField("BALANCE", $balance);
 $URL = CIBlock::ReplaceDetailUrl($arItems["DETAIL_PAGE_URL"], $arItems, true);
 $arPriceType = GetCatalogGroup($arPrice["PRICE"]["CATALOG_GROUP_ID"]);
 $PriceType = $arPriceType["NAME_LANG"];
 $productImg = "";
 if ($arItems["PREVIEW_PICTURE"] != "") {
     $productImg = $arItems["PREVIEW_PICTURE"];
 } elseif ($arItems["DETAIL_PICTURE"] != "") {
     $productImg = $arItems["DETAIL_PICTURE"];
 }
Example #10
0
 //получаем цену в зависимости от скидки
 $discountPrice = false;
 if ($arDiscounts) {
     $discountPrice = CCatalogProduct::CountPriceWithDiscount($el["CATALOG_PURCHASING_PRICE"], $el["CATALOG_PURCHASING_CURRENCY"], $arDiscounts);
 }
 // путь к директории, где хранятся изображения
 $imageId = empty($el["DETAIL_PICTURE"]) ? $el["PREVIEW_PICTURE"] : $el["DETAIL_PICTURE"];
 if (!empty($imageId)) {
     /*Неэффективный кусок кода*/
     $sPath = CFile::GetByID($imageId)->GetNext();
     /**********************************/
     $sPath = "/" . $strImageStorePath . "/" . $sPath["SUBDIR"] . "/" . $sPath["FILE_NAME"];
 } else {
     $sPath = "";
 }
 $price = CCurrencyLang::GetCurrencyFormat($el["CATALOG_PURCHASING_CURRENCY"], "ru")["FORMAT_STRING"];
 $arResult[$el["ID"]] = $el;
 $arResult[$el["ID"]]["PRICE"] = str_replace("#", $el["CATALOG_PURCHASING_PRICE"], $price);
 $arResult[$el["ID"]]["PRICE_WITH_DISCOUNT"] = $discountPrice ? str_replace("#", $discountPrice, $price) : "";
 $arResult[$el["ID"]]["PRODUCT_ID"] = $iProductId;
 /*Неэффективный кусок кода*/
 $arResult[$el["ID"]]["ARTNUMBER"] = CIBlockElement::GetProperty($el["IBLOCK_ID"], $el["ID"], array(), array("CODE" => "ARTNUMBER"))->GetNext()["VALUE"];
 //Получение артикула, для каждого инфоблока свой артикул, поэтому нельзя выбрать для всех сразу
 /**********************************/
 $arResult[$el["ID"]]["IMAGE"] = $sPath;
 /***Получение количества товара с учетом наличия его на складе***/
 $arProd = (int) CCatalogStoreProduct::GetList(array(), array('PRODUCT_ID' => $iProductId, "STORE_ID" => 1), false, false, array('AMOUNT'))->GetNext()['AMOUNT'];
 $arResult[$el["ID"]]["QUANTITY"] = $arProd <= 0 || $arResult[$el["ID"]]['CATALOG_QUANTITY'] <= 0 ? 0 : $arResult[$el["ID"]]['CATALOG_QUANTITY'];
 unset($arProd);
 /****Получение ссылок редактирования и удаления элемента из публичной части****/
 $arButtons = CIBlock::GetPanelButtons($el["IBLOCK_ID"], $el["ID"], 0, array("SECTION_BUTTONS" => false, "SESSID" => false));
Example #11
0
		null,
		null,
		null,
		null,
		$vat <= 0 ? "Всього без ПДВ:" : "Всього:",
		SaleFormatCurrency(
			$GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"],
			$GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"],
			true
		)
	);

	$showVat = false;
}

$arCurFormat = CCurrencyLang::GetCurrencyFormat($GLOBALS['SALE_INPUT_PARAMS']['ORDER']['CURRENCY']);
$currency = trim(str_replace('#', '', $arCurFormat['FORMAT_STRING']));
?>
<table class="it" width="100%">
	<tr>
		<td><nobr>№</nobr></td>
		<td><nobr>Товар/Послуга</nobr></td>
		<td><nobr>Кіл-сть</nobr></td>
		<td><nobr>Од.</nobr></td>
		<td><nobr><? if ($vat <= 0) { ?>Ціна без ПДВ<? } else { ?>Ціна з ПДВ<? } ?>, <?php 
echo $currency;
?>
</nobr></td>
		<? if ($showVat) { ?>
		<td><nobr>Ставка ПДВ</nobr></td>
		<? } ?>
Example #12
0
 protected function getSaleFormatCurrency($price, $currency)
 {
     $currency = (string) $currency;
     $arCurFormat = CCurrencyLang::GetCurrencyFormat($currency, $this->getLanguageId());
     $arDefaultValues = CCurrencyLang::GetDefaultValues();
     $arSeparators = CCurrencyLang::GetSeparators();
     if ($arCurFormat === false) {
         $arCurFormat = $arDefaultValues;
     } else {
         if (!isset($arCurFormat['DECIMALS'])) {
             $arCurFormat['DECIMALS'] = $arDefaultValues['DECIMALS'];
         }
         $arCurFormat['DECIMALS'] = (int) $arCurFormat['DECIMALS'];
         if (!isset($arCurFormat['DEC_POINT'])) {
             $arCurFormat['DEC_POINT'] = $arDefaultValues['DEC_POINT'];
         }
         if (!empty($arCurFormat['THOUSANDS_VARIANT']) && isset($arSeparators[$arCurFormat['THOUSANDS_VARIANT']])) {
             $arCurFormat['THOUSANDS_SEP'] = $arSeparators[$arCurFormat['THOUSANDS_VARIANT']];
         } elseif (!isset($arCurFormat['THOUSANDS_SEP'])) {
             $arCurFormat['THOUSANDS_SEP'] = $arDefaultValues['THOUSANDS_SEP'];
         }
         if (!isset($arCurFormat['FORMAT_STRING'])) {
             $arCurFormat['FORMAT_STRING'] = $arDefaultValues['FORMAT_STRING'];
         }
         if (!isset($arCurFormat['HIDE_ZERO']) || empty($arCurFormat['HIDE_ZERO'])) {
             $arCurFormat['HIDE_ZERO'] = $arDefaultValues['HIDE_ZERO'];
         }
     }
     $intDecimals = $arCurFormat['DECIMALS'];
     if ($arCurFormat['HIDE_ZERO'] == 'Y') {
         if (round($price, $arCurFormat["DECIMALS"]) == round($price, 0)) {
             $intDecimals = 0;
         }
     }
     $price = number_format($price, $intDecimals, $arCurFormat['DEC_POINT'], $arCurFormat['THOUSANDS_SEP']);
     if ($arCurFormat['THOUSANDS_VARIANT'] == CCurrencyLang::SEP_NBSPACE) {
         $price = str_replace(' ', '&nbsp;', $price);
     }
     return str_replace('#', $price, $arCurFormat['FORMAT_STRING']);
 }
Example #13
0
function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
{
    global $crmMode;
    $result = "";
    if (!is_array($arData["ITEMS"]) || count($arData["ITEMS"]) <= 0) {
        return $result;
    }
    $result = "<table width=\"100%\">";
    if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock')) {
        $arProductId = array();
        $arDataTab = array();
        $arSkuParentChildren = array();
        $arSkuParentId = array();
        $arSkuParent = array();
        foreach ($arData["ITEMS"] as $items) {
            if ($items["MODULE"] == "catalog") {
                $arProductId[$items["PRODUCT_ID"]] = $items["PRODUCT_ID"];
                $arDataTab[$items["PRODUCT_ID"]] = $items;
                $arParent = CCatalogSku::GetProductInfo($items["PRODUCT_ID"]);
                if ($arParent) {
                    $arSkuParentChildren[$items["PRODUCT_ID"]] = $arParent["ID"];
                    $arSkuParentId[$arParent["ID"]] = $arParent["ID"];
                }
            }
        }
        $res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
        while ($arItems = $res->GetNext()) {
            $arSkuParent[$arItems["ID"]] = $arItems;
        }
        $dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
        while ($arProduct = $dbProduct->Fetch()) {
            $imgCode = 0;
            $arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
            $arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
            $arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
            $arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
            $arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
            $items = $arDataTab[$arProduct['ID']];
            if ($items["PREVIEW_PICTURE"] == "" && $items["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$items["PRODUCT_ID"]])) {
                $idTmp = $arSkuParentChildren[$items["PRODUCT_ID"]];
                $items["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
                $items["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
            }
            if ($items["DETAIL_PICTURE"] > 0) {
                $imgCode = $items["DETAIL_PICTURE"];
            } elseif ($items["PREVIEW_PICTURE"] > 0) {
                $imgCode = $items["PREVIEW_PICTURE"];
            }
            $arSkuProperty = CSaleProduct::GetProductSkuProps($items["PRODUCT_ID"]);
            $items["NAME"] = htmlspecialcharsex($items["NAME"]);
            $items["EDIT_PAGE_URL"] = htmlspecialcharsex($items["EDIT_PAGE_URL"]);
            $items["CURRENCY"] = htmlspecialcharsex($items["CURRENCY"]);
            if ($imgCode > 0) {
                $arFile = CFile::GetFileArray($imgCode);
                $arImgProduct = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
            }
            if (is_array($arImgProduct)) {
                $imgUrl = $arImgProduct["src"];
                $imgProduct = "<a href=\"" . $items["EDIT_PAGE_URL"] . "\" target=\"_blank\"><img src=\"" . $imgUrl . "\" alt=\"\" title=\"" . $items["NAME"] . "\" ></a>";
            } else {
                $imgProduct = "<div class='no_foto'>" . GetMessage('NO_FOTO') . "</div>";
            }
            $arCurFormat = CCurrencyLang::GetCurrencyFormat($items["CURRENCY"]);
            $priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
            $currentTotalPrice = $items["PRICE"] + $items["DISCOUNT_PRICE"];
            $discountPercent = 0;
            if ($items["DISCOUNT_PRICE"] > 0) {
                $discountPercent = IntVal($items["DISCOUNT_PRICE"] * 100 / $currentTotalPrice);
            }
            $ar_res = CCatalogProduct::GetByID($items["PRODUCT_ID"]);
            $balance = FloatVal($ar_res["QUANTITY"]);
            $arParams = array();
            $arParams["id"] = $items["PRODUCT_ID"];
            $arParams["name"] = $items["NAME"];
            $arParams["url"] = $items["DETAIL_PAGE_URL"];
            $arParams["urlEdit"] = $items["EDIT_PAGE_URL"];
            $arParams["urlImg"] = $imgUrl;
            $arParams["price"] = FloatVal($items["PRICE"]);
            $arParams["priceBase"] = FloatVal($currentTotalPrice);
            $arParams["priceBaseFormat"] = CurrencyFormatNumber(FloatVal($currentTotalPrice), $items["CURRENCY"]);
            $arParams["priceFormated"] = CurrencyFormatNumber(FloatVal($items["PRICE"]), $items["CURRENCY"]);
            $arParams["valutaFormat"] = $priceValutaFormat;
            $arParams["priceDiscount"] = FloatVal($items["DISCOUNT_PRICE"]);
            $arParams["priceTotalFormated"] = SaleFormatCurrency($currentTotalPrice, $items["CURRENCY"]);
            $arParams["discountPercent"] = $discountPercent;
            $arParams["summaFormated"] = CurrencyFormatNumber($items["PRICE"], $items["CURRENCY"]);
            $arParams["quantity"] = 1;
            $arParams["module"] = $items["MODULE"];
            $arParams["currency"] = $items["CURRENCY"];
            $arParams["weight"] = 0;
            $arParams["vatRate"] = 0;
            $arParams["priceType"] = "";
            $arParams["balance"] = $balance;
            $arParams['skuProps'] = CUtil::PhpToJSObject($arSkuProperty);
            $arParams["catalogXmlID"] = "";
            $arParams["productXmlID"] = "";
            $arParams["callback"] = "CatalogBasketCallback";
            $arParams["orderCallback"] = "CatalogBasketOrderCallback";
            $arParams["cancelCallback"] = "CatalogBasketCancelCallback";
            $arParams["payCallback"] = "CatalogPayOrderCallback";
            $result .= "<tr id='more_" . $type . "_" . $items["ID"] . "'>\n\t\t\t\t\t\t\t<td class=\"tab_img\" >" . $imgProduct . "</td>\n\t\t\t\t\t\t\t<td class=\"tab_text\">\n\t\t\t\t\t\t\t\t<div class=\"order_name\"><a href=\"" . $items["EDIT_PAGE_URL"] . "\" target=\"_blank\" title=\"" . $items["NAME"] . "\">" . $items["NAME"] . "</a></div>\n\t\t\t\t\t\t\t\t<div class=\"order_price\">\n\t\t\t\t\t\t\t\t\t" . GetMessage('NEWO_SUBTAB_PRICE') . ": <b>" . SaleFormatCurrency($items["PRICE"], $currency) . "</b>\n\t\t\t\t\t\t\t\t</div>";
            $arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $items["PRODUCT_ID"], $items["NAME"]);
            if (count($arResult["SKU_ELEMENTS"]) > 0) {
                foreach ($arResult["SKU_ELEMENTS"] as $key => $val) {
                    $arTmp = array();
                    foreach ($val as $k => $v) {
                        if (is_numeric($k)) {
                            $arTmp[$arResult["SKU_PROPERTIES"][$k]["NAME"]] = $v;
                        }
                    }
                    $arResult["SKU_ELEMENTS"][$key]["SKU_PROPS"] = CUtil::PhpToJSObject($arTmp);
                }
            }
            $arResult["POPUP_MESSAGE"] = array("PRODUCT_ADD" => GetMEssage('NEWO_POPUP_TO_BUSKET'), "PRODUCT_ORDER" => GetMEssage('NEWO_POPUP_TO_ORDER'), "PRODUCT_NOT_ADD" => GetMEssage('NEWO_POPUP_DONT_CAN_BUY'), "PRODUCT_PRICE_FROM" => GetMessage('NEWO_POPUP_FROM'));
            if (count($arResult["SKU_ELEMENTS"]) <= 0) {
                $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProduct('" . $type . "', " . CUtil::PhpToJSObject($arParams) . ");return false;\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_BUSKET') . "</a><br>";
            } else {
                $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProductSku(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'busket', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_BUSKET') . "</a><br>";
            }
            if (!$crmMode) {
                if (count($arResult["SKU_ELEMENTS"]) > 0) {
                    $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProductSku(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'neworder', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_ORDER') . "</a>";
                } else {
                    $cntProd = floatval($items["QUANTITY"]) > 0 ? floatval($items["QUANTITY"]) : 1;
                    $url = "/bitrix/admin/sale_order_new.php?lang=" . LANG . "&user_id=" . $USER_ID . "&LID=" . $LID . "&product[" . $items["PRODUCT_ID"] . "]=" . $cntProd;
                    $result .= "<a href=\"" . $url . "\" target=\"_blank\" class=\"get_new_order\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_ORDER') . "</a>";
                }
            }
            $result .= "</td></tr>";
        }
        //end foreach
    }
    //end if
    if ($arData["CNT"] > 2 && $arData["CNT"] != count($arData["ITEMS"])) {
        $result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
        if ($type == "busket") {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreBusket(\"Y\");' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        } elseif ($type == "viewed") {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreViewed(\"Y\");' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        } else {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreRecom();' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        }
        $result .= "</td></tr>";
    }
    $result .= "</table>";
    return $result;
}
Example #14
0
//http://jabber.bx/view.php?id=37744
$arProdIdsPrIds = array();
while ($arBasket = $dbBasket->GetNext()) {
    $arProdIds[] = $arBasket["PRODUCT_ID"];
    $arProdIdsPrIds[$arBasket["PRODUCT_ID"]] = $arBasket["ID"];
    if ($bXmlId == "N") {
        $arPropsFilter["!CODE"] = array("PRODUCT.XML_ID", "CATALOG.XML_ID");
    }
    $arBasket["PROPS"] = array();
    $dbBasketProps = CSaleBasket::GetPropsList(array("BASKET_ID" => "ASC", "SORT" => "ASC", "NAME" => "ASC"), array("BASKET_ID" => $arBasket["ID"]), false, false, array("ID", "BASKET_ID", "NAME", "VALUE", "CODE", "SORT"));
    while ($arBasketProps = $dbBasketProps->GetNext()) {
        $arBasket["PROPS"][$arBasketProps["ID"]] = $arBasketProps;
    }
    $arResult["BASKET"][$arBasket["ID"]] = $arBasket;
    $arResult["BASKET"][$arBasket["ID"]]["BALANCE"] = "0";
    $arCurFormat = CCurrencyLang::GetCurrencyFormat($arBasket["CURRENCY"]);
    $CURRENCY_FORMAT = trim(str_replace("#", '', $arCurFormat["FORMAT_STRING"]));
    $priceDiscount = $priceBase = $arBasket["DISCOUNT_PRICE"] + $arBasket["PRICE"];
    if (DoubleVal($priceBase) > 0) {
        $priceDiscount = roundEx($arBasket["DISCOUNT_PRICE"] * 100 / $priceBase, SALE_VALUE_PRECISION);
    }
    $arResult["BASKET"][$arBasket["ID"]]["PRICE_STRING"] = CurrencyFormatNumber($arBasket["PRICE"], $arBasket["CURRENCY"]) . " " . $CURRENCY_FORMAT;
    if ($arBasket["DISCOUNT_PRICE"] > 0) {
        $arResult["BASKET"][$arBasket["ID"]]["OLD_PRICE_STRING"] = CurrencyFormatNumber($priceBase, $arBasket["CURRENCY"]) . " " . $CURRENCY_FORMAT;
        $arResult["BASKET"][$arBasket["ID"]]["DISCOUNT_STRING"] = $priceDiscount . "%";
    }
    $weight += $arBasket["WEIGHT"] * $arBasket["QUANTITY"];
    $price += $arBasket["PRICE"] * $arBasket["QUANTITY"];
    $price_total += ($arBasket["PRICE"] + $arBasket["DISCOUNT_PRICE"]) * $arBasket["QUANTITY"];
}
$arResult["WEIGHT"] = $weight;