From cb94c210c095f0f9873d801b14693d4415483dc6 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 2 Sep 2013 17:41:05 +0400 Subject: [PATCH 1/9] history update --- .../classes/general/ICrmOrderActions.php | 274 ++++++++++++++++++ 1 file changed, 274 insertions(+) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index d19090b2..a5446aea 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -148,6 +148,280 @@ class ICrmOrderActions return true; //all ok! } + + /** + * + * History update; doesnt work; always returns true, but writes log of errors + * @global CUser $USER + * @return boolean + */ + public static function orderHistory() { + global $USER; + + if(!isset($USER) || !$USER) { // for agent; to add order User + $USER = new CUser; + $USER->Update(1, array()); + } + + if (!CModule::IncludeModule("iblock")) { + //handle err + self::eventLog('ICrmOrderActions::orderHistory', 'iblock', 'module not found'); + return true; + } + + if (!CModule::IncludeModule("sale")) { + //handle err + self::eventLog('ICrmOrderActions::orderHistory', 'sale', 'module not found'); + return true; + } + + if (!CModule::IncludeModule("catalog")) { + //handle err + self::eventLog('ICrmOrderActions::orderHistory', 'catalog', 'module not found'); + return true; + } + + $api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0); + $api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0); + + //saved cat params (crm -> bitrix) + $optionsOrderTypes = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0))); + $optionsDelivTypes = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0))); + $optionsPayTypes = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0))); + $optionsPayStatuses = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0))); // --statuses + $optionsPayment = array_flip(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); + + $orderHistory = $api->orderHistory(); + + // pushing existing orders + foreach ($orderHistory as $order) { + var_dump($order); + continue; + + if(!isset($order['externalId']) && !$order['externalId']) { + + continue; + + // new order + /*array( + 'LID' => SITE_ID, //<----! + 'PERSON_TYPE_ID' => 1, // <------! + 'PAYED' => 'N', + 'CANCELED' => 'N', + 'STATUS_ID' => 'N', + 'PRICE' => 0, + 'CURRENCY' => 'RUB', + 'USER_ID' => IntVal($USER->GetID()), // <--------! + 'PAY_SYSTEM_ID' => 0, + 'PRICE_DELIVERY' => 0, + 'DELIVERY_ID' => 0, + 'DISCOUNT_VALUE' => 0, + 'USER_DESCRIPTION' => '' + ); + + $order['externalId'] = CSaleOrder::Add(array()); + + $api->orderFixExternalIds(array($order['id'], $order['externalId'])); + + if ($api->getStatusCode() != 200) { + //handle err - write log & continue + self::eventLog('ICrmOrderActions::orderHistory', 'IntaroCrm\RestApi::orderFixExternalIds', $api->getLastError()); + continue; + } + + */ + } + + if(isset($order['externalId']) && $order['externalId']) { + $arFields = CSaleOrder::GetById($order['externalId']); + + var_dump($arFields); + + // incorrect order + if(!$arFields || empty($arFields)) + continue; + + $userId = $arFields['USER_ID']; + $LID = $arFields['LID']; + + $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); + while ($ar = $rsOrderProps->Fetch()) { + if (isset($order['deliveryAddress']) && $order['deliveryAddress']) { + switch ($ar['CODE']) { + case 'ZIP': if (isset($order['deliveryAddress']['index'])) + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => self::fromJSON($order['deliveryAddress']['index']))); + break; + case 'CITY': if (isset($order['deliveryAddress']['city'])) + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => self::fromJSON($order['deliveryAddress']['city']))); + break; + case 'ADDRESS': if (isset($order['deliveryAddress']['text'])) + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => self::fromJSON($order['deliveryAddress']['text']))); + break; + case 'LOCATION': if (isset($order['deliveryAddress']['city'])) { + $cityId = self::getLocationCityId($order['deliveryAddress']['city']); + if (!$cityId) + break; + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => $cityId)); + } + break; + } + } + + switch ($ar['CODE']) { + case 'FIO': + if (isset($order['firstName'])) + $contactName['firstName'] = self::fromJSON($order['firstName']); + if (isset($order['lastName'])) + $contactName['lastName'] = self::fromJSON($order['lastName']); + if (isset($order['patronymic'])) + $contactName['patronymic'] = self::fromJSON($order['patronymic']); + + if (!isset($contactName) || empty($contactName)) + break; + + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => implode(" ", $contactName))); + break; + case 'PHONE': if (isset($order['phone'])) + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => self::fromJSON($order['phone']))); + break; + case 'EMAIL': if (isset($order['email'])) + CSaleOrderPropsValue::Update($ar['ID'], array('VALUE' => self::fromJSON($order['email']))); + break; + } + } + + // here check if smth wasnt added or new propetties + if (isset($order['deliveryAddress']) && $order['deliveryAddress']) { + if (isset($order['deliveryAddress']['index'])) + self::addOrderProperty('ZIP', self::fromJSON($order['deliveryAddress']['index']), $order['externalId']); + + if (isset($order['deliveryAddress']['city'])) + self::addOrderProperty('CITY', self::fromJSON($order['deliveryAddress']['city']), $order['externalId']); + + if (isset($order['deliveryAddress']['text'])) + self::addOrderProperty('ADDRESS', self::fromJSON($order['deliveryAddress']['text']), $order['externalId']); + } + + if (isset($order['phone'])) + self::addOrderProperty('PHONE', self::fromJSON($order['phone']), $order['externalId']); + + if (isset($order['email'])) + self::addOrderProperty('EMAIL', self::fromJSON($order['email']), $order['externalId']); + + if (isset($order['firstName'])) + $contactName['firstName'] = self::fromJSON($order['firstName']); + if (isset($order['lastName'])) + $contactName['lastName'] = self::fromJSON($order['lastName']); + if (isset($order['patronymic'])) + $contactName['patronymic'] = self::fromJSON($order['patronymic']); + + if (isset($contactName) && !empty($contactName)) + self::addOrderProperty('FIO', implode(" ", $contactName), $order['externalId']); + + /*foreach($order['items'] as $item) { + $p = CSaleBasket::GetList( + array('PRODUCT_ID' => 'ASC'), + array('ORDER_ID' => $order['externalId'], 'PRODUCT_ID' => $item['offer']['externalId']))->Fetch(); + + if(!$p) // if not found + continue; + + // del from basket + if(isset($item['deleted']) && $item['deleted']) { + CSaleBasket::Delete($p['ID']); + continue; + } + + // change existing basket items + if(!isset($item['offer']) && !$item['offer']['externalId']) + continue; + + $arProduct = array(); + + // create new + if(isset($item['created']) && $item['created']) { + $arProduct = array( + 'FUSER_ID' => $userId, + 'ORDER_ID' => $order['externalId'], + 'QUANTITY' => $item['quantity'], + 'CURRENCY' => $p['CURRENCY'], + 'LID' => $LID, + 'PRODUCT_ID' => $item['offer']['externalId'], + 'PRODUCT_PRICE_ID' => $p['PRODUCT_PRICE_ID'], + 'WEIGHT' => $p['WEIGHT'], + 'DELAY' => $p['DELAY'], + 'CAN_BUY' => $p['CAN_BUY'], + 'MODULE' => $p['MODULE'], + 'NOTES' => $p['NOTES'], + 'PRODUCT_PROVIDER_CLASS' => $p['PRODUCT_PROVIDER_CLASS'], + 'DETAIL_PAGE_URL' => $p['DETAIL_PAGE_URL'], + 'CATALOG_XML_ID' => $p['CATALOG_XML_ID'], + 'PRODUCT_XML_ID' => $p['PRODUCT_XML_ID'] + ); + + if (isset($item['initialPrice']) && $item['initialPrice']) + $arProduct['PRICE'] = (double) $item['initialPrice']; + + if (isset($item['discount']) && $item['discount']) { + $arProduct['PRICE'] = $arProduct['PRICE'] - (double) $item['disount']; + $arProduct['DISCOUNT_PRICE'] = $item['discount']; + } + + if (isset($item['discountPercent']) && $item['discountPercent']) { + //$arProducts['PRICE'] -- how ? + $arProduct['DISCOUNT_VALUE'] = $item['discountPercent']; + } + + if (isset($item['offer']['name']) && $item['offer']['name']) + $arProduct['NAME'] = $item['offer']['name']; + + CSaleBasket::Add($arProduct); + continue; + } + + // update old + if(isset($item['initialPrice']) && $item['initialPrice']) + $arProduct['PRICE'] = (double) $item['initialPrice']; + + if(isset($item['dicount']) && $item['discount']){ + $arProduct['PRICE'] = $arProducts['PRICE'] - (double) $item['disount']; + $arProduct['DISCOUNT_PRICE'] = $item['discount']; + } + + if(isset($item['discountPercent']) && $item['discountPercent']) { + //$arProducts['PRICE'] -- how ? + $arProduct['DISCOUNT_VALUE'] = $item['discountPercent']; + } + + if(isset($item['offer']['name']) && $item['offer']['name']) + $arProduct['NAME'] = $item['offer']['name']; + + CSaleBasket::Update($p['ID'], $arProduct); + }*/ + + // orderUpdate + $arFields = array( + 'PRICE_DELIVERY' => $order['deliveryCost'], + 'PRICE' => $order['summ'], + 'DATE_MARKED' => $order['markDatetime'], + 'USER_ID' => $order['customer'], + 'PAY_SYSTEM_ID' => $optionsPayTypes[$order['paymentType']], + 'PAYED' => $optionsPayment[$order['paymentStatus']], + 'PERSON_TYPE_ID' => $optionsOrderTypes[$order['orderType']], + 'DELIVERY_ID' => $optionsDelivTypes[$order['deliveryType']], + 'STATUS_ID' => $optionsPayStatuses[$order['status']] + ); + + CSaleOrder::Update($order['externalId'], $arFields); + + } + } + + return true; + } /** * From 3ebf5a1d31ac5807089240780123b5cbaa4b267c Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 2 Sep 2013 17:52:56 +0400 Subject: [PATCH 2/9] At now articles load from Product InfoBlock --- intaro.intarocrm/classes/general/ICMLLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intaro.intarocrm/classes/general/ICMLLoader.php b/intaro.intarocrm/classes/general/ICMLLoader.php index fa9a725a..cb5715c5 100644 --- a/intaro.intarocrm/classes/general/ICMLLoader.php +++ b/intaro.intarocrm/classes/general/ICMLLoader.php @@ -220,7 +220,7 @@ class ICMLLoader { $arOffer['PREVIEW_PICTURE'] = $product["PREVIEW_PICTURE"]; $arOffer['PRODUCT_NAME'] = $product["NAME"]; if (isset($this->articleProperties[$id])) - $arOffer['ARTICLE'] = $arOffer["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"]; + $arOffer['ARTICLE'] = $product["PROPERTY_" . $this->articleProperties[$id] . "_VALUE"]; $dbPrice = GetCatalogProductPrice($arOffer["ID"],1); $arOffer['PRICE'] = $dbPrice['PRICE']; From 28ccea77e792d74682c9d4ae53581a98a31d3d1f Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 2 Sep 2013 18:15:11 +0400 Subject: [PATCH 3/9] info in install --- intaro.intarocrm/install/step1.php | 3 +++ intaro.intarocrm/lang/ru/install/step1.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/intaro.intarocrm/install/step1.php b/intaro.intarocrm/install/step1.php index 0ca2ff7b..877d65f1 100755 --- a/intaro.intarocrm/install/step1.php +++ b/intaro.intarocrm/install/step1.php @@ -26,6 +26,9 @@ + + +   diff --git a/intaro.intarocrm/lang/ru/install/step1.php b/intaro.intarocrm/lang/ru/install/step1.php index 40a46a38..65eb0a60 100755 --- a/intaro.intarocrm/lang/ru/install/step1.php +++ b/intaro.intarocrm/lang/ru/install/step1.php @@ -9,4 +9,5 @@ $MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; $MESS ['ERR_FIELDS_API_HOST'] = 'Неверно заполнены поля.'; $MESS ['INFO_1'] = 'Введите адрес экземпляра IntaroCRM (например, http://demo.intarocrm.ru) и API-ключ.'; -$MESS ['INFO_2'] = 'API-ключ можно сгенерировать при регистрации магазина в IntaroCRM (Администрирование > Магазины).'; \ No newline at end of file +$MESS ['INFO_2'] = 'API-ключ можно сгенерировать при регистрации магазина в IntaroCRM (Администрирование > Интеграция).'; +$MESS ['INFO_3'] = 'Код сайта в 1С-Битрикс должен совпадать с кодом сайта в IntaroCRM (Администрирование > Магазины).'; \ No newline at end of file From 1d611ef2f7edba3bc28f9d155c5a6979955524db Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Wed, 4 Sep 2013 20:41:51 +0400 Subject: [PATCH 4/9] class fixes --- .../classes/general/ICrmOrderActions.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index a5446aea..d2128d2c 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -198,8 +198,8 @@ class ICrmOrderActions // pushing existing orders foreach ($orderHistory as $order) { + var_dump($order); - continue; if(!isset($order['externalId']) && !$order['externalId']) { @@ -238,13 +238,12 @@ class ICrmOrderActions if(isset($order['externalId']) && $order['externalId']) { $arFields = CSaleOrder::GetById($order['externalId']); - var_dump($arFields); - // incorrect order if(!$arFields || empty($arFields)) continue; $userId = $arFields['USER_ID']; + if(isset($order['customer']) && $order['customer']) $userId = $order['customer']; $LID = $arFields['LID']; $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); @@ -403,20 +402,22 @@ class ICrmOrderActions }*/ // orderUpdate - $arFields = array( + $arFields = self::clearArr(array( 'PRICE_DELIVERY' => $order['deliveryCost'], 'PRICE' => $order['summ'], 'DATE_MARKED' => $order['markDatetime'], - 'USER_ID' => $order['customer'], + 'USER_ID' => $userId, //$order['customer'] 'PAY_SYSTEM_ID' => $optionsPayTypes[$order['paymentType']], 'PAYED' => $optionsPayment[$order['paymentStatus']], 'PERSON_TYPE_ID' => $optionsOrderTypes[$order['orderType']], 'DELIVERY_ID' => $optionsDelivTypes[$order['deliveryType']], 'STATUS_ID' => $optionsPayStatuses[$order['status']] - ); + )); + + var_dump($arFields); CSaleOrder::Update($order['externalId'], $arFields); - + } } From 0ce04033117875d8e449831f5904e6e73132bd4f Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Wed, 4 Sep 2013 20:49:07 +0400 Subject: [PATCH 5/9] +orderHistory agent --- .../classes/general/ICrmOrderActions.php | 12 ++++++++++++ intaro.intarocrm/install/index.php | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index d2128d2c..d21719f8 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -452,6 +452,18 @@ class ICrmOrderActions return 'ICrmOrderActions::uploadOrdersAgent();'; } + /** + * + * Agent function + * + * @return self name + */ + + public static function orderHistoryAgent() { + self::orderHistory(); + return 'ICrmOrderActions::orderHistoryAgent();'; + } + /** * * creates order or returns array of order and customer for mass upload diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 57f8633f..f5381545 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -906,10 +906,7 @@ class intaro_intarocrm extends CModule } } - // - - //agent - + //agents $dateAgent = new DateTime(); $intAgent = new DateInterval('PT60S'); // PT60S - 60 sec; $dateAgent->add($intAgent); @@ -924,6 +921,17 @@ class intaro_intarocrm extends CModule $dateAgent->format('d.m.Y H:i:s'), // date of first start 30 ); + + CAgent::AddAgent( + "ICrmOrderActions::orderHistoryAgent();", + $this->MODULE_ID, + "N", + 600, // interval - 10 mins + $dateAgent->format('d.m.Y H:i:s'), // date of first check + "Y", // агент активен + $dateAgent->format('d.m.Y H:i:s'), // date of first start + 30 + ); $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); From be7d3d76cd34f0719ba428328a4365106e8a9b3f Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Wed, 4 Sep 2013 20:50:49 +0400 Subject: [PATCH 6/9] removed var_dumps --- intaro.intarocrm/classes/general/ICrmOrderActions.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index d21719f8..c0c970ce 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -199,8 +199,6 @@ class ICrmOrderActions // pushing existing orders foreach ($orderHistory as $order) { - var_dump($order); - if(!isset($order['externalId']) && !$order['externalId']) { continue; @@ -413,8 +411,6 @@ class ICrmOrderActions 'DELIVERY_ID' => $optionsDelivTypes[$order['deliveryType']], 'STATUS_ID' => $optionsPayStatuses[$order['status']] )); - - var_dump($arFields); CSaleOrder::Update($order['externalId'], $arFields); From f29c0f62a404b20f275c59c378041f081a27c53a Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 9 Sep 2013 16:49:08 +0400 Subject: [PATCH 7/9] fio parsing fix --- .../classes/general/ICrmOrderActions.php | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index c0c970ce..7d3011b4 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -538,6 +538,7 @@ class ICrmOrderActions $resOrder = array(); $resOrderDeliveryAddress = array(); + $contactNameArr = array(); $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); while ($ar = $rsOrderProps->Fetch()) { @@ -553,7 +554,7 @@ class ICrmOrderActions $resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']); } break; - case 'FIO': $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE'])); + case 'FIO': $contactNameArr = self::explodeFIO($ar['VALUE']); break; case 'PHONE': $resOrder['phone'] = $ar['VALUE']; break; @@ -592,10 +593,7 @@ class ICrmOrderActions $createdAt = new \DateTime($arFields['DATE_INSERT']); $createdAt = $createdAt->format('Y-m-d H:i:s'); - $resOrder = self::clearArr(array( - 'lastName' => $resOrder['contactName'][0], - 'firstName' => $resOrder['contactName'][1], - 'patronymic' => $resOrder['contactName'][2], + $resOrder = array( 'phone' => $resOrder['phone'], 'email' => $resOrder['email'], 'deliveryCost' => $arFields['PRICE_DELIVERY'], @@ -612,7 +610,16 @@ class ICrmOrderActions 'createdAt' => $createdAt, 'deliveryAddress' => $resOrderDeliveryAddress, 'items' => $items - )); + ); + + // parse fio + if(count($contactNameArr) == 1) { + $resOrder['firstName'] = $contactNameArr[0]; + } else { + $resOrder['lastName'] = $contactNameArr['contactName'][0]; + $resOrder['firstName'] = $contactNameArr['contactName'][1]; + $resOrder['patronymic'] = $contactNameArr['contactName'][2]; + } if(isset($arParams['optionsSites']) && is_array($arParams['optionsSites']) && in_array($arFields['LID'], $arParams['optionsSites'])) @@ -672,4 +679,17 @@ class ICrmOrderActions return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET); } + + public static function expodeFIO($str) { + if(!$str) + return array(); + + $array = expolde(" ", ICrmOrderActions::toJSON($str), 3); + + foreach($array as &$ar) + if(!$ar) + unset($ar); + + return $array; + } } \ No newline at end of file From b3f1800754f1d48939a3d01cee335364a565725a Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 9 Sep 2013 16:52:30 +0400 Subject: [PATCH 8/9] fix of fio fix --- intaro.intarocrm/classes/general/ICrmOrderActions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index 7d3011b4..b813083b 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -624,6 +624,8 @@ class ICrmOrderActions if(isset($arParams['optionsSites']) && is_array($arParams['optionsSites']) && in_array($arFields['LID'], $arParams['optionsSites'])) $resOrder['site'] = $arFields['LID']; + + $resOrder = self::clearArr($resOrder); if($send) $api->createOrder($resOrder); From 3e8013c29af847353588d099155bea8017bb12e3 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 9 Sep 2013 17:54:38 +0400 Subject: [PATCH 9/9] fix explode --- intaro.intarocrm/classes/general/ICrmOrderActions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index b813083b..246109d1 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -686,7 +686,7 @@ class ICrmOrderActions if(!$str) return array(); - $array = expolde(" ", ICrmOrderActions::toJSON($str), 3); + $array = explode(" ", self::toJSON($str), 3); foreach($array as &$ar) if(!$ar)