diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d100498..c0320a4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2015-03-19 v.1.1.1 +* Исправлена ошибка, связанная с версионностью PHP в History. +* Добавлена выгрузка закупочной цены вместе с заказом +* Добавлены индивидуальные настройки для профилей выгрузки +* Исправлены мелкие ошибки ## 2015-02-20 v.1.1.0 * Модуль переведен на новую версию API * Добавлена поддержка реквизитов юр. лиц @@ -16,7 +21,7 @@ ## 2015-02-12 v.1.0.16 * Исправлен агент * Исправлены ошибки с запоминанием пользователя - * Исправленна ошибка с выходом пользователя из системы + * Исправлена ошибка с выходом пользователя из системы * Исправлена ошибка хождения пользователя под другим логином * Исправлены проблема с fix-external-ids * Добавлена возможность получения скидки из CRM в Битрикс diff --git a/intaro.intarocrm/classes/general/ICMLLoader.php b/intaro.intarocrm/classes/general/ICMLLoader.php index 35c9d370..24eba372 100644 --- a/intaro.intarocrm/classes/general/ICMLLoader.php +++ b/intaro.intarocrm/classes/general/ICMLLoader.php @@ -5,6 +5,7 @@ IncludeModuleLangFile(__FILE__); class ICMLLoader { + public $profileID; public $iblocks; public $filename; public $serverName; @@ -222,8 +223,11 @@ class ICMLLoader { protected function BuildOffers(&$allCategories) { - $basePriceId = COption::GetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, 1); - + $basePriceId = COption::GetOptionString( + $this->MODULE_ID, + $this->CRM_CATALOG_BASE_PRICE . (is_null($this->profileID) === false ? '_' . $this->profileID : ''), + 1 + ); foreach ($this->iblocks as $key => $id) { diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index 854555bc..3caba6ed 100644 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -250,13 +250,20 @@ class ICrmOrderActions $item = array( 'quantity' => $p['QUANTITY'], 'productId' => $p['PRODUCT_ID'], + 'xmlId' => $p['PRODUCT_XML_ID'], 'productName' => $p['NAME'], 'comment' => $p['NOTES'], - 'discount' => $p['DISCOUNT_PRICE'] + 'createdAt' => new \DateTime($p['DATE_INSERT']) ); + $pp = CCatalogProduct::GetByID($p['PRODUCT_ID']); + if (is_null($pp['PURCHASING_PRICE']) == false) { + $item['purchasePrice'] = $pp['PURCHASING_PRICE']; + } + $propCancel = CSaleBasket::GetPropsList(array(), array('BASKET_ID' => $p['ID'], 'CODE' => self::CANCEL_PROPERTY_CODE))->Fetch(); - if ($propCancel && !(int)$propCancel['VALUE']) { + if (!$propCancel || ($propCancel && !(int)$propCancel['VALUE'])) { + $item['discount'] = (double) $p['DISCOUNT_PRICE']; $item['initialPrice'] = (double) $p['PRICE'] + (double) $p['DISCOUNT_PRICE']; } @@ -293,7 +300,7 @@ class ICrmOrderActions $customer = $normalizer->normalize($customer, 'customers'); $order = $normalizer->normalize($order, 'orders'); - $site = null; + if (isset($arParams['optionsSitesList']) && is_array($arParams['optionsSitesList']) && array_key_exists($arFields['LID'], $arParams['optionsSitesList'])) { $site = $arParams['optionsSitesList'][$arFields['LID']]; @@ -391,7 +398,7 @@ class ICrmOrderActions return false; } - $orderHistory = isset($orderHistory->orders) ? $orderHistory->orders : array(); + $orderHistory = isset($orderHistory['orders']) ? $orderHistory['orders'] : array(); $dateFinish = $api->getGeneratedAt(); if (is_null($dateFinish) || $dateFinish == false) { diff --git a/intaro.intarocrm/description.ru b/intaro.intarocrm/description.ru index 52611166..3ba43226 100644 --- a/intaro.intarocrm/description.ru +++ b/intaro.intarocrm/description.ru @@ -1,13 +1,4 @@ -- API -- . -- -- -- -- -- id -- $_SERVER['SERVER_NAME'] -- -- -- -- -- \ No newline at end of file +- Исправлена ошибка, связанная с версионностью PHP в History. +- Добавлена выгрузка закупочной цены вместе с заказом +- Добавлены индивидуальные настройки для профилей выгрузки +- Исправлены мелкие ошибки \ No newline at end of file diff --git a/intaro.intarocrm/export/export_run.php b/intaro.intarocrm/export/export_run.php index 983905a2..3174dcb5 100644 --- a/intaro.intarocrm/export/export_run.php +++ b/intaro.intarocrm/export/export_run.php @@ -1,5 +1,6 @@ profileID = $PROFILE_ID; $loader->iblocks = $IBLOCK_EXPORT; $loader->propertiesSKU = $IBLOCK_PROPERTY_SKU; $loader->propertiesUnitSKU = $IBLOCK_PROPERTY_UNIT_SKU; diff --git a/intaro.intarocrm/export/export_setup.php b/intaro.intarocrm/export/export_setup.php index ac2390b9..797235f3 100644 --- a/intaro.intarocrm/export/export_setup.php +++ b/intaro.intarocrm/export/export_setup.php @@ -17,7 +17,7 @@ __IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/intaro. $MODULE_ID = 'intaro.intarocrm'; $CRM_CATALOG_BASE_PRICE = 'catalog_base_price'; -$basePriceId = COption::GetOptionString($MODULE_ID, $CRM_CATALOG_BASE_PRICE, 1); +$basePriceId = COption::GetOptionString($MODULE_ID, $CRM_CATALOG_BASE_PRICE . '_' . $_REQUEST['PROFILE_ID'], 1); $arResult['PRICE_TYPES'] = array(); $dbPriceType = CCatalogGroup::GetList( @@ -665,7 +665,6 @@ if ($STEP==1) }; - @@ -693,7 +692,7 @@ if ($STEP==1) } elseif ($STEP==2) { - COption::SetOptionString($MODULE_ID, $CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types']))); + COption::SetOptionString($MODULE_ID, $CRM_CATALOG_BASE_PRICE . '_' . $_REQUEST['PROFILE_ID'], htmlspecialchars(trim($_POST['price-types']))); $FINITE = true; } diff --git a/intaro.intarocrm/install/version.php b/intaro.intarocrm/install/version.php index 84c7a46f..3913b629 100644 --- a/intaro.intarocrm/install/version.php +++ b/intaro.intarocrm/install/version.php @@ -1,6 +1,6 @@ "1.1.0", - "VERSION_DATE" => "2015-03-03 16:21:38" + "VERSION" => "1.1.1", + "VERSION_DATE" => "2015-03-19 14:56:00" ); diff --git a/intaro.intarocrm/updater.php b/intaro.intarocrm/updater.php index b775734c..8a60c4f9 100644 --- a/intaro.intarocrm/updater.php +++ b/intaro.intarocrm/updater.php @@ -1,87 +1,5 @@ apiUrl.'reference/sites'; - $result = $this->curlRequest($url); - return $result; - } -} -$mid = 'intaro.intarocrm'; -$CRM_API_HOST_OPTION = 'api_host'; -$CRM_API_KEY_OPTION = 'api_key'; -$CRM_CONTRAGENT_TYPE = 'contragent_type'; -$CRM_SITES_LIST= 'sites_list'; - -$api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0); -$api_key = COption::GetOptionString($mid, $CRM_API_KEY_OPTION, 0); -$api = new RestApiSite($api_host, $api_key); - -if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.intarocrm/classes/general/agent.php')) { - unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.intarocrm/classes/general/agent.php'); -} -if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.intarocrm/classes/general/Exception/ApiException.php')) { - unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.intarocrm/classes/general/Exception/ApiException.php'); -} -if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/retailcrm')) { - removeDirectory($_SERVER['DOCUMENT_ROOT'] . '/retailcrm'); -} - -//sites -$rsSites = CSite::GetList($by, $sort, array('ACTIVE' => 'Y')); -while ($ar = $rsSites->Fetch()){ - $arSites[] = $ar; -} -if(count($arSites)>1){ - try { - $sitesList = $api->sitesList(); - } catch (\IntaroCrm\Exception\CurlException $e) { - ICrmOrderActions::eventLog( - 'intaro.crm/updater.php', 'RetailCrm\RestApi::sitesList::CurlException', - $e->getCode() . ': ' . $e->getMessage() - ); - return; - } - foreach ($arResult['arSites'] as $arSites) { - $siteListArr[$arSites['LID']] = $sitesList[0]['code']; - } - COption::SetOptionString($mid, $CRM_SITES_LIST, serialize(ICrmOrderActions::clearArr($siteListArr))); -} - -//contragents type list -$dbOrderTypesList = CSalePersonType::GetList( - array( - "SORT" => "ASC", - "NAME" => "ASC" - ), - array( - "ACTIVE" => "Y", - ), - false, - false, - array() -); - -$orderTypesList = array(); -while ($arOrderTypesList = $dbOrderTypesList->Fetch()){ - $orderTypesList[] = $arOrderTypesList; -} -$contragentTypeArr = array(); -foreach ($orderTypesList as $orderType) { - $contragentTypeArr[$orderType['ID']] = 'individual'; -} -COption::SetOptionString($mid, $CRM_CONTRAGENT_TYPE, serialize(ICrmOrderActions::clearArr($contragentTypeArr))); - -function removeDirectory($dir) { - if ($objs = glob($dir."/*")) { - foreach($objs as $obj) { - is_dir($obj) ? removeDirectory($obj) : unlink($obj); - } - } - rmdir($dir); -} +if (!CModule::IncludeModule("main")) return; +DeleteDirFilesEx('/retailcrm'); +DeleteDirFilesEx('/bitrix/modules/intaro.intarocrm/classes/general/agent.php'); +DeleteDirFilesEx('/bitrix/modules/intaro.intarocrm/classes/general/Exception/ApiException.php'); \ No newline at end of file