From 6c340f17b2cec2053aef6327904c3b82a28d9525 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 2 Sep 2013 16:24:30 +0400 Subject: [PATCH 1/7] added timezone check before install --- intaro.intarocrm/install/index.php | 5 +++++ intaro.intarocrm/lang/ru/install/index.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 831952a4..9a4288ca 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -64,6 +64,11 @@ class intaro_intarocrm extends CModule $APPLICATION->ThrowException( GetMessage("INTAROCRM_CURL_ERR") ); return false; } + + if (!ini_get('date.timezone')) { + $APPLICATION->ThrowException( GetMessage("DATE_TIMEZONE_ERR") ); + return false; + } include($this->INSTALL_PATH . '/../classes/general/RestApi.php'); include($this->INSTALL_PATH . '/../classes/general/ICrmOrderActions.php'); diff --git a/intaro.intarocrm/lang/ru/install/index.php b/intaro.intarocrm/lang/ru/install/index.php index 4637485b..60196348 100755 --- a/intaro.intarocrm/lang/ru/install/index.php +++ b/intaro.intarocrm/lang/ru/install/index.php @@ -11,4 +11,5 @@ $MESS ['ERR_IBLOCK'] = 'Отсутствует модуль iblock! Дальне $MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.'; $MESS ['ERR_CATALOG'] = 'Отсутствует модуль catalog! Дальнейшая установка невозможна.'; $MESS ['INTAROCRM_CURL_ERR'] = 'Для работы модуля интеграции с IntaroCRM требуется PHP-расширение CURL.'; -$MESS ['ERR_ARTICLE_IBLOCK'] = 'Не установлены артикулы'; \ No newline at end of file +$MESS ['ERR_ARTICLE_IBLOCK'] = 'Не установлены артикулы'; +$MESS ['DATE_TIMEZONE_ERR'] = 'Не указана временная зона в настройках php.'; \ No newline at end of file From d02d4a9f1a08d0c3814604a570b8ab46acf92135 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 2 Sep 2013 16:30:50 +0400 Subject: [PATCH 2/7] added timezone check before install --- intaro.intarocrm/install/index.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 9a4288ca..57f8633f 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -61,13 +61,15 @@ class intaro_intarocrm extends CModule global $APPLICATION, $step, $arResult; if (!in_array('curl', get_loaded_extensions())) { - $APPLICATION->ThrowException( GetMessage("INTAROCRM_CURL_ERR") ); + $APPLICATION->ThrowException(GetMessage("INTAROCRM_CURL_ERR")); return false; } - if (!ini_get('date.timezone')) { - $APPLICATION->ThrowException( GetMessage("DATE_TIMEZONE_ERR") ); - return false; + if (!date_default_timezone_get()) { + if (!ini_get('date.timezone')) { + $APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR")); + return false; + } } include($this->INSTALL_PATH . '/../classes/general/RestApi.php'); From fbddb65f37aee9247c2cfb1cded781abe4cebbb7 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 2 Sep 2013 17:51:12 +0400 Subject: [PATCH 3/7] 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 84d9727fa408293e8569baa816c68b39c7dea545 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 2 Sep 2013 18:17:42 +0400 Subject: [PATCH 4/7] 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 98aa0afcbbd48480cb62bbcca45a2079795b8405 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 9 Sep 2013 16:55:28 +0400 Subject: [PATCH 5/7] fio fix --- .../classes/general/ICrmOrderActions.php | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index d19090b2..8447f985 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -255,6 +255,7 @@ class ICrmOrderActions $resOrder = array(); $resOrderDeliveryAddress = array(); + $contactNameArr = array(); $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); while ($ar = $rsOrderProps->Fetch()) { @@ -270,7 +271,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; @@ -309,10 +310,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'], @@ -329,11 +327,22 @@ 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'])) $resOrder['site'] = $arFields['LID']; + + $resOrder = self::clearArr($resOrder); if($send) $api->createOrder($resOrder); @@ -389,4 +398,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 8271e5ab4565dff0d8dc8306b0ea407f151cf84a Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 9 Sep 2013 16:56:57 +0400 Subject: [PATCH 6/7] fix explode name --- 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 8447f985..6b472538 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -399,7 +399,7 @@ class ICrmOrderActions return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET); } - public static function expodeFIO($str) { + public static function explodeFIO($str) { if(!$str) return array(); From f09cec3e5dae75de4a4d6fca61b338638ca214de Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Mon, 9 Sep 2013 17:52:55 +0400 Subject: [PATCH 7/7] fex method --- 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 6b472538..c98f9ccb 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -403,7 +403,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)