From fd34304c5f295fabc8b5c57918b1db32a94dbb4c Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Tue, 9 Jul 2013 19:03:56 +0400 Subject: [PATCH] +method to upload orders; +api upd; --- .../classes/general/ICrmOrderActions.php | 256 ++++++++++++++++++ intaro.crm/classes/general/RestApi.php | 167 ++++++++---- intaro.crm/include.php | 5 +- intaro.crm/install/index.php | 4 +- intaro.crm/options.php | 9 +- 5 files changed, 376 insertions(+), 65 deletions(-) create mode 100644 intaro.crm/classes/general/ICrmOrderActions.php diff --git a/intaro.crm/classes/general/ICrmOrderActions.php b/intaro.crm/classes/general/ICrmOrderActions.php new file mode 100644 index 00000000..28e3ecbf --- /dev/null +++ b/intaro.crm/classes/general/ICrmOrderActions.php @@ -0,0 +1,256 @@ +ConvertCharset($str, SITE_CHARSET, 'utf-8'); + } + + /** + * + * @global type $APPLICATION + * @param type $str in utf-8 + * @return type $str in SITE_CHARSET + */ + public static function fromJSON($str) { + global $APPLICATION; + + return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET); + } + + /** + * Mass order uploading func + */ + function uploadOrders() { + + //ini_set('display_errors', 1); + //error_reporting(E_ALL); + + COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, 0); + + if (!CModule::IncludeModule('iblock')) { + //ShowError(GetMessage("SOA_MODULE_NOT_INSTALL")); + return; + } + if (!CModule::IncludeModule("sale")) { + //ShowError(GetMessage("SOA_MODULE_NOT_INSTALL")); + return; + } + + $resOrders = array(); + + $dbOrder = CSaleOrder::GetList(); + + $lastUpOrderId = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, 0); + $lastUpOrderIdNew = 0; + + $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 + $optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0)); + $optionsDelivTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0)); + $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)); + + $api = new IntaroCrm\RestApi($api_host, $api_key); + + while ($arOrder = $dbOrder->GetNext()) { + if ($arOrder['ID'] < $lastUpOrderId) //old orders not to upload + break; + + if(!$lastUpOrderIdNew) + $lastUpOrderIdNew = $arOrder['ID']; + + $arFields = CSaleOrder::GetById($arOrder['ID']); + + if (empty($arFields)) { + //handle err + CEventLog::Add(array( + "SEVERITY" => "SECURITY", + "AUDIT_TYPE_ID" => "IntroCrm\uploadOrders", + "MODULE_ID" => self::$MODULE_ID, + "ITEM_ID" => 'empty($arFields)', + "DESCRIPTION" => "Не корректный заказ.", + )); + + return; + } + + $rsUser = CUser::GetByID($arFields['USER_ID']); + $arUser = $rsUser->Fetch(); + + // push customer (for crm) + $firstName = self::toJSON($arUser['NAME']); + $lastName = self::toJSON($arUser['LAST_NAME']); + $patronymic = self::toJSON($arUser['SECOND_NAME']); + + $phonePersonal = array( + 'number' => self::toJSON($arUser['PERSONAL_PHONE']), + 'type' => 'mobile' + ); + $phones[] = $phonePersonal; + + $phoneWork = array( + 'number' => self::toJSON($arUser['WORK_PHONE']), + 'type' => 'work' + ); + $phones[] = $phoneWork; + + $addressPersonal = array( + 'index' => self::toJSON($arUser['PERSONAL_ZIP']), + 'country' => self::toJSON(GetCountryByID($arUser['PERSONAL_COUNTRY'])), + 'city' => self::toJSON($arUser['PERSONAL_CITY']), + 'street' => self::toJSON($arUser['PERSONAL_STREET']), + 'building' => self::toJSON($arUser['UF_PERSONAL_BUILDING']), + 'flat' => self::toJSON($arUser['UF_PERSONAL_FLAT']), + 'notes' => self::toJSON($arUser['PERSONAL_NOTES']), + 'text' => self::toJSON($arUser['UF_PERSONAL_TEXT']), + 'type' => 'home' + ); + $addresses[] = $addressPersonal; + + $addressWork = array( + 'index' => self::toJSON($arUser['WORK_ZIP']), + 'country' => self::toJSON(GetCountryByID($arUser['WORK_COUNTRY'])), + 'city' => self::toJSON($arUser['WORK_CITY']), + 'street' => self::toJSON($arUser['WORK_STREET']), + 'building' => self::toJSON($arUser['UF_WORK_BUILDING']), // -- + 'flat' => self::toJSON($arUser['UF_WORK_FLAT']), + 'notes' => self::toJSON($arUser['PERSONAL_NOTES']), + 'text' => self::toJSON($arUser['UF_WORK_TEXT']), + 'type' => 'work' + ); + $addresses[] = $addressWork; + + $result = array( + 'externalId' => $arFields['USER_ID'], + 'lastName' => $lastName, + 'firstName' => $firstName, + 'patronymic' => $patronymic, + 'phones' => $phones, + 'addresses' => $addresses + ); + + $customer = $api->customerEdit($result); + + // error pushing customer + if (!$customer) { + // handle + CEventLog::Add(array( + "SEVERITY" => "SECURITY", + "AUDIT_TYPE_ID" => "IntroCrm\uploadOrders", + "MODULE_ID" => self::$MODULE_ID, + "ITEM_ID" => "customerEdit", + "DESCRIPTION" => $api->getLastError(), + )); + + return; + } + + // delivery types + $arId = array(); + if (strpos($arFields['DELIVERY_ID'], ":") !== false) + $arId = explode(":", $arFields["DELIVERY_ID"]); + + if ($arId) + $resultDeliveryTypeId = $arId[0]; + else + $resultDeliveryTypeId = $arFields['DELIVERY_ID']; + + + $resOrder = array(); + $resOrderDeliveryAddress = array(); + + $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); + while ($ar = $rsOrderProps->Fetch()) { + switch ($ar['CODE']) { + case 'ZIP': $resOrderDeliveryAddress['index'] = self::toJSON($ar['VALUE']); + break; + case 'CITY': $resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']); + break; + case 'ADDRESS': $resOrderDeliveryAddress['text'] = self::toJSON($ar['VALUE']); + break; + case 'FIO': $resOrder['contactName'] = self::toJSON($ar['VALUE']); + break; + case 'PHONE': $resOrder['phone'] = $ar['VALUE']; + break; + case 'EMAIL': $resOrder['email'] = $ar['VALUE']; + break; + } + } + + $resOrder['deliveryCost'] = $arFields['PRICE_DELIVERY']; + $resOrder['summ'] = $arFields['PRICE']; + $resOrder['markDateTime'] = $arFields['DATE_MARKED']; + $resOrder['externalId'] = $arFields['ID']; + $resOrder['customerId'] = $arFields['USER_ID']; + + $resOrder['paymentType'] = $optionsPayTypes[$arFields['PAY_SYSTEM_ID']]; + $resOrder['paymentStatus'] = $optionsPayment[$arFields['PAYED']]; + $resOrder['orderType'] = $optionsOrderTypes[$arFields['PERSON_TYPE_ID']]; + $resOrder['deliveryType'] = $optionsDelivTypes[$resultDeliveryTypeId]; + $resOrder['status'] = $optionsPayStatuses[$arFields['STATUS_ID']]; + + $resOrder['deliveryAddress'] = $resOrderDeliveryAddress; + + $items = array(); + + $rsOrderBasket = CSaleBasket::GetList(array('PRODUCT_ID' => 'ASC'), array('ORDER_ID' => $arFields['ID'])); + while ($p = $rsOrderBasket->Fetch()) { + $items[] = array( + 'price' => $p['PRICE'], + 'discount' => $p['DISCOUNT_VALUE'], + 'quantity' => $p['QUANTITY'], + 'productId' => $p['PRODUCT_ID'], + 'productName' => self::toJSON($p['NAME']) + ); + } + + $resOrder['items'] = $items; + $resOrders[] = $resOrder; + } + + $orders = $api->orderUpload($resOrders); + + // error pushing orders + if(!$orders) { + //handle err + CEventLog::Add(array( + "SEVERITY" => "SECURITY", + "AUDIT_TYPE_ID" => "IntroCrm\uploadOrders", + "MODULE_ID" => self::$MODULE_ID, + "ITEM_ID" => "orderUpload", + "DESCRIPTION" => $api->getLastError(), + )); + + return; + } + + COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, $lastUpOrderIdNew); + + return; //all ok! + } +} + +?> diff --git a/intaro.crm/classes/general/RestApi.php b/intaro.crm/classes/general/RestApi.php index cef13009..9900cebe 100644 --- a/intaro.crm/classes/general/RestApi.php +++ b/intaro.crm/classes/general/RestApi.php @@ -33,6 +33,7 @@ class RestApi protected $apiVersion = '1'; protected $lastError; protected $statusCode; + protected $parameters; /** * @param string $crmUrl - адрес CRM @@ -42,6 +43,7 @@ class RestApi { $this->apiUrl = $crmUrl.'/api/v'.$this->apiVersion.'/'; $this->apiKey = $apiKey; + $this->parameters = array('apiKey' => $this->apiKey); } @@ -71,11 +73,15 @@ class RestApi * Получение заказа по id * * @param string $id - идентификатор заказа + * @param string $by - поиск заказа по id или externalId * @return array - информация о заказе */ - public function orderGet($id) + public function orderGet($id, $by = 'externalId') { $url = $this->apiUrl.'orders/'.$id; + + if ($by != 'externalId') + $this->parameters['by'] = $by; $result = $this->curlRequest($url); return $result; } @@ -91,11 +97,10 @@ class RestApi $dataJson = json_encode($order); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['order'] = $dataJson; + $this->parameters['order'] = $dataJson; $url = $this->apiUrl.'orders/create'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -110,11 +115,10 @@ class RestApi $dataJson = json_encode($order); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['order'] = $dataJson; + $this->parameters['order'] = $dataJson; - $url = $this->apiUrl.'orders/'.$order['id'].'/edit'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $url = $this->apiUrl.'orders/'.$order['externalId'].'/edit'; + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -129,11 +133,10 @@ class RestApi $dataJson = json_encode($orders); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['orders'] = $dataJson; + $this->parameters['orders'] = $dataJson; $url = $this->apiUrl.'orders/upload'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -141,12 +144,15 @@ class RestApi * Удаление заказа * * @param string $id - идентификатор заказа + * @param string $by - поиск заказа по id или externalId * @return array */ - public function orderDelete($id) + public function orderDelete($id, $by = 'externalId') { $url = $this->apiUrl.'orders/'.$id.'/delete'; - $result = $this->curlRequest($url, array(), 'POST'); + if ($by != 'externalId') + $this->parameters['by'] = $by; + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -162,13 +168,12 @@ class RestApi public function orderHistory($startDate = null, $endDate = null, $limit = 100, $offset = 0) { $url = $this->apiUrl.'orders/history'; - $parameters = array(); - $parameters['startDate'] = $startDate; - $parameters['endDate'] = $endDate; - $parameters['limit'] = $limit; - $parameters['offset'] = $offset; + $this->parameters['startDate'] = $startDate; + $this->parameters['endDate'] = $endDate; + $this->parameters['limit'] = $limit; + $this->parameters['offset'] = $offset; - $result = $this->curlRequest($url, $parameters); + $result = $this->curlRequest($url); return $result; } @@ -178,11 +183,14 @@ class RestApi * Получение клиента по id * * @param string $id - идентификатор + * @param string $by - поиск заказа по id или externalId * @return array - информация о клиенте */ - public function customerGet($id) + public function customerGet($id, $by = 'externalId') { $url = $this->apiUrl.'customers/'.$id; + if ($by != 'externalId') + $this->parameters['by'] = $by; $result = $this->curlRequest($url); return $result; } @@ -198,11 +206,10 @@ class RestApi $dataJson = json_encode($customer); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['customer'] = $dataJson; + $this->parameters['customer'] = $dataJson; $url = $this->apiUrl.'customers/create'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -217,11 +224,10 @@ class RestApi $dataJson = json_encode($customer); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['customer'] = $dataJson; + $this->parameters['customer'] = $dataJson; - $url = $this->apiUrl.'customers/'.$customer['id'].'/edit'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $url = $this->apiUrl.'customers/'.$customer['externalId'].'/edit'; + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -229,12 +235,15 @@ class RestApi * Удаление клиента * * @param string $id - идентификатор + * @param string $by - поиск заказа по id или externalId * @return array */ - public function customerDelete($id) + public function customerDelete($id, $by = 'externalId') { $url = $this->apiUrl.'customers/'.$id.'/delete'; - $result = $this->curlRequest($url, array(), 'POST'); + if ($by != 'externalId') + $this->parameters['by'] = $by; + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -242,6 +251,7 @@ class RestApi * Получение списка заказов клиента * * @param string $id - идентификатор клиента + * @param string $by - поиск заказа по id или externalId * @param DateTime $startDate - начальная дата выборки * @param DateTime $endDate - конечная дата * @param int $limit - ограничение на размер выборки @@ -249,16 +259,17 @@ class RestApi * @return array - массив заказов */ public function customerOrdersList($id, $startDate = null, $endDate = null, - $limit = 100, $offset = 0) + $limit = 100, $offset = 0, $by = 'externalId') { $url = $this->apiUrl.'customers/'.$id.'/orders'; - $parameters = array(); - $parameters['startDate'] = $startDate; - $parameters['endDate'] = $endDate; - $parameters['limit'] = $limit; - $parameters['offset'] = $offset; + if ($by != 'externalId') + $this->parameters['by'] = $by; + $this->parameters['startDate'] = $startDate; + $this->parameters['endDate'] = $endDate; + $this->parameters['limit'] = $limit; + $this->parameters['offset'] = $offset; - $result = $this->curlRequest($url, $parameters); + $result = $this->curlRequest($url); return $result; } @@ -286,11 +297,10 @@ class RestApi $dataJson = json_encode($deliveryType); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['deliveryType'] = $dataJson; + $this->parameters['deliveryType'] = $dataJson; $url = $this->apiUrl.'delivery-types/'.$deliveryType['code'].'/edit'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -318,11 +328,10 @@ class RestApi $dataJson = json_encode($paymentType); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['paymentType'] = $dataJson; + $this->parameters['paymentType'] = $dataJson; $url = $this->apiUrl.'payment-types/'.$paymentType['code'].'/edit'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -350,11 +359,10 @@ class RestApi $dataJson = json_encode($paymentStatus); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['paymentStatus'] = $dataJson; + $this->parameters['paymentStatus'] = $dataJson; $url = $this->apiUrl.'payment-statuses/'.$paymentStatus['code'].'/edit'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $result = $this->curlRequest($url, 'POST'); return $result; } @@ -374,7 +382,7 @@ class RestApi /** * Редактирование типа заказа * - * @param array $paymentType - информация о типе заказа + * @param array $orderType - информация о типе заказа * @return array */ public function orderTypesEdit($orderType) @@ -382,39 +390,82 @@ class RestApi $dataJson = json_encode($orderType); $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, $dataJson); - $parameters = array(); - $parameters['orderType'] = $dataJson; + $this->parameters['orderType'] = $dataJson; - $url = $this->apiUrl.'order-types/'.$paymentType['code'].'/edit'; - $result = $this->curlRequest($url, $parameters, 'POST'); + $url = $this->apiUrl.'order-types/'.$orderType['code'].'/edit'; + $result = $this->curlRequest($url, 'POST'); + return $result; + } + + /** + * Получение списка статусов заказа + * + * @return array - массив статусов заказа + */ + public function orderStatusesList() + { + $url = $this->apiUrl.'reference/statuses'; + $result = $this->curlRequest($url); + return $result; + } + + /** + * Редактирование статуса заказа + * + * @param array $status - информация о статусе заказа + * @return array + */ + public function orderStatusEdit($status) + { + $dataJson = json_encode($status); + $dataJson = str_replace(self::$jsonReplaceSource, self::$jsonReplaceTarget, + $dataJson); + $this->parameters['status'] = $dataJson; + + $url = $this->apiUrl.'statuses/'.$status['code'].'/edit'; + $result = $this->curlRequest($url, 'POST'); + return $result; + } + + + /** + * Получение списка групп статусов заказа + * + * @return array - массив групп статусов заказа + */ + public function orderStatusGroupsList() + { + $url = $this->apiUrl.'reference/status-groups'; + $result = $this->curlRequest($url); return $result; } - protected function curlRequest($url, $parameters = null, $method = 'GET', $format = 'json') + protected function curlRequest($url, $method = 'GET', $format = 'json') { - $parameters['apiKey'] = $this->apiKey; - - if ($method == 'GET' && !is_null($parameters)) - $url .= '?'.http_build_query($parameters); + if ($method == 'GET' && !is_null($this->parameters)) + $url .= '?'.http_build_query($this->parameters); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FAILONERROR, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable - curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 3s + curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 30s if ($method == 'POST') { curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->parameters); } $response = curl_exec($ch); $this->statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + unset($this->parameters); + /* Сброс массива с параметрами */ + $this->parameters = array('apiKey' => $this->apiKey); if (curl_errno($ch)) { @@ -438,4 +489,4 @@ class RestApi } } -?> +?> \ No newline at end of file diff --git a/intaro.crm/include.php b/intaro.crm/include.php index 8acabe55..bedaf9b5 100644 --- a/intaro.crm/include.php +++ b/intaro.crm/include.php @@ -1,8 +1,9 @@ 'classes/general/RestApi.php' + 'IntaroCrm\RestApi' => 'classes/general/RestApi.php', + 'ICrmOrderActions' => 'classes/general/ICrmOrderActions.php' ) ); ?> diff --git a/intaro.crm/install/index.php b/intaro.crm/install/index.php index 767dff67..c7e89eb5 100644 --- a/intaro.crm/install/index.php +++ b/intaro.crm/install/index.php @@ -29,6 +29,7 @@ class intaro_crm extends CModule var $CRM_PAYMENT_TYPES = 'pay_types_arr'; 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 $INSTALL_PATH; @@ -107,7 +108,7 @@ class intaro_crm extends CModule $arResult['deliveryTypesList'] = $this->INTARO_CRM_API->deliveryTypesList(); $arResult['paymentTypesList'] = $this->INTARO_CRM_API->paymentTypesList(); $arResult['paymentStatusesList'] = $this->INTARO_CRM_API->paymentStatusesList(); // --statuses - //$arResult['payment'] = $this->INTARO_CRM_API->getPymentsList() -- not exist + $arResult['paymentList'] = $this->INTARO_CRM_API->orderStatusesList(); //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( @@ -307,6 +308,7 @@ class intaro_crm extends CModule COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_TYPES); COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES); COption::RemoveOption($this->MODULE_ID, $this->CRM_PAYMENT); + COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID); $APPLICATION->IncludeAdminFile( GetMessage('MODULE_UNINSTALL_TITLE'), diff --git a/intaro.crm/options.php b/intaro.crm/options.php index 7ec8d250..9325bbe3 100644 --- a/intaro.crm/options.php +++ b/intaro.crm/options.php @@ -10,6 +10,7 @@ $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr'; $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'; CModule::IncludeModule('intaro.crm'); CModule::IncludeModule('sale'); @@ -139,8 +140,8 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') { $uri .= '&ok=Y'; LocalRedirect($uri); } else { - $api_host = COption::GetOptionString($mid, 'api_host', 0); - $api_key = COption::GetOptionString($mid, 'api_key', 0); + $api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0); + $api_key = COption::GetOptionString($mid, $CRM_API_KEY_OPTION, 0); $api = new IntaroCrm\RestApi($api_host, $api_key); @@ -149,7 +150,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') { $arResult['deliveryTypesList'] = $api->deliveryTypesList(); $arResult['paymentTypesList'] = $api->paymentTypesList(); $arResult['paymentStatusesList'] = $api->paymentStatusesList(); // --statuses - //$arResult['payment'] = $this->INTARO_CRM_API->getPymentsList() -- not exist + $arResult['paymentList'] = $api->orderStatusesList(); //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( @@ -250,7 +251,7 @@ if (isset($_POST['Update']) && $_POST['Update']=='Y') { "DIV" => "edit2", "TAB" => GetMessage('ICRM_OPTIONS_CATALOG_TAB'), "ICON" => '', - "TITLE" => GetMessage('ICRM_OPTIONS_IMPORT_CAPTION') + "TITLE" => GetMessage('ICRM_OPTIONS_CATALOG_CAPTION') ), ); $tabControl = new CAdminTabControl("tabControl", $aTabs);