1
0
mirror of synced 2025-01-19 17:31:43 +03:00

Merge pull request #50 from iyzoer/master

v2.3.11
This commit is contained in:
Alex Lushpai 2018-10-09 13:59:56 +03:00 committed by GitHub
commit 7fd94ccd6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 474 additions and 416 deletions

View File

@ -1,3 +1,9 @@
## 2018-10-04 v.2.3.11
* Добавлен учет настроек часового пояса при создании заказа
* Устранено удаление событий изменения оплат при переводе выгрузки на агент
* Добавлена возможность указать свойство в настройках экспорта, из которого будет подставляться картинка, если отсутствует в "Подробно" и "Анонс"
* Добавлена подстановка домена в ссылках каталога в зависимости от пренадлежности инфоблока к сайту
## 2018-09-26 v.2.3.10 ## 2018-09-26 v.2.3.10
* Исправлена некорректная генерация скрипта UA * Исправлена некорректная генерация скрипта UA
* Исправлена выгрузка остатков, если для товара указано более 50 складов * Исправлена выгрузка остатков, если для товара указано более 50 складов

View File

@ -10,6 +10,7 @@ class RetailCrmICML
public $iblocks; public $iblocks;
public $filename; public $filename;
public $serverName; public $serverName;
public $defaultServerName;
public $propertiesSKU; public $propertiesSKU;
public $propertiesUnitSKU; public $propertiesUnitSKU;
public $propertiesProduct; public $propertiesProduct;
@ -20,6 +21,8 @@ class RetailCrmICML
public $encoding = 'utf-8'; public $encoding = 'utf-8';
public $encodingDefault = 'utf-8'; public $encodingDefault = 'utf-8';
public $loadPurchasePrice = false; public $loadPurchasePrice = false;
public $productPictures;
public $skuPictures;
protected $fp; protected $fp;
protected $mainSection = 1000000; protected $mainSection = 1000000;
@ -136,7 +139,7 @@ class RetailCrmICML
$newText = $this->application->ConvertCharset($text, $this->encodingDefault, $this->encoding); $newText = $this->application->ConvertCharset($text, $this->encodingDefault, $this->encoding);
$newText = strip_tags($newText); $newText = strip_tags($newText);
$newText = str_replace("&", "&", $newText); $newText = str_replace("&", "&", $newText);
return $newText; return $newText;
} }
@ -245,7 +248,6 @@ class RetailCrmICML
protected function BuildOffers(&$allCategories) protected function BuildOffers(&$allCategories)
{ {
$basePriceId = COption::GetOptionString( $basePriceId = COption::GetOptionString(
$this->MODULE_ID, $this->MODULE_ID,
$this->CRM_CATALOG_BASE_PRICE . (is_null($this->profileID) === false ? '_' . $this->profileID : ''), $this->CRM_CATALOG_BASE_PRICE . (is_null($this->profileID) === false ? '_' . $this->profileID : ''),
@ -253,7 +255,16 @@ class RetailCrmICML
); );
foreach ($this->iblocks as $key => $id) { foreach ($this->iblocks as $key => $id) {
$site = CAllIBlock::GetSite($id)->Fetch();
if ($site['SERVER_NAME']) {
$this->serverName = $site['SERVER_NAME'];
} else {
$this->serverName = $this->defaultServerName;
}
$barcodes = array(); $barcodes = array();
$dbBarCode = CCatalogStoreBarCode::getList( $dbBarCode = CCatalogStoreBarCode::getList(
array(), array(),
array("IBLOCK_ID" => $id), array("IBLOCK_ID" => $id),
@ -270,8 +281,8 @@ class RetailCrmICML
$highloadblockSkuProps = array(); $highloadblockSkuProps = array();
$highloadblockProductProps = array(); $highloadblockProductProps = array();
$productProps = CIBlockproperty::GetList(array(), array("IBLOCK_ID" => $id)); $productProps = CIBlockproperty::GetList(array(), array("IBLOCK_ID" => $id));
while ($arrProductProps = $productProps->Fetch()) { while ($arrProductProps = $productProps->Fetch()) {
if ($arrProductProps["USER_TYPE"] == 'directory') { if ($arrProductProps["USER_TYPE"] == 'directory') {
@ -282,10 +293,9 @@ class RetailCrmICML
// Get Info by infoblocks // Get Info by infoblocks
$iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch(); $iblock['IBLOCK_DB'] = CIBlock::GetByID($id)->Fetch();
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id); $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($id);
$skuProps = CIBlockproperty::GetList(array(), array("IBLOCK_ID" => $iblockOffer['IBLOCK_ID'])); $skuProps = CIBlockproperty::GetList(array(), array("IBLOCK_ID" => $iblockOffer['IBLOCK_ID']));
while ($arrSkuProps = $skuProps->Fetch()) {
while ($arrSkuProps = $skuProps->Fetch()) {
if ($arrSkuProps["USER_TYPE"] == 'directory') { if ($arrSkuProps["USER_TYPE"] == 'directory') {
$highloadblockSkuProps[$arrSkuProps['CODE']] = $arrSkuProps; $highloadblockSkuProps[$arrSkuProps['CODE']] = $arrSkuProps;
} }
@ -306,19 +316,26 @@ class RetailCrmICML
// Set selected properties // Set selected properties
foreach ($this->propertiesProduct[$id] as $key => $propProduct) { foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
if ($this->propertiesProduct[$id][$key] != "") { if ($this->propertiesProduct[$id][$key] != "") {
$arSelect[] = "PROPERTY_" . $propProduct; $arSelect[] = "PROPERTY_" . $propProduct;
$arSelect[] = "PROPERTY_" . $propProduct . ".NAME"; $arSelect[] = "PROPERTY_" . $propProduct . ".NAME";
} }
} }
if ($this->productPictures && isset($this->productPictures[$id])) {
$arSelect[] = "PROPERTY_" . $this->productPictures[$id]['picture'];
$arSelect[] = "PROPERTY_" . $this->productPictures[$id]['picture'] . ".NAME";
}
$arSelectOffer = array( $arSelectOffer = array(
'ID', 'ID',
"NAME", "NAME",
"DETAIL_PAGE_URL", "DETAIL_PAGE_URL",
"DETAIL_PICTURE", "DETAIL_PICTURE",
"PREVIEW_PICTURE",
'PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'], 'PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'],
"CATALOG_GROUP_" . $basePriceId "CATALOG_GROUP_" . $basePriceId
); );
// Set selected properties // Set selected properties
foreach ($this->propertiesSKU[$id] as $key => $propSKU) { foreach ($this->propertiesSKU[$id] as $key => $propSKU) {
if ($this->propertiesSKU[$id][$key] != "") { if ($this->propertiesSKU[$id][$key] != "") {
@ -327,6 +344,11 @@ class RetailCrmICML
} }
} }
if ($this->skuPictures && isset($this->skuPictures[$id])) {
$arSelectOffer[] = "PROPERTY_" . $this->skuPictures[$id]['picture'];
$arSelectOffer[] = "PROPERTY_" . $this->skuPictures[$id]['picture'] . ".NAME";
}
// Set filter // Set filter
$filter = array( $filter = array(
"IBLOCK_ID" => $id "IBLOCK_ID" => $id
@ -352,40 +374,16 @@ class RetailCrmICML
$dbResProducts = CIBlockElement::GetList($order, $arfilter, false, false, $arSelect); $dbResProducts = CIBlockElement::GetList($order, $arfilter, false, false, $arSelect);
$pictures = array();
$products = array(); $products = array();
while ($product = $dbResProducts->GetNext()) { while ($product = $dbResProducts->GetNext()) {
// Compile products to array // Compile products to array
$products[$product['ID']] = $product; $products[$product['ID']] = $product;
$products[$product['ID']]['offers'] = array(); $products[$product['ID']]['offers'] = array();
$detailPicture = intval($product["DETAIL_PICTURE"]);
$previewPicture = intval($product["PREVIEW_PICTURE"]);
if ($detailPicture > 0 || $previewPicture > 0) {
$picture = $detailPicture;
if ($picture <= 0) {
$picture = $previewPicture;
}
// Link pictureID and productID
$pictures[$picture] = $product['ID'];
}
} }
unset($product); unset($product);
unset($detailPicture, $previewPicture, $picture);
$pictureIDs = array_keys($pictures);
// Get pathes of pictures
$dbFiles = CFile::GetList(array(), array("@ID" => implode(',', $pictureIDs)));
while ($file = $dbFiles->GetNext()) {
// Link picture to product
$products[$pictures[$file['ID']]]['PICTURE'] = $this->protocol .
$this->serverName .
'/upload/' . $file['SUBDIR'] .
'/' . $file['FILE_NAME'] ;
}
unset($pictures);
if (!empty($iblockOffer['IBLOCK_ID'])) { if (!empty($iblockOffer['IBLOCK_ID'])) {
$arFilterOffer = array( $arFilterOffer = array(
@ -411,116 +409,140 @@ class RetailCrmICML
$stringOffers = ""; $stringOffers = "";
foreach ($products as $product) { foreach ($products as $product) {
// Get properties of product if (CFile::GetPath($product["DETAIL_PICTURE"])) {
$resPropertiesProduct = Array(); $product['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($product["DETAIL_PICTURE"]);
foreach ($this->propertiesProduct[$id] as $key => $propProduct) { } elseif (CFile::GetPath($product["PREVIEW_PICTURE"])){
$resPropertiesProduct[$key] = ""; $product['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($product["PREVIEW_PICTURE"]);
} elseif (
$this->productPictures
&& isset($this->productPictures[$id])
&& CFile::GetPath($product["PROPERTY_" . $this->productPictures[$id]['picture'] . "_VALUE"])
) {
$picture = CFile::GetPath($product["PROPERTY_" . $this->productPictures[$id]['picture'] . "_VALUE"]);
$product['PICTURE'] = $this->protocol . $this->serverName . $picture;
}
if ($propProduct != "") { // Get properties of product
if (isset($product["PROPERTY_" . $propProduct . "_NAME"])) { $resPropertiesProduct = Array();
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_NAME"]; foreach ($this->propertiesProduct[$id] as $key => $propProduct) {
} elseif (isset($product["PROPERTY_" . $propProduct . "_VALUE"])) { $resPropertiesProduct[$key] = "";
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"];
} elseif (isset($product[$propProduct])) {
$resPropertiesProduct[$key] = $product[$propProduct];
}
if (array_key_exists($key, $this->propertiesUnitProduct[$id])) {
$resPropertiesProduct[$key] *= $this->measurement[$this->propertiesUnitProduct[$id][$key]];
$resPropertiesProduct[$key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitProduct[$id][$key]];
}
if (isset($highloadblockProductProps[$propProduct])) {
$propVal = $this->getHBprop($highloadblockProductProps[$propProduct], $product["PROPERTY_" . $propProduct . "_VALUE"]);
$tableName = $highloadblockProductProps[$propProduct]['USER_TYPE_SETTINGS']['TABLE_NAME'];
$field = $this->highloadblockProductProperties[$tableName][$iblockOffer['IBLOCK_ID']][$key];
$resPropertiesProduct[$key] = $propVal[$field]; if ($propProduct != "") {
} if (isset($product["PROPERTY_" . $propProduct . "_NAME"])) {
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_NAME"];
} elseif (isset($product["PROPERTY_" . $propProduct . "_VALUE"])) {
$resPropertiesProduct[$key] = $product["PROPERTY_" . $propProduct . "_VALUE"];
} elseif (isset($product[$propProduct])) {
$resPropertiesProduct[$key] = $product[$propProduct];
}
if (array_key_exists($key, $this->propertiesUnitProduct[$id])) {
$resPropertiesProduct[$key] *= $this->measurement[$this->propertiesUnitProduct[$id][$key]];
$resPropertiesProduct[$key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitProduct[$id][$key]];
}
if (isset($highloadblockProductProps[$propProduct])) {
$propVal = $this->getHBprop($highloadblockProductProps[$propProduct], $product["PROPERTY_" . $propProduct . "_VALUE"]);
$tableName = $highloadblockProductProps[$propProduct]['USER_TYPE_SETTINGS']['TABLE_NAME'];
$field = $this->highloadblockProductProperties[$tableName][$id][$key];
$resPropertiesProduct[$key] = $propVal[$field];
} }
} }
}
// Get categories of product // Get categories of product
$categories = array(); $categories = array();
$dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true); $dbResCategories = CIBlockElement::GetElementGroups($product['ID'], true);
while ($arResCategory = $dbResCategories->Fetch()) { while ($arResCategory = $dbResCategories->Fetch()) {
$categories[$arResCategory["ID"]] = array( $categories[$arResCategory["ID"]] = array(
'ID' => $arResCategory["ID"], 'ID' => $arResCategory["ID"],
'NAME' => $arResCategory["NAME"], 'NAME' => $arResCategory["NAME"],
); );
} }
if (count($categories) == 0) { if (count($categories) == 0) {
$catId = $this->mainSection + $id; $catId = $this->mainSection + $id;
$categories[$catId] = $allCategories[$catId]; $categories[$catId] = $allCategories[$catId];
} }
$existOffer = false; $existOffer = false;
if (!empty($iblockOffer['IBLOCK_ID'])) { if (!empty($iblockOffer['IBLOCK_ID'])) {
foreach ($product['offers'] as $offer) { foreach ($product['offers'] as $offer) {
$offer['BARCODE'] = isset($barcodes[$offer['ID']]) ? $barcodes[$offer['ID']] : ''; $offer['BARCODE'] = isset($barcodes[$offer['ID']]) ? $barcodes[$offer['ID']] : '';
$offer['PRODUCT_ID'] = $product["ID"]; $offer['PRODUCT_ID'] = $product["ID"];
$offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"]; $offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
if (CFile::GetPath($offer["DETAIL_PICTURE"])) { if (CFile::GetPath($offer["DETAIL_PICTURE"])) {
$offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["DETAIL_PICTURE"]); $offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["DETAIL_PICTURE"]);
} else { } elseif (CFile::GetPath($offer["PREVIEW_PICTURE"])){
$offer['PICTURE'] = $product["PICTURE"]; $offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["PREVIEW_PICTURE"]);
} } elseif (
$this->skuPictures
$offer['PRODUCT_NAME'] = $product["NAME"]; && isset($this->skuPictures[$id])
$offer['PRODUCT_ACTIVE'] = $product["ACTIVE"]; && CFile::GetPath($offer["PROPERTY_" . $this->skuPictures[$id]['picture'] . "_VALUE"])
$offer['PRICE'] = $offer['CATALOG_PRICE_' . $basePriceId]; ) {
$offer['PURCHASE_PRICE'] = $offer['CATALOG_PURCHASING_PRICE']; $picture = CFile::GetPath($offer["PROPERTY_" . $this->skuPictures[$id]['picture'] . "_VALUE"]);
$offer['QUANTITY'] = $offer["CATALOG_QUANTITY"]; $offer['PICTURE'] = $this->protocol . $this->serverName . $picture;
} else {
// Get properties of product $offer['PICTURE'] = $product['PICTURE'];
foreach ($this->propertiesSKU[$id] as $key => $propSKU) { }
if ($propSKU != "") {
if (isset ($offer["PROPERTY_" . $propSKU . "_NAME"])) { $offer['PRODUCT_NAME'] = $product["NAME"];
$offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_NAME"]; $offer['PRODUCT_ACTIVE'] = $product["ACTIVE"];
} elseif (isset($offer["PROPERTY_" . $propSKU . "_VALUE"])) { $offer['PRICE'] = $offer['CATALOG_PRICE_' . $basePriceId];
$offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_VALUE"]; $offer['PURCHASE_PRICE'] = $offer['CATALOG_PURCHASING_PRICE'];
} elseif (isset($offer[$propSKU])) { $offer['QUANTITY'] = $offer["CATALOG_QUANTITY"];
$offer['_PROP_' . $key] = $offer[$propSKU];
} // Get properties of product
if (array_key_exists($key, $this->propertiesUnitSKU[$id])) { foreach ($this->propertiesSKU[$id] as $key => $propSKU) {
$offer['_PROP_' . $key] *= $this->measurement[$this->propertiesUnitSKU[$id][$key]]; if ($propSKU != "") {
$offer['_PROP_' . $key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitSKU[$id][$key]]; if (isset ($offer["PROPERTY_" . $propSKU . "_NAME"])) {
} $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_NAME"];
if (isset($highloadblockSkuProps[$propSKU])) { } elseif (isset($offer["PROPERTY_" . $propSKU . "_VALUE"])) {
$propVal = $this->getHBprop($highloadblockSkuProps[$propSKU], $offer["PROPERTY_" . $propSKU . "_VALUE"]); $offer['_PROP_' . $key] = $offer["PROPERTY_" . $propSKU . "_VALUE"];
$tableName = $highloadblockSkuProps[$propSKU]['USER_TYPE_SETTINGS']['TABLE_NAME']; } elseif (isset($offer[$propSKU])) {
$field = $this->highloadblockSkuProperties[$tableName][$id][$key]; $offer['_PROP_' . $key] = $offer[$propSKU];
$offer['_PROP_' . $key] = $propVal[$field]; }
} if (array_key_exists($key, $this->propertiesUnitSKU[$id])) {
} $offer['_PROP_' . $key] *= $this->measurement[$this->propertiesUnitSKU[$id][$key]];
} $offer['_PROP_' . $key . "_UNIT"] = $this->measurementLink[$this->propertiesUnitSKU[$id][$key]];
}
foreach ($resPropertiesProduct as $key => $propProduct) { if (isset($highloadblockSkuProps[$propSKU])) {
if ($this->propertiesProduct[$id][$key] != "" && !isset($offer[$key])) { $propVal = $this->getHBprop($highloadblockSkuProps[$propSKU], $offer["PROPERTY_" . $propSKU . "_VALUE"]);
$offer['_PROP_' . $key] = $propProduct; $tableName = $highloadblockSkuProps[$propSKU]['USER_TYPE_SETTINGS']['TABLE_NAME'];
} $field = $this->highloadblockSkuProperties[$tableName][$id][$key];
} $offer['_PROP_' . $key] = $propVal[$field];
}
$stringOffers .= $this->BuildOffer($offer, $categories, $iblock, $allCategories); }
$existOffer = true;
} }
}
if (!$existOffer) {
$offer['BARCODE'] = isset($barcodes[$product["ID"]]) ? $barcodes[$product["ID"]] : '';
$product['PRODUCT_ID'] = $product["ID"];
$product['PRODUCT_NAME'] = $product["NAME"];
$product['PRODUCT_ACTIVE'] = $product["ACTIVE"];
$product['PRICE'] = $product['CATALOG_PRICE_' . $basePriceId];
$product['PURCHASE_PRICE'] = $product['CATALOG_PURCHASING_PRICE'];
$product['QUANTITY'] = $product["CATALOG_QUANTITY"];
foreach ($resPropertiesProduct as $key => $propProduct) { foreach ($resPropertiesProduct as $key => $propProduct) {
if ($this->propertiesProduct[$id][$key] != "" || $this->propertiesProduct[$id][str_replace("_UNIT", "", $key)] != "") { if ($this->propertiesProduct[$id][$key] != "" && !isset($offer[$key])) {
$product['_PROP_' . $key] = $propProduct; $offer['_PROP_' . $key] = $propProduct;
} }
} }
$stringOffers .= $this->BuildOffer($product, $categories, $iblock, $allCategories); $stringOffers .= $this->BuildOffer($offer, $categories, $iblock, $allCategories);
$existOffer = true;
} }
}
if (!$existOffer) {
$offer['BARCODE'] = isset($barcodes[$product["ID"]]) ? $barcodes[$product["ID"]] : '';
$product['PRODUCT_ID'] = $product["ID"];
$product['PRODUCT_NAME'] = $product["NAME"];
$product['PRODUCT_ACTIVE'] = $product["ACTIVE"];
$product['PRICE'] = $product['CATALOG_PRICE_' . $basePriceId];
$product['PURCHASE_PRICE'] = $product['CATALOG_PURCHASING_PRICE'];
$product['QUANTITY'] = $product["CATALOG_QUANTITY"];
foreach ($resPropertiesProduct as $key => $propProduct) {
if ($this->propertiesProduct[$id][$key] != "" || $this->propertiesProduct[$id][str_replace("_UNIT", "", $key)] != "") {
$product['_PROP_' . $key] = $propProduct;
}
}
$stringOffers .= $this->BuildOffer($product, $categories, $iblock, $allCategories);
}
} }
unset($products); unset($products);
@ -568,7 +590,10 @@ class RetailCrmICML
$arOffer['DETAIL_PAGE_URL'] = str_replace("#SECTION_PATH#", $path, $arOffer['DETAIL_PAGE_URL']); $arOffer['DETAIL_PAGE_URL'] = str_replace("#SECTION_PATH#", $path, $arOffer['DETAIL_PAGE_URL']);
} }
$offer .= "<picture>" . $this->PrepareValue($arOffer["PICTURE"]) . "</picture>\n"; if (isset($arOffer["PICTURE"]) && $arOffer["PICTURE"]) {
$offer .= "<picture>" . $this->PrepareValue($arOffer["PICTURE"]) . "</picture>\n";
}
$offer .= "<url>" . $this->protocol . $this->serverName . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "</url>\n"; $offer .= "<url>" . $this->protocol . $this->serverName . $this->PrepareValue($arOffer['DETAIL_PAGE_URL']) . "</url>\n";
$offer .= "<price>" . $this->PrepareValue($arOffer['PRICE']) . "</price>\n"; $offer .= "<price>" . $this->PrepareValue($arOffer['PRICE']) . "</price>\n";
@ -615,7 +640,7 @@ class RetailCrmICML
} }
$offer.= "</offer>\n"; $offer.= "</offer>\n";
return $offer; return $offer;
} }

View File

@ -47,7 +47,7 @@ class RetailCrmOrder
$order = array( $order = array(
'number' => $arFields['NUMBER'], 'number' => $arFields['NUMBER'],
'externalId' => $arFields['ID'], 'externalId' => $arFields['ID'],
'createdAt' => new \DateTime($arFields['DATE_INSERT']), 'createdAt' => $arFields['DATE_INSERT'],
'customer' => array('externalId' => $arFields['USER_ID']), 'customer' => array('externalId' => $arFields['USER_ID']),
'paymentType' => isset($arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]]) ? 'paymentType' => isset($arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]]) ?
$arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]] : '', $arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]] : '',
@ -92,7 +92,7 @@ class RetailCrmOrder
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot(); $server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$countrys = array(); $countrys = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) { if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
$countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
foreach ($countrysFile->country as $country) { foreach ($countrysFile->country as $country) {
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; $countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
} }
@ -153,7 +153,7 @@ class RetailCrmOrder
$order = $newResOrder; $order = $newResOrder;
} elseif ($newResOrder === false) { } elseif ($newResOrder === false) {
RCrmActions::eventLog('RetailCrmOrder::orderSend', 'retailCrmBeforeOrderSend()', 'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend'); RCrmActions::eventLog('RetailCrmOrder::orderSend', 'retailCrmBeforeOrderSend()', 'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend');
return false; return false;
} }
} }
@ -172,7 +172,7 @@ class RetailCrmOrder
return $order; return $order;
} }
/** /**
* Mass order uploading, without repeating; always returns true, but writes error log * Mass order uploading, without repeating; always returns true, but writes error log
* @param $pSize * @param $pSize
@ -224,7 +224,7 @@ class RetailCrmOrder
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0); $api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0); $api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0)); $optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0)); $optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0)); $optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0)); $optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
@ -258,19 +258,19 @@ class RetailCrmOrder
} }
$order = self::orderObjToArr($id); $order = self::orderObjToArr($id);
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch(); $user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
$site = count($optionsSitesList) > 1 ? $optionsSitesList[$order['LID']] : null; $site = count($optionsSitesList) > 1 ? $optionsSitesList[$order['LID']] : null;
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site); $arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
$arOrders = self::orderSend($order, $api, $arParams, false, $site); $arOrders = self::orderSend($order, $api, $arParams, false, $site);
if (!$arCustomers || !$arOrders) { if (!$arCustomers || !$arOrders) {
continue; continue;
} }
$resCustomers[$order['LID']][] = $arCustomers; $resCustomers[$order['LID']][] = $arCustomers;
$resOrders[$order['LID']][] = $arOrders; $resOrders[$order['LID']][] = $arOrders;
$recOrders[] = $orderId; $recOrders[] = $orderId;
} }
@ -321,11 +321,12 @@ class RetailCrmOrder
public static function orderObjToArr($obOrder) public static function orderObjToArr($obOrder)
{ {
$culture = new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"));
$arOrder = array( $arOrder = array(
'ID' => $obOrder->getId(), 'ID' => $obOrder->getId(),
'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'), 'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'),
'LID' => $obOrder->getSiteId(), 'LID' => $obOrder->getSiteId(),
'DATE_INSERT' => $obOrder->getDateInsert(), 'DATE_INSERT' => $obOrder->getDateInsert()->toString($culture),
'STATUS_ID' => $obOrder->getField('STATUS_ID'), 'STATUS_ID' => $obOrder->getField('STATUS_ID'),
'USER_ID' => $obOrder->getUserId(), 'USER_ID' => $obOrder->getUserId(),
'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(), 'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(),
@ -341,7 +342,7 @@ class RetailCrmOrder
'COMMENTS' => $obOrder->getField('COMMENTS'), 'COMMENTS' => $obOrder->getField('COMMENTS'),
'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED'), 'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED'),
); );
$shipmentList = $obOrder->getShipmentCollection(); $shipmentList = $obOrder->getShipmentCollection();
foreach ($shipmentList as $shipmentData) { foreach ($shipmentList as $shipmentData) {
if ($shipmentData->isSystem()) { if ($shipmentData->isSystem()) {
@ -370,7 +371,7 @@ class RetailCrmOrder
foreach ($basketItems as $item) { foreach ($basketItems as $item) {
$arOrder['BASKET'][] = $item->getFields(); $arOrder['BASKET'][] = $item->getFields();
} }
return $arOrder; return $arOrder;
} }
} }

View File

@ -36,7 +36,7 @@ class RetailCrmOrder
* @return array - array('order' = $order, 'customer' => $customer) * @return array - array('order' = $order, 'customer' => $customer)
*/ */
public static function orderSend($arFields, $api, $arParams, $send = false, $site = null, $methodApi = 'ordersEdit') public static function orderSend($arFields, $api, $arParams, $send = false, $site = null, $methodApi = 'ordersEdit')
{ {
if (!$api || empty($arParams)) { // add cond to check $arParams if (!$api || empty($arParams)) { // add cond to check $arParams
return false; return false;
} }
@ -50,7 +50,7 @@ class RetailCrmOrder
$order = array( $order = array(
'number' => $arFields['NUMBER'], 'number' => $arFields['NUMBER'],
'externalId' => $arFields['ID'], 'externalId' => $arFields['ID'],
'createdAt' => new \DateTime($arFields['DATE_INSERT']), 'createdAt' => $arFields['DATE_INSERT'],
'customer' => array('externalId' => $arFields['USER_ID']), 'customer' => array('externalId' => $arFields['USER_ID']),
'orderType' => isset($arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']]) ? 'orderType' => isset($arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']]) ?
$arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '', $arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '',
@ -96,7 +96,7 @@ class RetailCrmOrder
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot(); $server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$countrys = array(); $countrys = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) { if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
$countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
foreach ($countrysFile->country as $country) { foreach ($countrysFile->country as $country) {
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; $countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
} }
@ -202,22 +202,30 @@ class RetailCrmOrder
} }
$payments[] = $pm; $payments[] = $pm;
} else { } else {
RCrmActions::eventLog('RetailCrmOrder::orderSend', 'payments', 'OrderID = ' . $arFields['ID'] . '. Payment not found.'); RCrmActions::eventLog(
'RetailCrmOrder::orderSend',
'payments',
'OrderID = ' . $arFields['ID'] . '. Payment not found.'
);
continue; continue;
} }
} }
if (count($payments) > 0) { if (count($payments) > 0) {
$order['payments'] = $payments; $order['payments'] = $payments;
} }
//send //send
if (function_exists('retailCrmBeforeOrderSend')) { if (function_exists('retailCrmBeforeOrderSend')) {
$newResOrder = retailCrmBeforeOrderSend($order, $arFields); $newResOrder = retailCrmBeforeOrderSend($order, $arFields);
if (is_array($newResOrder) && !empty($newResOrder)) { if (is_array($newResOrder) && !empty($newResOrder)) {
$order = $newResOrder; $order = $newResOrder;
} elseif ($newResOrder === false) { } elseif ($newResOrder === false) {
RCrmActions::eventLog('RetailCrmOrder::orderSend', 'retailCrmBeforeOrderSend()', 'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend'); RCrmActions::eventLog(
'RetailCrmOrder::orderSend',
'retailCrmBeforeOrderSend()',
'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend'
);
return false; return false;
} }
@ -237,7 +245,7 @@ class RetailCrmOrder
return $order; return $order;
} }
/** /**
* Mass order uploading, without repeating; always returns true, but writes error log * Mass order uploading, without repeating; always returns true, but writes error log
* @param $pSize * @param $pSize
@ -289,7 +297,7 @@ class RetailCrmOrder
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0); $api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0); $api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0)); $optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
$optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0)); $optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0)); $optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0));
$optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0)); $optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0));
@ -325,18 +333,18 @@ class RetailCrmOrder
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch(); $user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site); $arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
$arOrders = self::orderSend($order, $api, $arParams, false, $site); $arOrders = self::orderSend($order, $api, $arParams, false, $site);
if (!$arCustomers || !$arOrders) { if (!$arCustomers || !$arOrders) {
continue; continue;
} }
$resCustomers[$order['LID']][] = $arCustomers; $resCustomers[$order['LID']][] = $arCustomers;
$resOrders[$order['LID']][] = $arOrders; $resOrders[$order['LID']][] = $arOrders;
$recOrders[] = $orderId; $recOrders[] = $orderId;
} }
if (count($resOrders) > 0) { if (count($resOrders) > 0) {
foreach ($resCustomers as $key => $customerLoad) { foreach ($resCustomers as $key => $customerLoad) {
if ($optionsSitesList) { if ($optionsSitesList) {
@ -384,11 +392,12 @@ class RetailCrmOrder
public static function orderObjToArr($obOrder) public static function orderObjToArr($obOrder)
{ {
$culture = new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"));
$arOrder = array( $arOrder = array(
'ID' => $obOrder->getId(), 'ID' => $obOrder->getId(),
'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'), 'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'),
'LID' => $obOrder->getSiteId(), 'LID' => $obOrder->getSiteId(),
'DATE_INSERT' => $obOrder->getDateInsert(), 'DATE_INSERT' => $obOrder->getDateInsert()->toString($culture),
'STATUS_ID' => $obOrder->getField('STATUS_ID'), 'STATUS_ID' => $obOrder->getField('STATUS_ID'),
'USER_ID' => $obOrder->getUserId(), 'USER_ID' => $obOrder->getUserId(),
'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(), 'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(),

View File

@ -1,3 +1,4 @@
- Исправлена некорректная генерация скрипта UA - Добавлен учет настроек часового пояса при создании заказа
- Улучшена выгрузка остатков по складам в retailCRM - Устранено удаление событий изменения оплат при переводе выгрузки на агент
- Улучшена обработка истории изменений заказов - Добавлена возможность указать свойство в настройках экспорта, из которого будет подставляться картинка, если отсутствует в "Подробно" и "Анонс"
- Добавлена подстановка домена в ссылках каталога в зависимости от пренадлежности инфоблока к сайту

View File

@ -15,7 +15,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
if (!CModule::IncludeModule("intaro.retailcrm")){ if (!CModule::IncludeModule("intaro.retailcrm")){
return; return;
} }
$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); $rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y'));
while ($ar = $rsSites->Fetch()) { while ($ar = $rsSites->Fetch()) {
if ($ar['DEF'] == 'Y') { if ($ar['DEF'] == 'Y') {
@ -113,6 +113,22 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
} }
} }
$productPictures = array();
if (is_array($IBLOCK_PROPERTY_PRODUCT_picture)) {
foreach ($IBLOCK_PROPERTY_PRODUCT_picture as $key => $value) {
$productPictures[$key]['picture'] = $value;
}
}
$skuPictures = array();
if (is_array($IBLOCK_PROPERTY_SKU_picture)) {
foreach ($IBLOCK_PROPERTY_SKU_picture as $key => $value) {
$skuPictures[$key]['picture'] = $value;
}
}
$loader = new RetailCrmICML(); $loader = new RetailCrmICML();
$loader->profileID = $PROFILE_ID; $loader->profileID = $PROFILE_ID;
$loader->iblocks = $IBLOCK_EXPORT; $loader->iblocks = $IBLOCK_EXPORT;
@ -120,6 +136,8 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
$loader->propertiesUnitSKU = $IBLOCK_PROPERTY_UNIT_SKU; $loader->propertiesUnitSKU = $IBLOCK_PROPERTY_UNIT_SKU;
$loader->propertiesProduct = $IBLOCK_PROPERTY_PRODUCT; $loader->propertiesProduct = $IBLOCK_PROPERTY_PRODUCT;
$loader->propertiesUnitProduct = $IBLOCK_PROPERTY_UNIT_PRODUCT; $loader->propertiesUnitProduct = $IBLOCK_PROPERTY_UNIT_PRODUCT;
$loader->productPictures = $productPictures;
$loader->skuPictures = $skuPictures;
if ($hlblockModule === true) { if ($hlblockModule === true) {
$loader->highloadblockSkuProperties = $IBLOCK_PROPERTY_SKU_HIGHLOADBLOCK; $loader->highloadblockSkuProperties = $IBLOCK_PROPERTY_SKU_HIGHLOADBLOCK;
@ -127,7 +145,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
} }
$loader->filename = $SETUP_FILE_NAME; $loader->filename = $SETUP_FILE_NAME;
$loader->serverName = $SERVER_NAME; $loader->defaultServerName = $SERVER_NAME;
$loader->application = $APPLICATION; $loader->application = $APPLICATION;
$loader->loadPurchasePrice = $LOAD_PURCHASE_PRICE == 'Y'; $loader->loadPurchasePrice = $LOAD_PURCHASE_PRICE == 'Y';
$loader->Load(); $loader->Load();

View File

@ -29,6 +29,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
"length" => "length", "length" => "length",
"width" => "width", "width" => "width",
"height" => "height", "height" => "height",
"picture" => "picture"
); );
if(!check_bitrix_sessid()) { if(!check_bitrix_sessid()) {
@ -164,10 +165,10 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
"length" => GetMessage("PROPERTY_LENGTH_HEADER_NAME"), "length" => GetMessage("PROPERTY_LENGTH_HEADER_NAME"),
"width" => GetMessage("PROPERTY_WIDTH_HEADER_NAME"), "width" => GetMessage("PROPERTY_WIDTH_HEADER_NAME"),
"height" => GetMessage("PROPERTY_HEIGHT_HEADER_NAME"), "height" => GetMessage("PROPERTY_HEIGHT_HEADER_NAME"),
"picture" => GetMessage("PROPERTY_PICTURE_HEADER_NAME")
); );
$iblockFieldsName = Array( $iblockFieldsName = Array(
"weight" => Array("code" => "catalog_weight" , "name" => GetMessage("SELECT_WEIGHT_PROPERTY_NAME"), 'unit' => 'mass'), "weight" => Array("code" => "catalog_weight" , "name" => GetMessage("SELECT_WEIGHT_PROPERTY_NAME"), 'unit' => 'mass'),
"length" => Array("code" => "catalog_length" , "name" => GetMessage("SELECT_LENGTH_PROPERTY_NAME"), 'unit' => 'length'), "length" => Array("code" => "catalog_length" , "name" => GetMessage("SELECT_LENGTH_PROPERTY_NAME"), 'unit' => 'length'),
"width" => Array("code" => "catalog_width" , "name" => GetMessage("SELECT_WIDTH_PROPERTY_NAME"), 'unit' => 'length'), "width" => Array("code" => "catalog_width" , "name" => GetMessage("SELECT_WIDTH_PROPERTY_NAME"), 'unit' => 'length'),
@ -183,6 +184,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
"length" => Array("LENGTH", "DLINA"), "length" => Array("LENGTH", "DLINA"),
"width" => Array("WIDTH", "SHIRINA"), "width" => Array("WIDTH", "SHIRINA"),
"height" => Array("HEIGHT", "VISOTA"), "height" => Array("HEIGHT", "VISOTA"),
"picture" => Array("PICTURE", "PICTURE")
); );
$units = Array( $units = Array(
@ -795,7 +797,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
$vals .= ",IBLOCK_PROPERTY_PRODUCT_" . $val; $vals .= ",IBLOCK_PROPERTY_PRODUCT_" . $val;
$vals .= ",IBLOCK_PROPERTY_UNIT_PRODUCT_" . $val; $vals .= ",IBLOCK_PROPERTY_UNIT_PRODUCT_" . $val;
if ($hlblockModule === true) { if ($hlblockModule === true && $val != 'picture') {
foreach ($hlblockList as $hlblockTable => $hlblock) { foreach ($hlblockList as $hlblockTable => $hlblock) {
$vals .= ',highloadblock' . $hlblockTable . '_' . $val; $vals .= ',highloadblock' . $hlblockTable . '_' . $val;
} }

View File

@ -10,7 +10,7 @@ IncludeModuleLangFile(__FILE__);
if (class_exists('intaro_retailcrm')) if (class_exists('intaro_retailcrm'))
return; return;
class intaro_retailcrm extends CModule class intaro_retailcrm extends CModule
{ {
var $MODULE_ID = 'intaro.retailcrm'; var $MODULE_ID = 'intaro.retailcrm';
var $OLD_MODULE_ID = 'intaro.intarocrm'; var $OLD_MODULE_ID = 'intaro.intarocrm';
@ -19,10 +19,10 @@ class intaro_retailcrm extends CModule
var $MODULE_NAME; var $MODULE_NAME;
var $MODULE_DESCRIPTION; var $MODULE_DESCRIPTION;
var $MODULE_GROUP_RIGHTS = 'N'; var $MODULE_GROUP_RIGHTS = 'N';
var $PARTNER_NAME; var $PARTNER_NAME;
var $PARTNER_URI; var $PARTNER_URI;
var $RETAIL_CRM_API; var $RETAIL_CRM_API;
var $RETAIL_CRM_EXPORT = 'retailcrm'; var $RETAIL_CRM_EXPORT = 'retailcrm';
var $CRM_API_HOST_OPTION = 'api_host'; var $CRM_API_HOST_OPTION = 'api_host';
@ -59,16 +59,16 @@ class intaro_retailcrm extends CModule
var $CRM_PRICES = 'prices'; var $CRM_PRICES = 'prices';
var $CRM_PRICE_SHOPS = 'price_shops'; var $CRM_PRICE_SHOPS = 'price_shops';
var $CRM_IBLOCKS_PRICES = 'iblock_prices'; var $CRM_IBLOCKS_PRICES = 'iblock_prices';
var $CRM_COLLECTOR = 'collector'; var $CRM_COLLECTOR = 'collector';
var $CRM_COLL_KEY = 'coll_key'; var $CRM_COLL_KEY = 'coll_key';
var $CRM_UA = 'ua'; var $CRM_UA = 'ua';
var $CRM_UA_KEYS = 'ua_keys'; var $CRM_UA_KEYS = 'ua_keys';
var $CRM_API_VERSION = 'api_version'; var $CRM_API_VERSION = 'api_version';
var $HISTORY_TIME = 'history_time'; var $HISTORY_TIME = 'history_time';
var $INSTALL_PATH; var $INSTALL_PATH;
function intaro_retailcrm() function intaro_retailcrm()
@ -98,18 +98,18 @@ class intaro_retailcrm extends CModule
$APPLICATION->ThrowException(GetMessage("RETAILCRM_CURL_ERR")); $APPLICATION->ThrowException(GetMessage("RETAILCRM_CURL_ERR"));
return false; return false;
} }
$infoSale = CModule::CreateModuleObject('sale')->MODULE_VERSION; $infoSale = CModule::CreateModuleObject('sale')->MODULE_VERSION;
if (version_compare($infoSale, '16', '<=')) { if (version_compare($infoSale, '16', '<=')) {
$APPLICATION->ThrowException(GetMessage("SALE_VERSION_ERR")); $APPLICATION->ThrowException(GetMessage("SALE_VERSION_ERR"));
return false; return false;
} }
if (!date_default_timezone_get()) { if (!date_default_timezone_get()) {
if (!ini_get('date.timezone')) { if (!ini_get('date.timezone')) {
$APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR")); $APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR"));
return false; return false;
} }
} }
@ -124,7 +124,7 @@ class intaro_retailcrm extends CModule
include($this->INSTALL_PATH . '/../classes/general/Exception/CurlException.php'); include($this->INSTALL_PATH . '/../classes/general/Exception/CurlException.php');
include($this->INSTALL_PATH . '/../classes/general/RestNormalizer.php'); include($this->INSTALL_PATH . '/../classes/general/RestNormalizer.php');
include($this->INSTALL_PATH . '/../classes/general/Logger.php'); include($this->INSTALL_PATH . '/../classes/general/Logger.php');
$version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0); $version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0);
if ($version == 'v4') { if ($version == 'v4') {
include($this->INSTALL_PATH . '/../classes/general/ApiClient_v4.php'); include($this->INSTALL_PATH . '/../classes/general/ApiClient_v4.php');
@ -139,7 +139,7 @@ class intaro_retailcrm extends CModule
$step = intval($_REQUEST['step']); $step = intval($_REQUEST['step']);
if (file_exists($this->INSTALL_PATH . '/../classes/general/config/options.xml')) { if (file_exists($this->INSTALL_PATH . '/../classes/general/config/options.xml')) {
$options = simplexml_load_file($this->INSTALL_PATH . '/../classes/general/config/options.xml'); $options = simplexml_load_file($this->INSTALL_PATH . '/../classes/general/config/options.xml');
foreach ($options->contragents->contragent as $contragent) { foreach ($options->contragents->contragent as $contragent) {
$type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET); $type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET);
@ -157,8 +157,8 @@ class intaro_retailcrm extends CModule
$arResult['orderProps'][] = $type; $arResult['orderProps'][] = $type;
} else { } else {
$groups = explode(",", (string)$field["group"]); $groups = explode(",", (string)$field["group"]);
foreach ($groups as $group) { foreach ($groups as $group) {
$type["GROUP"][] = trim($group); $type["GROUP"][] = trim($group);
} }
$arResult['legalDetails'][] = $type; $arResult['legalDetails'][] = $type;
} }
@ -184,14 +184,14 @@ class intaro_retailcrm extends CModule
if (!CModule::IncludeModule("catalog")) { if (!CModule::IncludeModule("catalog")) {
$arResult['errCode'] = 'ERR_CATALOG'; $arResult['errCode'] = 'ERR_CATALOG';
} }
if ($api_host = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_API_HOST_OPTION, 0)) { if ($api_host = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_API_HOST_OPTION, 0)) {
$arResult['API_HOST'] = $api_host; $arResult['API_HOST'] = $api_host;
} }
if ($api_key = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_API_KEY_OPTION, 0)) { if ($api_key = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_API_KEY_OPTION, 0)) {
$arResult['API_KEY'] = $api_key; $arResult['API_KEY'] = $api_key;
} }
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
@ -213,17 +213,17 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
$api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
$api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION])); $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
// form correct url // form correct url
$api_host = parse_url($api_host); $api_host = parse_url($api_host);
if ($api_host['scheme'] != 'https') { if ($api_host['scheme'] != 'https') {
$api_host['scheme'] = 'https'; $api_host['scheme'] = 'https';
} }
$api_host = $api_host['scheme'] . '://' . $api_host['host']; $api_host = $api_host['scheme'] . '://' . $api_host['host'];
@ -232,10 +232,10 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
$ping = self::ping($api_host, $api_key); $ping = self::ping($api_host, $api_key);
if (isset($ping['sitesList'])) { if (isset($ping['sitesList'])) {
$arResult['sitesList'] = $ping['sitesList']; $arResult['sitesList'] = $ping['sitesList'];
@ -244,13 +244,13 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
if ($sites_list = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_SITES_LIST, 0)) { if ($sites_list = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_SITES_LIST, 0)) {
$arResult['SITES_LIST'] = unserialize($sites_list); $arResult['SITES_LIST'] = unserialize($sites_list);
} }
@ -273,14 +273,14 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
$arResult['arSites'] = RCrmActions::SitesList(); $arResult['arSites'] = RCrmActions::SitesList();
if (count($arResult['arSites']) > 1) { if (count($arResult['arSites']) > 1) {
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0); $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
@ -296,7 +296,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step11.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step11.php'
); );
return; return;
} }
@ -318,10 +318,10 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
$ping = self::ping($api_host, $api_key); $ping = self::ping($api_host, $api_key);
if (isset($ping['sitesList'])) { if (isset($ping['sitesList'])) {
$arResult['sitesList'] = $ping['sitesList']; $arResult['sitesList'] = $ping['sitesList'];
@ -330,18 +330,18 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key); $this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize(array())); COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize(array()));
} }
//prepare crm lists //prepare crm lists
try { try {
$arResult['orderTypesList'] = $this->RETAIL_CRM_API->orderTypesList()->orderTypes; $arResult['orderTypesList'] = $this->RETAIL_CRM_API->orderTypesList()->orderTypes;
$arResult['deliveryTypesList'] = $this->RETAIL_CRM_API->deliveryTypesList()->deliveryTypes; $arResult['deliveryTypesList'] = $this->RETAIL_CRM_API->deliveryTypesList()->deliveryTypes;
$arResult['deliveryServicesList'] = $this->RETAIL_CRM_API->deliveryServicesList()->deliveryServices; $arResult['deliveryServicesList'] = $this->RETAIL_CRM_API->deliveryServicesList()->deliveryServices;
@ -359,7 +359,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
); );
return; return;
} }
@ -370,10 +370,10 @@ class intaro_retailcrm extends CModule
} }
} }
$arResult['deliveryTypesList'] = $delivTypes; $arResult['deliveryTypesList'] = $delivTypes;
//bitrix personTypes //bitrix personTypes
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']); $arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
//bitrix deliveryList //bitrix deliveryList
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList(); $arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
@ -382,7 +382,7 @@ class intaro_retailcrm extends CModule
//bitrix statusesList --statuses //bitrix statusesList --statuses
$arResult['bitrixStatusesList'] = RCrmActions::StatusesList(); $arResult['bitrixStatusesList'] = RCrmActions::StatusesList();
if ($order_types = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_TYPES_ARR, 0)) { if ($order_types = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_TYPES_ARR, 0)) {
$arResult['ORDER_TYPES'] = array_flip(unserialize($order_types)); $arResult['ORDER_TYPES'] = array_flip(unserialize($order_types));
} }
@ -421,7 +421,7 @@ class intaro_retailcrm extends CModule
//bitrix orderTypesList //bitrix orderTypesList
$arResult['arSites'] = RCrmActions::SitesList(); $arResult['arSites'] = RCrmActions::SitesList();
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']); $arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
$orderTypesArr = array(); $orderTypesArr = array();
foreach ($arResult['bitrixOrderTypesList'] as $orderType) { foreach ($arResult['bitrixOrderTypesList'] as $orderType) {
$orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']])); $orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']]));
@ -429,7 +429,7 @@ class intaro_retailcrm extends CModule
//bitrix deliveryTypesList //bitrix deliveryTypesList
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList(); $arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'false') { if (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'false') {
$deliveryTypesArr = array(); $deliveryTypesArr = array();
foreach ($arResult['bitrixDeliveryTypesList'] as $delivery) { foreach ($arResult['bitrixDeliveryTypesList'] as $delivery) {
@ -482,7 +482,7 @@ class intaro_retailcrm extends CModule
//bitrix paymentTypesList //bitrix paymentTypesList
$arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList(); $arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList();
$paymentTypesArr = array(); $paymentTypesArr = array();
foreach ($arResult['bitrixPaymentTypesList'] as $payment) { foreach ($arResult['bitrixPaymentTypesList'] as $payment) {
$paymentTypesArr[$payment['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $payment['ID']])); $paymentTypesArr[$payment['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $payment['ID']]));
@ -490,7 +490,7 @@ class intaro_retailcrm extends CModule
//bitrix statusesList //bitrix statusesList
$arResult['bitrixStatusesList'] = RCrmActions::StatusesList(); $arResult['bitrixStatusesList'] = RCrmActions::StatusesList();
$paymentStatusesArr = array(); $paymentStatusesArr = array();
$canselOrderArr = array(); $canselOrderArr = array();
@ -505,9 +505,9 @@ class intaro_retailcrm extends CModule
$paymentArr = array(); $paymentArr = array();
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
//new page //new page
//form orderProps //form orderProps
$arResult['arProp'] = RCrmActions::OrderPropsList(); $arResult['arProp'] = RCrmActions::OrderPropsList();
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr($orderTypesArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr($orderTypesArr)));
@ -519,7 +519,7 @@ class intaro_retailcrm extends CModule
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1);
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array())); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array()));
COption::SetOptionString($this->MODULE_ID, $this->CRM_CANSEL_ORDER, serialize(RCrmActions::clearArr($canselOrderArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_CANSEL_ORDER, serialize(RCrmActions::clearArr($canselOrderArr)));
if ($orderProps = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_PROPS, 0)) { if ($orderProps = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_PROPS, 0)) {
$arResult['ORDER_PROPS'] = unserialize($orderProps); $arResult['ORDER_PROPS'] = unserialize($orderProps);
} }
@ -532,7 +532,7 @@ class intaro_retailcrm extends CModule
if ($contragentType = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_CONTRAGENT_TYPE, 0)) { if ($contragentType = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_CONTRAGENT_TYPE, 0)) {
$arResult['CONTRAGENT_TYPES'] = unserialize($contragentType); $arResult['CONTRAGENT_TYPES'] = unserialize($contragentType);
} }
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step3.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step3.php'
); );
@ -573,16 +573,16 @@ class intaro_retailcrm extends CModule
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
die(json_encode(array("finish" => $finish, "percent" => $percent))); die(json_encode(array("finish" => $finish, "percent" => $percent)));
} }
if (isset($_POST['back']) && $_POST['back']) { if (isset($_POST['back']) && $_POST['back']) {
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step2.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step2.php'
); );
} }
//bitrix orderTypesList //bitrix orderTypesList
$orderTypesList = RCrmActions::OrderTypesList(RCrmActions::SitesList()); $orderTypesList = RCrmActions::OrderTypesList(RCrmActions::SitesList());
$orderTypesArr = array(); $orderTypesArr = array();
foreach ($orderTypesList as $orderType) { foreach ($orderTypesList as $orderType) {
$orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']])); $orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']]));
@ -601,7 +601,7 @@ class intaro_retailcrm extends CModule
} }
$orderPropsArr[$orderType['ID']] = $_orderPropsArr; $orderPropsArr[$orderType['ID']] = $_orderPropsArr;
} }
//legal details props //legal details props
$legalDetailsArr = array(); $legalDetailsArr = array();
foreach ($orderTypesList as $orderType) { foreach ($orderTypesList as $orderType) {
@ -631,7 +631,7 @@ class intaro_retailcrm extends CModule
COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOM_FIELDS, serialize(RCrmActions::clearArr($customFieldsArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOM_FIELDS, serialize(RCrmActions::clearArr($customFieldsArr)));
COption::SetOptionString($this->MODULE_ID, $this->CRM_LEGAL_DETAILS, serialize(RCrmActions::clearArr($legalDetailsArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_LEGAL_DETAILS, serialize(RCrmActions::clearArr($legalDetailsArr)));
COption::SetOptionString($this->MODULE_ID, $this->CRM_CONTRAGENT_TYPE, serialize(RCrmActions::clearArr($contragentTypeArr))); COption::SetOptionString($this->MODULE_ID, $this->CRM_CONTRAGENT_TYPE, serialize(RCrmActions::clearArr($contragentTypeArr)));
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step4.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step4.php'
); );
@ -667,14 +667,14 @@ class intaro_retailcrm extends CModule
if (!CModule::IncludeModule("sale")) { if (!CModule::IncludeModule("sale")) {
$arResult['errCode'] = 'ERR_SALE'; $arResult['errCode'] = 'ERR_SALE';
} }
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0); $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
$api = new \RetailCrm\ApiClient($api_host, $api_key); $api = new \RetailCrm\ApiClient($api_host, $api_key);
$customerH = self::historyLoad($api, 'customersHistory'); $customerH = self::historyLoad($api, 'customersHistory');
COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY, $customerH); COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY, $customerH);
//new data //new data
if ($historyDate = COption::GetOptionString($this->OLD_MODULE_ID, 'order_history_date', 0)) { if ($historyDate = COption::GetOptionString($this->OLD_MODULE_ID, 'order_history_date', 0)) {
try { try {
@ -703,7 +703,7 @@ class intaro_retailcrm extends CModule
} }
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY, $orderH); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY, $orderH);
if ($orderLastId = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_LAST_ID, 0)) { if ($orderLastId = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_LAST_ID, 0)) {
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, $orderLastId); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, $orderLastId);
} else { } else {
@ -719,7 +719,7 @@ class intaro_retailcrm extends CModule
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
} }
} }
if ($orderFailedIds = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_FAILED_IDS, 0)) { if ($orderFailedIds = COption::GetOptionString($this->OLD_MODULE_ID, $this->CRM_ORDER_FAILED_IDS, 0)) {
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, $orderFailedIds); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, $orderFailedIds);
} }
@ -752,7 +752,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php' GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step5.php'
); );
return; return;
} }
@ -796,11 +796,13 @@ class intaro_retailcrm extends CModule
"length" => "length", "length" => "length",
"width" => "width", "width" => "width",
"height" => "height", "height" => "height",
"picture" => "picture",
); );
$propertiesSKU = array(); $propertiesSKU = array();
$propertiesUnitSKU = array(); $propertiesUnitSKU = array();
$propertiesHbSKU = array(); $propertiesHbSKU = array();
foreach ($iblockProperties as $prop) { foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) { foreach ($_POST['IBLOCK_PROPERTY_SKU'. '_' . $prop] as $iblock => $val) {
$propertiesSKU[$iblock][$prop] = $val; $propertiesSKU[$iblock][$prop] = $val;
@ -809,7 +811,7 @@ class intaro_retailcrm extends CModule
$propertiesUnitSKU[$iblock][$prop] = $val; $propertiesUnitSKU[$iblock][$prop] = $val;
} }
if ($hlblockModule === true) { if ($hlblockModule === true && $prop != 'picture') {
foreach ($hlblockList as $tableName => $hb) { foreach ($hlblockList as $tableName => $hb) {
foreach ($_POST['highloadblock' . $tableName . '_' . $prop] as $iblock => $val) { foreach ($_POST['highloadblock' . $tableName . '_' . $prop] as $iblock => $val) {
$propertiesHbSKU[$tableName][$iblock][$prop] = $val; $propertiesHbSKU[$tableName][$iblock][$prop] = $val;
@ -821,6 +823,7 @@ class intaro_retailcrm extends CModule
$propertiesProduct = array(); $propertiesProduct = array();
$propertiesUnitProduct = array(); $propertiesUnitProduct = array();
$propertiesHbProduct = array(); $propertiesHbProduct = array();
foreach ($iblockProperties as $prop) { foreach ($iblockProperties as $prop) {
foreach ($_POST['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) { foreach ($_POST['IBLOCK_PROPERTY_PRODUCT'. '_' . $prop] as $iblock => $val) {
$propertiesProduct[$iblock][$prop] = $val; $propertiesProduct[$iblock][$prop] = $val;
@ -829,7 +832,7 @@ class intaro_retailcrm extends CModule
$propertiesUnitProduct[$iblock][$prop] = $val; $propertiesUnitProduct[$iblock][$prop] = $val;
} }
if ($hlblockModule === true) { if ($hlblockModule === true && $prop != 'picture') {
foreach ($hlblockList as $tableName => $hb) { foreach ($hlblockList as $tableName => $hb) {
foreach ($_POST['highloadblock_product' . $tableName . '_' . $prop] as $iblock => $val) { foreach ($_POST['highloadblock_product' . $tableName . '_' . $prop] as $iblock => $val) {
$propertiesHbProduct[$tableName][$iblock][$prop] = $val; $propertiesHbProduct[$tableName][$iblock][$prop] = $val;
@ -891,7 +894,7 @@ class intaro_retailcrm extends CModule
RegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "paymentSave"); RegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $this->MODULE_ID, "RetailCrmEvent", "paymentSave");
RegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $this->MODULE_ID, "RetailCrmEvent", "paymentDelete"); RegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $this->MODULE_ID, "RetailCrmEvent", "paymentDelete");
COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types']))); COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types'])));
COption::SetOptionString($this->MODULE_ID, $this->CRM_INVENTORIES_UPLOAD, 'N'); COption::SetOptionString($this->MODULE_ID, $this->CRM_INVENTORIES_UPLOAD, 'N');
COption::SetOptionString($this->MODULE_ID, $this->CRM_PRICES_UPLOAD, 'N'); COption::SetOptionString($this->MODULE_ID, $this->CRM_PRICES_UPLOAD, 'N');
COption::SetOptionString($this->MODULE_ID, $this->CRM_COLLECTOR, 'N'); COption::SetOptionString($this->MODULE_ID, $this->CRM_COLLECTOR, 'N');
@ -911,7 +914,7 @@ class intaro_retailcrm extends CModule
); );
$this->CopyFiles(); $this->CopyFiles();
if (isset($_POST['LOAD_NOW'])) { if (isset($_POST['LOAD_NOW'])) {
$loader = new RetailCrmICML(); $loader = new RetailCrmICML();
$loader->iblocks = $iblocks; $loader->iblocks = $iblocks;
$loader->propertiesUnitProduct = $propertiesUnitProduct; $loader->propertiesUnitProduct = $propertiesUnitProduct;
@ -927,8 +930,8 @@ class intaro_retailcrm extends CModule
$loader->filename = $filename; $loader->filename = $filename;
$loader->serverName = \Bitrix\Main\Context::getCurrent()->getServer()->getHttpHost(); $loader->serverName = \Bitrix\Main\Context::getCurrent()->getServer()->getHttpHost();
$loader->application = $APPLICATION; $loader->application = $APPLICATION;
$loader->Load(); $loader->Load();
} }
if ($typeLoading == 'agent' || $typeLoading == 'cron') { if ($typeLoading == 'agent' || $typeLoading == 'cron') {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->RETAIL_CRM_EXPORT . '_run.php')) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/' . $this->RETAIL_CRM_EXPORT . '_run.php')) {
@ -965,7 +968,7 @@ class intaro_retailcrm extends CModule
)); ));
if (intval($PROFILE_ID) <= 0) { if (intval($PROFILE_ID) <= 0) {
$arResult['errCode'] = 'ERR_IBLOCK'; $arResult['errCode'] = 'ERR_IBLOCK';
return; return;
} }
if ($typeLoading == 'agent') { if ($typeLoading == 'agent') {
@ -1055,7 +1058,7 @@ class intaro_retailcrm extends CModule
} }
} }
function DoUninstall() function DoUninstall()
{ {
global $APPLICATION; global $APPLICATION;
@ -1086,23 +1089,23 @@ class intaro_retailcrm extends CModule
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_NUMBERS); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_NUMBERS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_CANSEL_ORDER); COption::RemoveOption($this->MODULE_ID, $this->CRM_CANSEL_ORDER);
COption::RemoveOption($this->MODULE_ID, $this->CRM_INVENTORIES_UPLOAD); COption::RemoveOption($this->MODULE_ID, $this->CRM_INVENTORIES_UPLOAD);
COption::RemoveOption($this->MODULE_ID, $this->CRM_STORES); COption::RemoveOption($this->MODULE_ID, $this->CRM_STORES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_SHOPS); COption::RemoveOption($this->MODULE_ID, $this->CRM_SHOPS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_IBLOCKS_INVENTORIES); COption::RemoveOption($this->MODULE_ID, $this->CRM_IBLOCKS_INVENTORIES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICES_UPLOAD); COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICES_UPLOAD);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICES); COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICE_SHOPS); COption::RemoveOption($this->MODULE_ID, $this->CRM_PRICE_SHOPS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_IBLOCKS_PRICES); COption::RemoveOption($this->MODULE_ID, $this->CRM_IBLOCKS_PRICES);
COption::RemoveOption($this->MODULE_ID, $this->CRM_COLLECTOR); COption::RemoveOption($this->MODULE_ID, $this->CRM_COLLECTOR);
COption::RemoveOption($this->MODULE_ID, $this->CRM_COLL_KEY); COption::RemoveOption($this->MODULE_ID, $this->CRM_COLL_KEY);
COption::RemoveOption($this->MODULE_ID, $this->CRM_UA); COption::RemoveOption($this->MODULE_ID, $this->CRM_UA);
COption::RemoveOption($this->MODULE_ID, $this->CRM_UA_KEYS); COption::RemoveOption($this->MODULE_ID, $this->CRM_UA_KEYS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_VERSION); COption::RemoveOption($this->MODULE_ID, $this->CRM_API_VERSION);
COption::RemoveOption($this->MODULE_ID, $this->HISTORY_TIME); COption::RemoveOption($this->MODULE_ID, $this->HISTORY_TIME);
@ -1135,7 +1138,7 @@ class intaro_retailcrm extends CModule
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_UNINSTALL_TITLE'), $this->INSTALL_PATH . '/unstep1.php' GetMessage('MODULE_UNINSTALL_TITLE'), $this->INSTALL_PATH . '/unstep1.php'
); );
} }
function CopyFiles() function CopyFiles()
{ {
@ -1170,18 +1173,18 @@ class intaro_retailcrm extends CModule
$filename $filename
) { ) {
$strVars = ""; $strVars = "";
foreach ($iblocks as $key => $val) foreach ($iblocks as $key => $val)
$strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&'; $strVars .= 'IBLOCK_EXPORT[' . $key . ']=' . $val . '&';
foreach ($propertiesSKU as $iblock => $arr) foreach ($propertiesSKU as $iblock => $arr)
foreach ($arr as $id => $val) foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_SKU_' . $id . '[' . $iblock . ']=' . $val . '&'; $strVars .= 'IBLOCK_PROPERTY_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesUnitSKU as $iblock => $arr) foreach ($propertiesUnitSKU as $iblock => $arr)
foreach ($arr as $id => $val) foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_SKU_' . $id . '[' . $iblock . ']=' . $val . '&'; $strVars .= 'IBLOCK_PROPERTY_UNIT_SKU_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesProduct as $iblock => $arr) foreach ($propertiesProduct as $iblock => $arr)
foreach ($arr as $id => $val) foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&'; $strVars .= 'IBLOCK_PROPERTY_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
foreach ($propertiesUnitProduct as $iblock => $arr) foreach ($propertiesUnitProduct as $iblock => $arr)
foreach ($arr as $id => $val) foreach ($arr as $id => $val)
$strVars .= 'IBLOCK_PROPERTY_UNIT_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&'; $strVars .= 'IBLOCK_PROPERTY_UNIT_PRODUCT_' . $id . '[' . $iblock . ']=' . $val . '&';
if ($propertiesHbSKU) { if ($propertiesHbSKU) {
@ -1201,7 +1204,7 @@ class intaro_retailcrm extends CModule
return $strVars; return $strVars;
} }
function historyLoad($api, $method) function historyLoad($api, $method)
{ {
$page = null; $page = null;
@ -1244,10 +1247,10 @@ class intaro_retailcrm extends CModule
return $end['id']; return $end['id'];
} }
if (isset($history['history'])) { if (isset($history['history'])) {
$end = array_pop($history['history']); $end = array_pop($history['history']);
break; break;
} else { } else {
$page--; $page--;
@ -1263,7 +1266,7 @@ class intaro_retailcrm extends CModule
return $end['id']; return $end['id'];
} }
function ping($api_host, $api_key) function ping($api_host, $api_key)
{ {
global $APPLICATION; global $APPLICATION;
@ -1283,7 +1286,7 @@ class intaro_retailcrm extends CModule
} }
if ($result->getStatusCode() == 200) { if ($result->getStatusCode() == 200) {
COption::SetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, $version); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, $version);
$res['sitesList'] = $APPLICATION->ConvertCharsetArray($result->sites, 'utf-8', SITE_CHARSET); $res['sitesList'] = $APPLICATION->ConvertCharsetArray($result->sites, 'utf-8', SITE_CHARSET);
return $res; return $res;

View File

@ -20,14 +20,13 @@ if (!empty($oldValues)) {
} }
?> ?>
<style type="text/css"> <style type="text/css">
.iblock-export-table-display-none { .iblock-export-table-display-none {
display: none; display: none;
} }
</style> </style>
<form method="post" action="<?php echo $APPLICATION->GetCurPage(); ?>" > <form method="post" action="<?php echo $APPLICATION->GetCurPage(); ?>" >
<h3><?=GetMessage("SETTINGS_INFOBLOCK");?></h3> <h3><?=GetMessage("SETTINGS_INFOBLOCK");?></h3>
<font class="text"><?=GetMessage("EXPORT_CATALOGS");?><br><br></font> <font class="text"><?=GetMessage("EXPORT_CATALOGS");?><br><br></font>
<? <?
@ -35,7 +34,7 @@ if (!empty($oldValues)) {
{ {
$IBLOCK_EXPORT = array(); $IBLOCK_EXPORT = array();
} }
$iblockPropertiesName = Array( $iblockPropertiesName = Array(
"article" => GetMessage("PROPERTY_ARTICLE_HEADER_NAME"), "article" => GetMessage("PROPERTY_ARTICLE_HEADER_NAME"),
"manufacturer" => GetMessage("PROPERTY_MANUFACTURER_HEADER_NAME"), "manufacturer" => GetMessage("PROPERTY_MANUFACTURER_HEADER_NAME"),
@ -45,16 +44,16 @@ if (!empty($oldValues)) {
"length" => GetMessage("PROPERTY_LENGTH_HEADER_NAME"), "length" => GetMessage("PROPERTY_LENGTH_HEADER_NAME"),
"width" => GetMessage("PROPERTY_WIDTH_HEADER_NAME"), "width" => GetMessage("PROPERTY_WIDTH_HEADER_NAME"),
"height" => GetMessage("PROPERTY_HEIGHT_HEADER_NAME"), "height" => GetMessage("PROPERTY_HEIGHT_HEADER_NAME"),
"picture" => GetMessage("PROPERTY_PICTURE_HEADER_NAME"),
); );
$iblockFieldsName = Array( $iblockFieldsName = Array(
"weight" => Array("code" => "catalog_size" , "name" => GetMessage("SELECT_WEIGHT_PROPERTY_NAME"), 'unit' => 'mass'), "weight" => Array("code" => "catalog_size" , "name" => GetMessage("SELECT_WEIGHT_PROPERTY_NAME"), 'unit' => 'mass'),
"length" => Array("code" => "catalog_length" , "name" => GetMessage("SELECT_LENGTH_PROPERTY_NAME"), 'unit' => 'length'), "length" => Array("code" => "catalog_length" , "name" => GetMessage("SELECT_LENGTH_PROPERTY_NAME"), 'unit' => 'length'),
"width" => Array("code" => "catalog_width" , "name" => GetMessage("SELECT_WIDTH_PROPERTY_NAME"), 'unit' => 'length'), "width" => Array("code" => "catalog_width" , "name" => GetMessage("SELECT_WIDTH_PROPERTY_NAME"), 'unit' => 'length'),
"height" => Array("code" => "catalog_height" , "name" => GetMessage("SELECT_HEIGHT_PROPERTY_NAME"), 'unit' => 'length'), "height" => Array("code" => "catalog_height" , "name" => GetMessage("SELECT_HEIGHT_PROPERTY_NAME"), 'unit' => 'length'),
); );
$iblockPropertiesHint = Array( $iblockPropertiesHint = Array(
"article" => Array("ARTICLE", "ART", "ARTNUMBER", "ARTICUL", "ARTIKUL"), "article" => Array("ARTICLE", "ART", "ARTNUMBER", "ARTICUL", "ARTIKUL"),
"manufacturer" => Array("MANUFACTURER", "PROISVODITEL", "PROISVOD", "PROISV"), "manufacturer" => Array("MANUFACTURER", "PROISVODITEL", "PROISVOD", "PROISV"),
@ -64,8 +63,9 @@ if (!empty($oldValues)) {
"length" => Array("LENGTH", "DLINA"), "length" => Array("LENGTH", "DLINA"),
"width" => Array("WIDTH", "SHIRINA"), "width" => Array("WIDTH", "SHIRINA"),
"height" => Array("HEIGHT", "VISOTA"), "height" => Array("HEIGHT", "VISOTA"),
"picture" => Array("PICTURE", "PICTURE"),
); );
$units = Array( $units = Array(
'length' => Array( 'length' => Array(
'mm' => GetMessage("UNIT_MEASUREMENT_MM"), 'mm' => GetMessage("UNIT_MEASUREMENT_MM"),
@ -78,13 +78,11 @@ if (!empty($oldValues)) {
'kg' => GetMessage("UNIT_MEASUREMENT_KG"), 'kg' => GetMessage("UNIT_MEASUREMENT_KG"),
) )
); );
$hintUnit = Array( $hintUnit = Array(
'length' => 'mm', 'length' => 'mm',
'mass' => 'g' 'mass' => 'g'
); );
$boolAll = false; $boolAll = false;
$intCountChecked = 0; $intCountChecked = 0;
@ -101,11 +99,11 @@ if (!empty($oldValues)) {
if ($arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P") if ($arCatalog['CATALOG_TYPE'] == "X" || $arCatalog['CATALOG_TYPE'] == "P")
{ {
$iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock["ID"]); $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock["ID"]);
$db_properties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], Array()); $db_properties = CIBlock::GetProperties($iblockOffer['IBLOCK_ID'], Array());
while($prop = $db_properties->Fetch()) while($prop = $db_properties->Fetch())
$propertiesSKU[] = $prop; $propertiesSKU[] = $prop;
$oldPropertySKU = null; $oldPropertySKU = null;
if (isset($IBLOCK_PROPERTY_SKU[$iblock['ID']])) { if (isset($IBLOCK_PROPERTY_SKU[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) { foreach ($iblockPropertiesName as $key => $prop) {
@ -118,28 +116,28 @@ if (!empty($oldValues)) {
$oldPropertyUnitSKU[$key] = $IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']][$key]; $oldPropertyUnitSKU[$key] = $IBLOCK_PROPERTY_UNIT_SKU[$iblock['ID']][$key];
} }
} }
} }
$propertiesProduct = null; $propertiesProduct = null;
$db_properties = CIBlock::GetProperties($iblock['ID'], Array()); $db_properties = CIBlock::GetProperties($iblock['ID'], Array());
while($prop = $db_properties->Fetch()) while($prop = $db_properties->Fetch())
$propertiesProduct[] = $prop; $propertiesProduct[] = $prop;
$oldPropertyProduct = null; $oldPropertyProduct = null;
if (isset($IBLOCK_PROPERTY_PRODUCT[$iblock['ID']])) { if (isset($IBLOCK_PROPERTY_PRODUCT[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) { foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyProduct[$key] = $IBLOCK_PROPERTY_PRODUCT[$iblock['ID']][$key]; $oldPropertyProduct[$key] = $IBLOCK_PROPERTY_PRODUCT[$iblock['ID']][$key];
} }
} }
$oldPropertyUnitProduct = null; $oldPropertyUnitProduct = null;
if (isset($IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']])) { if (isset($IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']])) {
foreach ($iblockPropertiesName as $key => $prop) { foreach ($iblockPropertiesName as $key => $prop) {
$oldPropertyUnitProduct[$key] = $IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']][$key]; $oldPropertyUnitProduct[$key] = $IBLOCK_PROPERTY_UNIT_PRODUCT[$iblock['ID']][$key];
} }
} }
$arSiteList = array(); $arSiteList = array();
$rsSites = CIBlock::GetSite($iblock["ID"]); $rsSites = CIBlock::GetSite($iblock["ID"]);
while ($arSite = $rsSites->Fetch()) while ($arSite = $rsSites->Fetch())
@ -183,12 +181,12 @@ if (!empty($oldValues)) {
?> ?>
<font class="text" style="font-weight: bold;"><?=GetMessage("CHECK_ALL_INFOBLOCKS");?></font> <font class="text" style="font-weight: bold;"><?=GetMessage("CHECK_ALL_INFOBLOCKS");?></font>
<input <input
style="vertical-align: middle;" style="vertical-align: middle;"
type="checkbox" type="checkbox"
name="icml_export_all" name="icml_export_all"
id="icml_export_all" id="icml_export_all"
value="Y" value="Y"
onclick="checkAll(this,<? echo $intCountAvailIBlock; ?>);" onclick="checkAll(this,<? echo $intCountAvailIBlock; ?>);"
<? echo ($boolAll ? ' checked' : ''); ?>> <? echo ($boolAll ? ' checked' : ''); ?>>
</br> </br>
@ -213,7 +211,7 @@ if (!empty($oldValues)) {
<table class="adm-list-table" id="export_setup" <?=($arIBlock['PROPERTIES_SKU'] == null ? 'style="width: 66%;"': "" )?> > <table class="adm-list-table" id="export_setup" <?=($arIBlock['PROPERTIES_SKU'] == null ? 'style="width: 66%;"': "" )?> >
<thead> <thead>
<tr class="adm-list-table-header"> <tr class="adm-list-table-header">
<td class="adm-list-table-cell"> <td class="adm-list-table-cell">
<div class="adm-list-table-cell-inner"><?=GetMessage("LOADED_PROPERTY");?></div> <div class="adm-list-table-cell-inner"><?=GetMessage("LOADED_PROPERTY");?></div>
</td> </td>
<td class="adm-list-table-cell"> <td class="adm-list-table-cell">
@ -227,9 +225,9 @@ if (!empty($oldValues)) {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<? foreach ($iblockPropertiesName as $key => $property): ?> <? foreach ($iblockPropertiesName as $key => $property): ?>
<? $productSelected = false;?> <? $productSelected = false;?>
<tr class="adm-list-table-row"> <tr class="adm-list-table-row">
@ -268,7 +266,7 @@ if (!empty($oldValues)) {
} }
?> ?>
> >
<?=$field['name'];?> <?=$field['name'];?>
</option> </option>
<? endif; ?> <? endif; ?>
@ -310,7 +308,7 @@ if (!empty($oldValues)) {
</optgroup> </optgroup>
<?}?> <?}?>
</select> </select>
<?if (array_key_exists($key, $iblockFieldsName)) :?> <?if (array_key_exists($key, $iblockFieldsName)) :?>
<select <select
style="width: 100px; margin-left: 50px;" style="width: 100px; margin-left: 50px;"
@ -358,7 +356,7 @@ if (!empty($oldValues)) {
<? if ($keyField == $key) :?> <? if ($keyField == $key) :?>
<option value="<?=$field['code'];?>" <option value="<?=$field['code'];?>"
<? <?
if (!$productSelected) { if (!$productSelected) {
if ($arIBlock['OLD_PROPERTY_SKU_SELECT'] != null) { if ($arIBlock['OLD_PROPERTY_SKU_SELECT'] != null) {
if ($field['code'] == $arIBlock['OLD_PROPERTY_SKU_SELECT'][$key] ) { if ($field['code'] == $arIBlock['OLD_PROPERTY_SKU_SELECT'][$key] ) {
@ -374,7 +372,7 @@ if (!empty($oldValues)) {
} }
}?> }?>
> >
<?=$field['name'];?> <?=$field['name'];?>
</option> </option>
<? endif; ?> <? endif; ?>
@ -416,7 +414,7 @@ if (!empty($oldValues)) {
</optgroup> </optgroup>
<? endif; ?> <? endif; ?>
</select> </select>
<?if (array_key_exists($key, $iblockFieldsName)) :?> <?if (array_key_exists($key, $iblockFieldsName)) :?>
<select <select
style="width: 100px; margin-left: 50px;" style="width: 100px; margin-left: 50px;"
@ -518,7 +516,7 @@ if (!empty($oldValues)) {
function checkAll(obj,cnt) function checkAll(obj,cnt)
{ {
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
if (obj.checked) if (obj.checked)
BX.removeClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); BX.removeClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none");
} }
@ -538,10 +536,10 @@ if (!empty($oldValues)) {
}, },
complete : function() { complete : function() {
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
if (!obj.checked) if (!obj.checked)
BX.addClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none"); BX.addClass('IBLOCK_EXPORT_TABLE'+(i+1),"iblock-export-table-display-none");
} }
} }
}); });
easing.animate(); easing.animate();
@ -567,7 +565,7 @@ if (!empty($oldValues)) {
}, },
complete : function() { complete : function() {
if (!obj.checked) if (!obj.checked)
BX.addClass(table,"iblock-export-table-display-none"); BX.addClass(table,"iblock-export-table-display-none");
} }
}); });
easing.animate(); easing.animate();
@ -646,7 +644,7 @@ if (!empty($oldValues)) {
if (type == 'product') { if (type == 'product') {
$(td).append('<select name="highloadblock_product' + res.table + '_' + key + '[' + iblock + ']" id="highloadblock" style="width: 100px; margin-left: 50px;">' + new_options + '</select>'); $(td).append('<select name="highloadblock_product' + res.table + '_' + key + '[' + iblock + ']" id="highloadblock" style="width: 100px; margin-left: 50px;">' + new_options + '</select>');
} }
}, },
beforeSend: function() { beforeSend: function() {
$(td).append('<span style="margin-left:50px;" id="waiting"><?=GetMessage("WAIT")?></span>'); $(td).append('<span style="margin-left:50px;" id="waiting"><?=GetMessage("WAIT")?></span>');

View File

@ -1,5 +1,5 @@
<? <?
$arModuleVersion = array( $arModuleVersion = array(
"VERSION" => "2.3.10", "VERSION" => "2.3.11",
"VERSION_DATE" => "2018-09-26 13:30:00" "VERSION_DATE" => "2018-10-04 16:15:00"
); );

View File

@ -28,6 +28,7 @@ $MESS["PROPERTY_WEIGHT_HEADER_NAME"] = "Вес (габариты)";
$MESS["PROPERTY_LENGTH_HEADER_NAME"] = "Длина (габариты)"; $MESS["PROPERTY_LENGTH_HEADER_NAME"] = "Длина (габариты)";
$MESS["PROPERTY_WIDTH_HEADER_NAME"] = "Ширина (габариты)"; $MESS["PROPERTY_WIDTH_HEADER_NAME"] = "Ширина (габариты)";
$MESS["PROPERTY_HEIGHT_HEADER_NAME"] = "Высота (габариты)"; $MESS["PROPERTY_HEIGHT_HEADER_NAME"] = "Высота (габариты)";
$MESS["PROPERTY_PICTURE_HEADER_NAME"] = "Фото";
$MESS["PROPERTY_SIZE_HEADER_NAME"] = "Размер"; $MESS["PROPERTY_SIZE_HEADER_NAME"] = "Размер";
$MESS["SELECT_FIELD_NAME"] = "Поле"; $MESS["SELECT_FIELD_NAME"] = "Поле";
$MESS["SELECT_PROPERTY_NAME"] = "Свойства"; $MESS["SELECT_PROPERTY_NAME"] = "Свойства";

View File

@ -1,4 +1,4 @@
<?php <?php
IncludeModuleLangFile(__FILE__); IncludeModuleLangFile(__FILE__);
$mid = 'intaro.retailcrm'; $mid = 'intaro.retailcrm';
$uri = $APPLICATION->GetCurPage() . '?mid=' . htmlspecialchars($mid) . '&lang=' . LANGUAGE_ID; $uri = $APPLICATION->GetCurPage() . '?mid=' . htmlspecialchars($mid) . '&lang=' . LANGUAGE_ID;
@ -56,8 +56,8 @@ if($_GET['ok'] && $_GET['ok'] == 'Y') echo CAdminMessage::ShowNote(GetMessage('I
$arResult = array(); $arResult = array();
if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml')) { if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml')) {
$options = simplexml_load_file($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml'); $options = simplexml_load_file($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml');
foreach($options->contragents->contragent as $contragent) { foreach($options->contragents->contragent as $contragent) {
$type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET); $type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET);
$type["ID"] = (string)$contragent["id"]; $type["ID"] = (string)$contragent["id"];
@ -74,8 +74,8 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/cl
$arResult['orderProps'][] = $type; $arResult['orderProps'][] = $type;
} else { } else {
$groups = explode(",", (string)$field["group"]); $groups = explode(",", (string)$field["group"]);
foreach ($groups as $group) { foreach ($groups as $group) {
$type["GROUP"][] = trim($group); $type["GROUP"][] = trim($group);
} }
$arResult['legalDetails'][] = $type; $arResult['legalDetails'][] = $type;
} }
@ -138,7 +138,7 @@ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_RE
$step = $_POST['step']; $step = $_POST['step'];
$orders = $_POST['orders']; $orders = $_POST['orders'];
$countStep = 50; // 50 orders on step $countStep = 50; // 50 orders on step
if ($orders) { if ($orders) {
$ordersArr = explode(',', $orders); $ordersArr = explode(',', $orders);
$orders = array(); $orders = array();
@ -152,37 +152,37 @@ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_RE
$orders[] = (int)$ordersList[0]; $orders[] = (int)$ordersList[0];
} }
} }
$splitedOrders = array_chunk($orders, $countStep); $splitedOrders = array_chunk($orders, $countStep);
$stepOrders = $splitedOrders[$step]; $stepOrders = $splitedOrders[$step];
RetailCrmOrder::uploadOrders($countStep, false, $stepOrders); RetailCrmOrder::uploadOrders($countStep, false, $stepOrders);
$percent = round((($step * $countStep + count($stepOrders)) * 100 / count($orders)), 1); $percent = round((($step * $countStep + count($stepOrders)) * 100 / count($orders)), 1);
$step++; $step++;
if (!$splitedOrders[$step]) { if (!$splitedOrders[$step]) {
$step = 'end'; $step = 'end';
} }
$res = array("step" => $step, "percent" => $percent, 'stepOrders' => $stepOrders); $res = array("step" => $step, "percent" => $percent, 'stepOrders' => $stepOrders);
} else { } else {
$orders = array(); $orders = array();
for($i = 1; $i <= $countStep; $i++){ for($i = 1; $i <= $countStep; $i++){
$orders[] = $i + $step * $countStep; $orders[] = $i + $step * $countStep;
} }
RetailCrmOrder::uploadOrders($countStep, false, $orders); RetailCrmOrder::uploadOrders($countStep, false, $orders);
$step++; $step++;
$countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $step * $countStep), array()); $countLeft = (int) CSaleOrder::GetList(array("ID" => "ASC"), array('>ID' => $step * $countStep), array());
$countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array()); $countAll = (int) CSaleOrder::GetList(array("ID" => "ASC"), array(), array());
$percent = round(100 - ($countLeft * 100 / $countAll), 1); $percent = round(100 - ($countLeft * 100 / $countAll), 1);
if ($countLeft == 0) { if ($countLeft == 0) {
$step = 'end'; $step = 'end';
} }
$res = array("step" => $step, "percent" => $percent, 'stepOrders' => $orders); $res = array("step" => $step, "percent" => $percent, 'stepOrders' => $orders);
} }
@ -197,7 +197,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$api_key = htmlspecialchars(trim($_POST['api_key'])); $api_key = htmlspecialchars(trim($_POST['api_key']));
//bitrix site list //bitrix site list
$siteListArr = array(); $siteListArr = array();
foreach ($arResult['arSites'] as $arSites) { foreach ($arResult['arSites'] as $arSites) {
if (count($arResult['arSites']) > 1) { if (count($arResult['arSites']) > 1) {
if ($_POST['sites-id-' . $arSites['LID']]) { if ($_POST['sites-id-' . $arSites['LID']]) {
@ -207,7 +207,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} }
} }
} }
if ($api_host && $api_key) { if ($api_host && $api_key) {
$api = new RetailCrm\ApiClient($api_host, $api_key); $api = new RetailCrm\ApiClient($api_host, $api_key);
try { try {
@ -225,15 +225,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
COption::SetOptionString($mid, 'api_host', $api_host); COption::SetOptionString($mid, 'api_host', $api_host);
COption::SetOptionString($mid, 'api_key', $api_key); COption::SetOptionString($mid, 'api_key', $api_key);
} }
//form order types ids arr //form order types ids arr
$orderTypesList = RCrmActions::OrderTypesList($arResult['arSites']); $orderTypesList = RCrmActions::OrderTypesList($arResult['arSites']);
$orderTypesArr = array(); $orderTypesArr = array();
foreach ($orderTypesList as $orderType) { foreach ($orderTypesList as $orderType) {
$orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']])); $orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']]));
} }
//form delivery types ids arr //form delivery types ids arr
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList(); $arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
@ -244,15 +244,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
//form payment types ids arr //form payment types ids arr
$arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList(); $arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList();
$paymentTypesArr = array(); $paymentTypesArr = array();
foreach ($arResult['bitrixPaymentTypesList'] as $payment) { foreach ($arResult['bitrixPaymentTypesList'] as $payment) {
$paymentTypesArr[$payment['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $payment['ID']])); $paymentTypesArr[$payment['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $payment['ID']]));
} }
//form payment statuses ids arr //form payment statuses ids arr
$arResult['bitrixStatusesList'] = RCrmActions::StatusesList(); $arResult['bitrixStatusesList'] = RCrmActions::StatusesList();
$paymentStatusesArr = array(); $paymentStatusesArr = array();
$canselOrderArr = array(); $canselOrderArr = array();
//$paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY'])); //$paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY']));
@ -262,34 +262,28 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$canselOrderArr[] = $status['ID']; $canselOrderArr[] = $status['ID'];
} }
} }
//form payment ids arr //form payment ids arr
$paymentArr = array(); $paymentArr = array();
$paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y']));
$paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N']));
$previousDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0); $previousDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0);
//order discharge mode //order discharge mode
// 0 - agent // 0 - agent
// 1 - event // 1 - event
$orderDischarge = 0; $orderDischarge = 0;
$orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge'])); $orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge']));
if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) { if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) {
// remove depenedencies // remove depenedencies
UnRegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave"); UnRegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave");
UnRegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder"); UnRegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder");
UnRegisterModuleDependences("sale", "OnSaleOrderDeleted", $mid, "RetailCrmEvent", "orderDelete"); UnRegisterModuleDependences("sale", "OnSaleOrderDeleted", $mid, "RetailCrmEvent", "orderDelete");
UnRegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $mid, "RetailCrmEvent", "paymentSave");
UnRegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $mid, "RetailCrmEvent", "paymentDelete");
} elseif (($orderDischarge != $previousDischarge) && ($orderDischarge == 1)) { } elseif (($orderDischarge != $previousDischarge) && ($orderDischarge == 1)) {
// event dependencies // event dependencies
RegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave"); RegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave");
RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder"); RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder");
RegisterModuleDependences("sale", "OnSaleOrderDeleted", $mid, "RetailCrmEvent", "orderDelete"); RegisterModuleDependences("sale", "OnSaleOrderDeleted", $mid, "RetailCrmEvent", "orderDelete");
RegisterModuleDependences("sale", "OnSalePaymentEntitySaved", $mid, "RetailCrmEvent", "paymentSave");
RegisterModuleDependences("sale", "OnSalePaymentEntityDeleted", $mid, "RetailCrmEvent", "paymentDelete");
} }
$orderPropsArr = array(); $orderPropsArr = array();
@ -309,7 +303,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} }
$orderPropsArr[$orderType['ID']] = $_orderPropsArr; $orderPropsArr[$orderType['ID']] = $_orderPropsArr;
} }
//legal details props //legal details props
$legalDetailsArr = array(); $legalDetailsArr = array();
foreach ($orderTypesList as $orderType) { foreach ($orderTypesList as $orderType) {
@ -356,18 +350,18 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$dateAgent->format('d.m.Y H:i:s'), // date of first start $dateAgent->format('d.m.Y H:i:s'), // date of first start
30 30
); );
$arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList(); $arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList();
foreach($arResult['bitrixStoresExportList'] as $bitrixStores){ foreach($arResult['bitrixStoresExportList'] as $bitrixStores){
$bitrixStoresArr[$bitrixStores['ID']] = htmlspecialchars(trim($_POST['stores-export-' . $bitrixStores['ID']])); $bitrixStoresArr[$bitrixStores['ID']] = htmlspecialchars(trim($_POST['stores-export-' . $bitrixStores['ID']]));
} }
function maskInv($var){ function maskInv($var){
return preg_match("/^shops-exoprt/", $var); return preg_match("/^shops-exoprt/", $var);
} }
$bitrixShopsArr = str_replace('shops-exoprt-', '', array_filter(array_keys($_POST), 'maskInv')); $bitrixShopsArr = str_replace('shops-exoprt-', '', array_filter(array_keys($_POST), 'maskInv'));
$arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList(); $arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList();
foreach($arResult['bitrixIblocksExportList'] as $bitrixIblocks){ foreach($arResult['bitrixIblocksExportList'] as $bitrixIblocks){
if(htmlspecialchars(trim($_POST['iblocks-stores-' . $bitrixIblocks['ID']])) === 'Y'){ if(htmlspecialchars(trim($_POST['iblocks-stores-' . $bitrixIblocks['ID']])) === 'Y'){
$bitrixIblocksInventories[] = $bitrixIblocks['ID']; $bitrixIblocksInventories[] = $bitrixIblocks['ID'];
@ -376,15 +370,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} else { } else {
$inventoriesUpload = 'N'; $inventoriesUpload = 'N';
CAgent::RemoveAgent("RetailCrmInventories::inventoriesUpload();", $mid); CAgent::RemoveAgent("RetailCrmInventories::inventoriesUpload();", $mid);
} }
//prices //prices
$bitrixPricesArr = array(); $bitrixPricesArr = array();
$bitrixIblocksPrices = array(); $bitrixIblocksPrices = array();
$bitrixPriceShopsArr = array(); $bitrixPriceShopsArr = array();
if(htmlspecialchars(trim($_POST['prices-upload'])) == 'Y'){ if(htmlspecialchars(trim($_POST['prices-upload'])) == 'Y'){
$pricesUpload = 'Y'; $pricesUpload = 'Y';
$dateAgent = new DateTime(); $dateAgent = new DateTime();
$intAgent = new DateInterval('PT60S'); // PT60S - 60 sec; $intAgent = new DateInterval('PT60S'); // PT60S - 60 sec;
$dateAgent->add($intAgent); $dateAgent->add($intAgent);
@ -396,18 +390,18 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$dateAgent->format('d.m.Y H:i:s'), // date of first start $dateAgent->format('d.m.Y H:i:s'), // date of first start
30 30
); );
$arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList(); $arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList();
foreach($arResult['bitrixPricesExportList'] as $bitrixPrices){ foreach($arResult['bitrixPricesExportList'] as $bitrixPrices){
$bitrixPricesArr[$bitrixPrices['ID']] = htmlspecialchars(trim($_POST['price-type-export-' . $bitrixPrices['ID']])); $bitrixPricesArr[$bitrixPrices['ID']] = htmlspecialchars(trim($_POST['price-type-export-' . $bitrixPrices['ID']]));
} }
function maskPrice($var){ function maskPrice($var){
return preg_match("/^shops-price/", $var); return preg_match("/^shops-price/", $var);
} }
$bitrixPriceShopsArr = str_replace('shops-price-', '', array_filter(array_keys($_POST), 'maskPrice')); $bitrixPriceShopsArr = str_replace('shops-price-', '', array_filter(array_keys($_POST), 'maskPrice'));
$arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList(); $arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList();
foreach($arResult['bitrixIblocksExportList'] as $bitrixIblocks){ foreach($arResult['bitrixIblocksExportList'] as $bitrixIblocks){
if(htmlspecialchars(trim($_POST['iblocks-prices-' . $bitrixIblocks['ID']])) === 'Y'){ if(htmlspecialchars(trim($_POST['iblocks-prices-' . $bitrixIblocks['ID']])) === 'Y'){
$bitrixIblocksPrices[] = $bitrixIblocks['ID']; $bitrixIblocksPrices[] = $bitrixIblocks['ID'];
@ -416,8 +410,8 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} else { } else {
$pricesUpload = 'N'; $pricesUpload = 'N';
CAgent::RemoveAgent("RetailCrmPrices::pricesUpload();", $mid); CAgent::RemoveAgent("RetailCrmPrices::pricesUpload();", $mid);
} }
//demon //demon
$collectorKeys = array(); $collectorKeys = array();
if (htmlspecialchars(trim($_POST['collector'])) == 'Y') { if (htmlspecialchars(trim($_POST['collector'])) == 'Y') {
@ -430,7 +424,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$collector = 'N'; $collector = 'N';
UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCollector", "add"); UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCollector", "add");
} }
//UA //UA
$uaKeys = array(); $uaKeys = array();
if (htmlspecialchars(trim($_POST['ua-integration'])) == 'Y') { if (htmlspecialchars(trim($_POST['ua-integration'])) == 'Y') {
@ -443,13 +437,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} else { } else {
$ua = 'N'; $ua = 'N';
UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmUa", "add"); UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmUa", "add");
} }
//version //version
$version = COption::GetOptionString($mid, $CRM_API_VERSION); $version = COption::GetOptionString($mid, $CRM_API_VERSION);
if (htmlspecialchars(trim($_POST['api_version'])) != $version) { if (htmlspecialchars(trim($_POST['api_version'])) != $version) {
if (htmlspecialchars(trim($_POST['api_version'])) == 'v4') { if (htmlspecialchars(trim($_POST['api_version'])) == 'v4') {
$version = 'v4'; $version = 'v4';
} elseif (htmlspecialchars(trim($_POST['api_version'])) == 'v5') { } elseif (htmlspecialchars(trim($_POST['api_version'])) == 'v5') {
@ -462,7 +456,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
//запрос к апи с $version //запрос к апи с $version
$crmUrl = htmlspecialchars(trim($_POST['api_host'])); $crmUrl = htmlspecialchars(trim($_POST['api_host']));
$apiKey = htmlspecialchars(trim($_POST['api_key'])); $apiKey = htmlspecialchars(trim($_POST['api_key']));
if ('/' !== $crmUrl[strlen($crmUrl) - 1]) { if ('/' !== $crmUrl[strlen($crmUrl) - 1]) {
$crmUrl .= '/'; $crmUrl .= '/';
} }
@ -474,9 +468,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
'/reference/payment-statuses', '/reference/payment-statuses',
'GET' 'GET'
); );
if ($result->getStatusCode() == 200) { if ($result->getStatusCode() == 200) {
COption::SetOptionString($mid, $CRM_API_VERSION, $version); COption::SetOptionString($mid, $CRM_API_VERSION, $version);
} else { } else {
LocalRedirect($uri); LocalRedirect($uri);
echo CAdminMessage::ShowMessage(GetMessage('API_NOT_WORK')); echo CAdminMessage::ShowMessage(GetMessage('API_NOT_WORK'));
@ -495,26 +489,26 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
COption::SetOptionString($mid, $CRM_PAYMENT_STATUSES, serialize(RCrmActions::clearArr($paymentStatusesArr))); COption::SetOptionString($mid, $CRM_PAYMENT_STATUSES, serialize(RCrmActions::clearArr($paymentStatusesArr)));
COption::SetOptionString($mid, $CRM_PAYMENT, serialize(RCrmActions::clearArr($paymentArr))); COption::SetOptionString($mid, $CRM_PAYMENT, serialize(RCrmActions::clearArr($paymentArr)));
COption::SetOptionString($mid, $CRM_ORDER_DISCHARGE, $orderDischarge); COption::SetOptionString($mid, $CRM_ORDER_DISCHARGE, $orderDischarge);
COption::SetOptionString($mid, $CRM_ORDER_PROPS, serialize(RCrmActions::clearArr($orderPropsArr))); COption::SetOptionString($mid, $CRM_ORDER_PROPS, serialize(RCrmActions::clearArr($orderPropsArr)));
COption::SetOptionString($mid, $CRM_CONTRAGENT_TYPE, serialize(RCrmActions::clearArr($contragentTypeArr))); COption::SetOptionString($mid, $CRM_CONTRAGENT_TYPE, serialize(RCrmActions::clearArr($contragentTypeArr)));
COption::SetOptionString($mid, $CRM_LEGAL_DETAILS, serialize(RCrmActions::clearArr($legalDetailsArr))); COption::SetOptionString($mid, $CRM_LEGAL_DETAILS, serialize(RCrmActions::clearArr($legalDetailsArr)));
COption::SetOptionString($mid, $CRM_CUSTOM_FIELDS, serialize(RCrmActions::clearArr($customFieldsArr))); COption::SetOptionString($mid, $CRM_CUSTOM_FIELDS, serialize(RCrmActions::clearArr($customFieldsArr)));
COption::SetOptionString($mid, $CRM_ORDER_NUMBERS, $orderNumbers); COption::SetOptionString($mid, $CRM_ORDER_NUMBERS, $orderNumbers);
COption::SetOptionString($mid, $CRM_CANSEL_ORDER, serialize(RCrmActions::clearArr($canselOrderArr))); COption::SetOptionString($mid, $CRM_CANSEL_ORDER, serialize(RCrmActions::clearArr($canselOrderArr)));
COption::SetOptionString($mid, $CRM_INVENTORIES_UPLOAD, $inventoriesUpload); COption::SetOptionString($mid, $CRM_INVENTORIES_UPLOAD, $inventoriesUpload);
COption::SetOptionString($mid, $CRM_STORES, serialize(RCrmActions::clearArr($bitrixStoresArr))); COption::SetOptionString($mid, $CRM_STORES, serialize(RCrmActions::clearArr($bitrixStoresArr)));
COption::SetOptionString($mid, $CRM_SHOPS, serialize(RCrmActions::clearArr($bitrixShopsArr))); COption::SetOptionString($mid, $CRM_SHOPS, serialize(RCrmActions::clearArr($bitrixShopsArr)));
COption::SetOptionString($mid, $CRM_IBLOCKS_INVENTORIES, serialize(RCrmActions::clearArr($bitrixIblocksInventories))); COption::SetOptionString($mid, $CRM_IBLOCKS_INVENTORIES, serialize(RCrmActions::clearArr($bitrixIblocksInventories)));
COption::SetOptionString($mid, $CRM_PRICES_UPLOAD, $pricesUpload); COption::SetOptionString($mid, $CRM_PRICES_UPLOAD, $pricesUpload);
COption::SetOptionString($mid, $CRM_PRICES, serialize(RCrmActions::clearArr($bitrixPricesArr))); COption::SetOptionString($mid, $CRM_PRICES, serialize(RCrmActions::clearArr($bitrixPricesArr)));
COption::SetOptionString($mid, $CRM_PRICE_SHOPS, serialize(RCrmActions::clearArr($bitrixPriceShopsArr))); COption::SetOptionString($mid, $CRM_PRICE_SHOPS, serialize(RCrmActions::clearArr($bitrixPriceShopsArr)));
COption::SetOptionString($mid, $CRM_IBLOCKS_PRICES, serialize(RCrmActions::clearArr($bitrixIblocksPrices))); COption::SetOptionString($mid, $CRM_IBLOCKS_PRICES, serialize(RCrmActions::clearArr($bitrixIblocksPrices)));
COption::SetOptionString($mid, $CRM_COLLECTOR, $collector); COption::SetOptionString($mid, $CRM_COLLECTOR, $collector);
COption::SetOptionString($mid, $CRM_COLL_KEY, serialize(RCrmActions::clearArr($collectorKeys))); COption::SetOptionString($mid, $CRM_COLL_KEY, serialize(RCrmActions::clearArr($collectorKeys)));
COption::SetOptionString($mid, $CRM_UA, $ua); COption::SetOptionString($mid, $CRM_UA, $ua);
COption::SetOptionString($mid, $CRM_UA_KEYS, serialize(RCrmActions::clearArr($uaKeys))); COption::SetOptionString($mid, $CRM_UA_KEYS, serialize(RCrmActions::clearArr($uaKeys)));
COption::SetOptionString($mid, $CRM_DIMENSIONS, $orderDimensions); COption::SetOptionString($mid, $CRM_DIMENSIONS, $orderDimensions);
@ -563,29 +557,29 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
//bitrix orderTypesList -- personTypes //bitrix orderTypesList -- personTypes
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']); $arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
//bitrix deliveryTypesList //bitrix deliveryTypesList
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList(); $arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
//bitrix paymentTypesList //bitrix paymentTypesList
$arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList(); $arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList();
//bitrix statusesList //bitrix statusesList
$arResult['bitrixPaymentStatusesList'] = RCrmActions::StatusesList(); $arResult['bitrixPaymentStatusesList'] = RCrmActions::StatusesList();
//bitrix pyament Y/N //bitrix pyament Y/N
$arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y'); $arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y');
$arResult['bitrixPaymentList'][0]['ID'] = 'Y'; $arResult['bitrixPaymentList'][0]['ID'] = 'Y';
$arResult['bitrixPaymentList'][1]['NAME'] = GetMessage('PAYMENT_N'); $arResult['bitrixPaymentList'][1]['NAME'] = GetMessage('PAYMENT_N');
$arResult['bitrixPaymentList'][1]['ID'] = 'N'; $arResult['bitrixPaymentList'][1]['ID'] = 'N';
//bitrix orderPropsList //bitrix orderPropsList
$arResult['arProp'] = RCrmActions::OrderPropsList(); $arResult['arProp'] = RCrmActions::OrderPropsList();
$arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList(); $arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList();
$arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList(); $arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList();
$arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList(); $arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList();
//saved cat params //saved cat params
$optionsOrderTypes = unserialize(COption::GetOptionString($mid, $CRM_ORDER_TYPES_ARR, 0)); $optionsOrderTypes = unserialize(COption::GetOptionString($mid, $CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, 0)); $optionsDelivTypes = unserialize(COption::GetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, 0));
@ -594,29 +588,29 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0)); $optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0));
$optionsSitesList = unserialize(COption::GetOptionString($mid, $CRM_SITES_LIST, 0)); $optionsSitesList = unserialize(COption::GetOptionString($mid, $CRM_SITES_LIST, 0));
$optionsDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0); $optionsDischarge = COption::GetOptionString($mid, $CRM_ORDER_DISCHARGE, 0);
$optionsOrderProps = unserialize(COption::GetOptionString($mid, $CRM_ORDER_PROPS, 0)); $optionsOrderProps = unserialize(COption::GetOptionString($mid, $CRM_ORDER_PROPS, 0));
$optionsContragentType = unserialize(COption::GetOptionString($mid, $CRM_CONTRAGENT_TYPE, 0)); $optionsContragentType = unserialize(COption::GetOptionString($mid, $CRM_CONTRAGENT_TYPE, 0));
$optionsLegalDetails = unserialize(COption::GetOptionString($mid, $CRM_LEGAL_DETAILS, 0)); $optionsLegalDetails = unserialize(COption::GetOptionString($mid, $CRM_LEGAL_DETAILS, 0));
$optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0)); $optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0));
$optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0); $optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0);
$canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0)); $canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0));
$optionInventotiesUpload = COption::GetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 0); $optionInventotiesUpload = COption::GetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 0);
$optionStores = unserialize(COption::GetOptionString($mid, $CRM_STORES, 0)); $optionStores = unserialize(COption::GetOptionString($mid, $CRM_STORES, 0));
$optionShops = unserialize(COption::GetOptionString($mid, $CRM_SHOPS, 0)); $optionShops = unserialize(COption::GetOptionString($mid, $CRM_SHOPS, 0));
$optionIblocksInventories = unserialize(COption::GetOptionString($mid, $CRM_IBLOCKS_INVENTORIES, 0)); $optionIblocksInventories = unserialize(COption::GetOptionString($mid, $CRM_IBLOCKS_INVENTORIES, 0));
$optionPricesUpload = COption::GetOptionString($mid, $CRM_PRICES_UPLOAD, 0); $optionPricesUpload = COption::GetOptionString($mid, $CRM_PRICES_UPLOAD, 0);
$optionPrices = unserialize(COption::GetOptionString($mid, $CRM_PRICES, 0)); $optionPrices = unserialize(COption::GetOptionString($mid, $CRM_PRICES, 0));
$optionPriceShops = unserialize(COption::GetOptionString($mid, $CRM_PRICE_SHOPS, 0)); $optionPriceShops = unserialize(COption::GetOptionString($mid, $CRM_PRICE_SHOPS, 0));
$optionIblocksPrices = unserialize(COption::GetOptionString($mid, $CRM_IBLOCKS_PRICES, 0)); $optionIblocksPrices = unserialize(COption::GetOptionString($mid, $CRM_IBLOCKS_PRICES, 0));
$optionCollector = COption::GetOptionString($mid, $CRM_COLLECTOR, 0); $optionCollector = COption::GetOptionString($mid, $CRM_COLLECTOR, 0);
$optionCollectorKeys = unserialize(COption::GetOptionString($mid, $CRM_COLL_KEY)); $optionCollectorKeys = unserialize(COption::GetOptionString($mid, $CRM_COLL_KEY));
$optionUa = COption::GetOptionString($mid, $CRM_UA, 0); $optionUa = COption::GetOptionString($mid, $CRM_UA, 0);
$optionUaKeys = unserialize(COption::GetOptionString($mid, $CRM_UA_KEYS)); $optionUaKeys = unserialize(COption::GetOptionString($mid, $CRM_UA_KEYS));
$version = COption::GetOptionString($mid, $CRM_API_VERSION, 0); $version = COption::GetOptionString($mid, $CRM_API_VERSION, 0);
//currency //currency
@ -658,11 +652,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
?> ?>
<?php $APPLICATION->AddHeadString('<script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script>'); ?> <?php $APPLICATION->AddHeadString('<script type="text/javascript" src="/bitrix/js/main/jquery/jquery-1.7.min.js"></script>'); ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('input.addr').change(function(){ $('input.addr').change(function(){
splitName = $(this).attr('name').split('-'); splitName = $(this).attr('name').split('-');
orderType = splitName[2]; orderType = splitName[2];
if(parseInt($(this).val()) === 1) if(parseInt($(this).val()) === 1)
$('tr.address-detail-' + orderType).show('slow'); $('tr.address-detail-' + orderType).show('slow');
else if(parseInt($(this).val()) === 0) else if(parseInt($(this).val()) === 0)
@ -673,7 +667,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
splitName = $(this).attr('name').split('-'); splitName = $(this).attr('name').split('-');
contragentType = $(this).val(); contragentType = $(this).val();
orderType = splitName[2]; orderType = splitName[2];
$('tr.legal-detail-' + orderType).hide(); $('tr.legal-detail-' + orderType).hide();
$('.legal-detail-title-' + orderType).hide(); $('.legal-detail-title-' + orderType).hide();
@ -684,47 +678,47 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} }
}); });
}); });
$('.inventories-batton label').change(function(){ $('.inventories-batton label').change(function(){
if($(this).find('input').is(':checked') === true){ if($(this).find('input').is(':checked') === true){
$('tr.inventories').show('slow'); $('tr.inventories').show('slow');
} else if($(this).find('input').is(':checked') === false){ } else if($(this).find('input').is(':checked') === false){
$('tr.inventories').hide('slow'); $('tr.inventories').hide('slow');
} }
return true; return true;
}); });
$('.prices-batton label').change(function(){ $('.prices-batton label').change(function(){
if($(this).find('input').is(':checked') === true){ if($(this).find('input').is(':checked') === true){
$('tr.prices').show('slow'); $('tr.prices').show('slow');
} else if($(this).find('input').is(':checked') === false){ } else if($(this).find('input').is(':checked') === false){
$('tr.prices').hide('slow'); $('tr.prices').hide('slow');
} }
return true; return true;
}); });
$('.r-ua-button label').change(function(){ $('.r-ua-button label').change(function(){
if($(this).find('input').is(':checked') === true){ if($(this).find('input').is(':checked') === true){
$('tr.r-ua').show('slow'); $('tr.r-ua').show('slow');
} else if($(this).find('input').is(':checked') === false){ } else if($(this).find('input').is(':checked') === false){
$('tr.r-ua').hide('slow'); $('tr.r-ua').hide('slow');
} }
return true; return true;
}); });
$('.r-coll-button label').change(function(){ $('.r-coll-button label').change(function(){
if($(this).find('input').is(':checked') === true){ if($(this).find('input').is(':checked') === true){
$('tr.r-coll').show('slow'); $('tr.r-coll').show('slow');
} else if($(this).find('input').is(':checked') === false){ } else if($(this).find('input').is(':checked') === false){
$('tr.r-coll').hide('slow'); $('tr.r-coll').hide('slow');
} }
return true; return true;
}); });
}); });
$('input[name="update-delivery-services"]').live('click', function() { $('input[name="update-delivery-services"]').live('click', function() {
BX.showWait(); BX.showWait();
@ -777,12 +771,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
border-bottom: 15px solid #f5f9f9 !important; border-bottom: 15px solid #f5f9f9 !important;
} }
.option-head{ .option-head{
text-align: center; text-align: center;
padding: 10px; padding: 10px;
font-size: 14px; font-size: 14px;
color: #4b6267; color: #4b6267;
} }
</style> </style>
<form method="POST" action="<?php echo $uri; ?>" id="FORMACTION"> <form method="POST" action="<?php echo $uri; ?>" id="FORMACTION">
<?php <?php
@ -808,7 +802,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<?php echo GetMessage('ICRM_SITES'); ?> <?php echo GetMessage('ICRM_SITES'); ?>
</b> </b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['arSites'] as $site): ?> <?php foreach ($arResult['arSites'] as $site): ?>
<tr> <tr>
<td width="50%" class="adm-detail-content-cell-l"><?php echo $site['NAME'] . ' (' . $site['LID'] . ')'; ?></td> <td width="50%" class="adm-detail-content-cell-l"><?php echo $site['NAME'] . ' (' . $site['LID'] . ')'; ?></td>
@ -981,7 +975,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<?php echo GetMessage('CONTRAGENTS_TYPES_LIST'); ?> <?php echo GetMessage('CONTRAGENTS_TYPES_LIST'); ?>
</td> </td>
<td width="50%" class="adm-detail-content-cell-r"> <td width="50%" class="adm-detail-content-cell-r">
<select name="contragent-type-<?php echo $bitrixOrderType['ID']; ?>" class="typeselect"> <select name="contragent-type-<?php echo $bitrixOrderType['ID']; ?>" class="typeselect">
<?php foreach ($arResult['contragentType'] as $contragentType): ?> <?php foreach ($arResult['contragentType'] as $contragentType): ?>
<option value="<?php echo $contragentType["ID"]; ?>" <?php if ($optionsContragentType[$bitrixOrderType['ID']] == $contragentType['ID']) echo 'selected'; ?>> <option value="<?php echo $contragentType["ID"]; ?>" <?php if ($optionsContragentType[$bitrixOrderType['ID']] == $contragentType['ID']) echo 'selected'; ?>>
<?php echo $contragentType["NAME"]; ?> <?php echo $contragentType["NAME"]; ?>
@ -990,7 +984,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</select> </select>
</td> </td>
</tr> </tr>
<?php $countProps = 1; foreach($arResult['orderProps'] as $orderProp): ?> <?php $countProps = 1; foreach($arResult['orderProps'] as $orderProp): ?>
<?php if($orderProp['ID'] == 'text'): ?> <?php if($orderProp['ID'] == 'text'): ?>
<tr class="heading"> <tr class="heading">
<td colspan="2" style="background-color: transparent;"> <td colspan="2" style="background-color: transparent;">
@ -1007,7 +1001,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</td> </td>
<td width="50%" class="adm-detail-content-cell-r"> <td width="50%" class="adm-detail-content-cell-r">
<select name="order-prop-<?php echo $orderProp['ID'] . '-' . $bitrixOrderType['ID']; ?>" class="typeselect"> <select name="order-prop-<?php echo $orderProp['ID'] . '-' . $bitrixOrderType['ID']; ?>" class="typeselect">
<option value=""></option> <option value=""></option>
<?php foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp): ?> <?php foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp): ?>
<option value="<?php echo $arProp['CODE']; ?>" <?php if ($optionsOrderProps[$bitrixOrderType['ID']][$orderProp['ID']] == $arProp['CODE']) echo 'selected'; ?>> <option value="<?php echo $arProp['CODE']; ?>" <?php if ($optionsOrderProps[$bitrixOrderType['ID']][$orderProp['ID']] == $arProp['CODE']) echo 'selected'; ?>>
<?php echo $arProp['NAME']; ?> <?php echo $arProp['NAME']; ?>
@ -1065,15 +1059,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php $tabControl->BeginNextTab(); ?> <?php $tabControl->BeginNextTab(); ?>
<input type="hidden" name="tab" value="catalog"> <input type="hidden" name="tab" value="catalog">
<tr class="heading"> <tr class="heading">
<td colspan="2" class="option-other-bottom"><b><?php echo GetMessage('ORDERS_OPTIONS'); ?></b></td> <td colspan="2" class="option-other-bottom"><b><?php echo GetMessage('ORDERS_OPTIONS'); ?></b></td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
<b> <b>
@ -1097,14 +1091,14 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<label><input class="addr" type="radio" name="order-discharge" value="0" <?php if($optionsDischarge == 0) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_AGENT'); ?></label> <label><input class="addr" type="radio" name="order-discharge" value="0" <?php if($optionsDischarge == 0) echo "checked"; ?>><?php echo GetMessage('DISCHARGE_AGENT'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<tr class="heading"> <tr class="heading">
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td> <td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
<select name="api_version" class="typeselect"> <select name="api_version" class="typeselect">
<?php for($v = 4; $v <= 5; $v++) { <?php for($v = 4; $v <= 5; $v++) {
$ver = 'v' . $v; ?> $ver = 'v' . $v; ?>
<option value="<?php echo $ver; ?>" <?php if ($ver == $version) echo 'selected'; ?>> <option value="<?php echo $ver; ?>" <?php if ($ver == $version) echo 'selected'; ?>>
API V<?php echo $v; ?> API V<?php echo $v; ?>
@ -1115,10 +1109,10 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</tr> </tr>
<tr class="heading"> <tr class="heading">
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CURRENCY'); ?></b></td> <td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CURRENCY'); ?></b></td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
<select name="currency" class="typeselect"> <select name="currency" class="typeselect">
<?php foreach ($currencyList as $currencyCode => $currencyName) : ?> <?php foreach ($currencyList as $currencyCode => $currencyName) : ?>
<option value="<?php echo $currencyCode; ?>" <?php if ($currencyCode == $currencyOption) echo 'selected'; ?>> <option value="<?php echo $currencyCode; ?>" <?php if ($currencyCode == $currencyOption) echo 'selected'; ?>>
<?php echo $currencyName; ?> <?php echo $currencyName; ?>
@ -1134,12 +1128,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<label><input class="addr" type="checkbox" name="inventories-upload" value="Y" <?php if($optionInventotiesUpload === 'Y') echo "checked"; ?>><?php echo GetMessage('INVENTORIES_UPLOAD'); ?></label> <label><input class="addr" type="checkbox" name="inventories-upload" value="Y" <?php if($optionInventotiesUpload === 'Y') echo "checked"; ?>><?php echo GetMessage('INVENTORIES_UPLOAD'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
<b><label><?php echo GetMessage('INVENTORIES'); ?></label></b> <b><label><?php echo GetMessage('INVENTORIES'); ?></label></b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['bitrixStoresExportList'] as $catalogExportStore): ?> <?php foreach ($arResult['bitrixStoresExportList'] as $catalogExportStore): ?>
<tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td width="50%" class="adm-detail-content-cell-l"><?php echo $catalogExportStore['TITLE'] ?></td> <td width="50%" class="adm-detail-content-cell-l"><?php echo $catalogExportStore['TITLE'] ?></td>
@ -1159,28 +1153,28 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<label><?php echo GetMessage('SHOPS_INVENTORIES_UPLOAD'); ?></label> <label><?php echo GetMessage('SHOPS_INVENTORIES_UPLOAD'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['sitesList'] as $sitesList): ?> <?php foreach ($arResult['sitesList'] as $sitesList): ?>
<tr class="inventories" align="center" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="inventories" align="center" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-other-center"> <td colspan="2" class="option-other-center">
<label><input class="addr" type="checkbox" name="shops-exoprt-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label> <label><input class="addr" type="checkbox" name="shops-exoprt-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label>
</td> </td>
</tr> </tr>
<?php endforeach;?> <?php endforeach;?>
<tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="inventories" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
<b> <b>
<label><?php echo GetMessage('IBLOCKS_UPLOAD'); ?></label> <label><?php echo GetMessage('IBLOCKS_UPLOAD'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['bitrixIblocksExportList'] as $catalogExportIblock) :?> <?php foreach ($arResult['bitrixIblocksExportList'] as $catalogExportIblock) :?>
<tr class="inventories" align="center" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="inventories" align="center" <?php if($optionInventotiesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-other-center"> <td colspan="2" class="option-other-center">
<label><input class="addr" type="checkbox" name="iblocks-stores-<?echo $catalogExportIblock['ID'];?>" value="Y" <?php if(in_array($catalogExportIblock['ID'], $optionIblocksInventories)) echo "checked"; ?>> <?php echo '['. $catalogExportIblock['CODE']. '] ' . $catalogExportIblock['NAME'] . ' (' . $catalogExportIblock['LID'] . ')'; ?></label> <label><input class="addr" type="checkbox" name="iblocks-stores-<?echo $catalogExportIblock['ID'];?>" value="Y" <?php if(in_array($catalogExportIblock['ID'], $optionIblocksInventories)) echo "checked"; ?>> <?php echo '['. $catalogExportIblock['CODE']. '] ' . $catalogExportIblock['NAME'] . ' (' . $catalogExportIblock['LID'] . ')'; ?></label>
</td> </td>
</tr> </tr>
<?php endforeach;?> <?php endforeach;?>
<?php endif;?> <?php endif;?>
<?php if ($optionPricesUpload === 'Y' || count($arResult['bitrixPricesExportList']) > 0) :?> <?php if ($optionPricesUpload === 'Y' || count($arResult['bitrixPricesExportList']) > 0) :?>
<tr class="heading prices-batton"> <tr class="heading prices-batton">
@ -1189,15 +1183,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<label><input class="addr" type="checkbox" name="prices-upload" value="Y" <?php if($optionPricesUpload === 'Y') echo "checked"; ?>><?php echo GetMessage('PRICES_UPLOAD'); ?></label> <label><input class="addr" type="checkbox" name="prices-upload" value="Y" <?php if($optionPricesUpload === 'Y') echo "checked"; ?>><?php echo GetMessage('PRICES_UPLOAD'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
<b> <b>
<label><?php echo GetMessage('PRICE_TYPES'); ?></label> <label><?php echo GetMessage('PRICE_TYPES'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['bitrixPricesExportList'] as $catalogExportPrice) :?> <?php foreach ($arResult['bitrixPricesExportList'] as $catalogExportPrice) :?>
<tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td width="50%" class="adm-detail-content-cell-l"><?php echo $catalogExportPrice['NAME_LANG'] . ' (' . $catalogExportPrice['NAME'] . ')'; ?></td> <td width="50%" class="adm-detail-content-cell-l"><?php echo $catalogExportPrice['NAME_LANG'] . ' (' . $catalogExportPrice['NAME'] . ')'; ?></td>
<td width="50%" class="adm-detail-content-cell-r"> <td width="50%" class="adm-detail-content-cell-r">
@ -1216,13 +1210,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<label><?php echo GetMessage('SHOPS_PRICES_UPLOAD'); ?></label> <label><?php echo GetMessage('SHOPS_PRICES_UPLOAD'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['sitesList'] as $sitesList): ?> <?php foreach ($arResult['sitesList'] as $sitesList): ?>
<tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-other-center"> <td colspan="2" class="option-other-center">
<label><input class="addr" type="checkbox" name="shops-price-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionPriceShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label> <label><input class="addr" type="checkbox" name="shops-price-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionPriceShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label>
</td> </td>
</tr> </tr>
<?php endforeach;?> <?php endforeach;?>
<tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="prices" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
@ -1230,28 +1224,28 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<label><?php echo GetMessage('IBLOCKS_UPLOAD'); ?></label> <label><?php echo GetMessage('IBLOCKS_UPLOAD'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['bitrixIblocksExportList'] as $catalogExportIblock) :?> <?php foreach ($arResult['bitrixIblocksExportList'] as $catalogExportIblock) :?>
<tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-other-center"> <td colspan="2" class="option-other-center">
<label><input class="addr" type="checkbox" name="iblocks-prices-<?echo $catalogExportIblock['ID'];?>" value="Y" <?php if(in_array($catalogExportIblock['ID'], $optionIblocksPrices)) echo "checked"; ?>> <?php echo '['. $catalogExportIblock['CODE']. '] ' . $catalogExportIblock['NAME'] . ' (' . $catalogExportIblock['LID'] . ')'; ?></label> <label><input class="addr" type="checkbox" name="iblocks-prices-<?echo $catalogExportIblock['ID'];?>" value="Y" <?php if(in_array($catalogExportIblock['ID'], $optionIblocksPrices)) echo "checked"; ?>> <?php echo '['. $catalogExportIblock['CODE']. '] ' . $catalogExportIblock['NAME'] . ' (' . $catalogExportIblock['LID'] . ')'; ?></label>
</td> </td>
</tr> </tr>
<?php endforeach;?> <?php endforeach;?>
<?php endif;?> <?php endif;?>
<tr class="heading r-coll-button"> <tr class="heading r-coll-button">
<td colspan="2" class="option-other-heading"> <td colspan="2" class="option-other-heading">
<b> <b>
<label><input class="addr" type="checkbox" name="collector" value="Y" <?php if($optionCollector === 'Y') echo "checked"; ?>><?php echo GetMessage('DEMON_COLLECTOR'); ?></label> <label><input class="addr" type="checkbox" name="collector" value="Y" <?php if($optionCollector === 'Y') echo "checked"; ?>><?php echo GetMessage('DEMON_COLLECTOR'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<tr class="r-coll" <?php if($optionCollector !== 'Y') echo 'style="display: none;"'; ?>> <tr class="r-coll" <?php if($optionCollector !== 'Y') echo 'style="display: none;"'; ?>>
<td class="option-head" colspan="2"> <td class="option-head" colspan="2">
<b><?php echo GetMessage('ICRM_SITES'); ?></b> <b><?php echo GetMessage('ICRM_SITES'); ?></b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['arSites'] as $sitesList): ?> <?php foreach ($arResult['arSites'] as $sitesList): ?>
<tr class="r-coll" <?php if($optionCollector !== 'Y') echo 'style="display: none;"'; ?>> <tr class="r-coll" <?php if($optionCollector !== 'Y') echo 'style="display: none;"'; ?>>
<td class="adm-detail-content-cell-l" width="50%"><?php echo GetMessage('DEMON_KEY'); ?> <?php echo $sitesList['NAME']; ?> (<?php echo $sitesList['LID']; ?>)</td> <td class="adm-detail-content-cell-l" width="50%"><?php echo GetMessage('DEMON_KEY'); ?> <?php echo $sitesList['NAME']; ?> (<?php echo $sitesList['LID']; ?>)</td>
@ -1266,13 +1260,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<label><input class="addr" type="checkbox" name="ua-integration" value="Y" <?php if($optionUa === 'Y') echo "checked"; ?>><?php echo GetMessage('UNIVERSAL_ANALYTICS'); ?></label> <label><input class="addr" type="checkbox" name="ua-integration" value="Y" <?php if($optionUa === 'Y') echo "checked"; ?>><?php echo GetMessage('UNIVERSAL_ANALYTICS'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<?php foreach ($arResult['arSites'] as $sitesList): ?> <?php foreach ($arResult['arSites'] as $sitesList): ?>
<tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>> <tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>>
<td class="option-head" colspan="2"> <td class="option-head" colspan="2">
<b><?php echo $sitesList['NAME']; ?> (<?php echo $sitesList['LID']; ?>)</b> <b><?php echo $sitesList['NAME']; ?> (<?php echo $sitesList['LID']; ?>)</b>
</td> </td>
</tr> </tr>
<tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>> <tr class="r-ua" <?php if($optionUa !== 'Y') echo 'style="display: none;"'; ?>>
<td class="adm-detail-content-cell-l" width="50%"><?php echo GetMessage('ID_UA'); ?></td> <td class="adm-detail-content-cell-l" width="50%"><?php echo GetMessage('ID_UA'); ?></td>
<td class="adm-detail-content-cell-r" width="50%"> <td class="adm-detail-content-cell-r" width="50%">
@ -1291,7 +1285,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<input type="hidden" name="Update" value="Y" /> <input type="hidden" name="Update" value="Y" />
<input type="submit" title="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_TITLE'); ?>" value="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_VALUE'); ?>" name="btn-update" class="adm-btn-save" /> <input type="submit" title="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_TITLE'); ?>" value="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_VALUE'); ?>" name="btn-update" class="adm-btn-save" />
<?php $tabControl->End(); ?> <?php $tabControl->End(); ?>
</form> </form>
<?php } ?> <?php } ?>
<?php //order upload?> <?php //order upload?>
@ -1356,21 +1350,21 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
left: -2px; left: -2px;
top: -2px; top: -2px;
} }
.order-upload-button{ .order-upload-button{
padding: 1px 13px 2px; padding: 1px 13px 2px;
height:28px; height:28px;
} }
.order-upload-button div{ .order-upload-button div{
float:right; float:right;
position:relative; position:relative;
visible: none; visible: none;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#percent').width($('.instal-progress-bar-outer').width()); $('#percent').width($('.instal-progress-bar-outer').width());
$(window).resize(function(){ // strechin progress bar $(window).resize(function(){ // strechin progress bar
@ -1398,7 +1392,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
BX.closeWait(); BX.closeWait();
} }
else{ else{
orderUpload(); orderUpload();
} }
$('#indicator').css('width', response.percent + '%'); $('#indicator').css('width', response.percent + '%');
$('#percent').html(response.percent + '%'); $('#percent').html(response.percent + '%');
@ -1414,7 +1408,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
}); });
} }
$('input[name="start"]').live('click', function() { $('input[name="start"]').live('click', function() {
BX.showWait(); BX.showWait();
$('#indicator').css('width', 0); $('#indicator').css('width', 0);
$('#percent2').html('0%'); $('#percent2').html('0%');