Exemplo n.º 1
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $APPLICATION;
     if ((is_set($arFields, "PRODUCT_ID") || $ACTION == "ADD") && intval($arFields["PRODUCT_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("KGP_EMPTY_PRODUCT"), "EMPTY_PRODUCT_ID");
         return false;
     }
     if ((is_set($arFields, "CATALOG_GROUP_ID") || $ACTION == "ADD") && intval($arFields["CATALOG_GROUP_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("KGP_EMPTY_CATALOG_GROUP"), "EMPTY_CATALOG_GROUP_ID");
         return false;
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("KGP_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
         return false;
     }
     if (isset($arFields['CURRENCY'])) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $APPLICATION->ThrowException(Loc::getMessage("KGP_NO_CURRENCY", array('#ID#' => $arFields["CURRENCY"])), "CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if ((is_set($arFields, "QUANTITY_FROM") || $ACTION == "ADD") && intval($arFields["QUANTITY_FROM"]) <= 0) {
         $arFields["QUANTITY_FROM"] = false;
     }
     if ((is_set($arFields, "QUANTITY_TO") || $ACTION == "ADD") && intval($arFields["QUANTITY_TO"]) <= 0) {
         $arFields["QUANTITY_TO"] = false;
     }
     return true;
 }
Exemplo n.º 2
0
 function Init()
 {
     if (\Bitrix\Main\Loader::includeModule('currency') && ($arCurrency = CCurrency::GetByID('RUR'))) {
         $base_currency = 'RUR';
     } else {
         $base_currency = 'RUB';
     }
     return array("SID" => "ems", "NAME" => GetMessage('SALE_DH_EMS_NAME'), "DESCRIPTION" => GetMessage('SALE_DH_EMS_DESCRIPTION'), "DESCRIPTION_INNER" => GetMessage('SALE_DH_EMS_DESCRIPTION_INNER'), "BASE_CURRENCY" => $base_currency, "HANDLER" => __FILE__, "DBGETSETTINGS" => array("CDeliveryEMS", "GetSettings"), "DBSETSETTINGS" => array("CDeliveryEMS", "SetSettings"), "GETCONFIG" => array("CDeliveryEMS", "GetConfig"), "COMPABILITY" => array("CDeliveryEMS", "Compability"), "CALCULATOR" => array("CDeliveryEMS", "Calculate"), "PROFILES" => array("delivery" => array("TITLE" => GetMessage("SALE_DH_EMS_DELIVERY_TITLE"), "DESCRIPTION" => '', "RESTRICTIONS_WEIGHT" => array(0, 31500), "RESTRICTIONS_SUM" => array(0))));
 }
Exemplo n.º 3
0
 public static function Init()
 {
     if ($arCurrency = CCurrency::GetByID('RUR')) {
         $base_currency = 'RUR';
     } else {
         $base_currency = 'RUB';
     }
     return array("SID" => "ups", "NAME" => GetMessage('SALE_DH_UPS_NAME'), "DESCRIPTION" => GetMessage('SALE_DH_UPS_DESCRIPTION'), "DESCRIPTION_INNER" => GetMessage('SALE_DH_UPS_DESCRIPTION_INNER'), "BASE_CURRENCY" => $base_currency, "HANDLER" => __FILE__, "DBGETSETTINGS" => array("CDeliveryUPS", "GetSettings"), "DBSETSETTINGS" => array("CDeliveryUPS", "SetSettings"), "GETCONFIG" => array("CDeliveryUPS", "GetConfig"), "COMPABILITY" => array("CDeliveryUPS", "Compability"), "CALCULATOR" => array("CDeliveryUPS", "Calculate"), "PROFILES" => array("express" => array("TITLE" => GetMessage("SALE_DH_UPS_EXPRESS_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_UPS_EXPRESS_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, CSaleMeasure::Convert(150, "LBS", "G")), "RESTRICTIONS_SUM" => array(0)), "express_saver" => array("TITLE" => GetMessage("SALE_DH_UPS_EXPRESS_SAVER_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_UPS_EXPRESS_SAVER_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, CSaleMeasure::Convert(150, "LBS", "G")), "RESTRICTIONS_SUM" => array(0))));
 }
Exemplo n.º 4
0
 function Init()
 {
     if ($arCurrency = CCurrency::GetByID('RUR')) {
         $base_currency = 'RUR';
     } else {
         $base_currency = 'RUB';
     }
     return array("SID" => "russianpost", "NAME" => GetMessage('SALE_DH_RUSSIANPOST_NAME'), "DESCRIPTION" => GetMessage('SALE_DH_RUSSIANPOST_DESCRIPTION'), "DESCRIPTION_INNER" => GetMessage('SALE_DH_RUSSIANPOST_DESCRIPTION_INNER') . GetMessage('SALE_DH_RUSSIANPOST_DESCRIPTION_INNER2'), "BASE_CURRENCY" => $base_currency, "HANDLER" => __FILE__, "DBGETSETTINGS" => array("CDeliveryRUSSIANPOST", "GetSettings"), "DBSETSETTINGS" => array("CDeliveryRUSSIANPOST", "SetSettings"), "GETCONFIG" => array("CDeliveryRUSSIANPOST", "GetConfig"), "COMPABILITY" => array("CDeliveryRUSSIANPOST", "Compability"), "CALCULATOR" => array("CDeliveryRUSSIANPOST", "Calculate"), "PROFILES" => array("ground" => array("TITLE" => GetMessage("SALE_DH_RUSSIANPOST_GROUND_TITLE"), "DESCRIPTION" => '', "RESTRICTIONS_WEIGHT" => array(0), "RESTRICTIONS_SUM" => array(0)), "avia" => array("TITLE" => GetMessage("SALE_DH_RUSSIANPOST_AVIA_TITLE"), "DESCRIPTION" => '', "RESTRICTIONS_WEIGHT" => array(0), "RESTRICTIONS_SUM" => array(0))));
 }
Exemplo n.º 5
0
 function Init()
 {
     // fix a possible currency bug
     if ($arCurrency = CCurrency::GetByID('RUR')) {
         $base_currency = 'RUR';
     } else {
         $base_currency = 'RUB';
     }
     return array("SID" => "cpcr", "NAME" => GetMessage('SALE_DH_CPCR_NAME'), "DESCRIPTION" => GetMessage('SALE_DH_CPCR_DESCRIPTION'), "DESCRIPTION_INNER" => GetMessage('SALE_DH_CPCR_DESCRIPTION_INNER'), "BASE_CURRENCY" => $base_currency, "HANDLER" => __FILE__, "COMPABILITY" => array("CDeliveryCPCR", "Compability"), "CALCULATOR" => array("CDeliveryCPCR", "Calculate"), "PROFILES" => array("simple" => array("TITLE" => GetMessage("SALE_DH_CPCR_SIMPLE_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_SIMPLE_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 31500), "RESTRICTIONS_SUM" => array(0, 500000)), "simple13" => array("TITLE" => GetMessage("SALE_DH_CPCR_SIMPLE13_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_SIMPLE_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 31500), "RESTRICTIONS_SUM" => array(0, 500000)), "simple18" => array("TITLE" => GetMessage("SALE_DH_CPCR_SIMPLE18_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_SIMPLE_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 31500), "RESTRICTIONS_SUM" => array(0, 500000)), "econom" => array("TITLE" => GetMessage("SALE_DH_CPCR_ECONOM_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_ECONOM_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 68000), "RESTRICTIONS_SUM" => array(0, 500000)), "bizon" => array("TITLE" => GetMessage("SALE_DH_CPCR_BIZON_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_BIZON_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 68000), "RESTRICTIONS_SUM" => array(0, 500000)), "colibri" => array("TITLE" => GetMessage("SALE_DH_CPCR_COLIBRI_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_COLIBRI_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 68000), "RESTRICTIONS_SUM" => array(0, 500000)), "pelican" => array("TITLE" => GetMessage("SALE_DH_CPCR_PELICAN_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_PELICAN_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 68000), "RESTRICTIONS_SUM" => array(0, 500000)), "fraxt" => array("TITLE" => GetMessage("SALE_DH_CPCR_FRAXT_TITLE"), "DESCRIPTION" => GetMessage("SALE_DH_CPCR_FRAXT_DESCRIPTION"), "RESTRICTIONS_WEIGHT" => array(0, 68000), "RESTRICTIONS_SUM" => array(0, 500000))));
 }
Exemplo n.º 6
0
	public static function Init()
	{
		if ($arCurrency = CCurrency::GetByID('RUR'))
		{
			$base_currency = 'RUR';
		}
		else
		{
			$base_currency = 'RUB';
		}

		return array(
			/* Basic description */
			"SID" => "ems",
			"NAME" => GetMessage('SALE_DH_EMS_NAME'),
			"DESCRIPTION" => GetMessage('SALE_DH_EMS_DESCRIPTION'),
			"DESCRIPTION_INNER" => GetMessage('SALE_DH_EMS_DESCRIPTION_INNER'),
			"BASE_CURRENCY" => $base_currency,

			"HANDLER" => __FILE__,

			/* Handler methods */
			"DBGETSETTINGS" => array("CDeliveryEMS", "GetSettings"),
			"DBSETSETTINGS" => array("CDeliveryEMS", "SetSettings"),
			"GETCONFIG" => array("CDeliveryEMS", "GetConfig"),

			"COMPABILITY" => array("CDeliveryEMS", "Compability"),
			"CALCULATOR" => array("CDeliveryEMS", "Calculate"),

			/* List of delivery profiles */
			"PROFILES" => array(
				"delivery" => array(
					"TITLE" => GetMessage("SALE_DH_EMS_DELIVERY_TITLE"),
					"DESCRIPTION" => '', //GetMessage("SALE_DH_EMS_DELIVERY_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 31500),
					"RESTRICTIONS_SUM" => array(0),
				),
			)
		);
	}
Exemplo n.º 7
0
<?php

$base_currency = CCurrency::GetByID('RUR') ? 'RUR' : 'RUB';
$arCMLCurrencies = array("USD" => "USD", "EUR" => "EUR", "RUR" => $base_currency, "RUB" => $base_currency, "руб." => $base_currency, "руб" => $base_currency);
Exemplo n.º 8
0
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$aContext = array(array("ICON" => "btn_list", "TEXT" => GetMessage("MAIN_ADMIN_MENU_LIST"), "LINK" => "currencies.php?lang=" . LANG, "TITLE" => GetMessage("MAIN_ADMIN_MENU_LIST")));
if (strlen($ID) > 0) {
    $aContext[] = array("ICON" => "btn_new", "TEXT" => GetMessage("MAIN_ADMIN_MENU_CREATE"), "LINK" => "currency_edit.php?lang=" . LANG, "TITLE" => GetMessage("MAIN_ADMIN_MENU_CREATE"));
    if ($CURRENCY_RIGHT == "W") {
        $aContext[] = array("ICON" => "btn_delete", "TEXT" => GetMessage("MAIN_ADMIN_MENU_DELETE"), "ONCLICK" => "javascript:if(confirm('" . GetMessage("CONFIRM_DEL_MESSAGE") . "'))window.location='currencies.php?action=delete&ID[]=" . CUtil::JSEscape($ID) . "&lang=" . LANG . "&" . bitrix_sessid_get() . "';");
    }
}
$context = new CAdminContextMenu($aContext);
$context->Show();
//Defaults
$f_SORT = "10";
$f_AMOUNT_CNT = "1";
if (strlen($ID) > 0 && !$bVarsFromForm) {
    $result = CCurrency::GetByID($ID);
    $f_AMOUNT_CNT = $result["AMOUNT_CNT"];
    $f_AMOUNT = number_format($result["AMOUNT"], 4);
    $f_SORT = $result["SORT"];
    $res = CCurrencyLang::GetList($by, $order, $ID);
    while ($ar = $res->Fetch()) {
        ${"l_FULL_NAME_" . $ar["LID"]} = $ar["FULL_NAME"];
        ${"l_FORMAT_STRING_" . $ar["LID"]} = $ar["FORMAT_STRING"];
        ${"l_DEC_POINT_" . $ar["LID"]} = $ar["DEC_POINT"];
        ${"l_THOUSANDS_SEP_" . $ar["LID"]} = $ar["THOUSANDS_SEP"];
        ${"l_THOUSANDS_VARIANT_" . $ar["LID"]} = $ar["THOUSANDS_VARIANT"];
        ${"l_DECIMALS_" . $ar["LID"]} = $ar["DECIMALS"];
    }
}
if ($bVarsFromForm) {
    $DB->InitTableVarsForEdit("b_catalog_currency", "", "f_");
Exemplo n.º 9
0
 function CheckFields($ACTION, &$arFields)
 {
     global $DB;
     global $APPLICATION;
     if ((is_set($arFields, "ACTIVE") || $ACTION == "ADD") && $arFields["ACTIVE"] != "Y") {
         $arFields["ACTIVE"] = "N";
     }
     if ((is_set($arFields, "DISCOUNT_TYPE") || $ACTION == "ADD") && $arFields["DISCOUNT_TYPE"] != "P") {
         $arFields["DISCOUNT_TYPE"] = "V";
     }
     if ((is_set($arFields, "SORT") || $ACTION == "ADD") && IntVal($arFields["SORT"]) <= 0) {
         $arFields["SORT"] = 100;
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         return false;
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGD_NO_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGD_NO_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if (is_set($arFields, "DISCOUNT_VALUE")) {
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
     }
     if ((is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") && DoubleVal($arFields["DISCOUNT_VALUE"]) <= 0) {
         $APPLICATION->ThrowException(GetMessage("SKGD_EMPTY_DVAL"), "ERROR_NO_DISCOUNT_VALUE");
         return false;
     }
     if (is_set($arFields, "PRICE_FROM")) {
         $arFields["PRICE_FROM"] = str_replace(",", ".", $arFields["PRICE_FROM"]);
         $arFields["PRICE_FROM"] = DoubleVal($arFields["PRICE_FROM"]);
     }
     if (is_set($arFields, "PRICE_TO")) {
         $arFields["PRICE_TO"] = str_replace(",", ".", $arFields["PRICE_TO"]);
         $arFields["PRICE_TO"] = DoubleVal($arFields["PRICE_TO"]);
     }
     /*
     if ($ACTION=="ADD"
     	&& (!is_set($arFields, "PRICE_FROM") && DoubleVal($arFields["PRICE_TO"])<=0
     	|| !is_set($arFields, "PRICE_TO") && DoubleVal($arFields["PRICE_FROM"])<=0
     	|| DoubleVal($arFields["PRICE_TO"])<=0 && DoubleVal($arFields["PRICE_FROM"])<=0))
     {
     	$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGD_WRONG_DBOUND"), "ERROR_BAD_BORDER");
     	return false;
     }
     */
     if ((is_set($arFields, "ACTIVE_FROM") || $ACTION == "ADD") && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANGUAGE_ID, "FULL")) {
         $arFields["ACTIVE_FROM"] = false;
     }
     if ((is_set($arFields, "ACTIVE_TO") || $ACTION == "ADD") && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANGUAGE_ID, "FULL")) {
         $arFields["ACTIVE_TO"] = false;
     }
     if ((is_set($arFields, 'USER_GROUPS') || $ACTION == "ADD") && (!is_array($arFields['USER_GROUPS']) || empty($arFields['USER_GROUPS']))) {
         $APPLICATION->ThrowException(GetMessage("BT_MOD_SALE_DISC_ERR_USER_GROUPS_ABSENT"), "USER_GROUPS");
         return false;
     }
     return true;
 }
Exemplo n.º 10
0
     if (!CCurrency::GetByID('UAH')) {
         $arFields = array("CURRENCY" => "UAH", "AMOUNT" => 39.41, "AMOUNT_CNT" => 10, "SORT" => 400);
         CCurrency::Add($arFields);
         $dbLangs = CLanguage::GetList($b, $o, array("ACTIVE" => "Y"));
         while ($arLangs = $dbLangs->Fetch()) {
             IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/install_lang.php", $arLangs["LID"]);
             $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "UAH", "FORMAT_STRING" => GetMessage("CUR_INSTALL_UAH_FORMAT_STRING") ? GetMessage("CUR_INSTALL_UAH_FORMAT_STRING") : "", "FULL_NAME" => GetMessage("CUR_INSTALL_UAH_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_UAH_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_UAH_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2, "HIDE_ZERO" => "Y");
             if (!empty($arFields)) {
                 CCurrencyLang::Add($arFields);
             }
         }
     }
     break;
 case 'bl':
     $iblockXMLFilePrices = WIZARD_SERVICE_RELATIVE_PATH . "/xml/" . LANGUAGE_ID . "/catalog_prices_bl.xml";
     if (!CCurrency::GetByID('BYR')) {
         $arFields = array("CURRENCY" => "BYR", "AMOUNT" => 36.72, "AMOUNT_CNT" => 10000, "SORT" => 500);
         CCurrency::Add($arFields);
         $dbLangs = CLanguage::GetList($b, $o, array("ACTIVE" => "Y"));
         while ($arLangs = $dbLangs->Fetch()) {
             IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/install_lang.php", $arLangs["LID"]);
             $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "BYR", "FORMAT_STRING" => GetMessage("CUR_INSTALL_BYR_FORMAT_STRING") ? GetMessage("CUR_INSTALL_BYR_FORMAT_STRING") : "", "FULL_NAME" => GetMessage("CUR_INSTALL_BYR_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_BYR_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_BYR_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2, "HIDE_ZERO" => "Y");
             if (!empty($arFields)) {
                 CCurrencyLang::Add($arFields);
             }
         }
     }
     break;
 default:
     $iblockXMLFilePrices = WIZARD_SERVICE_RELATIVE_PATH . "/xml/" . LANGUAGE_ID . "/catalog_prices.xml";
     break;
Exemplo n.º 11
0
 public static function GetCurrency($currency)
 {
     return CCurrency::GetByID($currency);
 }
Exemplo n.º 12
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $DB, $USER, $APPLICATION;
     if (is_set($arFields, "PRODUCT_ID")) {
         $arFields["PRODUCT_ID"] = IntVal($arFields["PRODUCT_ID"]);
     }
     if ((is_set($arFields, "PRODUCT_ID") || $ACTION == "ADD") && IntVal($arFields["PRODUCT_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("Empty product field", "EMPTY_PRODUCT_ID");
         return false;
     }
     if (is_set($arFields, "CALLBACK_FUNC") && strlen($arFields["CALLBACK_FUNC"]) > 0 || is_set($arFields, "PRODUCT_PROVIDER_CLASS") && strlen($arFields["PRODUCT_PROVIDER_CLASS"]) > 0 && (!is_set($arFields, "IGNORE_CALLBACK_FUNC") || $arFields["IGNORE_CALLBACK_FUNC"] != "Y")) {
         /** @var $productProvider IBXSaleProductProvider */
         if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arFields["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arFields["PRODUCT_PROVIDER_CLASS"]))) {
             $arPrice = $productProvider::GetProductData(array("PRODUCT_ID" => $arFields["PRODUCT_ID"], "QUANTITY" => $arFields["QUANTITY"], "RENEWAL" => $arFields["RENEWAL"], "USER_ID" => $arFields["USER_ID"], "SITE_ID" => $arFields["LID"]));
         } else {
             $arPrice = CSaleBasket::ExecuteCallbackFunction($arFields["CALLBACK_FUNC"], $arFields["MODULE"], $arFields["PRODUCT_ID"], $arFields["QUANTITY"], $arFields["RENEWAL"], $arFields["USER_ID"], $arFields["LID"]);
         }
         if (is_array($arPrice) && count($arPrice) > 0) {
             $arFields["PRICE"] = $arPrice["PRICE"];
             $arFields["CURRENCY"] = $arPrice["CURRENCY"];
             $arFields["CAN_BUY"] = "Y";
             $arFields["PRODUCT_PRICE_ID"] = $arPrice["PRODUCT_PRICE_ID"];
             $arFields["NOTES"] = $arPrice["NOTES"];
         } else {
             $arFields["CAN_BUY"] = "N";
         }
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if (is_set($arFields, "DISCOUNT_PRICE") || $ACTION == "ADD") {
         $arFields["DISCOUNT_PRICE"] = str_replace(",", ".", $arFields["DISCOUNT_PRICE"]);
         $arFields["DISCOUNT_PRICE"] = DoubleVal($arFields["DISCOUNT_PRICE"]);
     }
     if (is_set($arFields, "VAT_RATE") || $ACTION == "ADD") {
         $arFields["VAT_RATE"] = str_replace(",", ".", $arFields["VAT_RATE"]);
         $arFields["VAT_RATE"] = DoubleVal($arFields["VAT_RATE"]);
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("Empty currency field", "EMPTY_CURRENCY");
         return false;
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("Empty site field", "EMPTY_SITE");
         return false;
     }
     if ($ACTION != "ADD" && IntVal($ID) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("Empty ID field", "EMPTY_ID");
         return false;
     }
     if (is_set($arFields, "ORDER_ID")) {
         if (!($arOrder = CSaleOrder::GetByID($arFields["ORDER_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["ORDER_ID"], GetMessage("SKGB_NO_ORDER")), "ERROR_NO_ORDER");
             return false;
         }
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGB_NO_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGB_NO_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if ($ACTION != "ADD" && (strlen($arFields["LID"]) <= 0 && (is_set($arFields, "PRICE") || is_set($arFields, "CURRENCY")) || is_set($arFields, "PRICE") && !is_set($arFields, "CURRENCY") || !is_set($arFields, "PRICE") && is_set($arFields, "CURRENCY"))) {
         $tmp_res = CSaleBasket::GetByID($ID);
         if (strlen($arFields["LID"]) <= 0) {
             $arFields["LID"] = $tmp_res["LID"];
         }
         if (!is_set($arFields, "PRICE")) {
             $arFields["PRICE"] = $tmp_res["PRICE"];
         }
         if (!is_set($arFields, "CURRENCY") || strlen($arFields["CURRENCY"]) <= 0) {
             $arFields["CURRENCY"] = $tmp_res["CURRENCY"];
         }
     }
     if (strlen($arFields["LID"]) > 0 && strlen($arFields["CURRENCY"]) > 0) {
         $BASE_LANG_CURR = CSaleLang::GetLangCurrency($arFields["LID"]);
         if ($BASE_LANG_CURR != $arFields["CURRENCY"]) {
             $arFields["PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arFields["PRICE"], $arFields["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
             if (is_set($arFields, "DISCOUNT_PRICE")) {
                 $arFields["DISCOUNT_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arFields["DISCOUNT_PRICE"], $arFields["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
             }
             $arFields["CURRENCY"] = $BASE_LANG_CURR;
         }
     }
     // Changed by Sigurd, 2007-08-16
     if (is_set($arFields, "QUANTITY")) {
         $arFields["QUANTITY"] = DoubleVal($arFields["QUANTITY"]);
     }
     if ((is_set($arFields, "QUANTITY") || $ACTION == "ADD") && DoubleVal($arFields["QUANTITY"]) <= 0) {
         $arFields["QUANTITY"] = 1;
     }
     if (is_set($arFields, "DELAY") && $arFields["DELAY"] != "Y") {
         $arFields["DELAY"] = "N";
     }
     if (is_set($arFields, "CAN_BUY") && $arFields["CAN_BUY"] != "Y") {
         $arFields["CAN_BUY"] = "N";
     }
     if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("Empty name field", "EMPTY_NAME");
         return false;
     }
     if ($ACTION == "ADD" && !is_set($arFields, "FUSER_ID")) {
         $arFields["FUSER_ID"] = CSaleBasket::GetBasketUserID();
     }
     if ((is_set($arFields, "FUSER_ID") || $ACTION == "ADD") && IntVal($arFields["FUSER_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("Empty basket user field", "EMPTY_FUSER_ID");
         return false;
     }
     return true;
 }
Exemplo n.º 13
0
	{
		$arParams['CURRENCY_ID'] = '';
	}
	$arParams["PRICE_VAT_INCLUDE"] = $arParams["PRICE_VAT_INCLUDE"] !== "N";

	$arConvertParams = array();
	if ($arParams['CONVERT_CURRENCY'] == 'Y')
	{
		if (!CModule::IncludeModule('currency'))
		{
			$arParams['CONVERT_CURRENCY'] = 'N';
			$arParams['CURRENCY_ID'] = '';
		}
		else
		{
			$arCurrencyInfo = CCurrency::GetByID($arParams['CURRENCY_ID']);
			if (!(is_array($arCurrencyInfo) && !empty($arCurrencyInfo)))
			{
				$arParams['CONVERT_CURRENCY'] = 'N';
				$arParams['CURRENCY_ID'] = '';
			}
			else
			{
				$arParams['CURRENCY_ID'] = $arCurrencyInfo['CURRENCY'];
				$arConvertParams['CURRENCY_ID'] = $arCurrencyInfo['CURRENCY'];
			}
		}
	}
	$arResult['CONVERT_CURRENCY'] = $arConvertParams;

	$countSetDefaultItems = 0;
Exemplo n.º 14
0
	function CheckFields($ACTION, &$arFields)
	{
		global $DB;

		if ((is_set($arFields, "NAME") || $ACTION=="ADD") && strlen($arFields["NAME"]) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGD_EMPTY_DELIVERY"), "ERROR_NO_NAME");
			return false;
		}

		if ((is_set($arFields, "LID") || $ACTION=="ADD") && strlen($arFields["LID"]) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGD_EMPTY_SITE"), "ERROR_NO_SITE");
			return false;
		}

		if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y")
			$arFields["ACTIVE"] = "N";
		if ((is_set($arFields, "SORT") || $ACTION=="ADD") && IntVal($arFields["SORT"]) <= 0)
			$arFields["SORT"] = 100;

		if (is_set($arFields, "PRICE"))
		{
			$arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
			$arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
		}
		if ((is_set($arFields, "PRICE") || $ACTION=="ADD") && DoubleVal($arFields["PRICE"]) < 0)
			return false;

		if ((is_set($arFields, "CURRENCY") || $ACTION=="ADD") && strlen($arFields["CURRENCY"]) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGD_EMPTY_CURRENCY"), "ERROR_NO_CURRENCY");
			return false;
		}

		if (is_set($arFields, "ORDER_PRICE_FROM"))
		{
			$arFields["ORDER_PRICE_FROM"] = str_replace(",", ".", $arFields["ORDER_PRICE_FROM"]);
			$arFields["ORDER_PRICE_FROM"] = DoubleVal($arFields["ORDER_PRICE_FROM"]);
		}

		if (is_set($arFields, "ORDER_PRICE_TO"))
		{
			$arFields["ORDER_PRICE_TO"] = str_replace(",", ".", $arFields["ORDER_PRICE_TO"]);
			$arFields["ORDER_PRICE_TO"] = DoubleVal($arFields["ORDER_PRICE_TO"]);
		}

		if ((is_set($arFields, "LOCATIONS") || $ACTION=="ADD") && (!is_array($arFields["LOCATIONS"]) || count($arFields["LOCATIONS"]) <= 0))
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGD_EMPTY_LOCATION"), "ERROR_NO_LOCATIONS");
			return false;
		}

		if (is_set($arFields, "LID"))
		{
			$dbSite = CSite::GetByID($arFields["LID"]);
			if (!$dbSite->Fetch())
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGD_NO_SITE")), "ERROR_NO_SITE");
				return false;
			}
		}

		if (is_set($arFields, "CURRENCY"))
		{
			if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"])))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGD_NO_CURRENCY")), "ERROR_NO_CURRENCY");
				return false;
			}
		}

		if (is_set($arFields, "LOCATIONS"))
		{
			$countField = count($arFields["LOCATIONS"]);
			for ($i = 0; $i < $countField; $i++)
			{
				if ($arFields["LOCATIONS"][$i]["LOCATION_TYPE"] != "G")
					$arFields["LOCATIONS"][$i]["LOCATION_TYPE"] = "L";
			}
		}

		return True;
	}
Exemplo n.º 15
0
	public static function CheckFields($ACTION, &$arFields, $ID = 0)
	{
		global $USER_FIELD_MANAGER, $DB;

		if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0)
			$arFields["LID"] = $arFields["SITE_ID"];

		if ((is_set($arFields, "LID") || $ACTION=="ADD") && strlen($arFields["LID"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
			return false;
		}
		if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION=="ADD") && IntVal($arFields["PERSON_TYPE_ID"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
			return false;
		}
		if ((is_set($arFields, "USER_ID") || $ACTION=="ADD") && IntVal($arFields["USER_ID"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
			return false;
		}

		if (is_set($arFields, "PAYED") && $arFields["PAYED"]!="Y")
			$arFields["PAYED"]="N";
		if (is_set($arFields, "CANCELED") && $arFields["CANCELED"]!="Y")
			$arFields["CANCELED"]="N";
		if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"])<=0)
			$arFields["STATUS_ID"]="N";
		if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"]!="Y")
			$arFields["ALLOW_DELIVERY"]="N";

		if (is_set($arFields, "PRICE") || $ACTION=="ADD")
		{
			$arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
			$arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
		}
		if (is_set($arFields, "PRICE_DELIVERY") || $ACTION=="ADD")
		{
			$arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
			$arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
		}
		if (is_set($arFields, "SUM_PAID") || $ACTION=="ADD")
		{
			$arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
			$arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
		}
		if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION=="ADD")
		{
			$arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
			$arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
		}
		if (is_set($arFields, "TAX_VALUE") || $ACTION=="ADD")
		{
			$arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
			$arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
		}

		if(!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || (is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")))
		{
			$arFields["UPDATED_1C"] = "N";
		}

		if ((is_set($arFields, "CURRENCY") || $ACTION=="ADD") && strlen($arFields["CURRENCY"])<=0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
			return false;
		}

		if (is_set($arFields, "CURRENCY"))
		{
			if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"])))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
				return false;
			}
		}

		if (is_set($arFields, "LID"))
		{
			$dbSite = CSite::GetByID($arFields["LID"]);
			if (!$dbSite->Fetch())
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
				return false;
			}
		}

		if (is_set($arFields, "USER_ID"))
		{
			$dbUser = CUser::GetByID($arFields["USER_ID"]);
			if (!$dbUser->Fetch())
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
				return false;
			}
		}

		if (is_set($arFields, "PERSON_TYPE_ID"))
		{
			if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"])))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
				return false;
			}
		}

		if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0)
		{
			if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"]))))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], GetMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
				return false;
			}
		}

		if (is_set($arFields, "DELIVERY_ID") && (
				strpos($arFields["DELIVERY_ID"], ":") !== false
				||
				IntVal($arFields["DELIVERY_ID"]) > 0
			)
		)
		{
			if (strpos($arFields["DELIVERY_ID"], ":") !== false)
			{
				$arId = explode(":", $arFields["DELIVERY_ID"]);
				$obDelivery = new CSaleDeliveryHandler();
				if ($arDelivery = $obDelivery->GetBySID($arId[0]))
				{
					if ($arDelivery = $arDelivery->Fetch())
					{
						if (!is_set($arDelivery["PROFILES"], $arId[1]))
						{
							$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
							return false;
						}
					}
				}
				else
				{
					$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
					return false;
				}
			}
			else
			{
				if (!($arDelivery = CSaleDelivery::GetByID(IntVal($arFields["DELIVERY_ID"]))))
				{
					$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
					return false;
				}
			}
		}

		if (is_set($arFields, "STATUS_ID"))
		{
			if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"])))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], GetMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
				return false;
			}
		}

		if (is_set($arFields, "ACCOUNT_NUMBER") && $ACTION=="UPDATE")
		{
			if (strlen($arFields["ACCOUNT_NUMBER"]) <= 0)
			{
				$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_ACCOUNT_NUMBER"), "EMPTY_ACCOUNT_NUMBER");
				return false;
			}
			else
			{
				$dbres = $DB->Query("SELECT ID, ACCOUNT_NUMBER FROM b_sale_order WHERE ACCOUNT_NUMBER = '".$DB->ForSql($arFields["ACCOUNT_NUMBER"])."'", true);
				if ($arRes = $dbres->GetNext())
				{
					if (is_array($arRes) && $arRes["ID"] != $ID)
					{
						$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EXISTING_ACCOUNT_NUMBER"), "EXISTING_ACCOUNT_NUMBER");
						return false;
					}
				}
			}
		}

		if (!$USER_FIELD_MANAGER->CheckFields("ORDER", $ID, $arFields))
		{
			return false;
		}

		return True;
	}
Exemplo n.º 16
0
 public static function getRub()
 {
     $result = "RUB";
     if ($arCurrency = \CCurrency::GetByID('RUR')) {
         $result = 'RUR';
     }
     return $result;
 }
Exemplo n.º 17
0
	function CheckFields($ACTION, &$arFields, $ID = 0)
	{
		global $APPLICATION;
		static $orderList = array();

		$ACTION = strtoupper($ACTION);

		if (array_key_exists('ID', $arFields))
			unset($arFields['ID']);

		if ($ACTION != "ADD" && (int)$ID <=0)
		{
			$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_BASKET_ERR_ID_ABSENT'), "ID");
			return false;
		}

		if ('ADD' == $ACTION)
		{
			if (!array_key_exists('CUSTOM_PRICE', $arFields))
				$arFields['CUSTOM_PRICE'] = '';
		}

		if (array_key_exists('CUSTOM_PRICE', $arFields) && 'Y' != $arFields['CUSTOM_PRICE'])
			$arFields['CUSTOM_PRICE'] = 'N';

		if (is_set($arFields, "PRODUCT_ID"))
			$arFields["PRODUCT_ID"] = IntVal($arFields["PRODUCT_ID"]);
		if ((is_set($arFields, "PRODUCT_ID") || $ACTION=="ADD") && IntVal($arFields["PRODUCT_ID"])<=0)
		{
			$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_BASKET_ERR_PRODUCT_ID_ABSENT'), "PRODUCT_ID");
			return false;
		}

		if (!array_key_exists('IGNORE_CALLBACK_FUNC', $arFields) || 'Y' != $arFields['IGNORE_CALLBACK_FUNC'])
		{
			if ((array_key_exists("CALLBACK_FUNC", $arFields) && !empty($arFields["CALLBACK_FUNC"]))
				|| (array_key_exists("PRODUCT_PROVIDER_CLASS", $arFields) && !empty($arFields["PRODUCT_PROVIDER_CLASS"]))
				)
			{
				/** @var $productProvider IBXSaleProductProvider */
				if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arFields["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arFields["PRODUCT_PROVIDER_CLASS"])))
				{
					$providerParams = array(
						"PRODUCT_ID" => $arFields["PRODUCT_ID"],
						"QUANTITY" => $arFields["QUANTITY"],
						"RENEWAL" => $arFields["RENEWAL"],
						"USER_ID" => (isset($arFields["USER_ID"]) ? $arFields["USER_ID"] : 0),
						"SITE_ID" => (isset($arFields["LID"]) ? $arFields["LID"] : false),
						"BASKET_ID" => $ID
					);
					if (isset($arFields['NOTES']))
						$providerParams['NOTES'] = $arFields['NOTES'];
					$arPrice = $productProvider::GetProductData($providerParams);
					unset($providerParams);
				}
				else
				{
					$arPrice = CSaleBasket::ExecuteCallbackFunction(
						$arFields["CALLBACK_FUNC"],
						$arFields["MODULE"],
						$arFields["PRODUCT_ID"],
						$arFields["QUANTITY"],
						$arFields["RENEWAL"],
						$arFields["USER_ID"],
						$arFields["LID"]
					);
				}

				if (!empty($arPrice) && is_array($arPrice))
				{
					$arFields["PRICE"] = $arPrice["PRICE"];
					$arFields["CURRENCY"] = $arPrice["CURRENCY"];
					$arFields["CAN_BUY"] = "Y";
					$arFields["PRODUCT_PRICE_ID"] = $arPrice["PRODUCT_PRICE_ID"];
					$arFields["NOTES"] = $arPrice["NOTES"];
					if (!isset($arFields["NAME"]))
						$arFields["NAME"] = $arPrice["NAME"];
				}
				else
				{
					$arFields["CAN_BUY"] = "N";
				}
			}
		}

		if (is_set($arFields, "PRICE") || $ACTION=="ADD")
		{
			$arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
			$arFields["PRICE"] = floatval($arFields["PRICE"]);
		}

		if (is_set($arFields, "DISCOUNT_PRICE") || $ACTION=="ADD")
		{
			$arFields["DISCOUNT_PRICE"] = str_replace(",", ".", $arFields["DISCOUNT_PRICE"]);
			$arFields["DISCOUNT_PRICE"] = floatval($arFields["DISCOUNT_PRICE"]);
		}

		if (is_set($arFields, "VAT_RATE") || $ACTION=="ADD")
		{
			$arFields["VAT_RATE"] = str_replace(",", ".", $arFields["VAT_RATE"]);
			$arFields["VAT_RATE"] = floatval($arFields["VAT_RATE"]);
		}

		if ((is_set($arFields, "CURRENCY") || $ACTION=="ADD") && strlen($arFields["CURRENCY"])<=0)
		{
			$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_BASKET_ERR_CURRENCY_ABSENT'), "CURRENCY");
			return false;
		}

		if ((is_set($arFields, "LID") || $ACTION=="ADD") && strlen($arFields["LID"])<=0)
		{
			$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_BASKET_ERR_SITE_ID_ABSENT'), "LID");
			return false;
		}

		if (is_set($arFields, "ORDER_ID"))
		{
			if (!isset($orderList[$arFields["ORDER_ID"]]))
			{
				$rsOrders = CSaleOrder::GetList(
					array(),
					array('ID' => $arFields["ORDER_ID"]),
					false,
					false,
					array('ID')
				);
				if ($arOrder = $rsOrders->Fetch())
				{
					$orderList[$arFields["ORDER_ID"]] = true;
				}
			}
			if (!isset($orderList[$arFields["ORDER_ID"]]))
			{
				$APPLICATION->ThrowException(str_replace("#ID#", $arFields["ORDER_ID"], Loc::getMessage("SKGB_NO_ORDER")), "ORDER_ID");
				return false;
			}
		}

		if (is_set($arFields, "CURRENCY"))
		{
			if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"])))
			{
				$APPLICATION->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], Loc::getMessage("SKGB_NO_CURRENCY")), "CURRENCY");
				return false;
			}
		}

		if (is_set($arFields, "LID"))
		{
			$dbSite = CSite::GetByID($arFields["LID"]);
			if (!$dbSite->Fetch())
			{
				$APPLICATION->ThrowException(str_replace("#ID#", $arFields["LID"], Loc::getMessage("SKGB_NO_SITE")), "LID");
				return false;
			}
		}

		if ($ACTION!="ADD"
			&& (strlen($arFields["LID"])<=0
					&& (is_set($arFields, "PRICE") || is_set($arFields, "CURRENCY"))
				|| (is_set($arFields, "PRICE") && !is_set($arFields, "CURRENCY"))
				|| (!is_set($arFields, "PRICE") && is_set($arFields, "CURRENCY"))
				)
			)
		{
			$tmp_res = CSaleBasket::GetByID($ID);
			if (strlen($arFields["LID"])<=0)
				$arFields["LID"] = $tmp_res["LID"];
			if (!is_set($arFields, "PRICE"))
				$arFields["PRICE"] = $tmp_res["PRICE"];
			if (!is_set($arFields, "CURRENCY") || strlen($arFields["CURRENCY"])<=0)
				$arFields["CURRENCY"] = $tmp_res["CURRENCY"];
		}

		if (strlen($arFields["LID"])>0 && strlen($arFields["CURRENCY"])>0)
		{
			$BASE_LANG_CURR = CSaleLang::GetLangCurrency($arFields["LID"]);
			if ($BASE_LANG_CURR != $arFields["CURRENCY"])
			{
				$arFields["PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arFields["PRICE"], $arFields["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
				if (is_set($arFields, "DISCOUNT_PRICE"))
					$arFields["DISCOUNT_PRICE"] = roundEx(CCurrencyRates::ConvertCurrency($arFields["DISCOUNT_PRICE"], $arFields["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
				$arFields["CURRENCY"] = $BASE_LANG_CURR;
			}
		}

		// Changed by Sigurd, 2007-08-16
		if (is_set($arFields, "QUANTITY"))
			$arFields["QUANTITY"] = floatval($arFields["QUANTITY"]);
		if ((is_set($arFields, "QUANTITY") || $ACTION=="ADD") && floatval($arFields["QUANTITY"]) <= 0)
			$arFields["QUANTITY"] = 1;

		if (is_set($arFields, "DELAY") && $arFields["DELAY"]!="Y")
			$arFields["DELAY"]="N";
		if (is_set($arFields, "CAN_BUY") && $arFields["CAN_BUY"]!="Y")
			$arFields["CAN_BUY"]="N";

		if ((is_set($arFields, "NAME") || $ACTION=="ADD") && strlen($arFields["NAME"])<=0)
		{
			$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_BASKET_ERR_NAME_ABSENT'), "NAME");
			return false;
		}

		if ($ACTION=="ADD" && !is_set($arFields, "FUSER_ID"))
			$arFields["FUSER_ID"] = CSaleBasket::GetBasketUserID();

		if ((is_set($arFields, "FUSER_ID") || $ACTION=="ADD") && IntVal($arFields["FUSER_ID"])<=0)
		{
			$APPLICATION->ThrowException(Loc::getMessage('BT_MOD_SALE_BASKET_ERR_FUSER_ID_ABSENT'), "FUSER_ID");
			return false;
		}

		if (array_key_exists("TYPE", $arFields))
		{
			$arFields["TYPE"] = intval($arFields["TYPE"]);
			if ($arFields["TYPE"] != CSaleBasket::TYPE_SET)
			{
				unset($arFields["TYPE"]);
			}
		}

		if (array_key_exists('~TYPE', $arFields))
		{
			unset($arFields['~TYPE']);
		}

		if (array_key_exists('CATALOG_XML_ID', $arFields))
		{
			$arFields['CATALOG_XML_ID'] = (string)$arFields['CATALOG_XML_ID'];
			if ($arFields['CATALOG_XML_ID'] === '')
			{
				unset($arFields['CATALOG_XML_ID']);

				if (array_key_exists('~CATALOG_XML_ID', $arFields))
				{
					unset($arFields['~CATALOG_XML_ID']);
				}
			}
		}

		return true;
	}
Exemplo n.º 18
0
	/**
	 * <p>Функция возвращает массив языконезависимых параметров валюты по ее коду <b>currency</b>. Функция является оболочкой функции <a href="http://dev.1c-bitrix.ru/api_help/currency/developer/ccurrency/ccurrency__getbyid.a0947d8b.php">CCurrency::GetByID</a>.</p>
	 *
	 *
	 *
	 *
	 * @param string $currency  Код валюты.
	 *
	 *
	 *
	 * @return array <p>Ассоциативный массив с ключами</p><table class="tnormal" width="100%"> <tr> <th
	 * width="20%">Ключ</th> <th>Описание</th> </tr> <tr> <td>CURRENCY</td> <td>Код валюты
	 * (трехсимвольный)</td> </tr> <tr> <td>AMOUNT_CNT</td> <td>Количество единиц валюты
	 * по-умолчанию, которое учавствует в задании курса валюты
	 * (например, если 10 Датских крон стоят 48.7 рублей, то 10 - это
	 * количество единиц)</td> </tr> <tr> <td>AMOUNT</td> <td>Курс валюты по-умолчанию
	 * (одна из валют сайта должна иметь курс 1, она называется базовой,
	 * остальные валюты имеют курс относительно базовой валюты)</td> </tr>
	 * <tr> <td>SORT</td> <td>Порядок сортировки.</td> </tr> <tr> <td>DATE_UPDATE</td> <td>Дата
	 * последнего изменения записи.</td> </tr> </table><br><br>
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/currency/developer/ccurrency/ccurrency__getcurrency.205e6985.php
	 * @author Bitrix
	 */
	public static function GetCurrency($currency)
	{
		$arRes = CCurrency::GetByID($currency);
		return $arRes;
	}
Exemplo n.º 19
0
        }
        LocalRedirect('/bitrix/admin/currency_edit.php?ID=' . $ID . '&lang=' . LANGUAGE_ID . '&' . $tabControl->ActiveTabParam());
    }
}
$defaultValues = array('CURRENCY' => '', 'AMOUNT_CNT' => 1, 'AMOUNT' => 1, 'SORT' => 100, 'NUMCODE' => '', 'BASE' => 'N');
$defaultLangValues = array('FULL_NAME' => '', 'FORMAT_STRING' => '#', 'DEC_POINT' => '.', 'THOUSANDS_SEP' => '', 'DECIMALS' => 2, 'THOUSANDS_VARIANT' => CCurrencyLang::SEP_SPACE, 'HIDE_ZERO' => 'Y');
if ($ID != '') {
    $APPLICATION->SetTitle(GetMessage("CURRENCY_EDIT_TITLE"));
} else {
    $APPLICATION->SetTitle(GetMessage("CURRENCY_NEW_TITLE"));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$currency = $defaultValues;
$currencyLangs = array_fill_keys($langID, $defaultLangValues);
if ($ID != '') {
    $currency = CCurrency::GetByID($ID);
    if (empty($currency)) {
        $ID = '';
        $currency = $defaultValues;
    } else {
        $by = 'currency';
        $order = 'asc';
        $langIterator = CCurrencyLang::GetList($by, $order, $ID);
        while ($lang = $langIterator->Fetch()) {
            $lang['THOUSANDS_SEP'] = (string) $lang['THOUSANDS_SEP'];
            $lang['THOUSANDS_VARIANT'] = (string) $lang['THOUSANDS_VARIANT'];
            $currencyLangs[$lang['LID']] = $lang;
        }
        unset($lang, $langIterator, $order, $by);
    }
}
Exemplo n.º 20
0
	public static function Init()
	{
		// fix a possible currency bug
		if ($arCurrency = CCurrency::GetByID('RUR'))
		{
			$base_currency = 'RUR';
		}
		else
		{
			$base_currency = 'RUB';
		}

		return array(
			/* Basic description */
			"SID" => "cpcr", // unique string identifier
			"NAME" => GetMessage('SALE_DH_CPCR_NAME'), // handler public title
			"DESCRIPTION" => GetMessage('SALE_DH_CPCR_DESCRIPTION'), // handler public dedcription
			"DESCRIPTION_INNER" => GetMessage('SALE_DH_CPCR_DESCRIPTION_INNER'), // handler private description for admin panel
			"BASE_CURRENCY" => $base_currency, // handler base currency

			"HANDLER" => __FILE__, // handler path - don't change it if you do not surely know what you are doin

			"COMPABILITY" => array("CDeliveryCPCR", "Compability"), // callback method to check whether handler is compatible with current order
			"CALCULATOR" => array("CDeliveryCPCR", "Calculate"), // callback method to calculate delivery price

			/* List of delivery profiles */
			"PROFILES" => array(
				"simple" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_SIMPLE_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_SIMPLE_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 31500),
					"RESTRICTIONS_SUM" => array(0, 500000),
				),
				"simple13" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_SIMPLE13_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_SIMPLE_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 31500),
					"RESTRICTIONS_SUM" => array(0, 500000),
				),
				"simple18" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_SIMPLE18_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_SIMPLE_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 31500),
					"RESTRICTIONS_SUM" => array(0, 500000),
				),
				"econom" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_ECONOM_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_ECONOM_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 68000),
					"RESTRICTIONS_SUM" => array(0, 500000),
				),

				"bizon" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_BIZON_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_BIZON_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 68000),
					"RESTRICTIONS_SUM" => array(0, 500000),
				),
				"colibri" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_COLIBRI_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_COLIBRI_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 68000),
					"RESTRICTIONS_SUM" => array(0, 500000),
				),
				"pelican" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_PELICAN_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_PELICAN_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 68000),
					"RESTRICTIONS_SUM" => array(0, 500000),
				),
				"fraxt" => array(
					"TITLE" => GetMessage("SALE_DH_CPCR_FRAXT_TITLE"),
					"DESCRIPTION" => GetMessage("SALE_DH_CPCR_FRAXT_DESCRIPTION"),

					"RESTRICTIONS_WEIGHT" => array(0, 68000),
					"RESTRICTIONS_SUM" => array(0, 500000),
				)
			)
		);
	}
Exemplo n.º 21
0
     }
     /*		if ($GLOBALS["APPLICATION"]->GetFileAccessPermission($SETUP_FILE_NAME) < "W")
     			$strExportErrorMessage .= str_replace("#FILE#", $SETUP_FILE_NAME, "You do not have access rights to add or modify #FILE#")."<br>"; */
 }
 if (strlen($strExportErrorMessage) <= 0) {
     if (!($fp = @fopen($_SERVER["DOCUMENT_ROOT"] . $SETUP_FILE_NAME, "wb"))) {
         $strExportErrorMessage .= "Can not open \"" . $_SERVER["DOCUMENT_ROOT"] . $SETUP_FILE_NAME . "\" file for writing.\n";
     } else {
         if (!@fwrite($fp, "product_url\tname\tdescription\timage_url\tcategory\tprice\n")) {
             $strExportErrorMessage .= "Can not write in \"" . $_SERVER["DOCUMENT_ROOT"] . $SETUP_FILE_NAME . "\" file.\n";
             @fclose($fp);
         }
     }
 }
 if (strlen($strExportErrorMessage) <= 0) {
     if (!($ar_usd_cur = CCurrency::GetByID("USD"))) {
         $strExportErrorMessage .= "USD currency is not found.\n";
     }
 }
 if (strlen($strExportErrorMessage) <= 0) {
     $db_elems = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
     while ($ar_elems = $db_elems->GetNext()) {
         $ar_file = CFile::GetFileArray($ar_elems["DETAIL_PICTURE"]);
         if (!$ar_file) {
             $ar_file = CFile::GetFileArray($ar_elems["PREVIEW_PICTURE"]);
         }
         if ($ar_file) {
             if (substr($ar_file["SRC"], 0, 1) == "/") {
                 $strImage = "http://" . COption::GetOptionString("main", "server_name", $SERVER_NAME) . $ar_file["SRC"];
             } else {
                 $strImage = $ar_file["SRC"];
Exemplo n.º 22
0
	public static function RecountBaseCurrency($new_base_currency)
	{
		$err_mess = "File: ".__FILE__."<br>Line: ";
		$DB = CDatabase::GetModuleConnection('statistic');
		$base_currency = GetStatisticBaseCurrency();
		if ($base_currency!="xxx" && strlen($base_currency)>0)
		{
			if (CModule::IncludeModule("currency"))
			{
				if (CCurrency::GetByID($base_currency))
				{
					$rate = CCurrencyRates::GetConvertFactor($base_currency, $new_base_currency);
					if ($rate!=1 && $rate>0)
					{
						$arUpdate = array(
							array("TABLE" => "b_stat_adv", "FIELDS" => array("COST", "REVENUE")),
							array("TABLE" => "b_stat_event", "FIELDS" => array("MONEY")),
							array("TABLE" => "b_stat_event_day", "FIELDS" => array("MONEY")),
							array("TABLE" => "b_stat_event_list", "FIELDS" => array("MONEY"))
							);
						set_time_limit(0);
						ignore_user_abort(true);
						$DB->StartTransaction();
						foreach ($arUpdate as $arr)
						{
							$arFields = $arr["FIELDS"];
							$strSql = "UPDATE ".$arr["TABLE"]." SET ";
							$i = 0;
							$str = "";
							foreach ($arFields as $field)
							{
								if ($i>0) $str .= ", ";
								$str .= $field." = round(".$field."*".$rate.",2)";
								$i++;
							}
							$DB->Query($strSql.$str, false, $err_mess.__LINE__);
						}
						$DB->Commit();
					}
				}
			}
		}
	}
Exemplo n.º 23
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $USER_FIELD_MANAGER, $DB, $APPLICATION;
     if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0) {
         $arFields["LID"] = $arFields["SITE_ID"];
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
         return false;
     }
     if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
         return false;
     }
     if (is_set($arFields, "PAYED") && $arFields["PAYED"] != "Y") {
         $arFields["PAYED"] = "N";
     }
     if (is_set($arFields, "CANCELED") && $arFields["CANCELED"] != "Y") {
         $arFields["CANCELED"] = "N";
     }
     if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"]) <= 0) {
         $arFields["STATUS_ID"] = "N";
     }
     if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"] != "Y") {
         $arFields["ALLOW_DELIVERY"] = "N";
     }
     if (is_set($arFields, "EXTERNAL_ORDER") && $arFields["EXTERNAL_ORDER"] != "Y") {
         $arFields["EXTERNAL_ORDER"] = "N";
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if (is_set($arFields, "PRICE_DELIVERY") || $ACTION == "ADD") {
         $arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
         $arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
     }
     if (is_set($arFields, "SUM_PAID") || $ACTION == "ADD") {
         $arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
         $arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
     }
     if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") {
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
     }
     if (is_set($arFields, "TAX_VALUE") || $ACTION == "ADD") {
         $arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
         $arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
     }
     if (!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")) {
         $arFields["UPDATED_1C"] = "N";
         $arFields["~VERSION"] = "VERSION+0+1";
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], Loc::getMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["LID"], Loc::getMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if (is_set($arFields, "USER_ID")) {
         $dbUser = CUser::GetByID($arFields["USER_ID"]);
         if (!$dbUser->Fetch()) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["USER_ID"], Loc::getMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], Loc::getMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0) {
         if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"])))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], Loc::getMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
             return false;
         }
     }
     if (is_set($arFields, "DELIVERY_ID") && IntVal($arFields["DELIVERY_ID"]) > 0) {
         if (!($delivery = \Bitrix\Sale\Delivery\Services\Table::getById($arFields["DELIVERY_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], Loc::getMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
             return false;
         }
     }
     if (is_set($arFields, "STATUS_ID")) {
         if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"]))) {
             $APPLICATION->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], Loc::getMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
             return false;
         }
     }
     if (is_set($arFields, "ACCOUNT_NUMBER") && $ACTION == "UPDATE") {
         if (strlen($arFields["ACCOUNT_NUMBER"]) <= 0) {
             $APPLICATION->ThrowException(Loc::getMessage("SKGO_EMPTY_ACCOUNT_NUMBER"), "EMPTY_ACCOUNT_NUMBER");
             return false;
         } else {
             $dbres = $DB->Query("SELECT ID, ACCOUNT_NUMBER FROM b_sale_order WHERE ACCOUNT_NUMBER = '" . $DB->ForSql($arFields["ACCOUNT_NUMBER"]) . "'", true);
             if ($arRes = $dbres->GetNext()) {
                 if (is_array($arRes) && $arRes["ID"] != $ID) {
                     $APPLICATION->ThrowException(Loc::getMessage("SKGO_EXISTING_ACCOUNT_NUMBER"), "EXISTING_ACCOUNT_NUMBER");
                     return false;
                 }
             }
         }
     }
     if ($ACTION == "ADD") {
         $arFields["VERSION"] = 1;
     }
     if (!$USER_FIELD_MANAGER->CheckFields("ORDER", $ID, $arFields)) {
         return false;
     }
     return True;
 }
Exemplo n.º 24
0
if (empty($arRunErrors))
{
	@fwrite($fp, '<? header("Content-Type: text/xml; charset=windows-1251");?>');
	@fwrite($fp, '<? echo "<"."?xml version=\"1.0\" encoding=\"windows-1251\"?".">"?>');
	@fwrite($fp, "\n<!DOCTYPE yml_catalog SYSTEM \"shops.dtd\">\n");
	@fwrite($fp, "<yml_catalog date=\"".Date("Y-m-d H:i")."\">\n");
	@fwrite($fp, "<shop>\n");

	@fwrite($fp, "<name>".$APPLICATION->ConvertCharset(htmlspecialcharsbx(COption::GetOptionString("main", "site_name", "")), LANG_CHARSET, 'windows-1251')."</name>\n");

	@fwrite($fp, "<company>".$APPLICATION->ConvertCharset(htmlspecialcharsbx(COption::GetOptionString("main", "site_name", "")), LANG_CHARSET, 'windows-1251')."</company>\n");
	@fwrite($fp, "<url>http://".htmlspecialcharsbx($ar_iblock['SERVER_NAME'])."</url>\n");

	$strTmp = "<currencies>\n";

	if ($arCurrency = CCurrency::GetByID('RUR'))
		$RUR = 'RUR';
	else
		$RUR = 'RUB';

	$arCurrencyAllowed = array($RUR, 'USD', 'EUR', 'UAH', 'BYR', 'KZT');

	$BASE_CURRENCY = CCurrency::GetBaseCurrency();
	if (is_array($XML_DATA['CURRENCY']))
	{
		foreach ($XML_DATA['CURRENCY'] as $CURRENCY => $arCurData)
		{
			if (in_array($CURRENCY, $arCurrencyAllowed))
			{
				$strTmp.= "<currency id=\"".$CURRENCY."\""
				." rate=\"".($arCurData['rate'] == 'SITE' ? CCurrencyRates::ConvertCurrency(1, $CURRENCY, $RUR) : $arCurData['rate'])."\""
Exemplo n.º 25
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     if (is_set($arFields, "SITE_ID") && strlen($arFields["SITE_ID"]) > 0) {
         $arFields["LID"] = $arFields["SITE_ID"];
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_SITE"), "EMPTY_SITE_ID");
         return false;
     }
     if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION == "ADD") && IntVal($arFields["PERSON_TYPE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_PERS_TYPE"), "EMPTY_PERSON_TYPE_ID");
         return false;
     }
     if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_USER_ID"), "EMPTY_USER_ID");
         return false;
     }
     if (is_set($arFields, "PAYED") && $arFields["PAYED"] != "Y") {
         $arFields["PAYED"] = "N";
     }
     if (is_set($arFields, "CANCELED") && $arFields["CANCELED"] != "Y") {
         $arFields["CANCELED"] = "N";
     }
     if (is_set($arFields, "STATUS_ID") && strlen($arFields["STATUS_ID"]) <= 0) {
         $arFields["STATUS_ID"] = "N";
     }
     if (is_set($arFields, "ALLOW_DELIVERY") && $arFields["ALLOW_DELIVERY"] != "Y") {
         $arFields["ALLOW_DELIVERY"] = "N";
     }
     if (is_set($arFields, "PRICE") || $ACTION == "ADD") {
         $arFields["PRICE"] = str_replace(",", ".", $arFields["PRICE"]);
         $arFields["PRICE"] = DoubleVal($arFields["PRICE"]);
     }
     if (is_set($arFields, "PRICE_DELIVERY") || $ACTION == "ADD") {
         $arFields["PRICE_DELIVERY"] = str_replace(",", ".", $arFields["PRICE_DELIVERY"]);
         $arFields["PRICE_DELIVERY"] = DoubleVal($arFields["PRICE_DELIVERY"]);
     }
     if (is_set($arFields, "SUM_PAID") || $ACTION == "ADD") {
         $arFields["SUM_PAID"] = str_replace(",", ".", $arFields["SUM_PAID"]);
         $arFields["SUM_PAID"] = DoubleVal($arFields["SUM_PAID"]);
     }
     if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") {
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = DoubleVal($arFields["DISCOUNT_VALUE"]);
     }
     if (is_set($arFields, "TAX_VALUE") || $ACTION == "ADD") {
         $arFields["TAX_VALUE"] = str_replace(",", ".", $arFields["TAX_VALUE"]);
         $arFields["TAX_VALUE"] = DoubleVal($arFields["TAX_VALUE"]);
     }
     if (!is_set($arFields, "LOCKED_BY") && (!is_set($arFields, "UPDATED_1C") || is_set($arFields, "UPDATED_1C") && $arFields["UPDATED_1C"] != "Y")) {
         $arFields["UPDATED_1C"] = "N";
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["CURRENCY"], GetMessage("SKGO_WRONG_CURRENCY")), "ERROR_NO_CURRENCY");
             return false;
         }
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGO_WRONG_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if (is_set($arFields, "USER_ID")) {
         $dbUser = CUser::GetByID($arFields["USER_ID"]);
         if (!$dbUser->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SKGO_WRONG_USER")), "ERROR_NO_USER_ID");
             return false;
         }
     }
     if (is_set($arFields, "PERSON_TYPE_ID")) {
         if (!($arPersonType = CSalePersonType::GetByID($arFields["PERSON_TYPE_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERSON_TYPE_ID"], GetMessage("SKGO_WRONG_PERSON_TYPE")), "ERROR_NO_PERSON_TYPE");
             return false;
         }
     }
     if (is_set($arFields, "PAY_SYSTEM_ID") && IntVal($arFields["PAY_SYSTEM_ID"]) > 0) {
         if (!($arPaySystem = CSalePaySystem::GetByID(IntVal($arFields["PAY_SYSTEM_ID"])))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PAY_SYSTEM_ID"], GetMessage("SKGO_WRONG_PS")), "ERROR_NO_PAY_SYSTEM");
             return false;
         }
     }
     if (is_set($arFields, "DELIVERY_ID") && (strpos($arFields["DELIVERY_ID"], ":") !== false || IntVal($arFields["DELIVERY_ID"]) > 0)) {
         if (strpos($arFields["DELIVERY_ID"], ":") !== false) {
             $arId = explode(":", $arFields["DELIVERY_ID"]);
             $obDelivery = new CSaleDeliveryHandler();
             if ($arDelivery = $obDelivery->GetBySID($arId[0])) {
                 if ($arDelivery = $arDelivery->Fetch()) {
                     if (!is_set($arDelivery["PROFILES"], $arId[1])) {
                         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                         return false;
                     }
                 }
             } else {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                 return false;
             }
         } else {
             if (!($arDelivery = CSaleDelivery::GetByID(IntVal($arFields["DELIVERY_ID"])))) {
                 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["DELIVERY_ID"], GetMessage("SKGO_WRONG_DELIVERY")), "ERROR_NO_DELIVERY");
                 return false;
             }
         }
     }
     if (is_set($arFields, "STATUS_ID")) {
         if (!($arStatus = CSaleStatus::GetByID($arFields["STATUS_ID"]))) {
             $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["STATUS_ID"], GetMessage("SKGO_WRONG_STATUS")), "ERROR_NO_STATUS_ID");
             return false;
         }
     }
     return True;
 }
Exemplo n.º 26
0
	function __getHandlersData($arFullHandlersList, $SITE_ID = false)
	{
		global $DB;

		if (!is_array($arFullHandlersList) || count($arFullHandlersList) <= 0)
			return false;

		$strKeys = '';
		$cnt = count($arFullHandlersList);
		$arHandlersMap = array();

		for ($i = 0; $i < $cnt; $i++)
		{
			$strKeys .= ($i > 0 ? ', ' : '')."'".$DB->ForSql($arFullHandlersList[$i]['SID'])."'";
			$arHandlersMap[$arFullHandlersList[$i]['SID']] = $i;
		}

		$query = "
SELECT HID AS SID, LID, ACTIVE, NAME, SORT, DESCRIPTION, HANDLER, SETTINGS, PROFILES, TAX_RATE, LOGOTIP, BASE_CURRENCY
FROM b_sale_delivery_handler
WHERE HID IN (".$strKeys.")";

		if ($SITE_ID)
			$query .= "AND (LID='".$DB->ForSql($SITE_ID)."' OR LID='' OR LID IS NULL)";

		$dbRes = $DB->Query($query);
		$arHandlersList = array();

		$arInstalledHandlersMap = array();

		while ($arRes = $dbRes->Fetch())
		{
			$arHandler = $arFullHandlersList[$arHandlersMap[$arRes['SID']]];
			$arRes["LID"] = trim($arRes["LID"]);
			$arHandler["LID"] = $arRes["LID"];
			$arHandler["ACTIVE"] = $arRes["ACTIVE"];
			$arHandler["SORT"] = $arRes["SORT"];
			$arHandler["NAME"] = $arRes["NAME"];
			$arHandler["DESCRIPTION"] = $arRes["DESCRIPTION"];
			$arHandler["TAX_RATE"] = doubleval($arRes["TAX_RATE"]);

			if(strlen($arRes["BASE_CURRENCY"]) > 0)
				$arHandler["BASE_CURRENCY"] = $arRes["BASE_CURRENCY"];

			$arHandler["INSTALLED"] = "Y";

			if (intval($arRes["LOGOTIP"]) > 0)
				$arHandler["LOGOTIP"] = CFile::GetFileArray($arRes["LOGOTIP"]);

			$arInstalledHandlersMap[$arRes["SID"]] = 1;

			if (is_callable($arHandler["GETCONFIG"]))
			{
				$arHandler["CONFIG"] = call_user_func($arHandler["GETCONFIG"], $SITE_ID);

				if (strlen($arRes["SETTINGS"]) > 0 && is_callable($arHandler["DBGETSETTINGS"]))
				{
					$arConfigValues = call_user_func($arHandler["DBGETSETTINGS"], $arRes["SETTINGS"]);

					foreach ($arConfigValues as $key => $value)
					{
						if (is_array($arHandler["CONFIG"]["CONFIG"][$key]))
							$arHandler["CONFIG"]["CONFIG"][$key]["VALUE"] = $value;
					}
				}
				else
				{
					foreach ($arHandler["CONFIG"]["CONFIG"] as $key => $arConfig)
					{
						if (is_array($arHandler["CONFIG"]["CONFIG"][$key]))
							$arHandler["CONFIG"]["CONFIG"][$key]["VALUE"] = $arHandler["CONFIG"]["CONFIG"][$key]["DEFAULT"];
					}
				}
			}
			else
			{
				$arHandler["CONFIG"] = array(
					"CONFIG_GROUPS" => array(),
					"CONFIG" => array(),
				);
			}

			// set handler profiles data
			if (strlen($arRes["PROFILES"]) > 0)
			{
				$arHandler["PROFILES"] = unserialize($arRes["PROFILES"]);
				$arHandler["PROFILE_USE_DEFAULT"] = "N";
			}
			else
			{
				$arHandler["PROFILE_USE_DEFAULT"] = "Y";
				foreach ($arHandler['PROFILES'] as $pkey => $arProfile)
				{
					$arHandler['PROFILES'][$pkey]['ACTIVE'] = 'Y';
				}
			}

			$arHandlersList[] = $arHandler;
		}

		foreach ($arFullHandlersList as $key => $arHandler)
		{
			if (array_key_exists($arHandler["SID"], $arInstalledHandlersMap)) continue;

			$siteList = array();

			if(strlen($SITE_ID) <= 0 && isset($arHandler["MULTISITE_CONFIG"]) && $arHandler["MULTISITE_CONFIG"] == "Y")
			{
				$rsSites = CSite::GetList($by = "sort", $order = "asc", Array());

				while($arRes = $rsSites->Fetch())
					$siteList[] = $arRes['ID'];
			}
			else
			{
				$siteList[] = $SITE_ID;
			}

			foreach($siteList as $siteId)
			{
				$arHandler["INSTALLED"] = "N";
				$arHandler["LID"] = trim($siteId);
				$arHandler['ACTIVE'] = "N";
				$arHandler["SORT"] = '';
				$arHandler["TAX_RATE"] = 0;
				$arHandler["PROFILE_USE_DEFAULT"] = "Y";

				if (is_callable($arHandler["GETCONFIG"]))
				{
					$arHandler["CONFIG"] = call_user_func($arHandler["GETCONFIG"], $siteId);
				}
				else
				{
					$arHandler["CONFIG"] = array(
						"CONFIG_GROUPS" => array(),
						"CONFIG" => array(),
					);
				}

				$arHandlersList[] = $arHandler;
			}
		}

		foreach ($arHandlersList as $key => $arHandler)
		{
			$handler_path = strtolower($arHandler["HANDLER"]);
			$handler_path = str_replace("\\", "/", $handler_path);
			$handler_path = str_replace(strtolower($_SERVER["DOCUMENT_ROOT"]), '', $handler_path);

			if (strlen($arHandler["BASE_CURRENCY"]) <=0 || !CCurrency::GetByID($arHandler["BASE_CURRENCY"]))
				$arHandlersList[$key]["BASE_CURRENCY"] = COption::GetOptionString('sale', 'default_currency', 'RUB');

			$arHandlersList[$key]['HANDLER'] = $handler_path;
		}

		return $arHandlersList;
	}
Exemplo n.º 27
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;
 }
Exemplo n.º 28
0
function GetStatisticBaseCurrency()
{
    $base_currency = trim(COption::GetOptionString("statistic", "BASE_CURRENCY"));
    if ($base_currency != "xxx" && strlen($base_currency) > 0) {
        if (CModule::IncludeModule("currency")) {
            if (CCurrency::GetByID($base_currency)) {
                return $base_currency;
            }
        }
    }
    return "";
}