diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index 0c7245b1..3da2f92b 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -40,11 +40,11 @@ class ICrmOrderActions * Mass order uploading, without repeating; always returns true, but writes error log * @return boolean */ - public static function uploadOrders($steps = false, $pSize = 500) { + public static function uploadOrders($steps = false, $pSize = 50) { //COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, 0); // -- for test - if (!CModule::IncludeModule('iblock')) { + if (!CModule::IncludeModule("iblock")) { //handle err self::eventLog('ICrmOrderActions::uploadOrders', 'iblock', 'module not found'); return true; @@ -163,7 +163,7 @@ class ICrmOrderActions return true; //all ok! } - + /** * * w+ event in bitrix log @@ -303,7 +303,8 @@ class ICrmOrderActions $items[] = array( 'price' => $p['PRICE'], 'purchasePrice' => $pr, - 'discount' => $p['DISCOUNT_VALUE'], + 'discount' => $p['DISCOUNT_PRICE'], + 'discountPercent' => $p['DISCOUNT_VALUE'], 'quantity' => $p['QUANTITY'], 'productId' => $p['PRODUCT_ID'], 'productName' => self::toJSON($p['NAME']) diff --git a/intaro.intarocrm/include.php b/intaro.intarocrm/include.php index 6623ad4b..0851bb33 100755 --- a/intaro.intarocrm/include.php +++ b/intaro.intarocrm/include.php @@ -2,8 +2,8 @@ CModule::AddAutoloadClasses( 'intaro.intarocrm', // module name array ( - 'IntaroCrm\RestApi' => 'classes/general/RestApi.php', - 'ICrmOrderActions' => 'classes/general/ICrmOrderActions.php', - 'ICrmOrderEvent' => 'classes/general/events/ICrmOrderEvent.php' + 'IntaroCrm\RestApi' => 'classes/general/RestApi.php', + 'ICrmOrderActions' => 'classes/general/ICrmOrderActions.php', + 'ICrmOrderEvent' => 'classes/general/events/ICrmOrderEvent.php' ) ); \ No newline at end of file diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index c09bfc81..4e5cc2a5 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -63,13 +63,41 @@ class intaro_intarocrm extends CModule $step = intval($_REQUEST['step']); if ($step <= 1) { + if(!CModule::IncludeModule("sale")) { + $arResult['errCode'] = 'ERR_SALE'; + } + + if(!CModule::IncludeModule("iblock")) { + $arResult['errCode'] = 'ERR_IBLOCK'; + } + + if(!CModule::IncludeModule("catalog")) { + $arResult['errCode'] = 'ERR_CATALOG'; + } + $APPLICATION->IncludeAdminFile( GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' ); } else if ($step == 2) { if(!CModule::IncludeModule("sale")) { - //handler + $arResult['errCode'] = 'ERR_SALE'; + } + + if(!CModule::IncludeModule("iblock")) { + $arResult['errCode'] = 'ERR_IBLOCK'; + } + + if(!CModule::IncludeModule("catalog")) { + $arResult['errCode'] = 'ERR_CATALOG'; + } + + if(isset($arResult['errCode']) && $arResult['errCode']) { + $APPLICATION->IncludeAdminFile( + GetMessage('MODULE_INSTALL_TITLE'), + $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' + ); + return; } $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); @@ -191,7 +219,7 @@ class intaro_intarocrm extends CModule $arResult['bitrixPaymentStatusesList'][] = array( 'ID' => 'Y', - 'NAME' => 'Отменен' + 'NAME' => GetMessage('CANCELED') ); $APPLICATION->IncludeAdminFile( @@ -219,7 +247,7 @@ class intaro_intarocrm extends CModule else $finish = (int) $_POST['finish']; - $percent = 100 - $countLeft * 100 / $countAll; + $percent = 100 - round(($countLeft * 100 / $countAll), 1); if(!$countLeft) $finish = 1; diff --git a/intaro.intarocrm/install/step1.php b/intaro.intarocrm/install/step1.php index e3e88e6f..f1aad63d 100755 --- a/intaro.intarocrm/install/step1.php +++ b/intaro.intarocrm/install/step1.php @@ -1,6 +1,9 @@ - + + if(isset($arResult['errCode']) && $arResult['errCode']) + echo CAdminMessage::ShowMessage(GetMessage($arResult['errCode'])); +?>
diff --git a/intaro.intarocrm/install/version.php b/intaro.intarocrm/install/version.php index 167ad49c..979ac045 100755 --- a/intaro.intarocrm/install/version.php +++ b/intaro.intarocrm/install/version.php @@ -1,5 +1,5 @@ '0.3.5', - 'VERSION_DATE' => '2013-07-23 17:01:00', + 'VERSION_DATE' => '2013-07-24 13:41:00', ); diff --git a/intaro.intarocrm/lang/ru/install/index.php b/intaro.intarocrm/lang/ru/install/index.php index e529dbd1..b2c7819e 100755 --- a/intaro.intarocrm/lang/ru/install/index.php +++ b/intaro.intarocrm/lang/ru/install/index.php @@ -5,4 +5,7 @@ $MESS ['MODULE_PARTNER_NAME'] = 'Интаро Софт'; $MESS ['MODULE_PARTNER_URI'] = 'http://intaro.ru'; $MESS ['MODULE_INSTALL_TITLE'] = 'Установка модуля'; $MESS ['MODULE_UNINSTALL_TITLE'] = 'Удаление модуля'; -?> +$MESS ['CANCELED'] = 'Флаг «Отменен»'; +$MESS ['ERR_SALE'] = 'Отсутсвует модуль sale! Дальнейшая установка невозможна'; +$MESS ['ERR_IBLOCK'] = 'Отсутсвует модуль iblock! Дальнейшая установка невозможна'; +$MESS ['ERR_CATALOG'] = 'Отсутсвует модуль catalog! Дальнейшая установка невозможна'; diff --git a/intaro.intarocrm/lang/ru/install/step1.php b/intaro.intarocrm/lang/ru/install/step1.php index d2b2a632..2e620c0f 100755 --- a/intaro.intarocrm/lang/ru/install/step1.php +++ b/intaro.intarocrm/lang/ru/install/step1.php @@ -3,10 +3,9 @@ $MESS ['STEP_NAME'] = 'Шаг 1'; $MESS ['MOD_NEXT_STEP'] = 'Следующий шаг'; $MESS ['ICRM_API_HOST'] = 'Адрес IntaroCRM:'; $MESS ['ICRM_API_KEY'] = 'Ключ авторизации:'; -$MESS ['ERR_404'] = 'Возможно не верно введен адрес IntaroCRM.'; -$MESS ['ERR_403'] = 'Не верный apiKey.'; +$MESS ['ERR_404'] = 'Возможно неверно введен адрес IntaroCRM.'; +$MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; -$MESS ['ERR_FIELDS_API_HOST'] = 'Не верно заполнены поля.'; +$MESS ['ERR_FIELDS_API_HOST'] = 'Неверно заполнены поля.'; $MESS ['INFO_1'] = 'Введите адрес экземпляра IntaroCRM (например, http://demo.intarocrm.ru) и API-ключ.'; -$MESS ['INFO_2'] = 'API-ключ можно сгенерировать при регистрации магазина в IntaroCRM (Администрирование > Магазины).'; -?> +$MESS ['INFO_2'] = 'API-ключ можно сгенерировать при регистрации магазина в IntaroCRM (Администрирование > Магазины).'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/install/step2.php b/intaro.intarocrm/lang/ru/install/step2.php index b1267ddd..691c1f45 100755 --- a/intaro.intarocrm/lang/ru/install/step2.php +++ b/intaro.intarocrm/lang/ru/install/step2.php @@ -7,7 +7,7 @@ $MESS ['PAYMENT_TYPES_LIST'] = 'Способы оплаты'; $MESS ['PAYMENT_STATUS_LIST'] = 'Статусы'; $MESS ['ORDER_TYPES_LIST'] = 'Типы заказа'; $MESS ['PAYMENT_LIST'] = 'Оплата'; -$MESS ['PAYMENT_Y'] = 'Оплачен'; +$MESS ['PAYMENT_Y'] = 'Флаг «Отменен»'; $MESS ['PAYMENT_N'] = 'Не оплачен'; -$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.'; -?> +$MESS ['CANCELED'] = 'Отменен'; +$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/install/step3.php b/intaro.intarocrm/lang/ru/install/step3.php index 5273f2c9..624acc2c 100755 --- a/intaro.intarocrm/lang/ru/install/step3.php +++ b/intaro.intarocrm/lang/ru/install/step3.php @@ -1,6 +1,6 @@ \ No newline at end of file +$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/install/unstep1.php b/intaro.intarocrm/lang/ru/install/unstep1.php index 2005f2ef..176e7982 100755 --- a/intaro.intarocrm/lang/ru/install/unstep1.php +++ b/intaro.intarocrm/lang/ru/install/unstep1.php @@ -1,4 +1,3 @@ +$MESS['MOD_BACK'] = 'Вернуться в список'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/options.php b/intaro.intarocrm/lang/ru/options.php index fa64e193..148e6782 100755 --- a/intaro.intarocrm/lang/ru/options.php +++ b/intaro.intarocrm/lang/ru/options.php @@ -18,6 +18,7 @@ $MESS ['ICRM_OPTIONS_SUBMIT_TITLE'] = 'Сохранить настройки'; $MESS ['ICRM_OPTIONS_SUBMIT_VALUE'] = 'Сохранить'; $MESS ['ERR_404'] = 'Возможно не верно введен адрес CRM.'; -$MESS ['ERR_403'] = 'Не верный apiKey.'; +$MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; -$MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.'; \ No newline at end of file +$MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.'; +$MESS ['CANCELED'] = 'Отменен'; \ No newline at end of file diff --git a/intaro.intarocrm/options.php b/intaro.intarocrm/options.php index 1cf55881..82d8c66e 100755 --- a/intaro.intarocrm/options.php +++ b/intaro.intarocrm/options.php @@ -12,8 +12,9 @@ $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; $CRM_PAYMENT = 'payment_arr'; //order payment Y/N $CRM_ORDER_LAST_ID = 'order_last_id'; -CModule::IncludeModule('intaro.intarocrm'); -CModule::IncludeModule('sale'); +if(!CModule::IncludeModule('intaro.intarocrm') + || !CModule::IncludeModule('sale')) + return; $_GET['errc'] = htmlspecialchars(trim($_GET['errc'])); $_GET['ok'] = htmlspecialchars(trim($_GET['ok'])); @@ -24,7 +25,7 @@ if($_GET['ok'] && $_GET['ok'] == 'Y') echo CAdminMessage::ShowNote(GetMessage('I $arResult = array(); //update connection settings -if (isset($_POST['Update']) && $_POST['Update']=='Y') { +if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $api_host = htmlspecialchars(trim($_POST['api_host'])); $api_key = htmlspecialchars(trim($_POST['api_key'])); @@ -43,7 +44,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') { } } - //bitrix orderTypesList -- personTypes + //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( array( "SORT" => "ASC", @@ -151,6 +152,10 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') { $arResult['paymentTypesList'] = $api->paymentTypesList(); $arResult['paymentStatusesList'] = $api->paymentStatusesList(); // --statuses $arResult['paymentList'] = $api->orderStatusesList(); + + //check connection & apiKey valid + if ((int) $api->getStatusCode() != 200) + echo CAdminMessage::ShowMessage(GetMessage('ERR_' . $api->getStatusCode())); //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( @@ -228,7 +233,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') { } $arResult['bitrixPaymentStatusesList'][] = array( 'ID' => 'Y', - 'NAME' => 'Отменен' + 'NAME' => GetMessage('CANCELED') ); //bitrix pyament Y/N @@ -264,7 +269,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') { BeginNextTab(); + $tabControl->BeginNextTab(); ?>