diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index a56f6a50..00653968 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -105,6 +105,259 @@ class intaro_intarocrm extends CModule ); return; } + + if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') + && isset($_POST['ajax']) && ($_POST['ajax'] == 1)) { + + $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); + $this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key); + + //prepare crm lists + $arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList(); + + if ((int) $this->INTARO_CRM_API->getStatusCode() != 200) { + $APPLICATION->RestartBuffer(); + header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); + die(json_encode(array("success" => false))); + } + + $arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList(); + $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList(); + $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses + $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList(); + $arResult['paymentGroupList'] = $this->INTARO_CRM_API->orderStatusGroupsList(); // -- statuses groups + + //bitrix orderTypesList -- personTypes + $dbOrderTypesList = CSalePersonType::GetList( + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), + array( + "ACTIVE" => "Y", + ), + false, + false, + array() + ); + + + //form order types ids arr + $orderTypesArr = array(); + if ($arOrderTypesList = $dbOrderTypesList->Fetch()) { + do { + $arResult['bitrixOrderTypesList'][] = $arOrderTypesList; + $orderTypesArr[$arOrderTypesList['ID']] = htmlspecialchars(trim($_POST['order-type-' . $arOrderTypesList['ID']])); + } while ($arOrderTypesList = $dbOrderTypesList->Fetch()); + } + + //bitrix deliveryTypesList + $dbDeliveryTypesList = CSaleDelivery::GetList( + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), + array( + "ACTIVE" => "Y", + ), + false, + false, + array() + ); + + //form delivery types ids arr + $deliveryTypesArr = array(); + if ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()) { + do { + $arResult['bitrixDeliveryTypesList'][] = $arDeliveryTypesList; + $deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']])); + } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()); + } + + //bitrix paymentTypesList + $dbPaymentTypesList = CSalePaySystem::GetList( + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), + array( + "ACTIVE" => "Y" + ) + ); + + //form payment types ids arr + $paymentTypesArr = array(); + if ($arPaymentTypesList = $dbPaymentTypesList->Fetch()) { + do { + $arResult['bitrixPaymentTypesList'][] = $arPaymentTypesList; + $paymentTypesArr[$arPaymentTypesList['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $arPaymentTypesList['ID']])); + } while ($arPaymentTypesList = $dbPaymentTypesList->Fetch()); + } + + //bitrix paymentStatusesList + $dbPaymentStatusesList = CSaleStatus::GetList( + array( + "SORT" => "ASC", + "NAME" => "ASC" + ), + array( + "LID" => "ru", //ru + "ACTIVE" => "Y" + ) + ); + + //form payment statuses ids arr + $paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y'])); + if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { + do { + $arResult['bitrixPaymentStatusesList'][] = $arPaymentStatusesList; + $paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']])); + } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); + } + + $arResult['bitrixPaymentStatusesList'][] = array( + 'ID' => 'Y', + 'NAME' => GetMessage('CANCELED') + ); + + //form payment ids arr + $paymentArr = array(); + $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); + $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); + + COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize($orderTypesArr)); + COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr)); + COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_TYPES, serialize($paymentTypesArr)); + COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr)); + COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize($paymentArr)); + + // generate updated select inputs + $input = array(); + + foreach($arResult['bitrixDeliveryTypesList'] as $bitrixDeliveryType) { + $input['delivery-type-' . $bitrixDeliveryType['ID']] = + ''; + } + + foreach($arResult['bitrixPaymentTypesList'] as $bitrixPaymentType) { + $input['payment-type-' . $bitrixPaymentType['ID']] = + ''; + } + + foreach($arResult['bitrixPaymentStatusesList'] as $bitrixPaymentStatus) { + $input['payment-status-' . $bitrixPaymentStatus['ID']] = + ''; + } + + foreach($arResult['bitrixPaymentList'] as $bitrixPayment) { + $input['payment-' . $bitrixPayment['ID']] = + ''; + } + + foreach($arResult['bitrixOrderTypesList'] as $bitrixOrderType) { + $input['order-type-' . $bitrixOrderType['ID']] = + ''; + } + + $APPLICATION->RestartBuffer(); + header('Content-Type: application/x-javascript; charset='.LANG_CHARSET); + die(json_encode(array("success" => true, "result" => $input))); + } $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION])); @@ -445,5 +698,4 @@ class intaro_intarocrm extends CModule function DeleteFiles() { unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_run.php'); unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php'); - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/intaro.intarocrm/install/step2.php b/intaro.intarocrm/install/step2.php index 030c96f5..a7128715 100755 --- a/intaro.intarocrm/install/step2.php +++ b/intaro.intarocrm/install/step2.php @@ -1,6 +1,10 @@ + + + + +
@@ -48,11 +107,20 @@ $defaultPayment = array( - + + + + + + + diff --git a/intaro.intarocrm/install/version.php b/intaro.intarocrm/install/version.php index d490a8c4..84278a8d 100755 --- a/intaro.intarocrm/install/version.php +++ b/intaro.intarocrm/install/version.php @@ -1,5 +1,5 @@ '0.3.7', - 'VERSION_DATE' => '2013-08-06 15:07:00', -); + 'VERSION_DATE' => '2013-08-14 10:59:00', +); \ 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 cad51a52..a0a57f6c 100755 --- a/intaro.intarocrm/lang/ru/install/step2.php +++ b/intaro.intarocrm/lang/ru/install/step2.php @@ -10,4 +10,9 @@ $MESS ['PAYMENT_LIST'] = 'Оплата'; $MESS ['PAYMENT_Y'] = 'Оплачен'; $MESS ['PAYMENT_N'] = 'Не оплачен'; $MESS ['CANCELED'] = 'Флаг «Отменен»'; -$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.'; \ No newline at end of file +$MESS ['INFO_1'] = 'Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.'; +$MESS ['INFO_2'] = 'В случае, если вы не нашли подходящих значений в справочниках IntaroCRM, вы можете внести их в разделе'; +$MESS ['URL_1'] = 'Администрирование'; +$MESS ['INFO_3'] = 'После этого подгрузите новые значения, нажав кнопку «Обновить справочники»'; +$MESS ['UPDATE_CATS'] = 'Обновить справочники'; +$MESS ['MESS_5'] = 'Произошла ошибка сервера, обратитесь в Интаро Софт.'; \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/options.php b/intaro.intarocrm/lang/ru/options.php index 473cf341..34572124 100755 --- a/intaro.intarocrm/lang/ru/options.php +++ b/intaro.intarocrm/lang/ru/options.php @@ -21,4 +21,5 @@ $MESS ['ERR_404'] = 'Возможно не верно введен адрес CR $MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; $MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.'; -$MESS ['CANCELED'] = 'Флаг «Отменен»'; \ No newline at end of file +$MESS ['CANCELED'] = 'Флаг «Отменен»'; +$MESS ['INFO_1'] = ' Задайте соответствие между справочниками 1C-Битрикс и справочниками IntaroCRM.'; \ No newline at end of file diff --git a/intaro.intarocrm/options.php b/intaro.intarocrm/options.php index 9c8043f8..3f1d439a 100755 --- a/intaro.intarocrm/options.php +++ b/intaro.intarocrm/options.php @@ -286,6 +286,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { BeginNextTab(); ?> + + +
+ + +
" . GetMessage('URL_1') . "" . " " . 'IntaroCRM.'; ?>