1
0
mirror of synced 2025-03-23 16:43:54 +03:00
* v.2.2.8
* v.2.2.10
* v.2.3.0
* Displaying error message about forbidden api method
This commit is contained in:
Akolzin Dmitry 2017-12-04 17:44:30 +03:00 committed by GitHub
parent c357c45072
commit 6d398f7160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 198 additions and 285 deletions

View File

@ -1,3 +1,9 @@
## 2017-12-04 v.2.3.0
* Добавлен выбор валюты в настройках, для выгрузки заказов из CRM
* Исправлена выборка свойств заказа
* Устранен баг в настройках соответствия полей свойств заказа
* Улучшена механика выгрузки заказов из CRM
## 2017-11-20 v.2.2.10 ## 2017-11-20 v.2.2.10
* Устранен баг с созданием чеков * Устранен баг с созданием чеков
* Улучшен механизм работы с оплатами * Улучшен механизм работы с оплатами

View File

@ -98,7 +98,8 @@ class RCrmActions
{ {
$bitrixPropsList = array(); $bitrixPropsList = array();
$arPropsAll = \Bitrix\Sale\Internals\OrderPropsTable::getList(array( $arPropsAll = \Bitrix\Sale\Internals\OrderPropsTable::getList(array(
'select' => array('*') 'select' => array('*'),
'filter' => array('CODE' => '_%')
)); ));
while ($prop = $arPropsAll->Fetch()) { while ($prop = $arPropsAll->Fetch()) {
$bitrixPropsList[$prop['PERSON_TYPE_ID']][] = $prop; $bitrixPropsList[$prop['PERSON_TYPE_ID']][] = $prop;

View File

@ -356,7 +356,7 @@ class RetailCrmEvent
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 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); $api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
$api = new RetailCrm\ApiClient($api_host, $api_key); $api = new RetailCrm\ApiClient($api_host, $api_key);
$orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arPayment('ORDER_ID'), $site); $orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arPayment['ORDER_ID'], $site);
if (isset($orderCrm['order']['payments']) && $orderCrm['order']['payments']) { if (isset($orderCrm['order']['payments']) && $orderCrm['order']['payments']) {
foreach ($orderCrm['order']['payments'] as $payment) { foreach ($orderCrm['order']['payments'] as $payment) {

View File

@ -22,6 +22,7 @@ class RetailCrmHistory
public static $CRM_CATALOG_BASE_PRICE = 'catalog_base_price'; public static $CRM_CATALOG_BASE_PRICE = 'catalog_base_price';
public static $CRM_ORDER_NUMBERS = 'order_numbers'; public static $CRM_ORDER_NUMBERS = 'order_numbers';
public static $CRM_CANSEL_ORDER = 'cansel_order'; public static $CRM_CANSEL_ORDER = 'cansel_order';
public static $CRM_CURRENCY = 'currency';
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED'; const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
@ -252,9 +253,11 @@ class RetailCrmHistory
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0)); $optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
$optionsOrderNumbers = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_NUMBERS, 0); $optionsOrderNumbers = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_NUMBERS, 0);
$optionsCanselOrder = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CANSEL_ORDER, 0)); $optionsCanselOrder = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CANSEL_ORDER, 0));
$optionsCurrency = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CURRENCY, 0);
$currency = $optionsCurrency ? $optionsCurrency : \Bitrix\Currency\CurrencyManager::getBaseCurrency();
$api = new RetailCrm\ApiClient($api_host, $api_key); $api = new RetailCrm\ApiClient($api_host, $api_key);
$historyFilter = array(); $historyFilter = array();
$historyStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY); $historyStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY);
if ($historyStart && $historyStart > 0) { if ($historyStart && $historyStart > 0) {
@ -395,42 +398,38 @@ class RetailCrmHistory
} }
$newOrder = Bitrix\Sale\Order::create($site, $order['customer']['externalId']); $newOrder = Bitrix\Sale\Order::create($site, $order['customer']['externalId']);
$newOrder->save(); $newOrder->setField('CURRENCY', $currency);
$externalId = $newOrder->getId(); $externalId = $newOrder->getId();
if (isset($externalId)) {
if(RCrmActions::apiMethod($api, 'ordersFixExternalIds', __METHOD__, array(array('id' => $order['id'], 'externalId' => $externalId))) == false){
continue;
}
} else {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::create', 'Error order create');
}
$order['externalId'] = $externalId; $order['externalId'] = $externalId;
} }
if (isset($order['externalId']) && $order['externalId']) { if (isset($order['externalId'])) {
$itemUpdate = false; $itemUpdate = false;
try {
$newOrder = Bitrix\Sale\Order::load($order['externalId']); if ($order['externalId']) {
} catch (Bitrix\Main\ArgumentNullException $e) { try {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::load', $e->getMessage() . ': ' . $order['externalId']); $newOrder = Bitrix\Sale\Order::load($order['externalId']);
} catch (Bitrix\Main\ArgumentNullException $e) {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::load', $e->getMessage() . ': ' . $order['externalId']);
continue;
}
}
if (!$newOrder instanceof \Bitrix\Sale\Order) {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::load', 'Error order load number=' . $order['number']);
continue; continue;
} }
if (!$newOrder instanceof \Bitrix\Sale\Order) {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::load', 'Error order load id=' . $order['externalId']);
continue;
}
if ($optionsSitesList) { if ($optionsSitesList) {
$site = array_search($order['site'], $optionsSitesList); $site = array_search($order['site'], $optionsSitesList);
} else { } else {
$site = CSite::GetDefSite(); $site = CSite::GetDefSite();
} }
if (empty($site)) { if (empty($site)) {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::edit', 'Site = ' . $order['site'] . ' not found in setting. Order id=' . $order['externalId']); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::edit', 'Site = ' . $order['site'] . ' not found in setting. Order number=' . $order['number']);
continue; continue;
} }
@ -448,7 +447,7 @@ class RetailCrmHistory
continue; continue;
} }
} }
$newOrder->setField('ACCOUNT_NUMBER', $order['number']); $newOrder->setField('ACCOUNT_NUMBER', $order['number']);
} }
@ -569,7 +568,7 @@ class RetailCrmHistory
} elseif (count($loc) == 2) { } elseif (count($loc) == 2) {
$parameters['filter']['PHRASE'] = RCrmActions::fromJSON(trim($loc[1])); $parameters['filter']['PHRASE'] = RCrmActions::fromJSON(trim($loc[1]));
} else{ } else{
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'RetailCrmHistory::setProp', 'Error location. ' . $order['delivery']['address'][$key] . ' not found add in order id=' . $order['externalId']); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'RetailCrmHistory::setProp', 'Error location. ' . $order['delivery']['address'][$key] . ' not found add in order number=' . $order['number']);
continue; continue;
} }
$parameters['filter']['NAME.LANGUAGE_ID'] = 'ru'; $parameters['filter']['NAME.LANGUAGE_ID'] = 'ru';
@ -578,7 +577,7 @@ class RetailCrmHistory
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, $location['CODE']); self::setProp($somePropValue, $location['CODE']);
} else { } else {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'RetailCrmHistory::setProp', 'Error location. ' . $order['delivery']['address'][$key] . ' is empty in order id=' . $order['externalId']); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'RetailCrmHistory::setProp', 'Error location. ' . $order['delivery']['address'][$key] . ' is empty in order number=' . $order['number']);
continue; continue;
} }
@ -614,6 +613,12 @@ class RetailCrmHistory
//items //items
$basket = $newOrder->getBasket(); $basket = $newOrder->getBasket();
if (!$basket) {
$basket = Bitrix\Sale\Basket::create($site);
$newOrder->setBasket($basket);
}
if (isset($order['items'])) { if (isset($order['items'])) {
$itemUpdate = true; $itemUpdate = true;
foreach ($order['items'] as $product) { foreach ($order['items'] as $product) {
@ -626,7 +631,7 @@ class RetailCrmHistory
if ($item instanceof \Bitrix\Sale\BasketItem) { if ($item instanceof \Bitrix\Sale\BasketItem) {
$elem = self::getInfoElement($product['offer']['externalId']); $elem = self::getInfoElement($product['offer']['externalId']);
$item->setFields(array( $item->setFields(array(
'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(), 'CURRENCY' => $newOrder->getCurrency(),
'LID' => $site, 'LID' => $site,
'BASE_PRICE' => $product['initialPrice'], 'BASE_PRICE' => $product['initialPrice'],
'NAME' => $product['offer']['name'] ? RCrmActions::fromJSON($product['offer']['name']) : $elem['NAME'], 'NAME' => $product['offer']['name'] ? RCrmActions::fromJSON($product['offer']['name']) : $elem['NAME'],
@ -682,7 +687,6 @@ class RetailCrmHistory
$newOrder->setField('PRICE', $orderSumm); $newOrder->setField('PRICE', $orderSumm);
$order['summ'] = $orderSumm; $order['summ'] = $orderSumm;
$newOrder->save();
//payment //payment
if (array_key_exists('payments', $order)) { if (array_key_exists('payments', $order)) {
@ -693,53 +697,47 @@ class RetailCrmHistory
$newOrder = self::paymentsUpdate($newOrder, $orderCrm['order'], $api); $newOrder = self::paymentsUpdate($newOrder, $orderCrm['order'], $api);
} }
} }
//delivery //delivery
if (array_key_exists('code', $order['delivery'])) { if (array_key_exists('delivery', $order)) {
$itemUpdate = true; $itemUpdate = true;
//delete empty //delete empty
if (!isset($orderCrm)) { if (!isset($orderCrm)) {
$orderCrm = RCrmActions::apiMethod($api, 'orderGet', __METHOD__, $order['id']); $orderCrm = RCrmActions::apiMethod($api, 'orderGet', __METHOD__, $order['id']);
} }
if ($orderCrm) { if ($orderCrm) {
self::shipmentUpdate($orderCrm['order'], $optionsDelivTypes, $newOrder->getField('ACCOUNT_NUMBER')); $newOrder = self::deliveryEdit($newOrder, $optionsDelivTypes, $orderCrm['order']);
} }
} }
if (isset($orderCrm)) { if (isset($orderCrm)) {
unset($orderCrm); unset($orderCrm);
} }
//delivery cost $newOrder->save();
if (array_key_exists('cost', $order['delivery'])) {
$shipment = Bitrix\Sale\Internals\ShipmentTable::getList(array( if (!$order['externalId']) {
'filter' => array('ORDER_ID' => $order['externalId'], 'SYSTEM' => 'N'), if(RCrmActions::apiMethod($api, 'ordersFixExternalIds', __METHOD__, array(array('id' => $order['id'], 'externalId' => $newOrder->getId()))) == false){
'order' => array('ID') continue;
))->fetch();
if ($shipment) {
Bitrix\Sale\Internals\ShipmentTable::update($shipment['ID'], array('BASE_PRICE_DELIVERY' => $order['delivery']['cost'], 'PRICE_DELIVERY' => $order['delivery']['cost'], 'CUSTOM_PRICE_DELIVERY' => 'Y'));
} }
} else {
Bitrix\Sale\OrderTable::update($order['externalId'], array('PRICE_DELIVERY' => $order['delivery']['cost'])); RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::create', 'Error order create');
}
Bitrix\Sale\OrderTable::update($order['externalId'], array('MARKED' => 'N', 'EMP_MARKED_ID' => '', 'REASON_MARKED' => ''));
if ($itemUpdate) {
self::updateShipmentItem($order['externalId']);
} }
if (function_exists('retailCrmAfterOrderSave')) { if (function_exists('retailCrmAfterOrderSave')) {
retailCrmAfterOrderSave($order); retailCrmAfterOrderSave($order);
} }
} }
unset($newOrder);
} }
$GLOBALS['RETAIL_CRM_HISTORY'] = false; $GLOBALS['RETAIL_CRM_HISTORY'] = false;
//end id //end id
$end = array_pop($orderH); $end = array_pop($orderH);
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY, $end['id']); COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY, $end['id']);
if ($orderHistory['pagination']['totalPageCount'] == 1) { if ($orderHistory['pagination']['totalPageCount'] == 1) {
return true; return true;
} }
@ -798,7 +796,7 @@ class RetailCrmHistory
} }
} }
} }
return $customers; return $customers;
} }
@ -909,234 +907,89 @@ class RetailCrmHistory
return $orders; return $orders;
} }
public static function shipmentUpdate($orderCrm, $optionsDelivTypes, $accountNumber = '') /**
* Update shipment in order
*
* @param order object
* @param options delivery types
* @param order from crm
*
* @return order object
*/
public static function deliveryEdit(Bitrix\Sale\Order $order, $optionsDelivTypes, $orderCrm)
{ {
if (strlen($accountNumber) < 1) { if (!$order instanceof Bitrix\Sale\Order) {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'shipmentUpdate', 'ACCOUNT_NUMBER not found');
return false; return false;
} }
if (isset($orderCrm['delivery']['code'])) {
$crmCode = $orderCrm['delivery']['code'];
if (isset($orderCrm['delivery']['data']['deliveryType'])) {
$crmService = $orderCrm['delivery']['data']['deliveryType'];
} elseif (isset($orderCrm['delivery']['service'])) {
$crmService = $orderCrm['delivery']['service']['code'];
}
//select bitrix service code if ($order->getId()) {
$arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList(); $update = true;
foreach ($arDeliveryServiceAll as $arDeliveryService) {
$arDeliveryCode[$arDeliveryService['CODE']] = $arDeliveryService['ID'];
$arDeliveryID[$arDeliveryService['ID']] = $arDeliveryService;
if ($arDeliveryService['ID'] == $optionsDelivTypes[$crmCode]) {
$dCode = $arDeliveryService['CODE'] . ':' . $crmService;
}
}
//We will change delivery to this id
if ($crmService && $arDeliveryCode[$dCode]) {
$nowDelivery = $arDeliveryCode[$dCode];
} elseif (!empty($optionsDelivTypes[$crmCode])) {
$nowDelivery = $optionsDelivTypes[$crmCode];
} else {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'shipmentUpdate', 'Delivery ' . $crmCode . ' not found in options');
return false;
}
//Find the current delivery in the order
$cnt = Bitrix\Sale\Internals\ShipmentTable::getCount(array('ORDER_ID' => $orderCrm['externalId']));
if ($cnt > 0) {//update
$obDeliverys = \Bitrix\Sale\Internals\ShipmentTable::getList(array('filter' => array('ORDER_ID' => $orderCrm['externalId']),
'order' => array('ID')));
while ($arDelivery = $obDeliverys->fetch()) {
if ($arDelivery['DELIVERY_ID'] != $nowDelivery) {
\Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $nowDelivery));
\Bitrix\Sale\Internals\ShipmentTable::update($arDelivery['ID'], array('DELIVERY_ID' => $nowDelivery, 'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME']));
}
}
if ($cnt == 1 && $arDelivery['DELIVERY_ID'] == 0) {
$shipment = Bitrix\Sale\Internals\ShipmentTable::add(array(
'ORDER_ID' => $orderCrm['externalId'],
'STATUS_ID' => 'DN',
'PRICE_DELIVERY' => 0,
'BASE_PRICE_DELIVERY' => 0,
'CUSTOM_PRICE_DELIVERY' => 'N',
'ALLOW_DELIVERY' => 'N',
'DEDUCTED' => 'N',
'RESERVED' => 'N',
'DELIVERY_ID' => $nowDelivery,
'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME'],
'CANCELED' => 'N',
'MARKED' => 'N',
'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(),
'SYSTEM' => 'N',
'ACCOUNT_NUMBER' => $accountNumber . '/2',
'EXTERNAL_DELIVERY' => 'N',
'UPDATED_1C' => 'N',
'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime()
));
}
} else {//create
\Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $nowDelivery));
$shipmentSystem = \Bitrix\Sale\Internals\ShipmentTable::add(array(
'ORDER_ID' => $orderCrm['externalId'],
'STATUS_ID' => 'DN',
'CUSTOM_PRICE_DELIVERY' => 'N',
'ALLOW_DELIVERY' => 'N',
'DEDUCTED' => 'N',
'RESERVED' => 'N',
'DELIVERY_ID' => $nowDelivery,
'DELIVERY_NAME' => $nowDelivery[$nowDelivery]['NAME'],
'CANCELED' => 'N',
'MARKED' => 'N',
'SYSTEM' => 'Y',
'ACCOUNT_NUMBER' => $accountNumber . '/1',
'EXTERNAL_DELIVERY' => 'N',
'UPDATED_1C' => 'N',
'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime()
));
$shipment = Bitrix\Sale\Internals\ShipmentTable::add(array(
'ORDER_ID' => $orderCrm['externalId'],
'STATUS_ID' => 'DN',
'PRICE_DELIVERY' => 0,
'BASE_PRICE_DELIVERY' => 0,
'CUSTOM_PRICE_DELIVERY' => 'N',
'ALLOW_DELIVERY' => 'N',
'DEDUCTED' => 'N',
'RESERVED' => 'N',
'DELIVERY_ID' => $nowDelivery,
'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME'],
'CANCELED' => 'N',
'MARKED' => 'N',
'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(),
'SYSTEM' => 'N',
'ACCOUNT_NUMBER' => $accountNumber . '/2',
'EXTERNAL_DELIVERY' => 'N',
'UPDATED_1C' => 'N',
'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime()
));
}
} else { } else {
//search for the order on the delivery site and delete / replace with no delivery $update = false;
$noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
\Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $noOrderId));
$obDeliverys = Bitrix\Sale\Internals\ShipmentTable::getList(array('filter' => array('ORDER_ID' => $orderCrm['externalId']),
'order' => array('ID')));
$create = true;
while ($arDelivery = $obDeliverys->fetch()) {
\Bitrix\Sale\Internals\ShipmentTable::update($arDelivery['ID'], array('DELIVERY_ID' => $noOrderId, 'DELIVERY_NAME' => GetMessage('NO_DELIVERY')));
$create = false;
}
if ($create) {
$shipmentSystem = \Bitrix\Sale\Internals\ShipmentTable::add(array(
'ORDER_ID' => $orderCrm['externalId'],
'STATUS_ID' => 'DN',
'CUSTOM_PRICE_DELIVERY' => 'N',
'ALLOW_DELIVERY' => 'N',
'DEDUCTED' => 'N',
'RESERVED' => 'N',
'DELIVERY_ID' => $noOrderId,
'DELIVERY_NAME' => GetMessage('NO_DELIVERY'),
'CANCELED' => 'N',
'MARKED' => 'N',
'SYSTEM' => 'Y',
'ACCOUNT_NUMBER' => $accountNumber . '/1',
'EXTERNAL_DELIVERY' => 'N',
'UPDATED_1C' => 'N',
'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime()
));
$shipment = Bitrix\Sale\Internals\ShipmentTable::add(array(
'ORDER_ID' => $orderCrm['externalId'],
'STATUS_ID' => 'DN',
'PRICE_DELIVERY' => 0,
'BASE_PRICE_DELIVERY' => 0,
'CUSTOM_PRICE_DELIVERY' => 'N',
'ALLOW_DELIVERY' => 'N',
'DEDUCTED' => 'N',
'RESERVED' => 'N',
'DELIVERY_ID' => $noOrderId,
'DELIVERY_NAME' => GetMessage('NO_DELIVERY'),
'CANCELED' => 'N',
'MARKED' => 'N',
'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(),
'SYSTEM' => 'N',
'ACCOUNT_NUMBER' => $accountNumber . '/2',
'EXTERNAL_DELIVERY' => 'N',
'UPDATED_1C' => 'N',
'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime()
));
}
}
return true;
}
public static function updateShipmentItem($orderId)
{
$orderBasket = \Bitrix\Sale\Internals\BasketTable::getList(array(
'filter' => array('ORDER_ID' => $orderId),
'select' => array('ID', 'QUANTITY')
));
$basketItems = array();
while ($basketItem = $orderBasket->fetch()) {
$basketItems[] = $basketItem;
$bItems[] = $basketItem['ID'];
} }
$obShipments = \Bitrix\Sale\Internals\ShipmentTable::getList(array( $crmCode = isset($orderCrm['delivery']['code']) ? $orderCrm['delivery']['code'] : false;
'filter' => array('ORDER_ID' => $orderId, 'SYSTEM' => 'N'), $noDeliveryId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
'select' => array('ID') $basket = $order->getBasket();
));
$shipmentItems = array(); if ($crmCode === false || !isset($optionsDelivTypes[$crmCode])) {
while ($arShipment = $obShipments->fetch()) { $deliveryId = $noDeliveryId;
$dlvBaslet = \Bitrix\Sale\Internals\ShipmentItemTable::getList(array( } else {
'order' => array('ORDER_DELIVERY_ID'), $deliveryId = $optionsDelivTypes[$crmCode];
'filter' => array('ORDER_DELIVERY_ID' => $arShipment['ID'])
));
$shipmentItems[$arShipment['ID']] = array();
while ($item = $dlvBaslet->fetch()) {
$shipmentItems[$arShipment['ID']][] = $item;
}
}
foreach ($basketItems as $basketItem) { if (isset($orderCrm['delivery']['service']['code'])) {
foreach ($shipmentItems as $key => $arShipmentItems) { $deliveryCode = \Bitrix\Sale\Delivery\Services\Manager::getCodeById($deliveryId);
$found = false;
foreach ($arShipmentItems as $elShipmentItem) { if ($deliveryCode) {
if (!in_array($elShipmentItem['BASKET_ID'], $bItems)) { try {
//delete the element $deliveryService = \Bitrix\Sale\Delivery\Services\Manager::getObjectByCode($deliveryCode . ':' . $orderCrm['delivery']['service']['code']);
\Bitrix\Sale\Internals\ShipmentItemTable::delete($elShipmentItem['ID']); } catch (Bitrix\Main\SystemException $systemException) {
RCrmActions::eventLog('RetailCrmHistory::deliveryEdit', '\Bitrix\Sale\Delivery\Services\Manager::getObjectByCode', $systemException->getMessage());
} }
if ($elShipmentItem['BASKET_ID'] == $basketItem['ID']) {
//found
$found = true;
//update quantity
if ($elShipmentItem['QUANTITY'] != $basketItem['QUANTITY']) {
\Bitrix\Sale\Internals\ShipmentItemTable::update($elShipmentItem['ID'], array('QUANTITY' => $basketItem['QUANTITY']));
}
if (isset($deliveryService)) {
$deliveryId = $deliveryService->getId();
} }
} }
if (!$found) { }
//create }
\Bitrix\Sale\Internals\ShipmentItemTable::add(array(
'ORDER_DELIVERY_ID' => $key, $delivery = \Bitrix\Sale\Delivery\Services\Manager::getObjectById($deliveryId);
'BASKET_ID' => $basketItem['ID'], $shipmentColl = $order->getShipmentCollection();
'DATE_INSERT' => new \Bitrix\Main\Type\DateTime(),
'QUANTITY' => $basketItem['QUANTITY'], if ($delivery) {
'RESERVED_QUANTITY' => '0.00', if (!$update) {
$shipment = $shipmentColl->createItem($delivery);
$shipment->setFields(array(
'PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'CURRENCY' => $order->getCurrency(),
'DELIVERY_NAME' => $delivery->getName()
)); ));
} else {
foreach ($shipmentColl as $shipment) {
if (!$shipment->isSystem()) {
$shipment->setFields(array(
'PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'CURRENCY' => $order->getCurrency(),
'DELIVERY_ID' => $deliveryId,
'DELIVERY_NAME' => $delivery->getName()
));
}
} }
} }
} }
if (isset($shipment) && $shipment) {
$shipmentItemColl = $shipment->getShipmentItemCollection();
$shipmentItemColl->resetCollection($basket);
}
return $order;
} }
public static function paymentsUpdate($order, $paymentsCrm, $api) public static function paymentsUpdate($order, $paymentsCrm, $api)
{ {
$optionsPayTypes = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0))); $optionsPayTypes = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0)));
@ -1177,7 +1030,7 @@ class RetailCrmHistory
$newPayment->setField('PAY_SYSTEM_ID', $optionsPayTypes[$paymentCrm['type']]); $newPayment->setField('PAY_SYSTEM_ID', $optionsPayTypes[$paymentCrm['type']]);
$newPayment->setField('PAY_SYSTEM_NAME', $arPaySysmems[$optionsPayTypes[$paymentCrm['type']]]); $newPayment->setField('PAY_SYSTEM_NAME', $arPaySysmems[$optionsPayTypes[$paymentCrm['type']]]);
$newPayment->setField('PAID', $optionsPayment[$paymentCrm['status']] ? $optionsPayment[$paymentCrm['status']] : 'N'); $newPayment->setField('PAID', $optionsPayment[$paymentCrm['status']] ? $optionsPayment[$paymentCrm['status']] : 'N');
$newPayment->setField('CURRENCY', \Bitrix\Currency\CurrencyManager::getBaseCurrency()); $newPayment->setField('CURRENCY', $order->getCurrency());
$newPayment->setField('IS_RETURN', 'N'); $newPayment->setField('IS_RETURN', 'N');
$newPayment->setField('PRICE_COD', '0.00'); $newPayment->setField('PRICE_COD', '0.00');
$newPayment->setField('EXTERNAL_PAYMENT', 'N'); $newPayment->setField('EXTERNAL_PAYMENT', 'N');
@ -1206,11 +1059,10 @@ class RetailCrmHistory
} else { } else {
$order->setFieldNoDemand('PAYED', 'N'); $order->setFieldNoDemand('PAYED', 'N');
} }
$order->save();
return $order; return $order;
} }
public static function newValue($value) public static function newValue($value)
{ {
if (array_key_exists('code', $value)) { if (array_key_exists('code', $value)) {
@ -1219,7 +1071,7 @@ class RetailCrmHistory
return $value; return $value;
} }
} }
public static function removeEmpty($inputArray) public static function removeEmpty($inputArray)
{ {
$outputArray = array(); $outputArray = array();
@ -1295,7 +1147,7 @@ class RetailUser extends CUser
{ {
public function GetID() public function GetID()
{ {
$rsUser = CUser::GetList(($by = 'ID'), ($order = 'DESC'), array('LOGIN' => 'retailcrm%')); $rsUser = CUser::GetList(($by = 'ID'), ($order = 'DESC'), array('LOGIN' => 'retailcrm'));
if ($arUser = $rsUser->Fetch()) { if ($arUser = $rsUser->Fetch()) {
return $arUser['ID']; return $arUser['ID'];

View File

@ -87,7 +87,7 @@ class RetailCrmOrder
if ($arLoc) { if ($arLoc) {
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot(); $server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$countrys = array(); $countrys = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) { if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
$countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
foreach ($countrysFile->country as $country) { foreach ($countrysFile->country as $country) {
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; $countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;

View File

@ -83,7 +83,7 @@ class RetailCrmOrder
if ($arLoc) { if ($arLoc) {
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot(); $server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$countrys = array(); $countrys = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) { if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
$countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); $countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
foreach ($countrysFile->country as $country) { foreach ($countrysFile->country as $country) {
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; $countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;

View File

@ -1,2 +1,5 @@
- Устранен баг с созданием чеков - Добавлен выбор валюты в настройках, для выгрузки заказов из CRM
- Улучшен механизм работы с оплатами - Исправлена выборка свойств заказа
- Устранен баг в настройках соответствия полей свойств заказа
- Улучшена механика выгрузки заказов из CRM

View File

@ -47,7 +47,9 @@ class intaro_retailcrm extends CModule
//var $CRM_CATALOG_IBLOCKS = 'catalog_base_iblocks'; //var $CRM_CATALOG_IBLOCKS = 'catalog_base_iblocks';
var $CRM_ORDER_NUMBERS = 'order_numbers'; var $CRM_ORDER_NUMBERS = 'order_numbers';
var $CRM_CANSEL_ORDER = 'cansel_order'; var $CRM_CANSEL_ORDER = 'cansel_order';
var $CRM_CURRENCY = 'currency';
var $CRM_ADDRESS_OPTIONS = 'address_options';
var $CRM_INVENTORIES_UPLOAD = 'inventories_upload'; var $CRM_INVENTORIES_UPLOAD = 'inventories_upload';
var $CRM_STORES = 'stores'; var $CRM_STORES = 'stores';
var $CRM_SHOPS = 'shops'; var $CRM_SHOPS = 'shops';
@ -352,7 +354,15 @@ class intaro_retailcrm extends CModule
'intaro.retailcrm/install/index.php', 'RetailCrm\ApiClient::*List::CurlException', 'intaro.retailcrm/install/index.php', 'RetailCrm\ApiClient::*List::CurlException',
$e->getCode() . ': ' . $e->getMessage() $e->getCode() . ': ' . $e->getMessage()
); );
} catch (\InvalidArgumentException $e) {
$arResult['errCode'] = 'ERR_METHOD_NOT_FOUND';
$APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php'
);
return;
} }
$delivTypes = array(); $delivTypes = array();
foreach ($arResult['deliveryTypesList'] as $delivType) { foreach ($arResult['deliveryTypesList'] as $delivType) {
if ($delivType['active'] === true) { if ($delivType['active'] === true) {
@ -993,6 +1003,8 @@ class intaro_retailcrm extends CModule
COption::RemoveOption($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY); COption::RemoveOption($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY);
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_HISTORY); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_HISTORY);
COption::RemoveOption($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE); COption::RemoveOption($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE);
COption::RemoveOption($this->MODULE_ID, $this->CRM_CURRENCY);
COption::RemoveOption($this->MODULE_ID, $this->CRM_ADDRESS_OPTIONS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_NUMBERS); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_NUMBERS);
COption::RemoveOption($this->MODULE_ID, $this->CRM_CANSEL_ORDER); COption::RemoveOption($this->MODULE_ID, $this->CRM_CANSEL_ORDER);

View File

@ -1,5 +1,5 @@
<? <?
$arModuleVersion = array( $arModuleVersion = array(
"VERSION" => "2.2.10", "VERSION" => "2.3.0",
"VERSION_DATE" => "2017-11-20 16:00:00" "VERSION_DATE" => "2017-12-04 12:00:00"
); );

View File

@ -27,6 +27,7 @@ $MESS ['ICRM_OPTIONS_SUBMIT_VALUE'] = 'Сохранить';
$MESS ['ERR_404'] = 'Возможно не верно введен адрес CRM.'; $MESS ['ERR_404'] = 'Возможно не верно введен адрес CRM.';
$MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_403'] = 'Неверный apiKey.';
$MESS ['ERR_JSON'] = 'Получены некорректные данные из CRM, проверьте данные справочников в настройках';
$MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.';
$MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.'; $MESS ['ICRM_OPTIONS_OK'] = 'Изменения успешно сохранены.';
$MESS ['CANCELED'] = 'Является флагом «Отменен»'; $MESS ['CANCELED'] = 'Является флагом «Отменен»';
@ -71,6 +72,7 @@ $MESS ['ORDERS_OPTIONS'] = 'Настройки заказов';
$MESS ['ORDER_NUMBERS'] = 'Транслировать номера заказов созданных в црм в магазин'; $MESS ['ORDER_NUMBERS'] = 'Транслировать номера заказов созданных в црм в магазин';
$MESS ['CRM_API_VERSION'] = 'Версия API клиента'; $MESS ['CRM_API_VERSION'] = 'Версия API клиента';
$MESS ['CURRENCY'] = 'Валюта, устанавливаемая в заказе при выгрузке из CRM';
$MESS ['INVENTORIES_UPLOAD'] = 'Включить выгрузку остатков в разрезе складов'; $MESS ['INVENTORIES_UPLOAD'] = 'Включить выгрузку остатков в разрезе складов';
$MESS ['INVENTORIES'] = 'Склады'; $MESS ['INVENTORIES'] = 'Склады';

View File

@ -40,6 +40,9 @@ $CRM_UA_KEYS = 'ua_keys';
$CRM_API_VERSION = 'api_version'; $CRM_API_VERSION = 'api_version';
$CRM_CURRENCY = 'currency';
$CRM_ADDRESS_OPTIONS = 'address_options';
if(!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog')) if(!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog'))
return; return;
@ -293,6 +296,10 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$propsCount = 0; $propsCount = 0;
$_orderPropsArr = array(); $_orderPropsArr = array();
foreach ($arResult['orderProps'] as $orderProp) { foreach ($arResult['orderProps'] as $orderProp) {
if (isset($_POST['address-detail-' . $orderType['ID']])) {
$addressDatailOptions[$orderType['ID']] = $_POST['address-detail-' . $orderType['ID']];
}
if ((!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']]))) && $propsCount > 4) { if ((!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']]))) && $propsCount > 4) {
break; break;
} }
@ -472,7 +479,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
echo CAdminMessage::ShowMessage(GetMessage('API_NOT_WORK')); echo CAdminMessage::ShowMessage(GetMessage('API_NOT_WORK'));
} }
} }
if ($_POST['currency']) {
COption::SetOptionString($mid, $CRM_CURRENCY, $_POST['currency']);
}
COption::SetOptionString($mid, $CRM_ADDRESS_OPTIONS, serialize($addressDatailOptions));
COption::SetOptionString($mid, $CRM_SITES_LIST, serialize($siteListArr)); COption::SetOptionString($mid, $CRM_SITES_LIST, serialize($siteListArr));
COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr($orderTypesArr))); COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr($orderTypesArr)));
COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize(RCrmActions::clearArr($deliveryTypesArr))); COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize(RCrmActions::clearArr($deliveryTypesArr)));
@ -532,7 +544,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
$badKey = true; $badKey = true;
echo CAdminMessage::ShowMessage(GetMessage('ERR_403')); echo CAdminMessage::ShowMessage(GetMessage('ERR_403'));
} catch (\RetailCrm\Exception\InvalidJsonException $e) {
$badJson = true;
echo CAdminMessage::ShowMessage(GetMessage('ERR_JSON'));
} }
$delivTypes = array(); $delivTypes = array();
foreach ($arResult['deliveryTypesList'] as $delivType) { foreach ($arResult['deliveryTypesList'] as $delivType) {
if ($delivType['active'] === true) { if ($delivType['active'] === true) {
@ -599,6 +615,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$version = COption::GetOptionString($mid, $CRM_API_VERSION, 0); $version = COption::GetOptionString($mid, $CRM_API_VERSION, 0);
//currency
$baseCurrency = \Bitrix\Currency\CurrencyManager::getBaseCurrency();
$currencyOption = COption::GetOptionString($mid, $CRM_CURRENCY, 0) ? COption::GetOptionString($mid, $CRM_CURRENCY, 0) : $baseCurrency;
$currencyList = \Bitrix\Currency\CurrencyManager::getCurrencyList();
$addressOptions = unserialize(COption::GetOptionString($mid, $CRM_ADDRESS_OPTIONS, 0));
$aTabs = array( $aTabs = array(
array( array(
"DIV" => "edit1", "DIV" => "edit1",
@ -795,7 +818,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif;?> <?php endif;?>
<?php if(!$badKey):?> <?php if(!$badKey && !$badJson):?>
<?php $tabControl->BeginNextTab(); ?> <?php $tabControl->BeginNextTab(); ?>
<input type="hidden" name="tab" value="catalog"> <input type="hidden" name="tab" value="catalog">
<tr class="option-head"> <tr class="option-head">
@ -967,13 +990,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<tr class="heading"> <tr class="heading">
<td colspan="2" style="background-color: transparent;"> <td colspan="2" style="background-color: transparent;">
<b> <b>
<label><input class="addr" type="radio" name="address-detail-<?php echo $bitrixOrderType['ID']; ?>" value="0" <?php if(count($optionsOrderProps[$bitrixOrderType['ID']]) < 6) echo "checked"; ?>><?php echo GetMessage('ADDRESS_SHORT'); ?></label> <label><input class="addr" type="radio" name="address-detail-<?php echo $bitrixOrderType['ID']; ?>" value="0" <?php if($addressOptions[$bitrixOrderType['ID']] == 0) echo "checked"; ?>><?php echo GetMessage('ADDRESS_SHORT'); ?></label>
<label><input class="addr" type="radio" name="address-detail-<?php echo $bitrixOrderType['ID']; ?>" value="1" <?php if(count($optionsOrderProps[$bitrixOrderType['ID']]) > 5) echo "checked"; ?>><?php echo GetMessage('ADDRESS_FULL'); ?></label> <label><input class="addr" type="radio" name="address-detail-<?php echo $bitrixOrderType['ID']; ?>" value="1" <?php if($addressOptions[$bitrixOrderType['ID']] == 1) echo "checked"; ?>><?php echo GetMessage('ADDRESS_FULL'); ?></label>
</b> </b>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<tr <?php if ($countProps > 4) echo 'class="address-detail-' . $bitrixOrderType['ID'] . '"'; if(($countProps > 4) && (count($optionsOrderProps[$bitrixOrderType['ID']]) < 6)) echo 'style="display:none;"';?>> <tr <?php if ($countProps > 4) echo 'class="address-detail-' . $bitrixOrderType['ID'] . '"'; if(($countProps > 4) && ($addressOptions[$bitrixOrderType['ID']] == 0)) echo 'style="display:none;"';?>>
<td width="50%" class="adm-detail-content-cell-l" name="<?php echo $orderProp['ID']; ?>"> <td width="50%" class="adm-detail-content-cell-l" name="<?php echo $orderProp['ID']; ?>">
<?php echo $orderProp['NAME']; ?> <?php echo $orderProp['NAME']; ?>
</td> </td>
@ -1004,7 +1027,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</td> </td>
<td width="50%" class=""> <td width="50%" class="">
<select name="custom-fields-<?=$customFields['ID'] . '-' . $bitrixOrderType['ID']; ?>" class="typeselect"> <select name="custom-fields-<?=$customFields['ID'] . '-' . $bitrixOrderType['ID']; ?>" class="typeselect">
<option value=""></option> <option value=""></option>
<?foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp):?> <?foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp):?>
<option value="<?=$arProp['CODE']?>" <?php if ($optionsCustomFields[$bitrixOrderType['ID']][$customFields['ID']] == $arProp['CODE']) echo 'selected'; ?>> <option value="<?=$arProp['CODE']?>" <?php if ($optionsCustomFields[$bitrixOrderType['ID']][$customFields['ID']] == $arProp['CODE']) echo 'selected'; ?>>
<?=$arProp['NAME']; ?> <?=$arProp['NAME']; ?>
@ -1029,7 +1052,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</td> </td>
<td width="50%" class=""> <td width="50%" class="">
<select name="legal-detail-<?php echo $legalDetails['ID'] . '-' . $bitrixOrderType['ID']; ?>" class="typeselect"> <select name="legal-detail-<?php echo $legalDetails['ID'] . '-' . $bitrixOrderType['ID']; ?>" class="typeselect">
<option value=""></option> <option value=""></option>
<?php foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp): ?> <?php foreach ($arResult['arProp'][$bitrixOrderType['ID']] as $arProp): ?>
<option value="<?php echo $arProp['CODE']; ?>" <?php if ($optionsLegalDetails[$bitrixOrderType['ID']][$legalDetails['ID']] == $arProp['CODE']) echo 'selected'; ?>> <option value="<?php echo $arProp['CODE']; ?>" <?php if ($optionsLegalDetails[$bitrixOrderType['ID']][$legalDetails['ID']] == $arProp['CODE']) echo 'selected'; ?>>
<?php echo $arProp['NAME']; ?> <?php echo $arProp['NAME']; ?>
@ -1061,12 +1084,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
</b> </b>
</td> </td>
</tr> </tr>
<tr class="heading" > <tr class="heading">
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td> <td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="option-head option-other-top option-other-bottom"> <td colspan="2" class="option-head option-other-top option-other-bottom">
<select name="api_version" class="typeselect"> <select name="api_version" class="typeselect">
<?php for($v = 4; $v <= 5; $v++) { <?php for($v = 4; $v <= 5; $v++) {
$ver = 'v' . $v; ?> $ver = 'v' . $v; ?>
<option value="<?php echo $ver; ?>" <?php if ($ver == $version) echo 'selected'; ?>> <option value="<?php echo $ver; ?>" <?php if ($ver == $version) echo 'selected'; ?>>
@ -1075,6 +1098,20 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<?php } ?> <?php } ?>
</select> </select>
</td> </td>
</tr>
<tr class="heading">
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CURRENCY'); ?></b></td>
</tr>
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<select name="currency" class="typeselect">
<?php foreach ($currencyList as $currencyCode => $currencyName) : ?>
<option value="<?php echo $currencyCode; ?>" <?php if ($currencyCode == $currencyOption) echo 'selected'; ?>>
<?php echo $currencyName; ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr> </tr>
<?php if ($optionInventotiesUpload === 'Y' || count($arResult['bitrixStoresExportList']) > 0) :?> <?php if ($optionInventotiesUpload === 'Y' || count($arResult['bitrixStoresExportList']) > 0) :?>
<tr class="heading inventories-batton"> <tr class="heading inventories-batton">