예제 #1
0
	public static function PrepareCurrency4Where($val, $key, $operation, $negative, $field, &$arField, &$arFilter)
	{
		$val = DoubleVal($val);

		$baseSiteCurrency = "";
		if (isset($arFilter["LID"]) && strlen($arFilter["LID"]) > 0)
			$baseSiteCurrency = CSaleLang::GetLangCurrency($arFilter["LID"]);
		elseif (isset($arFilter["CURRENCY"]) && strlen($arFilter["CURRENCY"]) > 0)
			$baseSiteCurrency = $arFilter["CURRENCY"];

		if (strlen($baseSiteCurrency) <= 0)
			return False;

		$strSqlSearch = "";

		$dbCurrency = CCurrency::GetList(($by = "sort"), ($order = "asc"));
		while ($arCurrency = $dbCurrency->Fetch())
		{
			$val1 = roundEx(CCurrencyRates::ConvertCurrency($val, $baseSiteCurrency, $arCurrency["CURRENCY"]), SALE_VALUE_PRECISION);
			if (strlen($strSqlSearch) > 0)
				$strSqlSearch .= " OR ";

			$strSqlSearch .= "(D.ORDER_CURRENCY = '".$arCurrency["CURRENCY"]."' AND ";
			if ($negative == "Y")
				$strSqlSearch .= "NOT";
			$strSqlSearch .= "(".$field." ".$operation." ".$val1." OR ".$field." IS NULL OR ".$field." = 0)";
			$strSqlSearch .= ")";
		}

		return "(".$strSqlSearch.")";
	}
예제 #2
0
 static function DoProcessOrderDelivery(&$arOrder, $arOptions, &$arErrors)
 {
     if ((!array_key_exists("TAX_LOCATION", $arOrder) || intval($arOrder["TAX_LOCATION"]) <= 0) && !$arOrder["USE_VAT"]) {
         return;
     }
     if (!array_key_exists("COUNT_DELIVERY_TAX", $arOptions)) {
         $arOptions["COUNT_DELIVERY_TAX"] = COption::GetOptionString("sale", "COUNT_DELIVERY_TAX", "N");
     }
     if (doubleval($arOrder["DELIVERY_PRICE"]) <= 0 || $arOptions["COUNT_DELIVERY_TAX"] != "Y") {
         return;
     }
     if (!$arOrder["USE_VAT"]) {
         if (!array_key_exists("TAX_EXEMPT", $arOrder)) {
             $arUserGroups = CUser::GetUserGroup($arOrder["USER_ID"]);
             $dbTaxExemptList = CSaleTax::GetExemptList(array("GROUP_ID" => $arUserGroups));
             while ($TaxExemptList = $dbTaxExemptList->Fetch()) {
                 if (!in_array(intval($TaxExemptList["TAX_ID"]), $arOrder["TAX_EXEMPT"])) {
                     $arOrder["TAX_EXEMPT"][] = intval($TaxExemptList["TAX_ID"]);
                 }
             }
         }
         if (!array_key_exists("TAX_LIST", $arOrder)) {
             $arOrder["TAX_LIST"] = array();
             $dbTaxRate = CSaleTaxRate::GetList(array("APPLY_ORDER" => "ASC"), array("LID" => $arOrder["SITE_ID"], "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"], "ACTIVE" => "Y", "LOCATION" => $arOrder["TAX_LOCATION"]));
             while ($arTaxRate = $dbTaxRate->GetNext()) {
                 if (!in_array(intval($arTaxRate["TAX_ID"]), $arOrder["TAX_EXEMPT"])) {
                     if ($arTaxRate["IS_PERCENT"] != "Y") {
                         $arTaxRate["VALUE"] = RoundEx(CCurrencyRates::ConvertCurrency($arTaxRate["VALUE"], $arTaxRate["CURRENCY"], $arOrder["CURRENCY"]), SALE_VALUE_PRECISION);
                         $arTaxRate["CURRENCY"] = $arOrder["CURRENCY"];
                     }
                     $arOrder["TAX_LIST"][] = $arTaxRate;
                 }
             }
         }
         if (count($arOrder["TAX_LIST"]) > 0) {
             CSaleOrderTax::CountTaxes($arOrder["DELIVERY_PRICE"], $arOrder["TAX_LIST"], $arOrder["CURRENCY"]);
             foreach ($arOrder["TAX_LIST"] as &$arTax) {
                 $arTax["VALUE_MONEY"] += roundEx($arTax["TAX_VAL"], SALE_VALUE_PRECISION);
             }
             unset($arTax);
             $arOrder["TAX_PRICE"] = 0;
             foreach ($arOrder["TAX_LIST"] as $arTax) {
                 if ($arTax["IS_IN_PRICE"] != "Y") {
                     $arOrder["TAX_PRICE"] += roundEx($arTax["VALUE_MONEY"], SALE_VALUE_PRECISION);
                 }
             }
         }
     } else {
         $deliveryVat = roundEx($arOrder["DELIVERY_PRICE"] * $arOrder["VAT_RATE"] / (1 + $arOrder["VAT_RATE"]), 2);
         $arOrder["VAT_SUM"] += $deliveryVat;
         $arOrder["VAT_DELIVERY"] += $deliveryVat;
         //if (!array_key_exists("TAX_LIST", $arOrder))
         //{
         $arOrder["TAX_LIST"][0] = array("NAME" => GetMessage("SOA_VAT"), "IS_PERCENT" => "Y", "VALUE" => $arOrder["VAT_RATE"] * 100, "VALUE_FORMATED" => "(" . $arOrder["VAT_RATE"] * 100 . "%, " . GetMessage("SOA_VAT_INCLUDED") . ")", "VALUE_MONEY" => $arOrder["VAT_SUM"], "VALUE_MONEY_FORMATED" => SaleFormatCurrency($arOrder["VAT_SUM"], $arOrder["CURRENCY"]), "APPLY_ORDER" => 100, "IS_IN_PRICE" => "Y", "CODE" => "VAT");
         //}
     }
 }
예제 #3
0
 /**
  *	Обработчик события подтверждения оплаты товара
  */
 function OnSalePayOrderHandler($id, $val)
 {
     $currentUserId = $GLOBALS['USER']->GetID();
     //Идентификатор текущего пользователя, по идее администратор
     $idRatingGroup = 5;
     //группа акции
     $curTo = "UAH";
     //тип гривневой цены
     $arOrder = CSaleOrder::GetByID($id);
     //информация о заказе
     $price = CCurrencyRates::ConvertCurrency(floatval($arOrder["SUM_PAID"]), $arOrder["CURRENCY"], $curTo);
     $price = intval(ceil($price));
     //стоимость заказа
     $userId = intval($arOrder["USER_ID"]);
     //пользователь, который оплатил заказ
     $arUserData = CUser::GetByID($userId)->Fetch();
     //Информация о пользователе
     $userGroups = CUser::GetUserGroup($userId);
     //ИД групп, к которым принадлежит пользователь
     //Если пользователя нет в акционной группе, и он совершил заказ более чем на 900 грн, то добавить его в группу
     if (!in_array($idRatingGroup, $userGroups)) {
         if ($price >= 900 && $price <= 4000 && $val === 'Y') {
             $userGroups[] = $idRatingGroup;
             CUser::SetUserGroup($userId, $userGroups);
         }
     }
     $points = $price * 5;
     $payedUser = new CUser();
     //Если оплата подтверждается, то добавить баллы
     if ($val === 'Y' && in_array($idRatingGroup, $userGroups)) {
         $points = intval($arUserData['UF_ACTION_POINTS']) + $points;
         $payedUser->Update($userId, array("UF_ACTION_POINTS" => $points, "UF_DATE_LAST_BUY" => $arOrder["DATE_UPDATE_FORMAT"]));
     } else {
         if ($val === 'N') {
             $price = CCurrencyRates::ConvertCurrency(floatval($arOrder["PRICE"]), $arOrder["CURRENCY"], $curTo);
             $price = intval(ceil($price));
             //вычитаем полную стоимость
             $points = $price * 5;
             if ($arUserData['UF_ACTION_POINTS'] >= $points) {
                 $points = intval($arUserData['UF_ACTION_POINTS']) - $points;
                 $payedUser->Update($userId, array("UF_ACTION_POINTS" => $points));
                 //Если очков стало меньше 4500, то исключаем пользователя из группы участников
                 if (in_array($idRatingGroup, $userGroups) && $points < 4500) {
                     $indexGroup = array_search($idRatingGroup, $userGroups);
                     if (isset($userGroups[$indexGroup])) {
                         unset($userGroups[$indexGroup]);
                         CUser::SetUserGroup($userId, $userGroups);
                     }
                 }
             }
         }
     }
     unset($payedUser);
 }
예제 #4
0
파일: utils.php 프로젝트: Satariall/izurit
 public static function convertToBaseCurrency($value, $currency)
 {
     static $module, $baseCurrency;
     if (!$module) {
         $module = Loader::includeModule('currency');
         $baseCurrency = Config::getBaseCurrency();
     }
     if ($module && $currency != $baseCurrency) {
         $value = \CCurrencyRates::ConvertCurrency($value, $currency, $baseCurrency);
     }
     return $value;
 }
예제 #5
0
	static function DoProcessOrder(&$arOrder, $deliveryId, &$arErrors)
	{
		if (!array_key_exists("DELIVERY_LOCATION", $arOrder) || intval($arOrder["DELIVERY_LOCATION"]) <= 0)
			return;

		if (strlen($deliveryId) > 0 && strpos($deliveryId, ":") !== false)
		{
			$arOrder["DELIVERY_ID"] = $deliveryId;

			$delivery = explode(":", $deliveryId);

			$arOrderTmpDel = array(
				"PRICE" => $arOrder["ORDER_PRICE"] + $arOrder["TAX_PRICE"] - $arOrder["DISCOUNT_PRICE"],
				"WEIGHT" => $arOrder["ORDER_WEIGHT"],
				"LOCATION_FROM" => COption::GetOptionString('sale', 'location', '2961', $arOrder["SITE_ID"]),
				"LOCATION_TO" => $arOrder["DELIVERY_LOCATION"],
				"LOCATION_ZIP" => $arOrder["DELIVERY_LOCATION_ZIP"],
				"ITEMS" => $arOrder["BASKET_ITEMS"]
			);

			$arDeliveryPrice = CSaleDeliveryHandler::CalculateFull($delivery[0], $delivery[1], $arOrderTmpDel, $arOrder["CURRENCY"],$arOrder["LID"]);

			if ($arDeliveryPrice["RESULT"] == "ERROR")
				$arErrors[] = array("CODE" => "CALCULATE", "TEXT" => $arDeliveryPrice["TEXT"]);
			else
				$arOrder["DELIVERY_PRICE"] = roundEx($arDeliveryPrice["VALUE"], SALE_VALUE_PRECISION);
		}
		elseif (intval($deliveryId) > 0)
		{
			if ($arDelivery = CSaleDelivery::GetByID($deliveryId))
			{
				$arOrder["DELIVERY_ID"] = $deliveryId;
				$arOrder["DELIVERY_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arDelivery["PRICE"], $arDelivery["CURRENCY"], $arOrder["CURRENCY"]), SALE_VALUE_PRECISION);
			}
			else
			{
				$arErrors[] = array("CODE" => "CALCULATE", "TEXT" => GetMessage('SKGD_DELIVERY_NOT_FOUND'));
			}
		}
	}
예제 #6
0
         $arItem['JS_OFFERS'] = $arMatrix;
         $arItem['OFFERS_SELECTED'] = $intSelected;
         $arItem['OFFERS_PROPS_DISPLAY'] = $boolSKUDisplayProperties;
     } else {
         $arMinPrice = false;
         $dblMinPrice = 0;
         $strMinCurrency = $boolConvert ? $arResult['CONVERT_CURRENCY']['CURRENCY_ID'] : $strBaseCurrency;
         foreach ($arItem['OFFERS'] as $keyOffer => $arOffer) {
             if (!$arOffer['CAN_BUY']) {
                 continue;
             }
             if (empty($arMinPrice)) {
                 $dblMinPrice = $boolConvert || $arOffer['MIN_PRICE']['CURRENCY'] == $strMinCurrency ? $arOffer['MIN_PRICE']['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arOffer['MIN_PRICE']['DISCOUNT_VALUE'], $arOffer['MIN_PRICE']['CURRENCY'], $strMinCurrency);
                 $arMinPrice = $arOffer['MIN_PRICE'];
             } else {
                 $dblComparePrice = $boolConvert || $arOffer['MIN_PRICE']['CURRENCY'] == $strMinCurrency ? $arOffer['MIN_PRICE']['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arOffer['MIN_PRICE']['DISCOUNT_VALUE'], $arOffer['MIN_PRICE']['CURRENCY'], $strMinCurrency);
                 if ($dblMinPrice > $dblComparePrice) {
                     $dblMinPrice = $dblComparePrice;
                     $arMinPrice = $arOffer['MIN_PRICE'];
                 }
             }
         }
         $arItem['MIN_PRICE'] = $arMinPrice;
     }
 }
 if (empty($arItem['PREVIEW_PICTURE'])) {
     $arItem['PREVIEW_PICTURE'] = $arItem['DETAIL_PICTURE'];
 }
 if ('' != $arParams['ADD_PICT_PROP'] && isset($arItem['PROPERTIES'][$arParams['ADD_PICT_PROP']])) {
     if ('F' == $arItem['PROPERTIES'][$arParams['ADD_PICT_PROP']]['PROPERTY_TYPE']) {
         $arPict = false;
예제 #7
0
 protected function getPrices($productId, $siteId)
 {
     $minPrice = 0;
     $minPriceRUR = 0;
     $minPriceGroup = 0;
     $minPriceCurrency = "";
     $baseCurrency = \CCurrency::GetBaseCurrency();
     $RUR = $this->getRub();
     if ($this->xmlData['PRICE'] > 0) {
         $rsPrices = \CPrice::GetListEx(array(), array('PRODUCT_ID' => $productId, 'CATALOG_GROUP_ID' => $this->xmlData['PRICE'], 'CAN_BUY' => 'Y', 'GROUP_GROUP_ID' => array(2), '+<=QUANTITY_FROM' => 1, '+>=QUANTITY_TO' => 1));
         if ($arPrice = $rsPrices->Fetch()) {
             if ($arOptimalPrice = \CCatalogProduct::GetOptimalPrice($productId, 1, array(2), 'N', array($arPrice), $siteId)) {
                 $minPrice = $arOptimalPrice['DISCOUNT_PRICE'];
                 $minPriceCurrency = $baseCurrency;
                 $minPriceRUR = \CCurrencyRates::ConvertCurrency($minPrice, $baseCurrency, $RUR);
                 $minPriceGroup = $arOptimalPrice['PRICE']['CATALOG_GROUP_ID'];
             }
         }
     } else {
         if ($arPrice = \CCatalogProduct::GetOptimalPrice($productId, 1, array(2), 'N', array(), $siteId)) {
             $minPrice = $arPrice['DISCOUNT_PRICE'];
             $minPriceCurrency = $baseCurrency;
             $minPriceRUR = \CCurrencyRates::ConvertCurrency($minPrice, $baseCurrency, $RUR);
             $minPriceGroup = $arPrice['PRICE']['CATALOG_GROUP_ID'];
         }
     }
     $result = array("MIN" => $minPrice, "MIN_RUB" => $minPriceRUR, "MIN_GROUP" => $minPriceGroup, "MIN_CURRENCY" => $minPriceCurrency);
     return $result;
 }
예제 #8
0
 protected function __ConvertOldFormat($strAction, &$arFields)
 {
     global $APPLICATION;
     $arMsg = array();
     $boolResult = true;
     $arNeedFields = array('LID', 'CURRENCY', 'DISCOUNT_TYPE', 'DISCOUNT_VALUE', 'PRICE_FROM', 'PRICE_TO');
     $arUpdateFields = array('DISCOUNT_VALUE', 'PRICE_FROM', 'PRICE_TO');
     $strAction = ToUpper($strAction);
     if (!array_key_exists('CONDITIONS', $arFields) && !array_key_exists('ACTIONS', $arFields)) {
         $strSiteCurrency = '';
         $boolUpdate = false;
         if ('UPDATE' == $strAction) {
             $boolNeedQuery = false;
             foreach ($arUpdateFields as &$strFieldID) {
                 if (array_key_exists($strFieldID, $arFields)) {
                     $boolUpdate = true;
                     break;
                 }
             }
             if (isset($strFieldID)) {
                 unset($strFieldID);
             }
             if ($boolUpdate) {
                 foreach ($arNeedFields as &$strFieldID) {
                     if (!array_key_exists($strFieldID, $arFields)) {
                         $boolNeedQuery = true;
                         break;
                     }
                 }
                 if (isset($strFieldID)) {
                     unset($strFieldID);
                 }
                 if ($boolNeedQuery) {
                     $rsDiscounts = CSaleDiscount::GetList(array(), array('ID' => $arFields['ID']), false, false, $arNeedFields);
                     if ($arDiscount = $rsDiscounts->Fetch()) {
                         foreach ($arNeedFields as &$strFieldID) {
                             if (!array_key_exists($strFieldID, $arFields)) {
                                 $arFields[$strFieldID] = $arDiscount[$strFieldID];
                             }
                         }
                         if (isset($strFieldID)) {
                             unset($strFieldID);
                         }
                     } else {
                         $boolUpdate = false;
                         $boolResult = false;
                         $arMsg[] = array('id' => 'ID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_ABSENT'));
                     }
                 }
             }
         }
         if ('ADD' == $strAction || $boolUpdate) {
             if (!array_key_exists('LID', $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_SITE_ID_ABSENT'));
             } else {
                 $arFields['LID'] = strval($arFields['LID']);
                 if ('' == $arFields['LID']) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_SITE_ID_ABSENT'));
                 } else {
                     $rsSites = CSite::GetByID($arFields["LID"]);
                     if (!($arSite = $rsSites->Fetch())) {
                         $boolResult = false;
                         $arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('SKGD_NO_SITE', array('#ID#' => $arFields['LID'])));
                     } else {
                         $strSiteCurrency = CSaleLang::GetLangCurrency($arFields['LID']);
                     }
                 }
             }
             if (!array_key_exists('CURRENCY', $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_CURRENCY_ABSENT'));
             } else {
                 $arFields['CURRENCY'] = strval($arFields['CURRENCY']);
                 if ('' == $arFields['CURRENCY']) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_CURRENCY_ABSENT'));
                 } else {
                     if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
                         $boolResult = false;
                         $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('SKGD_NO_CURRENCY', array('#ID#' => $arFields['CURRENCY'])));
                     }
                 }
             }
             if (!array_key_exists("DISCOUNT_TYPE", $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'DISCOUNT_TYPE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_TYPE_ABSENT'));
             } else {
                 $arFields["DISCOUNT_TYPE"] = strval($arFields["DISCOUNT_TYPE"]);
                 if (CSaleDiscount::OLD_DSC_TYPE_PERCENT != $arFields["DISCOUNT_TYPE"] && CSaleDiscount::OLD_DSC_TYPE_FIX != $arFields["DISCOUNT_TYPE"]) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'DISCOUNT_TYPE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_TYPE_BAD'));
                 }
             }
             if (!array_key_exists('DISCOUNT_VALUE', $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'DISCOUNT_VALUE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_VALUE_ABSENT'));
             } else {
                 $arFields['DISCOUNT_VALUE'] = (double) str_replace(',', '.', $arFields['DISCOUNT_VALUE']);
                 if (0 >= $arFields['DISCOUNT_VALUE']) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'DISCOUNT_VALUE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_VALUE_BAD'));
                 }
             }
             if ($boolResult) {
                 $arConditions = array('CLASS_ID' => 'CondGroup', 'DATA' => array('All' => 'AND', 'True' => 'True'), 'CHILDREN' => array());
                 $arActions = array('CLASS_ID' => 'CondGroup', 'DATA' => array('All' => 'AND', 'True' => 'True'), 'CHILDREN' => array());
                 $boolCurrency = $arFields['CURRENCY'] == $strSiteCurrency;
                 if (array_key_exists('PRICE_FROM', $arFields)) {
                     $arFields["PRICE_FROM"] = str_replace(",", ".", strval($arFields["PRICE_FROM"]));
                     $arFields["PRICE_FROM"] = doubleval($arFields["PRICE_FROM"]);
                     if (0 < $arFields["PRICE_FROM"]) {
                         $dblValue = roundEx($boolCurrency ? $arFields['PRICE_FROM'] : CCurrencyRates::ConvertCurrency($arFields['PRICE_FROM'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
                         $arConditions['CHILDREN'][] = array('CLASS_ID' => 'CondBsktAmtGroup', 'DATA' => array('logic' => 'EqGr', 'Value' => (string) $dblValue, 'All' => 'AND'), 'CHILDREN' => array());
                         $arFields["PRICE_FROM"] = $dblValue;
                     }
                 }
                 if (array_key_exists('PRICE_TO', $arFields)) {
                     $arFields["PRICE_TO"] = str_replace(",", ".", strval($arFields["PRICE_TO"]));
                     $arFields["PRICE_TO"] = doubleval($arFields["PRICE_TO"]);
                     if (0 < $arFields["PRICE_TO"]) {
                         $dblValue = roundEx($boolCurrency ? $arFields['PRICE_TO'] : CCurrencyRates::ConvertCurrency($arFields['PRICE_TO'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
                         $arConditions['CHILDREN'][] = array('CLASS_ID' => 'CondBsktAmtGroup', 'DATA' => array('logic' => 'EqLs', 'Value' => (string) $dblValue, 'All' => 'AND'), 'CHILDREN' => array());
                         $arFields["PRICE_TO"] = $dblValue;
                     }
                 }
                 if (self::OLD_DSC_TYPE_PERCENT == $arFields['DISCOUNT_TYPE']) {
                     $arActions['CHILDREN'][] = array('CLASS_ID' => 'ActSaleBsktGrp', 'DATA' => array('Type' => 'Discount', 'Value' => (string) roundEx($arFields['DISCOUNT_VALUE'], SALE_VALUE_PRECISION), 'Unit' => 'Perc', 'All' => 'AND'), 'CHILDREN' => array());
                 } else {
                     $dblValue = roundEx($boolCurrency ? $arFields['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arFields['DISCOUNT_VALUE'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
                     $arActions['CHILDREN'][] = array('CLASS_ID' => 'ActSaleBsktGrp', 'DATA' => array('Type' => 'Discount', 'Value' => (string) $dblValue, 'Unit' => 'CurAll', 'All' => 'AND'), 'CHILDREN' => array());
                     $arFields['DISCOUNT_VALUE'] = $dblValue;
                 }
                 $arFields['CONDITIONS'] = $arConditions;
                 $arFields['ACTIONS'] = $arActions;
                 $arFields['CURRENCY'] = $strSiteCurrency;
             } else {
                 $obError = new CAdminException($arMsg);
                 $APPLICATION->ThrowException($obError);
             }
         }
     }
     return $boolResult;
 }
예제 #9
0
                     }
                 }
             }
         }
     }
 }
 $arCurrencyList = array();
 $arDBCurrencies = array();
 $dbCurrencyList = CCurrency::GetList($b = "", $o = "");
 while ($arCurrency = $dbCurrencyList->Fetch()) {
     $arDBCurrencies[$arCurrency["CURRENCY"]] = $arCurrency["AMOUNT_CNT"];
 }
 foreach ($arParams["arrCURRENCY_FROM"] as &$strCurrencyCode) {
     if (array_key_exists($strCurrencyCode, $arDBCurrencies)) {
         $arCurrencyList[] = $strCurrencyCode;
         $rate = CCurrencyRates::ConvertCurrency($arDBCurrencies[$strCurrencyCode], $strCurrencyCode, $arParams["CURRENCY_BASE"], $arParams["RATE_DAY"]);
         $arResult["CURRENCY"][] = array('FROM' => CurrencyFormat($arDBCurrencies[$strCurrencyCode], $strCurrencyCode), 'BASE' => CurrencyFormat($rate, $arParams["CURRENCY_BASE"]));
     }
 }
 if (isset($strCurrencyCode)) {
     unset($strCurrencyCode);
 }
 if (!empty($arCurrencyList)) {
     if (defined("BX_COMP_MANAGED_CACHE")) {
         $arCurrencyList[] = $arParams["CURRENCY_BASE"];
         $arCurrencyList = array_unique($arCurrencyList);
         $CACHE_MANAGER->StartTagCache($this->GetCachePath());
         foreach ($arCurrencyList as &$strOneCurrency) {
             $CACHE_MANAGER->RegisterTag("currency_id_" . $strOneCurrency);
         }
         if (isset($strOneCurrency)) {
예제 #10
0
	{
		//convert all prices to main element currency
		foreach($arResult["SET_ITEMS"]["DEFAULT"] as $key=>$arItem)
		{
			$arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem['PRICE_DISCOUNT_VALUE'], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
			$arResult["SET_ITEMS"]["PRICE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"];
			$arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
			$arResult["SET_ITEMS"]["OLD_PRICE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_VALUE"];
			$arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
			$arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"];
		}
		foreach($arResult["SET_ITEMS"]["OTHER"] as $key=>$arItem)
		{
			$arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem['PRICE_DISCOUNT_VALUE'], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
			$arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
			$arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"], $arItem["PRICE_CURRENCY"] , $arResult["ELEMENT"]["PRICE_CURRENCY"]);
		}
	}

	if ($arResult["SET_ITEMS"]["OLD_PRICE"] && $arResult["SET_ITEMS"]["OLD_PRICE"] != $arResult["SET_ITEMS"]["PRICE"])
		$arResult["SET_ITEMS"]["OLD_PRICE"] = FormatCurrency($arResult["SET_ITEMS"]["OLD_PRICE"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
	else
		$arResult["SET_ITEMS"]["OLD_PRICE"] = 0;

	if ($arResult["SET_ITEMS"]["PRICE"])
		$arResult["SET_ITEMS"]["PRICE"] = FormatCurrency($arResult["SET_ITEMS"]["PRICE"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);

	if ($arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"])
		$arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"] = FormatCurrency($arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);

예제 #11
0
 if (strlen($noc) <= 0) {
     $strErrorTmp .= "Please fill in \"Cardholder\" field. ";
 }
 $address1 = htmlspecialcharsbx(trim($_POST["address1"]));
 if (strlen($address1) <= 0) {
     $strErrorTmp .= "Please fill in \"Address\" field. ";
 }
 $zipcode = htmlspecialcharsbx(trim($_POST["zipcode"]));
 if (strlen($zipcode) <= 0) {
     $strErrorTmp .= "Please fill in \"Zip\" field. ";
 }
 if (strlen($strErrorTmp) <= 0) {
     $ret_var = "";
     $AMT = $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"];
     if ($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"] != "USD") {
         $AMT = CCurrencyRates::ConvertCurrency($AMT, $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"], "USD");
         $additor = 1;
         for ($i = 0; $i < SALE_VALUE_PRECISION; $i++) {
             $additor = $additor / 10;
         }
         $AMT_tmp = round($AMT, SALE_VALUE_PRECISION);
         while ($AMT_tmp < $AMT) {
             $AMT_tmp = round($AMT_tmp + $additor, SALE_VALUE_PRECISION);
         }
         $AMT = $AMT_tmp;
     }
     $AMT = str_replace(",", ".", $AMT);
     $cardExp = $cardexp1 . $cardexp2;
     $parms = "ACCT=" . urlencode($cardnum);
     // Credit card number
     $parms .= "&CVV2=" . urlencode($cvv2);
예제 #12
0
 public static function calculateInReportCurrency($value)
 {
     $res = $value;
     if (self::$reportCurrencyId != self::$siteCurrencyId) {
         $res = \CCurrencyRates::ConvertCurrency($value, self::$siteCurrencyId, self::$reportCurrencyId);
     }
     return $res;
 }
예제 #13
0
function PayUserAccountDeliveryOrderCallback($productID, $userID, $bPaid, $orderID, $quantity = 1)
{
    global $DB;
    $productID = IntVal($productID);
    $userID = IntVal($userID);
    $bPaid = $bPaid ? True : False;
    $orderID = IntVal($orderID);
    if ($userID <= 0) {
        return False;
    }
    if ($orderID <= 0) {
        return False;
    }
    if (!($arOrder = CSaleOrder::GetByID($orderID))) {
        return False;
    }
    $baseLangCurrency = CSaleLang::GetLangCurrency($arOrder["LID"]);
    $arAmount = unserialize(COption::GetOptionString("sale", "pay_amount", 'a:4:{i:1;a:2:{s:6:"AMOUNT";s:2:"10";s:8:"CURRENCY";s:3:"EUR";}i:2;a:2:{s:6:"AMOUNT";s:2:"20";s:8:"CURRENCY";s:3:"EUR";}i:3;a:2:{s:6:"AMOUNT";s:2:"30";s:8:"CURRENCY";s:3:"EUR";}i:4;a:2:{s:6:"AMOUNT";s:2:"40";s:8:"CURRENCY";s:3:"EUR";}}'));
    if (!array_key_exists($productID, $arAmount)) {
        return False;
    }
    $currentPrice = $arAmount[$productID]["AMOUNT"] * $quantity;
    $currentCurrency = $arAmount[$productID]["CURRENCY"];
    if ($arAmount[$productID]["CURRENCY"] != $baseLangCurrency) {
        $currentPrice = CCurrencyRates::ConvertCurrency($arAmount[$productID]["AMOUNT"], $arAmount[$productID]["CURRENCY"], $baseLangCurrency) * $quantity;
        $currentCurrency = $baseLangCurrency;
    }
    if (!CSaleUserAccount::UpdateAccount($userID, $bPaid ? $currentPrice : -$currentPrice, $currentCurrency, "MANUAL", $orderID, "Payment to user account")) {
        return False;
    }
    return True;
}
예제 #14
0
function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
{
	global $crmMode;
	$result = "";
	$arSet = array();

	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 $item)
		{
			if (!empty($item["CURRENCY"]) && $item["CURRENCY"] != $currency)
			{
				if (floatval($item["PRICE"]) > 0)
					$item["PRICE"] = CCurrencyRates::ConvertCurrency($item["PRICE"], $item["CURRENCY"], $currency);

				if (floatval($item["DISCOUNT_PRICE"]) > 0)
					$item["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($item["DISCOUNT_PRICE"], $item["CURRENCY"], $currency);

				$item["CURRENCY"] = $currency;
			}

			/** @var $productProvider IBXSaleProductProvider */
			if ($productProvider = CSaleBasket::GetProductProvider($item))
			{
				if (method_exists($productProvider, "GetSetItems"))
				{
					$itemInfo = (isset($item['ID']) ? array('BASKET_ID' => $item['ID']) : array());
					$arSets = $productProvider::GetSetItems($item["PRODUCT_ID"], CSaleBasket::TYPE_SET, $itemInfo);
					unset($itemInfo);

					if (is_array($arSets))
					{
						foreach ($arSets as $arSetData)
						{
							foreach ($arSetData["ITEMS"] as $setItem)
							{
								$setItem["FUSER_ID"] = $item["FUSER_ID"];
								$setItem["LID"] = $item["LID"];
								$setItem["MODULE"] = $item["MODULE"];
								$setItem["PRODUCT_PROVIDER_CLASS"] = $productProvider;
								$setItem["SET_PARENT_ID"] = $item["ID"];

								$arSet[$item["PRODUCT_ID"]][] = $setItem;
							}
						}
					}
				}
			}

			if ($item["MODULE"] == "catalog")
			{
				$arProductId[$item["PRODUCT_ID"]] = $item["PRODUCT_ID"];
				$arDataTab[$item["PRODUCT_ID"]] = $item;

				$arParent = CCatalogSku::GetProductInfo($item["PRODUCT_ID"]);
				if ($arParent)
				{
					$arSkuParentChildren[$item["PRODUCT_ID"]] = $arParent["ID"];
					$arSkuParentId[$arParent["ID"]] = $arParent["ID"];
				}
			}
		}

		if(!empty($arSkuParentId))
		{
			$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;
		}

		if(!empty($arProductId))
		{
			$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;
				$arImgProduct = false;
				$arFile = false;
				$imgUrl = '';
				$imgProduct = '';
				$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'];
				$item = $arDataTab[$arProduct['ID']];

				if ($item["PREVIEW_PICTURE"] == "" && $item["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$item["PRODUCT_ID"]]))
				{
					$idTmp = $arSkuParentChildren[$item["PRODUCT_ID"]];
					$item["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
					$item["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
				}

				if ($item["DETAIL_PICTURE"] > 0)
					$imgCode = $item["DETAIL_PICTURE"];
				elseif ($item["PREVIEW_PICTURE"] > 0)
					$imgCode = $item["PREVIEW_PICTURE"];

				$arSkuProperty = CSaleProduct::GetProductSkuProps($item["PRODUCT_ID"], $item["IBLOCK_ID"]);

				$item["NAME"] = htmlspecialcharsex($item["NAME"]);
				$item["EDIT_PAGE_URL"] = htmlspecialcharsex($item["EDIT_PAGE_URL"]);
				$item["CURRENCY"] = htmlspecialcharsex($item["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=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\"><img src=\"".$imgUrl."\" alt=\"\" title=\"".$item["NAME"]."\" ></a>";
				}
				else
					$imgProduct = "<div class='no_foto'>".GetMessage('NO_FOTO')."</div>";

				$arCurFormat = CCurrencyLang::GetCurrencyFormat($item["CURRENCY"]);
				$priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);

				$currentTotalPrice = ($item["PRICE"] + $item["DISCOUNT_PRICE"]);

				$discountPercent = 0;
				if ($item["DISCOUNT_PRICE"] > 0)
					$discountPercent = intval(($item["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);

				$arProduct = CCatalogProduct::GetByID($item["PRODUCT_ID"]);
				$balance = floatval($arProduct["QUANTITY"]);

				$result .= "<tr id='more_".$type."_".$item["ID"]."'>
								<td class=\"tab_img\" >".$imgProduct."</td>
								<td class=\"tab_text\">
									<div class=\"order_name\"><a href=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\" title=\"".$item["NAME"]."\">".$item["NAME"]."</a></div>
									<div class=\"order_price\">
										".GetMessage('NEWO_SUBTAB_PRICE').": <b>".SaleFormatCurrency($item["PRICE"], $currency)."</b>";

				if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet)) // show/hide set item link
				{
					$result .= '<br/>
						<div>
							<a id="set_toggle_link_b'.$arProduct["ID"].'"
								href="javascript:void(0);"
								class="dashed-link show-set-link"
								title="'.GetMessage("SOE_SHOW_SET").'"
								onclick="fToggleSetItems(\'b'.$arProduct["ID"].'\');">'.GetMessage("SOE_SHOW_SET").'</a>
						</div>';
				}

				$result .= "</div>";

				$arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $item["PRODUCT_ID"], $item["NAME"], $currency, $arProduct);

				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_BASKET'),
					"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=\"fAddToBasketMoreProduct('".$type."', ".$item["PRODUCT_ID"].");return false;\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";
				else
					$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']).", ".CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']).", 'basket', ".CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]).");\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";

				if (!$crmMode)
				{
					if (count($arResult["SKU_ELEMENTS"]) > 0)
					{
						$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".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($item["QUANTITY"]) > 0) ? floatval($item["QUANTITY"]) : 1;
						$url = "/bitrix/admin/sale_order_new.php?lang=".LANGUAGE_ID."&user_id=".$USER_ID."&LID=".$LID."&product[".$item["PRODUCT_ID"]."]=".$cntProd;
						$result .= "<a href=\"".$url."\" target=\"_blank\" class=\"get_new_order\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_ORDER')."</a>";
					}
				}

				$result .= "</td></tr>";

				// show set items
				if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet))
				{
					foreach ($arSet[$arProduct["ID"]] as $set)
					{
						$editUrl = CIBlock::GetAdminElementEditLink($set["IBLOCK_ID"], $set["ITEM_ID"], array(
							"find_section_section" => $set["IBLOCK_SECTION_ID"],
							'WF' => 'Y',
						));

						if ($set["PREVIEW_PICTURE"] > 0)
							$imgCode = $set["PREVIEW_PICTURE"];
						elseif ($set["DETAIL_PICTURE"] > 0)
							$imgCode = $set["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"];
								$img = '<a href="'.$editUrl.'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$set["NAME"].'" ></a>';
							}
						}
						else
							$img = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";

						$result .= '
							<tr style="display:none" class="set_item_b'.$arProduct["ID"].'">
								<td class="tab_img">'.$img.'</td>
								<td class="tab_text">
									<div class="order_name">
										<a href="'.$editUrl.'" style="font-style:italic" target="_blank" title="'.$set["NAME"].'">'.$set["NAME"].'</a>
									</div>
									<div class="order_price">'.GetMessage('NEWO_SUBTAB_PRICE').': <b>'.SaleFormatCurrency($set["PRICE"], $currency).'</b></div>
								</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 == "basket")
			$result .= "<a href='javascript:void(0);' onClick='fGetMoreBasket(\"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;
}
예제 #15
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;
 }
예제 #16
0
 public function fillItemPrices(&$resultItem, $arElement)
 {
     if (isset($arElement["MIN_VALUE_NUM"]) && isset($arElement["MAX_VALUE_NUM"])) {
         $currency = $arElement["VALUE"];
         $existCurrency = strlen($currency) > 0;
         if ($existCurrency) {
             $currency = $this->facet->lookupDictionaryValue($currency);
         }
         if ($this->convertCurrencyId && $existCurrency) {
             $priceValue = CCurrencyRates::ConvertCurrency($arElement["MIN_VALUE_NUM"], $currency, $this->convertCurrencyId);
         } else {
             $priceValue = $arElement["MIN_VALUE_NUM"];
         }
         if (!isset($resultItem["VALUES"]["MIN"]["VALUE"]) || $resultItem["VALUES"]["MIN"]["VALUE"] > $priceValue) {
             $resultItem["VALUES"]["MIN"]["VALUE"] = $priceValue;
             if ($existCurrency) {
                 $resultItem["VALUES"]["MIN"]["CURRENCY"] = $currency;
             }
         }
         if ($this->convertCurrencyId && $existCurrency) {
             $priceValue = CCurrencyRates::ConvertCurrency($arElement["MAX_VALUE_NUM"], $currency, $this->convertCurrencyId);
         } else {
             $priceValue = $arElement["MAX_VALUE_NUM"];
         }
         if (!isset($resultItem["VALUES"]["MAX"]["VALUE"]) || $resultItem["VALUES"]["MAX"]["VALUE"] < $priceValue) {
             $resultItem["VALUES"]["MAX"]["VALUE"] = $priceValue;
             if ($existCurrency) {
                 $resultItem["VALUES"]["MAX"]["CURRENCY"] = $currency;
             }
         }
     } else {
         $currency = $arElement["CATALOG_CURRENCY_" . $resultItem["ID"]];
         $existCurrency = strlen($currency) > 0;
         $price = $arElement["CATALOG_PRICE_" . $resultItem["ID"]];
         if (strlen($price)) {
             if ($this->convertCurrencyId && $existCurrency) {
                 $convertPrice = CCurrencyRates::ConvertCurrency($price, $currency, $this->convertCurrencyId);
             } else {
                 $convertPrice = (double) $price;
             }
             if (!isset($resultItem["VALUES"]["MIN"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MIN"]) || doubleval($resultItem["VALUES"]["MIN"]["VALUE"]) > $convertPrice) {
                 $resultItem["VALUES"]["MIN"]["VALUE"] = $price;
                 if ($existCurrency) {
                     $resultItem["VALUES"]["MIN"]["CURRENCY"] = $currency;
                 }
             }
             if (!isset($resultItem["VALUES"]["MAX"]) || !array_key_exists("VALUE", $resultItem["VALUES"]["MAX"]) || doubleval($resultItem["VALUES"]["MAX"]["VALUE"]) < $convertPrice) {
                 $resultItem["VALUES"]["MAX"]["VALUE"] = $price;
                 if ($existCurrency) {
                     $resultItem["VALUES"]["MAX"]["CURRENCY"] = $currency;
                 }
             }
         }
     }
     if ($existCurrency) {
         if ($this->convertCurrencyId) {
             $resultItem["CURRENCIES"][$this->convertCurrencyId] = isset($this->currencyCache[$this->convertCurrencyId]) ? $this->currencyCache[$this->convertCurrencyId] : $this->getCurrencyFullName($this->convertCurrencyId);
             $resultItem["~CURRENCIES"][$currency] = isset($this->currencyCache[$currency]) ? $this->currencyCache[$currency] : $this->getCurrencyFullName($currency);
         } else {
             $resultItem["CURRENCIES"][$currency] = isset($this->currencyCache[$currency]) ? $this->currencyCache[$currency] : $this->getCurrencyFullName($currency);
         }
     }
 }
예제 #17
0
							else
							{
								//$arResFields[$i] = $res1["PROPERTY_".substr($arNeedFields[$i], strlen("IP_PROP"))."_VALUE"];
								$arResFields[$i] = $res1["PROPERTY_".$strTempo."_VALUE"];
							}
							$bFieldOut = True;
						}
						elseif ($boolCatalog && substr($arNeedFields[$i], 0, strlen("CR_PRICE_"))=="CR_PRICE_")
						{
							$sPriceTmp = substr($arNeedFields[$i], strlen("CR_PRICE_"));
							$arPriceTmp = explode("_", $sPriceTmp);

							if (strlen($res1["CATALOG_CURRENCY_".intval($arPriceTmp[0])])>0
								&& $res1["CATALOG_CURRENCY_".intval($arPriceTmp[0])]!=$arPriceTmp[1])
							{
								$arResFields[$i] = Round(CCurrencyRates::ConvertCurrency($res1["CATALOG_PRICE_".intval($arPriceTmp[0])], $res1["CATALOG_CURRENCY_".intval($arPriceTmp[0])], $arPriceTmp[1]), 2);
							}
							else
							{
								$arResFields[$i] = $res1["CATALOG_PRICE_".intval($arPriceTmp[0])];
							}
							$bFieldOut = True;
						}
					}

					if (!$bFieldOut)
					{
						foreach ($arAvailGroupFields_names as $key => $value)
						{
							if ($key==substr($arNeedFields[$i], 0, strlen($key))
								&& is_numeric(substr($arNeedFields[$i], strlen($key))))
예제 #18
0
				$str_QUANTITY = doubleval($arAcc["CATALOG_QUANTITY"]);
				$str_QUANTITY_TRACE = $arAcc["CATALOG_QUANTITY_TRACE"];
				if (($str_QUANTITY <= 0) && ($str_QUANTITY_TRACE == "Y"))
					$str_AVAILABLE = ' available="false"';
				else
					$str_AVAILABLE = ' available="true"';

				$minPrice = 0;
				$minPriceRUR = 0;
				$minPriceGroup = 0;
				$minPriceCurrency = "";
				for ($i = 0, $intCount = count($arPTypes); $i < $intCount; $i++)
				{
					if (strlen($arAcc["CATALOG_CURRENCY_".$arPTypes[$i]])<=0) continue;

					$tmpPrice = CCurrencyRates::ConvertCurrency($arAcc["CATALOG_PRICE_".$arPTypes[$i]], $arAcc["CATALOG_CURRENCY_".$arPTypes[$i]], "RUR");
					if ($minPriceRUR<=0 || $minPriceRUR>$tmpPrice)
					{
						$minPriceRUR = $tmpPrice;
						$minPrice = $arAcc["CATALOG_PRICE_".$arPTypes[$i]];
						$minPriceGroup = $arPTypes[$i];
						$minPriceCurrency = $arAcc["CATALOG_CURRENCY_".$arPTypes[$i]];
						if ($minPriceCurrency!="USD" && $minPriceCurrency!="RUR")
						{
							$minPriceCurrency = "RUR";
							$minPrice = $tmpPrice;
						}
					}
				}

				if ($minPrice <= 0) continue;
예제 #19
0
$sum = 0;
$sumHtml = "";
$alertIntervalText = "";
$uptimeRate = 1;
if ($bAlert) {
    if ($uptime !== "") {
        $uptime = explode("/", $uptime);
        if ($uptime[0] > 0 && $uptime[1] > 0) {
            $uptimeRate = $uptime[0] / $uptime[1];
        }
    }
    if ($uptimeRate < 1 && $saleIncluded) {
        $base = CCurrency::GetBaseCurrency();
        $r = CSaleOrder::GetList(array(), array(">=DATE_INSERT" => ConvertTimeStamp(time() - $monitoring->getInterval() * 24 * 3400, "SHORT")), array("LID", "CURRENCY", "SUM" => "PRICE"));
        while ($a = $r->fetch()) {
            $sum += CCurrencyRates::ConvertCurrency($a["PRICE"], $a["CURRENCY"], $base);
        }
        $sum *= 1 - $uptimeRate;
        if ($sum <= 0.0) {
            $sumHtml = number_format((1 - $uptimeRate) * 100, 2, '.', ' ') . "%";
            $alertIntervalText = $intervalLang["uptime"][$monitoring->getInterval()];
        } else {
            $sumHtml = CurrencyFormat($sum, $base);
            $alertIntervalText = $intervalLang["sale"][$monitoring->getInterval()];
        }
    } elseif ($testCount === 1 && HasMessage("GD_BITRIXCLOUD_MONITOR_" . strtoupper($testAlert->getName()))) {
        $uptimeRate = 1;
        $resultText = FormatDate("ddiff", time(), $testAlert->getResult());
        $sumHtml = GetMessage("GD_BITRIXCLOUD_MONITOR_" . strtoupper($testAlert->getName()), array("#DOMAIN#" => $converter->Decode($testDomain), "#DAYS#" => $resultText));
    } elseif ($uptimeRate < 1) {
        $sumHtml = number_format((1 - $uptimeRate) * 100, 2, '.', ' ') . "%";
예제 #20
0
 if ($arResult['ERROR'] == '') {
     $dbBaket = CSaleBasket::GetList(array(), array('FUSER_ID' => CSaleBasket::GetBasketUserID(), 'LID' => SITE_ID, 'ORDER_ID' => 'NULL'));
     while ($arBasket = $dbBaket->GetNext()) {
         if ($arBasket['CATALOG_XML_ID'] != '' && strpos($arBasket['CATALOG_XML_ID'], '@') !== false) {
             list($amount, $curr) = explode('@', $arBasket['CATALOG_XML_ID']);
             if ($curr == $arResult['REQUEST_ACCOUNT']) {
                 CSaleBasket::Delete($arBasket['ID']);
             }
         }
     }
     if ($arParams['PAY_IMMED']) {
         CSaleBasket::DeleteAll(CSaleBasket::GetBasketUserID());
     }
     CSaleBasket::Add(array('PRODUCT_ID' => $arResult['CURRENCIES'][$arResult['REQUEST_ACCOUNT']]['ID'], 'PRICE' => CCurrencyRates::ConvertCurrency($arResult['MONEY_OFF'], $arResult['REQUEST_ACCOUNT'], $arResult['LANG_CURRENCY']), 'CURRENCY' => $arResult['LANG_CURRENCY'], 'QUANTITY' => 1, 'LID' => LANG, 'DELAY' => 'N', 'CAN_BUY' => 'Y', 'NAME' => GetMessage('SPT_NAME_IN_CART', array('#VALUE#' => SaleFormatCurrency($arResult['REQUEST_AMOUNT'], $arResult['REQUEST_ACCOUNT']))), 'MODULE' => 'asd.money', 'DETAIL_PAGE_URL' => '', 'CATALOG_XML_ID' => $arResult['REQUEST_AMOUNT'] . '@' . $arResult['REQUEST_ACCOUNT']));
     if ($arParams['PAY_IMMED']) {
         $ORDER_ID = CSaleOrder::Add(array('LID' => SITE_ID, 'PERSON_TYPE_ID' => $arParams['PERSON_TYPE'], 'PRICE' => CCurrencyRates::ConvertCurrency($arResult['MONEY_OFF'], $arResult['REQUEST_ACCOUNT'], $arResult['LANG_CURRENCY']), 'CURRENCY' => $arResult['LANG_CURRENCY'], 'PAY_SYSTEM_ID' => $arResult['REQUEST_PAY_SYSTEM'], 'USER_ID' => $USER->getID()));
         if ($ORDER_ID > 0) {
             $arOrder = CSaleOrder::GetByID($ORDER_ID);
             CSaleBasket::OrderBasket($ORDER_ID);
         }
         $arPaySysAction = $arResult['PAY_SYSTEMS'][$arResult['REQUEST_PAY_SYSTEM']];
         if (strlen($arPaySysAction['ACTION_FILE']) > 0) {
             CSalePaySystemAction::InitParamArrays($arOrder, $ORDER_ID, $arPaySysAction['PARAMS']);
             $pathToAction = $_SERVER['DOCUMENT_ROOT'] . $arPaySysAction['ACTION_FILE'];
             $pathToAction = rtrim(str_replace('\\', '/', $pathToAction), '/');
             if (file_exists($pathToAction)) {
                 if (is_dir($pathToAction)) {
                     if (file_exists($pathToAction . '/payment.php')) {
                         include $pathToAction . '/payment.php';
                     }
                 } else {
예제 #21
0
		}
		else
			$arDelivery = fGetDeliverySystemsHTML($location, $locationZip, $arOrder["ORDER_WEIGHT"], $arOrder["ORDER_PRICE"], $currency, $LID, $deliveryId, $arShoppingCart);

		$arData[0]["ORDER_ID"] = $id;
		$arData[0]["DELIVERY"] = $arDelivery["DELIVERY"];

		if (isset($arOrder["PRICE_DELIVERY"]) && floatval($arOrder["PRICE_DELIVERY"]) >= 0 && floatval($arOrder["PRICE_DELIVERY"])."!" == $arOrder["PRICE_DELIVERY"]."!") //if number
		{
			$arData[0]["DELIVERY_PRICE"] = $arOrder["PRICE_DELIVERY"];
			$arData[0]["DELIVERY_PRICE_FORMAT"] = SaleFormatCurrency($arOrder["PRICE_DELIVERY"], $currency);
		}
		else
		{
			if ($arDelivery["CURRENCY"] != $currency)
				$arDelivery["DELIVERY_DEFAULT_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arDelivery["DELIVERY_DEFAULT_PRICE"], $arDelivery["CURRENCY"], $currency), SALE_VALUE_PRECISION);

			$arDelivery["DELIVERY_DEFAULT_PRICE"] = floatval($arDelivery["DELIVERY_DEFAULT_PRICE"]);
			$arData[0]["DELIVERY_PRICE"] = $arDelivery["DELIVERY_DEFAULT_PRICE"];
			$arData[0]["DELIVERY_PRICE_FORMAT"] = SaleFormatCurrency($arDelivery["DELIVERY_DEFAULT_PRICE"], $currency);
		}
		$arData[0]["DELIVERY_DEFAULT"] = $arDelivery["DELIVERY_DEFAULT"];

		if (isset($arOrder["PRICE_DELIVERY_DIFF"]))
			$arData[0]["PRICE_DELIVERY_DIFF"] = SaleFormatCurrency(roundEx($arOrder["PRICE_DELIVERY_DIFF"], SALE_VALUE_PRECISION), $currency);

		if (strlen($arDelivery["DELIVERY_DEFAULT_ERR"]) > 0)
		{
			$arData[0]["DELIVERY_DESCRIPTION"] = $arDelivery["DELIVERY_DEFAULT_ERR"];
			$arData[0]["ORDER_ERROR"] = "Y";
		}
예제 #22
0
					$arOffer['MIN_PRICE']['CATALOG_MEASURE_NAME'] = $arOffer['CATALOG_MEASURE_NAME'];
					$arOffer['MIN_PRICE']['~CATALOG_MEASURE_NAME'] = $arOffer['~CATALOG_MEASURE_NAME'];

					if (empty($arMinPrice))
					{
						$dblMinPrice = ($boolConvert || ($arOffer['MIN_PRICE']['CURRENCY'] == $strMinCurrency)
							? $arOffer['MIN_PRICE']['DISCOUNT_VALUE']
							: CCurrencyRates::ConvertCurrency($arOffer['MIN_PRICE']['DISCOUNT_VALUE'], $arOffer['MIN_PRICE']['CURRENCY'], $strMinCurrency)
						);
						$arMinPrice = $arOffer['MIN_PRICE'];
					}
					else
					{
						$dblComparePrice = ($boolConvert || ($arOffer['MIN_PRICE']['CURRENCY'] == $strMinCurrency)
							? $arOffer['MIN_PRICE']['DISCOUNT_VALUE']
							: CCurrencyRates::ConvertCurrency($arOffer['MIN_PRICE']['DISCOUNT_VALUE'], $arOffer['MIN_PRICE']['CURRENCY'], $strMinCurrency)
						);
						if ($dblMinPrice > $dblComparePrice)
						{
							$dblMinPrice = $dblComparePrice;
							$arMinPrice = $arOffer['MIN_PRICE'];
						}
					}
				}
				$arItem['MIN_PRICE'] = $arMinPrice;
			}
		}

		if ($arResult['MODULES']['catalog'] && $arItem['CATALOG'] && CCatalogProduct::TYPE_PRODUCT == $arItem['CATALOG_TYPE'])
		{
			CIBlockPriceTools::setRatioMinPrice($arItem, true);
예제 #23
0
	protected function __PrimaryDiscountFilter(&$arDiscount, &$arPriceDiscount, &$arDiscSave, &$arParams)
	{
		if (isset($arParams['PRICE']) && isset($arParams['CURRENCY']))
		{
			$arParams['PRICE'] = doubleval($arParams['PRICE']);
			if (0 < $arParams['PRICE'])
			{
				$arPriceDiscount = array();
				$arDiscSave = array();

				foreach ($arDiscount as $arOneDiscount)
				{
					$dblDiscountValue = 0.0;
					if ('F' == $arOneDiscount['VALUE_TYPE'])
					{
						if ($arParams['CURRENCY'] == $arOneDiscount["CURRENCY"])
							$dblDiscountValue = $arOneDiscount["VALUE"];
						else
							$dblDiscountValue = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arParams['CURRENCY']);
						if ($arParams['PRICE'] < $dblDiscountValue)
							continue;
						$arOneDiscount['DISCOUNT_CONVERT'] = $dblDiscountValue;
					}
					elseif ('S' == $arOneDiscount['VALUE_TYPE'])
					{
						if ($arParams['CURRENCY'] == $arOneDiscount["CURRENCY"])
							$dblDiscountValue = $arOneDiscount["VALUE"];
						else
							$dblDiscountValue = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arParams['CURRENCY']);
						if ($arParams['PRICE'] <= $dblDiscountValue)
							continue;
						$arOneDiscount['DISCOUNT_CONVERT'] = $dblDiscountValue;
					}
					elseif ('P' == $arOneDiscount['VALUE_TYPE'])
					{
						if (100 < $arOneDiscount["VALUE"])
							continue;
						if (DISCOUNT_TYPE_STANDART == $arOneDiscount['TYPE'] && 0 < $arOneDiscount["MAX_DISCOUNT"])
						{
							if ($arParams['CURRENCY'] == $arOneDiscount["CURRENCY"])
								$dblDiscountValue = $arOneDiscount["MAX_DISCOUNT"];
							else
								$dblDiscountValue = CCurrencyRates::ConvertCurrency($arOneDiscount["MAX_DISCOUNT"], $arOneDiscount["CURRENCY"], $arParams['CURRENCY']);
							$arOneDiscount['DISCOUNT_CONVERT'] = $dblDiscountValue;
						}
					}
					if (DISCOUNT_TYPE_SAVE == $arOneDiscount['TYPE'])
					{
						$arDiscSave[] = $arOneDiscount;
					}
					else
					{
						$arPriceDiscount[intval($arOneDiscount['PRIORITY'])][] = $arOneDiscount;
					}
				}

				if (!empty($arPriceDiscount))
					krsort($arPriceDiscount);
			}
		}
	}
예제 #24
0
 $found = false;
 $resort = false;
 foreach ($currentSet['ITEMS'] as &$setItem) {
     if (!isset($setItem['ITEM_DATA'])) {
         continue;
     }
     $setItem['ITEM_DATA']['SET_QUANTITY'] = empty($setItem['QUANTITY']) ? 1 : $setItem['QUANTITY'];
     $setItem['ITEM_DATA']['MEASURE_RATIO'] = $arResult['ITEMS_RATIO'][$setItem['ITEM_DATA']['ID']];
     $setItem['ITEM_DATA']['MEASURE'] = !empty($ratioResult[$setItem['ITEM_DATA']['ID']]['MEASURE']) ? $ratioResult[$setItem['ITEM_DATA']['ID']]['MEASURE'] : $defaultMeasure;
     $setItem['ITEM_DATA']['BASKET_QUANTITY'] = $setItem['ITEM_DATA']['SET_QUANTITY'] * $setItem['ITEM_DATA']['MEASURE_RATIO'];
     $arResult['BASKET_QUANTITY'][$setItem['ITEM_DATA']['ID']] = $setItem['ITEM_DATA']['BASKET_QUANTITY'];
     $setItem['ITEM_DATA']['SET_SORT'] = $setItem['SORT'];
     if ($arParams['CONVERT_CURRENCY'] == 'N' && $setItem['ITEM_DATA']['PRICE_CURRENCY'] != $defaultCurrency) {
         $setItem['ITEM_DATA']['PRICE_CONVERT_DISCOUNT_VALUE'] = CCurrencyRates::ConvertCurrency($setItem['ITEM_DATA']['PRICE_DISCOUNT_VALUE'], $setItem['ITEM_DATA']['PRICE_CURRENCY'], $defaultCurrency);
         $setItem['ITEM_DATA']['PRICE_CONVERT_VALUE'] = CCurrencyRates::ConvertCurrency($setItem['ITEM_DATA']["PRICE_VALUE"], $setItem['ITEM_DATA']['PRICE_CURRENCY'], $defaultCurrency);
         $setItem['ITEM_DATA']['PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE'] = CCurrencyRates::ConvertCurrency($setItem['ITEM_DATA']['PRICE_DISCOUNT_DIFFERENCE_VALUE'], $setItem['ITEM_DATA']['PRICE_CURRENCY'], $defaultCurrency);
         $setItem['ITEM_DATA']['PRICE_CURRENCY'] = $defaultCurrency;
     }
     if ($setItem['ITEM_DATA']['CAN_BUY'] && $countSetDefaultItems < 3) {
         $arResult['SET_ITEMS']['DEFAULT'][] = $setItem['ITEM_DATA'];
         $arResult['SET_ITEMS']['PRICE'] += $setItem['ITEM_DATA']['PRICE_DISCOUNT_VALUE'] * $setItem['ITEM_DATA']['BASKET_QUANTITY'];
         $arResult['SET_ITEMS']['OLD_PRICE'] += $setItem['ITEM_DATA']['PRICE_VALUE'] * $setItem['ITEM_DATA']['BASKET_QUANTITY'];
         $arResult['SET_ITEMS']['PRICE_DISCOUNT_DIFFERENCE'] += $setItem['ITEM_DATA']['PRICE_DISCOUNT_DIFFERENCE_VALUE'] * $setItem['ITEM_DATA']['BASKET_QUANTITY'];
         $countSetDefaultItems++;
     } else {
         if (!$setItem['ITEM_DATA']['CAN_BUY']) {
             $resort = true;
         }
         $arResult['SET_ITEMS']['OTHER'][] = $setItem['ITEM_DATA'];
     }
     $found = true;
예제 #25
0
 $bCorrectPayment = True;
 $err = 0;
 $err_text = '';
 if ($arOrder = CSaleOrder::GetByID(IntVal($lmi_payment_no))) {
     $bCorrectPayment = False;
     $err = 1;
     $err_text = 'ERR: НЕТ ТАКОГО ЗАКАЗА';
 }
 if ($bCorrectPayment) {
     CSalePaySystemAction::InitParamArrays($arOrder, $arOrder["ID"]);
 }
 $IdM = CSalePaySystemAction::GetParamValue("ZP_SHOP_ID");
 $sk = CSalePaySystemAction::GetParamValue("ZP_MERCHANT_KEY");
 $CruR = CSalePaySystemAction::GetParamValue("ZP_CODE_RUR");
 // Проверяем, не произошла ли подмена суммы.
 $order_amount = CCurrencyRates::ConvertCurrency($arOrder["PRICE"], $arOrder["CURRENCY"], $CruR);
 if ($order_amount != $lmi_payment_amount) {
     $err = 2;
     $err_text = 'ERR: НЕВЕРНАЯ СУММА : ' . $lmi_payment_amount;
 }
 //проверяем ID магазина
 if ($lmi_payee_purse != $IdM) {
     $err = 3;
     $err_text = 'ERR: НЕВЕРЕН ID МАГАЗИНА : ' . $lmi_payee_purse;
 }
 if ($lmi_prerequest == 1) {
     if ($err != 0) {
         echo $err_text;
     } else {
         echo 'YES';
     }
예제 #26
0
                $strCategory = $ar_iblock["NAME"];
                $sections_path = GetIBlockSectionPath($IBLOCK_ID, $ar_elems["IBLOCK_SECTION_ID"]);
                while ($arSection = $sections_path->GetNext()) {
                    if (strlen($strCategory) > 0) {
                        $strCategory .= ">";
                    }
                    $strCategory .= $arSection["NAME"];
                }
                $arSectionPaths[IntVal($ar_elems["IBLOCK_SECTION_ID"])] = PrepareString($strCategory);
            }
            $minPrice = 0;
            for ($i = 0, $intPCount = count($arPTypes); $i < $intPCount; $i++) {
                if (strlen($ar_elems["CATALOG_CURRENCY_" . $arPTypes[$i]]) <= 0) {
                    continue;
                }
                $tmpPrice = Round(CCurrencyRates::ConvertCurrency($ar_elems["CATALOG_PRICE_" . $arPTypes[$i]], $ar_elems["CATALOG_CURRENCY_" . $arPTypes[$i]], "USD"), 2);
                if ($minPrice <= 0 || $minPrice > $tmpPrice) {
                    $minPrice = $tmpPrice;
                }
            }
            if ($minPrice <= 0) {
                continue;
            }
            @fwrite($fp, "http://" . COption::GetOptionString("main", "server_name", $SERVER_NAME) . str_replace("//", "/", $ar_elems["DETAIL_PAGE_URL"]) . "\t" . $ar_elems["~NAME"] . "\t" . PrepareString($ar_elems["~PREVIEW_TEXT"], true) . "\t" . $strImage . "\t" . $arSectionPaths[IntVal($ar_elems["IBLOCK_SECTION_ID"])] . "\t" . $minPrice . "\n");
        }
        @fclose($fp);
    }
}
CCatalogDiscountSave::Enable();
if ($bTmpUserCreated) {
    unset($USER);
예제 #27
0
 protected function __SaleOrderSumm($arOrderFilter, $strCurrency)
 {
     $arOrderSumm = array('ORDER_FILTER' => $arOrderFilter, 'SUMM' => 0, 'CURRENCY' => '', 'LAST_ORDER_DATE' => '', 'TIMESTAMP' => 0, 'RANGE_SUMM' => 0, 'RANGE_SUMM_CURRENCY' => $strCurrency);
     foreach (GetModuleEvents('catalog', 'OnSaleOrderSumm', true) as $arEvent) {
         $mxOrderCount = ExecuteModuleEventEx($arEvent, array($arOrderFilter));
         if (!empty($mxOrderCount) && is_array($mxOrderCount)) {
             $mxOrderCount['PRICE'] = (double) $mxOrderCount['PRICE'];
             $arOrderSumm['LAST_ORDER_DATE'] = $mxOrderCount['LAST_ORDER_DATE'];
             $arOrderSumm['SUMM'] = $mxOrderCount['PRICE'];
             $arOrderSumm['CURRENCY'] = $mxOrderCount['CURRENCY'];
             $arOrderSumm['TIMESTAMP'] = $mxOrderCount['TIMESTAMP'];
             $arOrderSumm['RANGE_SUMM'] = $mxOrderCount['CURRENCY'] != $strCurrency ? CCurrencyRates::ConvertCurrency($mxOrderCount['PRICE'], $mxOrderCount['CURRENCY'], $strCurrency) : $mxOrderCount['PRICE'];
             break;
         }
     }
     foreach (GetModuleEvents('catalog', 'OnSaleOrderSummResult', true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$arOrderSumm));
     }
     return $arOrderSumm;
 }
예제 #28
0
 function Calculate($STEP, $SID, $profile, $arOrder, $currency, $TMP = false, $SITE_ID = false)
 {
     global $APPLICATION;
     if (!defined('SALE_DH_INITIALIZED')) {
         CSaleDeliveryHandler::Initialize();
     }
     if (!$SITE_ID) {
         $SITE_ID = SITE_ID;
     }
     $rsDeliveryHandler = CSaleDeliveryHandler::GetBySID($SID, $SITE_ID);
     if (!($arHandler = $rsDeliveryHandler->Fetch())) {
         return array("RESULT" => "ERROR", "TEXT" => GetMessage("SALE_DH_ERROR_HANDLER_NOT_INSTALLED"));
     }
     if (is_callable($arHandler["CALCULATOR"])) {
         $arConfig = $arHandler["CONFIG"]["CONFIG"];
         $arOrder["PRICE"] = CCurrencyRates::ConvertCurrency($arOrder["PRICE"], $currency, $arHandler["BASE_CURRENCY"]);
         if ($res = call_user_func($arHandler["CALCULATOR"], $profile, $arConfig, $arOrder, $STEP, $TMP)) {
             if (is_array($res)) {
                 $arReturn = $res;
             } elseif (is_numeric($res)) {
                 $arReturn = array("RESULT" => "OK", "VALUE" => doubleval($res));
             }
         } else {
             if ($ex = $APPLICATION->GetException()) {
                 return array("RESULT" => "ERROR", "TEXT" => $ex->GetString());
             } else {
                 return array("RESULT" => "OK", "VALUE" => 0);
             }
         }
         if (is_array($arReturn) && $arReturn["RESULT"] == "OK" && $currency != $arHandler["BASE_CURRENCY"] && CModule::IncludeModule('currency')) {
             $arReturn["VALUE"] = CCurrencyRates::ConvertCurrency($arReturn["VALUE"], $arHandler["BASE_CURRENCY"], $currency);
         }
         $arReturn["VALUE"] *= 1 + $arHandler["TAX_RATE"] / 100;
         $arReturn = CSaleDeliveryHandler::__executeCalculateEvents($SID, $profile, $arOrder, $arReturn);
         return $arReturn;
     } else {
         return array("RESULT" => "ERROR", "TEXT" => GetMessage("SALE_DH_ERROR_WRONG_HANDLER_FILE"));
     }
 }
예제 #29
0
         $arResult["ROWS"] = array();
         do {
             if ($currentBasketModule != $arItemsList["BASKET_MODULE"] || $currentBasketProductID != $arItemsList["BASKET_PRODUCT_ID"] || $currentBasketName != $arItemsList["BASKET_NAME"]) {
                 $arResult["ROWS"][] = array("NAME" => htmlspecialcharsex($currentBasketName), "QUANTITY" => $currentQuantity, "SUM" => $currentSum, "CURRENCY" => $affiliateCurrency, "SUM_FORMAT" => SaleFormatCurrency($currentSum, $affiliateCurrency));
                 $currentBasketModule = $arItemsList["BASKET_MODULE"];
                 $currentBasketProductID = $arItemsList["BASKET_PRODUCT_ID"];
                 $currentBasketName = $arItemsList["BASKET_NAME"];
                 $totalQuantity += $currentQuantity;
                 $totalSum += $currentSum;
                 $currentQuantity = 0;
                 $currentSum = 0;
             }
             $currentQuantity += $arItemsList["BASKET_QUANTITY"];
             if ($affiliateCurrency != $arItemsList["BASKET_CURRENCY"]) {
                 //$currentSum += CCurrencyRates::ConvertCurrency(($arItemsList["BASKET_PRICE"] - $arItemsList["BASKET_DISCOUNT_PRICE"]) * $arItemsList["BASKET_QUANTITY"], $arItemsList["BASKET_CURRENCY"], $affiliateCurrency);
                 $currentSum += CCurrencyRates::ConvertCurrency($arItemsList["BASKET_PRICE"] * $arItemsList["BASKET_QUANTITY"], $arItemsList["BASKET_CURRENCY"], $affiliateCurrency);
             } else {
                 //$currentSum += ($arItemsList["BASKET_PRICE"] - $arItemsList["BASKET_DISCOUNT_PRICE"]) * $arItemsList["BASKET_QUANTITY"];
                 $currentSum += $arItemsList["BASKET_PRICE"] * $arItemsList["BASKET_QUANTITY"];
             }
         } while ($arItemsList = $dbItemsList->Fetch());
         $arResult["ROWS"][] = array("NAME" => $currentBasketName, "QUANTITY" => $currentQuantity, "SUM" => $currentSum, "CURRENCY" => $affiliateCurrency, "SUM_FORMAT" => SaleFormatCurrency($currentSum, $affiliateCurrency));
         $totalQuantity += $currentQuantity;
         $totalSum += $currentSum;
         $arResult["TOTAL"] = array("QUANTITY" => $totalQuantity, "SUM" => $totalSum, "CURRENCY" => $affiliateCurrency, "SUM_FORMAT" => SaleFormatCurrency($totalSum, $affiliateCurrency));
     }
     $arResult["FILTER_ID"] = rand(0, 10000);
 } else {
     $arResult = false;
 }
 $this->IncludeComponentTemplate();
예제 #30
0
     if ($arStoreTmp["IMAGE_ID"] > 0) {
         $arStoreTmp["IMAGE_ID"] = CFile::GetFileArray($arStoreTmp["IMAGE_ID"]);
     }
     $arStore[$arStoreTmp["ID"]] = $arStoreTmp;
 }
 $arResult["STORE_LIST"] = $arStore;
 if (!$bFound && !empty($arUserResult["DELIVERY_ID"]) && strpos($arUserResult["DELIVERY_ID"], ":") === false) {
     $arUserResult["DELIVERY_ID"] = "";
 }
 foreach ($arDeliveryAll as $arDelivery) {
     if (count($arP2D[$arUserResult["PAY_SYSTEM_ID"]]) <= 0 || in_array($arDelivery["ID"], $arP2D[$arUserResult["PAY_SYSTEM_ID"]])) {
         $arDelivery["FIELD_NAME"] = "DELIVERY_ID";
         if (IntVal($arUserResult["DELIVERY_ID"]) == IntVal($arDelivery["ID"])) {
             $arDelivery["CHECKED"] = "Y";
             $arUserResult["DELIVERY_ID"] = $arDelivery["ID"];
             $arResult["DELIVERY_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arDelivery["PRICE"], $arDelivery["CURRENCY"], $arResult["BASE_LANG_CURRENCY"]), SALE_VALUE_PRECISION);
             $bSelected = true;
         }
         if (IntVal($arDelivery["PERIOD_FROM"]) > 0 || IntVal($arDelivery["PERIOD_TO"]) > 0) {
             $arDelivery["PERIOD_TEXT"] = GetMessage("SALE_DELIV_PERIOD");
             if (IntVal($arDelivery["PERIOD_FROM"]) > 0) {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_FROM") . " " . IntVal($arDelivery["PERIOD_FROM"]);
             }
             if (IntVal($arDelivery["PERIOD_TO"]) > 0) {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_TO") . " " . IntVal($arDelivery["PERIOD_TO"]);
             }
             if ($arDelivery["PERIOD_TYPE"] == "H") {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_HOUR") . " ";
             } elseif ($arDelivery["PERIOD_TYPE"] == "M") {
                 $arDelivery["PERIOD_TEXT"] .= " " . GetMessage("SOA_MONTH") . " ";
             } else {