diff --git a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php index f8ec28d4..740aa32f 100644 --- a/intaro.retailcrm/classes/general/icml/RetailCrmICML.php +++ b/intaro.retailcrm/classes/general/icml/RetailCrmICML.php @@ -29,6 +29,7 @@ class RetailCrmICML protected $mainSection = 1000000; protected $pageSize = 500; protected $protocol; + protected $purchasePriceNull; protected $isLogged = false; protected $logFile = '/bitrix/catalog_export/i_crm_load_log.txt'; @@ -37,6 +38,7 @@ class RetailCrmICML protected $MODULE_ID = 'intaro.retailcrm'; protected $CRM_CATALOG_BASE_PRICE = 'catalog_base_price'; protected $PROTOCOL_OPTION = 'protocol'; + protected $CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; protected $measurement = array ( 'mm' => 1, // 1 mm = 1 mm @@ -76,6 +78,7 @@ class RetailCrmICML $this->encodingDefault = $defaultSite["CHARSET"]; $this->protocol = COption::GetOptionString($this->MODULE_ID, $this->PROTOCOL_OPTION); + $this->purchasePriceNull = COption::GetOptionString($this->MODULE_ID, $this->CRM_PURCHASE_PRICE_NULL); $this->PrepareSettings(); @@ -621,9 +624,15 @@ class RetailCrmICML $offer .= "" . $this->protocol . $this->serverName . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "\n"; $offer .= "" . $this->PrepareValue($arOffer['PRICE']) . "\n"; - if ($arOffer['PURCHASE_PRICE'] && $this->loadPurchasePrice) { - $offer .= "" . $this->PrepareValue($arOffer['PURCHASE_PRICE']) . "\n"; + + if ($this->loadPurchasePrice) { + if ($arOffer['PURCHASE_PRICE']) { + $offer .= "" . $this->PrepareValue($arOffer['PURCHASE_PRICE']) . "\n"; + } elseif ("Y" == $this->purchasePriceNull) { + $offer .= "0\n"; + } } + foreach ($categories as $category) { $offer .= "" . $category['ID'] . "\n"; } diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index fb995d66..b3cc6a0e 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -46,6 +46,7 @@ $CRM_DIMENSIONS = 'order_dimensions'; $PROTOCOL = 'protocol'; $CRM_DISCOUNT_ROUND = 'discount_round'; +$CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; if(!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog')) return; @@ -451,6 +452,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmDc", "add"); } + //purchasePrice_null + if (htmlspecialchars(trim($_POST['purchasePrice_null'])) == 'Y') { + $purchasePrice_null = 'Y'; + RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmPricePrchase", "add"); + } else { + $purchasePrice_null = 'N'; + UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmPricePrchase", "add"); + } + //version $version = COption::GetOptionString($mid, $CRM_API_VERSION); @@ -526,6 +536,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { COption::SetOptionString($mid, $CRM_DIMENSIONS, $orderDimensions); COption::SetOptionString($mid, $CRM_DISCOUNT_ROUND, $discount_round); + COption::SetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, $purchasePrice_null); $request = \Bitrix\Main\Application::getInstance()->getContext()->getRequest(); @@ -634,6 +645,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $optionUaKeys = unserialize(COption::GetOptionString($mid, $CRM_UA_KEYS)); $optionDiscRound = COption::GetOptionString($mid, $CRM_DISCOUNT_ROUND, 0); + $optionPricePrchaseNull = COption::GetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, 0); $version = COption::GetOptionString($mid, $CRM_API_VERSION, 0); @@ -752,6 +764,17 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { return true; }); + + $('.r-purchaseprice-button label').change(function() { + if($(this).find('input').is(':checked') === true) { + $('tr.r-purchaseprice').show('slow'); + } else if($(this).find('input').is(':checked') === false) { + $('tr.r-purchaseprice').hide('slow'); + } + + return true; + }); + }); $('input[name="update-delivery-services"]').live('click', function() { @@ -1303,6 +1326,23 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { + + + + + + + + + > + + + + +