diff --git a/intaro.intarocrm/classes/general/ICMLLoader.php b/intaro.intarocrm/classes/general/ICMLLoader.php index b28e36ce..af3ea5ac 100644 --- a/intaro.intarocrm/classes/general/ICMLLoader.php +++ b/intaro.intarocrm/classes/general/ICMLLoader.php @@ -7,13 +7,14 @@ class ICMLLoader { public $iblocks; public $filename; - public $articleProperties; + public $propertiesSKU; + public $propertiesProduct; public $application; public $encoding = 'utf-8'; protected $fp; - protected $mainSection = 1000000; - + protected $mainSection = 1000000; + public function Load() { global $USER; @@ -22,7 +23,9 @@ class ICMLLoader { if (count($this->iblocks) < count($this->articleProperties)) return false; - + + $this->PrepareSettings(); + $this->PrepareFile(); $this->PreWriteCatalog(); @@ -41,7 +44,21 @@ class ICMLLoader { return true; } - + + protected function PrepareSettings() + { + foreach ($this->propertiesSKU as $iblock => $arr) { + foreach ($arr as $id => $sku) { + $this->propertiesSKU[$iblock][$id] = strtoupper($sku); + } + } + foreach ($this->propertiesProduct as $iblock => $arr) { + foreach ($arr as $id => $prod) { + $this->propertiesProduct[$iblock][$id] = strtoupper($prod); + } + } + } + protected function PrepareValue($text) { $newText = $this->application->ConvertCharset($text, LANG_CHARSET, $this->encoding); @@ -63,12 +80,11 @@ class ICMLLoader { protected function PreWriteCatalog() { - @fwrite($this->fp, "PrepareValue(Date("Y-m-d H:i:s")) . "\">\n"); - @fwrite($this->fp, "\n"); - - @fwrite($this->fp, "". $this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n"); - - @fwrite($this->fp, "".$this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n"); + @fwrite($this->fp, "PrepareValue(Date("Y-m-d H:i:s")) . "\">\n + \n + " . $this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n + " . $this->PrepareValue(COption::GetOptionString("main", "site_name", ""))."\n" + ); } @@ -99,8 +115,8 @@ class ICMLLoader { protected function PostWriteCatalog() { - @fwrite($this->fp, "\n"); - @fwrite($this->fp, "\n"); + @fwrite($this->fp, "\n + \n"); } protected function CloseFile() @@ -160,11 +176,9 @@ class ICMLLoader { { foreach ($this->iblocks as $key => $id) { - $iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch(); $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id); - $arSelect = Array ( "ID", "LID", @@ -180,10 +194,12 @@ class ICMLLoader { "LANG_DIR", "DETAIL_PAGE_URL" ); - - if (isset($this->articleProperties[$id])) - $arSelect[] = "PROPERTY_" . $this->articleProperties[$id]; - + + foreach ($this->propertiesProduct[$id] as $key => $propProduct) { + if ($this->propertiesProduct[$id][$key] != "") + $arSelect[] = "PROPERTY_" . $propProduct; + } + $filter = Array ( "IBLOCK_ID" => $id, @@ -198,7 +214,23 @@ class ICMLLoader { $product = $product->GetFields(); - // Get categories in InfoBlock + // Get properties of product + $resPropertiesProduct = Array(); + foreach ($this->propertiesProduct[$id] as $key => $propProduct) { + $resPropertiesProduct[$key] = ""; + if ($propProduct != "") { + $propDesc = CIBlockProperty::GetByID($propProduct, $id)->GetNext(); + + if ($propDesc['PROPERTY_TYPE'] == 'E') { + $el = CIBlockElement::GetById($product["PROPERTY_" . $propProduct . "_VALUE"])->Fetch(); + $resPropertiesProduct[$key] = $el['NAME']; + } else { + $resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"]; + } + } + } + + // Get categories of product $categories = Array(); $dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true); while ($arResCategory = $dbResCategories->Fetch()) { @@ -216,8 +248,7 @@ class ICMLLoader { $existOffer = false; if (!empty($iblockOffer['IBLOCK_ID'])) { - - + $arFilterOffer = Array ( 'IBLOCK_ID' => $iblockOffer['IBLOCK_ID'], 'PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'] => $product["ID"] @@ -229,9 +260,11 @@ class ICMLLoader { "DETAIL_PAGE_URL", "DETAIL_PICTURE" ); - if (isset($this->articleProperties[$id])) - $arSelectOffer[] = "PROPERTY_" . $this->articleProperties[$id]; - + + foreach ($this->propertiesSKU[$id] as $key => $propSKU) { + if ($this->propertiesSKU[$id][$key] != "") + $arSelectOffer[] = "PROPERTY_" . $propSKU; + } $rsOffers = CIBlockElement::GetList(array(), $arFilterOffer, false, false, $arSelectOffer); while ($arOffer = $rsOffers->GetNext()) { @@ -244,9 +277,27 @@ class ICMLLoader { $arOffer['DETAIL_PICTURE'] = $product["DETAIL_PICTURE"]; $arOffer['PREVIEW_PICTURE'] = $product["PREVIEW_PICTURE"]; $arOffer['PRODUCT_NAME'] = $product["NAME"]; - if (isset($this->articleProperties[$id])) - $arOffer['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"]; + + // Get properties of offer + + foreach ($this->propertiesSKU[$id] as $key => $propSKU) { + if ($propSKU != "") { + $propDesc = CIBlockProperty::GetByID($propSKU,$arOffer['ID'])->GetNext(); + if ($propDesc['PROPERTY_TYPE'] == 'E') { + $el = CIBlockElement::GetById($product["PROPERTY_" . $propSKU . "_VALUE"])->Fetch(); + $arOffer[$key] = $el['NAME']; + } else { + $arOffer[$key] = $arOffer["PROPERTY_" . $propSKU . "_VALUE"]; + } + } + } + + foreach ($resPropertiesProduct as $key => $propProduct) { + if ($this->propertiesProduct[$id][$key] != "") + $arOffer[$key] = $propProduct; + } + $dbPrice = GetCatalogProductPrice($arOffer["ID"],1); $arOffer['PRICE'] = $dbPrice['PRICE']; @@ -261,8 +312,11 @@ class ICMLLoader { $product['PRODUCT_ID'] = $product["ID"]; $product['PRODUCT_NAME'] = $product["NAME"]; - if (isset($this->articleProperties[$id])) - $product['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"]; + + foreach ($resPropertiesProduct as $key => $propProduct) { + if ($this->propertiesProduct[$id][$key] != "") + $product[$key] = $propProduct; + } $dbPrice = GetCatalogProductPrice($product["ID"],1); $product['PRICE'] = $dbPrice['PRICE']; @@ -326,9 +380,12 @@ class ICMLLoader { $offer .= "" . $this->PrepareValue($arOffer["EXTERNAL_ID"]) . "\n"; $offer .= "" . $this->PrepareValue($arOffer["PRODUCT_NAME"]) . "\n"; - if (isset($arOffer["ARTICLE"])) - $offer .= "
" . $this->PrepareValue($arOffer["ARTICLE"]) . "
\n"; + foreach ($this->propertiesProduct[$iblock['IBLOCK_DB']['ID']] as $key => $propProduct) { + if ($propProduct != "" && $arOffer[$key] != null) + $offer .= "<" . $key . ">" . $this->PrepareValue($arOffer[$key]) . "\n"; + } + $offer.= "\n"; return $offer; } diff --git a/intaro.intarocrm/export/export_run.php b/intaro.intarocrm/export/export_run.php index ea2d7464..b0ddb912 100644 --- a/intaro.intarocrm/export/export_run.php +++ b/intaro.intarocrm/export/export_run.php @@ -2,7 +2,6 @@ set_time_limit(0); - global $APPLICATION; if (!CModule::IncludeModule("iblock")) return; @@ -13,7 +12,8 @@ if (!CModule::IncludeModule("intaro.intarocrm")) $loader = new ICMLLoader(); $loader->iblocks = $IBLOCK_EXPORT; -$loader->articleProperties = $IBLOCK_PROPERTY_ARTICLE; +$loader->propertiesSKU = $IBLOCK_PROPERTY_SKU; +$loader->propertiesProduct = $IBLOCK_PROPERTY_PRODUCT; $loader->filename = $SETUP_FILE_NAME; $loader->application = $APPLICATION; $loader->Load(); \ No newline at end of file diff --git a/intaro.intarocrm/export/export_setup.php b/intaro.intarocrm/export/export_setup.php index 1fafdeee..008ddf9a 100644 --- a/intaro.intarocrm/export/export_setup.php +++ b/intaro.intarocrm/export/export_setup.php @@ -1,30 +1,29 @@ - 1) { - - if (count($IBLOCK_EXPORT) < count($IBLOCK_PROPERTY_ARTICLE)) - $arSetupErrors[] = GetMessage("ERROR_ARTICLE_NOT_SET"); - if (strlen($SETUP_FILE_NAME)<=0) { $arSetupErrors[] = GetMessage("CET_ERROR_NO_FILENAME"); @@ -54,18 +53,43 @@ if ($STEP==1) ?> + + +
+ +



"Артикул", + "manufacturer" => "Производитель", + "color" => "Цвет", + "weight" => "Вес", + "size" => "Размер", + ); + + $iblockPropertiesHint = Array( + "article" => Array("ARTICLE", "ART", "ARTNUMBER", "ARTICUL", "ARTIKUL"), + "manufacturer" => Array("MANUFACTURER", "PROISVODITEL", "PROISVOD", "PROISV"), + "color" => Array("COLOR", "CVET"), + "weight" => Array("WEIGHT", "VES", "VEC"), + "size" => Array("SIZE", "RAZMER"), + ); $boolAll = false; @@ -73,42 +97,70 @@ if ($STEP==1) $intCountAvailIBlock = 0; $arIBlockList = array(); $db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W')); - while ($res = $db_res->Fetch()) + while ($iblock = $db_res->Fetch()) { - if ($arCatalog = CCatalog::GetByIDExt($res["ID"])) + if ($arCatalog = CCatalog::GetByIDExt($iblock["ID"])) { if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") { - $arSiteList = array(); - $rsSites = CIBlock::GetSite($res["ID"]); - while ($arSite = $rsSites->Fetch()) - { - $arSiteList[] = $arSite["SITE_ID"]; - } - $db_properties = CIBlock::GetProperties($res['ID'], Array()); - - $properties = Array(); + $propertiesSKU = null; + if ($arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") + { + $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock["ID"]); + + $db_properties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], Array()); while($prop = $db_properties->Fetch()) - $properties[] = $prop; + $propertiesSKU[] = $prop; + + $oldPropertySKU = null; + if (isset($IBLOCK_PROPERTY_SKU[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertySKU[$key] = $IBLOCK_PROPERTY_SKU[$iblock['ID']][$key]; + } + } + } + + + $propertiesProduct = null; + $db_properties = CIBlock::GetProperties($iblock['ID'], Array()); + while($prop = $db_properties->Fetch()) + $propertiesProduct[] = $prop; + + $oldPropertyProduct = null; + if (isset($IBLOCK_PROPERTY_PRODUCT[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertyProduct[$key] = $IBLOCK_PROPERTY_PRODUCT[$iblock['ID']][$key]; + } + } + + $arSiteList = array(); + $rsSites = CIBlock::GetSite($iblock["ID"]); + while ($arSite = $rsSites->Fetch()) + { + $arSiteList[] = $arSite["SITE_ID"]; + } - if (count($IBLOCK_EXPORT) != 0) - $boolExport = (in_array($res['ID'], $IBLOCK_EXPORT)); - else - $boolExport = true; + if (count($IBLOCK_EXPORT) != 0) + $boolExport = (in_array($iblock['ID'], $IBLOCK_EXPORT)); + else + $boolExport = true; + - $arIBlockList[] = array( - 'ID' => $res['ID'], - 'NAME' => $res['NAME'], - 'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'], - 'IBLOCK_EXPORT' => $boolExport, - 'PROPERTIES' => $properties, - 'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null, - 'SITE_LIST' => '('.implode(' ',$arSiteList).')', - ); + $arIBlockList[] = array( + 'ID' => $iblock['ID'], + 'NAME' => $iblock['NAME'], + 'IBLOCK_TYPE_ID' => $iblock['IBLOCK_TYPE_ID'], + 'IBLOCK_EXPORT' => $boolExport, + 'PROPERTIES_SKU' => $propertiesSKU, + 'PROPERTIES_PRODUCT' => $propertiesProduct, + 'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU, + 'OLD_PROPERTY_PRODUCT_SELECT' => $oldPropertyProduct, + 'SITE_LIST' => '('.implode(' ',$arSiteList).')', + ); - if ($boolExport) - $intCountChecked++; - $intCountAvailIBlock++; + if ($boolExport) + $intCountChecked++; + $intCountAvailIBlock++; } } } @@ -120,105 +172,148 @@ if ($STEP==1) $boolAll = true; } + + ?> - - - - - - + + + + + + +
-
+ + > +
+
+
+ + $arIBlock):?> +
+
+ + ]" + id="IBLOCK_EXPORT" + value="" + + onclick="checkOne(this,);" + > +
+
+
+ > + + + + + + + + + + + $property): ?> + + + - - - - - - - - - $arIBlock) - { - ?> - - - - - - - -
+
Выгружаемое свойство
-
-   -
+
Свойство товара
+
+
Свойство торгового предложения
+
+ -
-
- - - > - - -   -
- - - - ]" - id="IBLOCK_EXPORT" - value="" - - onclick="checkOne(this,);" - > - - - " + name="IBLOCK_PROPERTY_PRODUCT[][]" + class="property-export" + onchange="propertyChange(this);"> + + - - -
+ + +
+ +
+
+
+ + + + + + +
-
-
+

+

function checkAll(obj,cnt) { - var boolCheck = obj.checked; - for (i = 0; i < cnt; i++) - { - BX('IBLOCK_EXPORT'+i).checked = boolCheck; - } - BX('count_checked').value = (boolCheck ? cnt : 0); + for (i = 0; i < cnt; i++) + { + if (obj.checked) + BX.removeClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); + } + var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE')); + if (obj.checked) + BX.removeClass(table,"iblock-export-table-display-none"); + var easing = new BX.easing({ + duration : 150, + start : {opacity : obj.checked ? 0 : 100 }, + finish : {opacity: obj.checked ? 100 : 0 }, + transition : BX.easing.transitions.linear, + step : function(state){ + for (i = 0; i < cnt; i++) + { + BX('IBLOCK_EXPORT_TABLE'+(i+1)).style.opacity = state.opacity/100; + } + }, + complete : function() { + for (i = 0; i < cnt; i++) + { + if (!obj.checked) + BX.addClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); + } + } + }); + easing.animate(); + var boolCheck = obj.checked; + for (i = 0; i < cnt; i++) + { + BX('IBLOCK_EXPORT'+(i+1)).checked = boolCheck; + } + BX('count_checked').value = (boolCheck ? cnt : 0); }; function checkOne(obj,cnt) { - var boolCheck = obj.checked; - var intCurrent = parseInt(BX('count_checked').value); - intCurrent += (boolCheck ? 1 : -1); - BX('icml_export_all').checked = (intCurrent < cnt ? false : true); - BX('count_checked').value = intCurrent; - if (!boolCheck) - BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_PROPERTY_ARTICLE')).value = 'none'; + var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE')); + if (obj.checked) + BX.removeClass(table,"iblock-export-table-display-none"); + var easing = new BX.easing({ + duration : 150, + start : {opacity : obj.checked ? 0 : 100 }, + finish : {opacity: obj.checked ? 100 : 0 }, + transition : BX.easing.transitions.linear, + step : function(state){ + table.style.opacity = state.opacity/100; + }, + complete : function() { + if (!obj.checked) + BX.addClass(table,"iblock-export-table-display-none"); + } + }); + easing.animate(); + var boolCheck = obj.checked; + var intCurrent = parseInt(BX('count_checked').value); + intCurrent += (boolCheck ? 1 : -1); + BX('icml_export_all').checked = (intCurrent < cnt ? false : true); + BX('count_checked').value = intCurrent; + }; + function propertyChange(obj) + { + if (BX(obj.id).value !== 'none') { + if (obj.id.indexOf("SKU") !== -1) + BX(obj.id.replace('SKU','PRODUCT')).value = 'none'; + else + BX(obj.id.replace('PRODUCT','SKU')).value = 'none'; + } }; @@ -279,7 +426,7 @@ if ($STEP==1) "> - + "> diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index d178d6fa..2a8e5cec 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -822,21 +822,22 @@ class intaro_intarocrm extends CModule { $arResult['errCode'] = 'ERR_FIELDS_IBLOCK'; else $iblocks = $_POST['IBLOCK_EXPORT']; - - if (!isset($_POST['IBLOCK_PROPERTY_ARTICLE'])) - $arResult['errCode'] = 'ERR_FIELDS_ARTICLE'; + + if(!isset($_POST['IBLOCK_PROPERTY_SKU'])) + $arResult['errCode'] = 'ERR_FIELDS_SKU'; else - $articleProperties = $_POST['IBLOCK_PROPERTY_ARTICLE']; + $propertiesSKU = $_POST['IBLOCK_PROPERTY_SKU']; + + if(!isset($_POST['IBLOCK_PROPERTY_PRODUCT'])) + $arResult['errCode'] = 'ERR_FIELDS_PRODUCT'; + else + $propertiesProduct = $_POST['IBLOCK_PROPERTY_PRODUCT']; if (!isset($_POST['SETUP_FILE_NAME'])) $arResult['errCode'] = 'ERR_FIELDS_FILE'; else $filename = $_POST['SETUP_FILE_NAME']; - - if (count($iblocks) < count($articleProperties)) - $arResult['errCode'] = 'ERR_ARTICLE_IBLOCK'; - - + if (!isset($_POST['TYPE_LOADING'])) $typeLoading = 0; else @@ -857,15 +858,16 @@ class intaro_intarocrm extends CModule { $arOldValues = Array( 'IBLOCK_EXPORT' => $iblocks, - 'IBLOCK_PROPERTY_ARTICLE' => $articleProperties, + 'IBLOCK_PROPERTY_SKU' => $propertiesSKU, + 'IBLOCK_PROPERTY_PRODUCT' => $propertiesProduct, 'SETUP_FILE_NAME' => $filename, 'SETUP_PROFILE_NAME' => $profileName ); global $oldValues; $oldValues = $arOldValues; $APPLICATION->IncludeAdminFile( - GetMessage('MODULE_INSTALL_TITLE'), - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step5.php' + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step4.php' ); return; } @@ -878,12 +880,14 @@ class intaro_intarocrm extends CModule { $loader = new ICMLLoader(); $loader->iblocks = $iblocks; - $loader->articleProperties = $articleProperties; + $loader->propertiesProduct = $propertiesProduct; + $loader->propertiesSKU = $propertiesSKU; $loader->filename = $filename; $loader->application = $APPLICATION; $loader->Load(); - } - + + } + if ($typeLoading == 'agent' || $typeLoading == 'cron') { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->INTARO_CRM_EXPORT . '_run.php')) { $dbProfile = CCatalogExport::GetList(array(), array("FILE_NAME" => $this->INTARO_CRM_EXPORT)); @@ -895,18 +899,18 @@ class intaro_intarocrm extends CModule { } } } - $ar = $this->GetProfileSetupVars($iblocks, $articleProperties, $filename); + $ar = $this->GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename); $PROFILE_ID = CCatalogExport::Add(array( - "LAST_USE" => false, - "FILE_NAME" => $this->INTARO_CRM_EXPORT, - "NAME" => $profileName, - "DEFAULT_PROFILE" => "N", - "IN_MENU" => "N", - "IN_AGENT" => "N", - "IN_CRON" => "N", - "NEED_EDIT" => "N", - "SETUP_VARS" => $ar - )); + "LAST_USE" => false, + "FILE_NAME" => $this->INTARO_CRM_EXPORT, + "NAME" => $profileName, + "DEFAULT_PROFILE" => "N", + "IN_MENU" => "N", + "IN_AGENT" => "N", + "IN_CRON" => "N", + "NEED_EDIT" => "N", + "SETUP_VARS" => $ar + )); if (intval($PROFILE_ID) <= 0) { $arResult['errCode'] = 'ERR_IBLOCK'; return; @@ -1074,21 +1078,26 @@ class intaro_intarocrm extends CModule { unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php'); } - function GetProfileSetupVars($iblocks, $articleProperties, $filename) { + function GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename) { // Get string like IBLOCK_EXPORT[0]=3& // IBLOCK_EXPORT[1]=6& // IBLOCK_PROPERTY_ARTICLE[0]=ARTICLE& // IBLOCK_PROPERTY_ARTICLE[1]=ARTNUMBER& // SETUP_FILE_NAME=%2Fbitrix%2Fcatalog_export%2Ftestintarocrm.xml + //$arProfileFields = explode(",", $SETUP_FIELDS_LIST); $strVars = ""; - foreach ($iblocks as $key => $val) + foreach ($iblocks as $key => $val) $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; - foreach ($articleProperties as $key => $val) - $strVars .= 'IBLOCK_PROPERTY_ARTICLE[' . $key . ']=' . $val . '&'; - + foreach ($propertiesSKU as $iblock => $arr) + foreach ($arr as $id => $val) + $strVars .= 'IBLOCK_PROPERTY_SKU[' . $iblock . '][' . $id . ']=' . $val . '&'; + foreach ($propertiesProduct as $iblock => $arr) + foreach ($arr as $id => $val) + $strVars .= 'IBLOCK_PROPERTY_PRODUCT[' . $iblock . '][' . $id . ']=' . $val . '&'; + $strVars .= 'SETUP_FILE_NAME=' . urlencode($filename); - + return $strVars; } diff --git a/intaro.intarocrm/install/step5.php b/intaro.intarocrm/install/step5.php index 4b19cc2c..a3389bcb 100644 --- a/intaro.intarocrm/install/step5.php +++ b/intaro.intarocrm/install/step5.php @@ -11,60 +11,115 @@ if(isset($arResult['errCode']) && $arResult['errCode']) global $oldValues; if (!empty($oldValues)) { $IBLOCK_EXPORT = $oldValues['IBLOCK_EXPORT']; - $IBLOCK_PROPERTY_ARTICLE = $oldValues['IBLOCK_PROPERTY_ARTICLE']; + $IBLOCK_PROPERTY_SKU = $oldValues['IBLOCK_PROPERTY_SKU']; + $IBLOCK_PROPERTY_PRODUCT = $oldValues['IBLOCK_PROPERTY_PRODUCT']; $SETUP_FILE_NAME = $oldValues['SETUP_FILE_NAME']; $SETUP_PROFILE_NAME = $oldValues['SETUP_PROFILE_NAME']; } ?> - + + + + + +



"Артикул", + "manufacturer" => "Производитель", + "color" => "Цвет", + "weight" => "Вес", + "size" => "Размер", + ); + + $iblockPropertiesHint = Array( + "article" => Array("ARTICLE", "ART", "ARTNUMBER", "ARTICUL", "ARTIKUL"), + "manufacturer" => Array("MANUFACTURER", "PROISVODITEL", "PROISVOD", "PROISV"), + "color" => Array("COLOR", "CVET"), + "weight" => Array("WEIGHT", "VES", "VEC"), + "size" => Array("SIZE", "RAZMER"), + ); + $boolAll = false; $intCountChecked = 0; $intCountAvailIBlock = 0; $arIBlockList = array(); $db_res = CIBlock::GetList(Array("IBLOCK_TYPE"=>"ASC", "NAME"=>"ASC"),array('CHECK_PERMISSIONS' => 'Y','MIN_PERMISSION' => 'W')); - while ($res = $db_res->Fetch()) + while ($iblock = $db_res->Fetch()) { - if ($arCatalog = CCatalog::GetByIDExt($res["ID"])) + if ($arCatalog = CCatalog::GetByIDExt($iblock["ID"])) { if($arCatalog['CATALOG_TYPE'] == "D" || $arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") { - $arSiteList = array(); - $rsSites = CIBlock::GetSite($res["ID"]); - while ($arSite = $rsSites->Fetch()) - { - $arSiteList[] = $arSite["SITE_ID"]; - } - $db_properties = CIBlock::GetProperties($res['ID'], Array()); - - $properties = Array(); + $propertiesSKU = null; + if ($arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") + { + $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock["ID"]); + + $db_properties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], Array()); while($prop = $db_properties->Fetch()) - $properties[] = $prop; + $propertiesSKU[] = $prop; + + $oldPropertySKU = null; + if (isset($IBLOCK_PROPERTY_SKU[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertySKU[$key] = $IBLOCK_PROPERTY_SKU[$iblock['ID']][$key]; + } + } + } + + + $propertiesProduct = null; + $db_properties = CIBlock::GetProperties($iblock['ID'], Array()); + while($prop = $db_properties->Fetch()) + $propertiesProduct[] = $prop; + + $oldPropertyProduct = null; + if (isset($IBLOCK_PROPERTY_PRODUCT[$iblock['ID']])) { + foreach ($iblockPropertiesName as $key => $prop) { + $oldPropertyProduct[$key] = $IBLOCK_PROPERTY_PRODUCT[$iblock['ID']][$key]; + } + } + + $arSiteList = array(); + $rsSites = CIBlock::GetSite($iblock["ID"]); + while ($arSite = $rsSites->Fetch()) + { + $arSiteList[] = $arSite["SITE_ID"]; + } - if (count($IBLOCK_EXPORT) != 0) - $boolExport = (in_array($res['ID'], $IBLOCK_EXPORT)); - else - $boolExport = true; + if (count($IBLOCK_EXPORT) != 0) + $boolExport = (in_array($iblock['ID'], $IBLOCK_EXPORT)); + else + $boolExport = true; + - $arIBlockList[] = array( - 'ID' => $res['ID'], - 'NAME' => $res['NAME'], - 'IBLOCK_TYPE_ID' => $res['IBLOCK_TYPE_ID'], - 'IBLOCK_EXPORT' => $boolExport, - 'PROPERTIES' => $properties, - 'OLD_PROPERTY_SELECT' => $IBLOCK_PROPERTY_ARTICLE[$res['ID']] != "" ? $IBLOCK_PROPERTY_ARTICLE[$res['ID']] : null, - 'SITE_LIST' => '('.implode(' ',$arSiteList).')', - ); + $arIBlockList[] = array( + 'ID' => $iblock['ID'], + 'NAME' => $iblock['NAME'], + 'IBLOCK_TYPE_ID' => $iblock['IBLOCK_TYPE_ID'], + 'IBLOCK_EXPORT' => $boolExport, + 'PROPERTIES_SKU' => $propertiesSKU, + 'PROPERTIES_PRODUCT' => $propertiesProduct, + 'OLD_PROPERTY_SKU_SELECT' => $oldPropertySKU, + 'OLD_PROPERTY_PRODUCT_SELECT' => $oldPropertyProduct, + 'SITE_LIST' => '('.implode(' ',$arSiteList).')', + ); - if ($boolExport) - $intCountChecked++; - $intCountAvailIBlock++; + if ($boolExport) + $intCountChecked++; + $intCountAvailIBlock++; } } } @@ -78,99 +133,141 @@ if (!empty($oldValues)) { ?> - - - - - - + + + + + + +
-
+ + > +
+
+
+ + $arIBlock):?> +
+
+ + ]" + id="IBLOCK_EXPORT" + value="" + + onclick="checkOne(this,);" + > +
+
+
+ > + + + + + + + + + + + $property): ?> + + + - - - - - - - - - $arIBlock) - { - ?> - - - - - - - -
+
Выгружаемое свойство
-
-   -
+
Свойство товара
+
+
Свойство торгового предложения
+
+ -
-
- - - > - - -   -
- - - - ]" - id="IBLOCK_EXPORT" - value="" - - onclick="checkOne(this,);" - > - - - " + name="IBLOCK_PROPERTY_PRODUCT[][]" + class="property-export" + onchange="propertyChange(this);"> + + - - -
+ + +
+ +
+
+
+ + + + + + +
-
-
+

function checkAll(obj,cnt) { - var boolCheck = obj.checked; - for (i = 0; i < cnt; i++) - { - BX('IBLOCK_EXPORT'+i).checked = boolCheck; - } - BX('count_checked').value = (boolCheck ? cnt : 0); + for (i = 0; i < cnt; i++) + { + if (obj.checked) + BX.removeClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); + } + var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE')); + if (obj.checked) + BX.removeClass(table,"iblock-export-table-display-none"); + var easing = new BX.easing({ + duration : 150, + start : {opacity : obj.checked ? 0 : 100 }, + finish : {opacity: obj.checked ? 100 : 0 }, + transition : BX.easing.transitions.linear, + step : function(state){ + for (i = 0; i < cnt; i++) + { + BX('IBLOCK_EXPORT_TABLE'+(i+1)).style.opacity = state.opacity/100; + } + }, + complete : function() { + for (i = 0; i < cnt; i++) + { + if (!obj.checked) + BX.addClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); + } + } + }); + easing.animate(); + var boolCheck = obj.checked; + for (i = 0; i < cnt; i++) + { + BX('IBLOCK_EXPORT'+(i+1)).checked = boolCheck; + } + BX('count_checked').value = (boolCheck ? cnt : 0); }; function checkOne(obj,cnt) { + var table = BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_EXPORT_TABLE')); + if (obj.checked) + BX.removeClass(table,"iblock-export-table-display-none"); + var easing = new BX.easing({ + duration : 150, + start : {opacity : obj.checked ? 0 : 100 }, + finish : {opacity: obj.checked ? 100 : 0 }, + transition : BX.easing.transitions.linear, + step : function(state){ + table.style.opacity = state.opacity/100; + }, + complete : function() { + if (!obj.checked) + BX.addClass(table,"iblock-export-table-display-none"); + } + }); + easing.animate(); var boolCheck = obj.checked; var intCurrent = parseInt(BX('count_checked').value); intCurrent += (boolCheck ? 1 : -1); BX('icml_export_all').checked = (intCurrent < cnt ? false : true); BX('count_checked').value = intCurrent; - if (!boolCheck) - BX(obj.id.replace('IBLOCK_EXPORT','IBLOCK_PROPERTY_ARTICLE')).value = 'none'; }; - function checkProfile(obj) + function propertyChange(obj) { - if (obj.value !== 'none') - $('#profile-field').show(); - else - $('#profile-field').hide(); + if (BX(obj.id).value !== 'none') { + if (obj.id.indexOf("SKU") !== -1) + BX(obj.id.replace('SKU','PRODUCT')).value = 'none'; + else + BX(obj.id.replace('PRODUCT','SKU')).value = 'none'; + } }; diff --git a/intaro.intarocrm/lang/ru/icml_export_setup.php b/intaro.intarocrm/lang/ru/icml_export_setup.php index 8b39a170..ee440a48 100644 --- a/intaro.intarocrm/lang/ru/icml_export_setup.php +++ b/intaro.intarocrm/lang/ru/icml_export_setup.php @@ -14,4 +14,8 @@ $MESS["ERROR_IBLOCK_CATALOG"] = "Модуль Каталог не установ $MESS["ERROR_IBLOCK_INTAROCRM"] = "Модуль IntaroCRM не установлен"; $MESS["ERROR_ARTICLE_NOT_SET"] = "Были установлены поля артикулов, но не установлены Информационные блоки"; $MESS["PROFILE_NAME"] = "Имя профиля"; +$MESS["SETTINGS_INFOBLOCK"] = "Настройки инфоблоков"; +$MESS["SETTINGS_EXPORT"] = "Настройки экспорта"; +$MESS["CHECK_ALL_INFOBLOCKS"] = "Выбрать все инфоблоки "; + ?> \ No newline at end of file