diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index f8aabb24..9e897880 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -11,6 +11,7 @@ class ICrmOrderActions protected static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N protected static $CRM_ORDER_LAST_ID = 'order_last_id'; + protected static $CRM_ORDER_SITES = 'sites_ids'; /** * Mass order uploading, without repeating; always returns true, but writes error log @@ -55,6 +56,7 @@ class ICrmOrderActions $optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0)); $optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses $optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0)); + $optionsSites = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_SITES, 0)); $api = new IntaroCrm\RestApi($api_host, $api_key); @@ -63,7 +65,8 @@ class ICrmOrderActions 'optionsDelivTypes' => $optionsDelivTypes, 'optionsPayTypes' => $optionsPayTypes, 'optionsPayStatuses' => $optionsPayStatuses, - 'optionsPayment' => $optionsPayment + 'optionsPayment' => $optionsPayment, + 'optionSites' => $optionsSites ); //packmode @@ -71,12 +74,15 @@ class ICrmOrderActions $orderCount = 0; while ($arOrder = $dbOrder->GetNext()) { // here orders by id asc + + if(is_array($optionsSites) && !empty($optionsSites) && !in_array($arOrder['LID'], $optionsSites)) + continue; $result = self::orderCreate($arOrder, $api, $arParams); if (!$result['order'] || !$result['customer']) continue; - + $orderCount++; $resOrders[] = $result['order']; @@ -324,9 +330,13 @@ class ICrmOrderActions 'deliveryAddress' => $resOrderDeliveryAddress, 'items' => $items )); - + + if(isset($arParams['optionsSites']) && is_array($arParams['optionsSites']) + && in_array($arFields['LID'], $arParams['optionsSites'])) + $resOrder['site'] = $arFields['LID']; + if($send) - return $api->createOrder($resOrder); + $api->createOrder($resOrder); return array( 'order' => $resOrder, @@ -379,4 +389,4 @@ class ICrmOrderActions return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET); } -} +} \ No newline at end of file diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index c0a7c172..831952a4 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -31,6 +31,7 @@ class intaro_intarocrm extends CModule var $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; var $CRM_PAYMENT = 'payment_arr'; //order payment Y/N var $CRM_ORDER_LAST_ID = 'order_last_id'; + var $CRM_ORDER_SITES = 'sites_ids'; var $INSTALL_PATH; @@ -83,11 +84,17 @@ class intaro_intarocrm extends CModule $arResult['errCode'] = 'ERR_CATALOG'; } + $arResult['arSites'] = array(); + $rsSites = CSite::GetList($by, $sort, array()); + while ($ar = $rsSites->Fetch()) + $arResult['arSites'][] = $ar; + $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")) { $arResult['errCode'] = 'ERR_SALE'; } @@ -99,8 +106,13 @@ class intaro_intarocrm extends CModule if(!CModule::IncludeModule("catalog")) { $arResult['errCode'] = 'ERR_CATALOG'; } + + $arResult['arSites'] = array(); + $rsSites = CSite::GetList($by, $sort, array()); + while ($ar = $rsSites->Fetch()) + $arResult['arSites'][] = $ar; - if(isset($arResult['errCode']) && $arResult['errCode']) { + if (isset($arResult['errCode']) && $arResult['errCode']) { $APPLICATION->IncludeAdminFile( GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step1.php' @@ -363,6 +375,12 @@ class intaro_intarocrm extends CModule $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION])); $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION])); + + // empty == select all + $orderSites = array(); + foreach($_POST[$this->CRM_ORDER_SITES] as $site) { + $orderSites[] = htmlspecialchars(trim($site)); + } // form correct url $api_host = parse_url($api_host); @@ -395,6 +413,7 @@ class intaro_intarocrm extends CModule 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_ORDER_SITES, serialize($orderSites)); //prepare crm lists $arResult['orderTypesList'] = $this->INTARO_CRM_API->orderTypesList(); diff --git a/intaro.intarocrm/install/step1.php b/intaro.intarocrm/install/step1.php index f1aad63d..0ca2ff7b 100755 --- a/intaro.intarocrm/install/step1.php +++ b/intaro.intarocrm/install/step1.php @@ -37,6 +37,16 @@ + + + + + +
diff --git a/intaro.intarocrm/install/version.php b/intaro.intarocrm/install/version.php index 56978304..8dc479e8 100755 --- a/intaro.intarocrm/install/version.php +++ b/intaro.intarocrm/install/version.php @@ -1,5 +1,5 @@ "0.3.9", - "VERSION_DATE" => "2013-08-27 18:00:00", + "VERSION" => "0.4.0", + "VERSION_DATE" => "2013-09-02 15:46:00", ); \ No newline at end of file diff --git a/intaro.intarocrm/lang/ru/install/step1.php b/intaro.intarocrm/lang/ru/install/step1.php index 2e620c0f..40a46a38 100755 --- a/intaro.intarocrm/lang/ru/install/step1.php +++ b/intaro.intarocrm/lang/ru/install/step1.php @@ -3,6 +3,7 @@ $MESS ['STEP_NAME'] = 'Шаг 1'; $MESS ['MOD_NEXT_STEP'] = 'Следующий шаг'; $MESS ['ICRM_API_HOST'] = 'Адрес IntaroCRM:'; $MESS ['ICRM_API_KEY'] = 'Ключ авторизации:'; +$MESS ['ICRM_SITES'] = 'Активные сайты:'; $MESS ['ERR_404'] = 'Возможно неверно введен адрес IntaroCRM.'; $MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; diff --git a/intaro.intarocrm/lang/ru/options.php b/intaro.intarocrm/lang/ru/options.php index 34572124..0fa2a864 100755 --- a/intaro.intarocrm/lang/ru/options.php +++ b/intaro.intarocrm/lang/ru/options.php @@ -4,6 +4,7 @@ $MESS ['ICRM_OPTIONS_IMPORT_TAB'] = 'Настройки импората'; $MESS ['ICRM_CONN_SETTINGS'] = 'Настройка соединения'; $MESS ['ICRM_API_HOST'] = 'Адрес Intaro CRM:'; $MESS ['ICRM_API_KEY'] = 'Ключ авторизации:'; +$MESS ['ICRM_SITES'] = 'Активные сайты:'; $MESS ['ICRM_OPTIONS_CATALOG_TAB'] = 'Настройка справочников'; $MESS ['DELIVERY_TYPES_LIST'] = 'Способы доставки'; diff --git a/intaro.intarocrm/options.php b/intaro.intarocrm/options.php index 3f1d439a..b95bb9ae 100755 --- a/intaro.intarocrm/options.php +++ b/intaro.intarocrm/options.php @@ -11,6 +11,7 @@ $CRM_PAYMENT_TYPES = 'pay_types_arr'; $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; $CRM_PAYMENT = 'payment_arr'; //order payment Y/N $CRM_ORDER_LAST_ID = 'order_last_id'; +$CRM_ORDER_SITES = 'sites_ids'; if(!CModule::IncludeModule('intaro.intarocrm') || !CModule::IncludeModule('sale')) @@ -28,6 +29,12 @@ $arResult = array(); if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $api_host = htmlspecialchars(trim($_POST['api_host'])); $api_key = htmlspecialchars(trim($_POST['api_key'])); + + // if empty so select all? or exception --not obligatory + $orderSites = array(); + foreach ($_POST[$CRM_ORDER_SITES] as $site) { + $orderSites[] = htmlspecialchars(trim($site)); + } if($api_host && $api_key) { $api = new IntaroCrm\RestApi($api_host, $api_key); @@ -137,6 +144,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { COption::SetOptionString($mid, $CRM_PAYMENT_TYPES, serialize($paymentTypesArr)); COption::SetOptionString($mid, $CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr)); COption::SetOptionString($mid, $CRM_PAYMENT, serialize($paymentArr)); + COption::SetOptionString($mid, $CRM_ORDER_SITES, serialize($orderSites)); $uri .= '&ok=Y'; LocalRedirect($uri); @@ -145,6 +153,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $api_key = COption::GetOptionString($mid, $CRM_API_KEY_OPTION, 0); $api = new IntaroCrm\RestApi($api_host, $api_key); + + $arResult['arSites'] = array(); + $rsSites = CSite::GetList($by, $sort, array()); + while ($ar = $rsSites->Fetch()) + $arResult['arSites'][] = $ar; //prepare crm lists $arResult['orderTypesList'] = $api->orderTypesList(); @@ -249,6 +262,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $optionsPayTypes = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_TYPES, 0)); $optionsPayStatuses = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_STATUSES, 0)); // --statuses $optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0)); + $optionsSites = unserialize(COption::GetOptionString($mid, $CRM_ORDER_SITES, 0)); $aTabs = array( array( @@ -284,6 +298,16 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { + + + + + + BeginNextTab(); ?>