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 @@