GetCurPage() . '?mid=' . htmlspecialchars($mid) . '&lang=' . LANGUAGE_ID; if (!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog')) { return; } $_GET['errc'] = htmlspecialchars(trim($_GET['errc'])); $_GET['ok'] = htmlspecialchars(trim($_GET['ok'])); if (RetailcrmConfigProvider::isPhoneRequired()) { echo ShowMessage(["TYPE" => "ERROR", "MESSAGE" => GetMessage('PHONE_REQUIRED')]); } if (array_key_exists('errc', $_GET) && is_string($_GET['errc']) && strlen($_GET['errc']) > 0) { echo CAdminMessage::ShowMessage(GetMessage($_GET['errc'])); } if (!empty($_GET['ok']) && $_GET['ok'] === 'Y') { echo CAdminMessage::ShowNote(GetMessage('ICRM_OPTIONS_OK')); } $arResult = []; $enabledCustom = false; $loyaltySetup = new LoyaltyInstaller(); if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml')) { $options = simplexml_load_file($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/classes/general/config/options.xml'); foreach($options->contragents->contragent as $contragent) { $type["NAME"] = $APPLICATION->ConvertCharset((string)$contragent, 'utf-8', SITE_CHARSET); $type["ID"] = (string)$contragent["id"]; $arResult['contragentType'][] = $type; unset ($type); } foreach ($options->fields->field as $field) { $type["NAME"] = $APPLICATION->ConvertCharset((string) $field, 'utf-8', SITE_CHARSET); $type["ID"] = (string) $field["id"]; if (!$field["group"]) { $arResult['orderProps'][] = $type; } else { $groups = explode(",", (string) $field["group"]); foreach ($groups as $group) { $type["GROUP"][] = trim($group); } $arResult['legalDetails'][] = $type; } unset($type); } } $arResult['arSites'] = RCrmActions::getSitesList(); $arResult['arCurrencySites'] = RCrmActions::getCurrencySites(); $arResult['bitrixOrdersCustomProp'] = []; $arResult['bitrixCustomUserFields'] = []; if (method_exists(RCrmActions::class, 'customOrderPropList') && method_exists(RCrmActions::class, 'customUserFieldList') ) { $arResult['bitrixOrdersCustomProp'] = RCrmActions::customOrderPropList(); $arResult['bitrixCustomUserFields'] = RCrmActions::customUserFieldList(); } //ajax update deliveryServices if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') && isset($_POST['ajax']) && ($_POST['ajax'] === '1')) { $api_host = COption::GetOptionString($mid, Constants::CRM_API_HOST_OPTION, 0); $api_key = COption::GetOptionString($mid, Constants::CRM_API_KEY_OPTION , 0); $api = new RetailCrm\ApiClient($api_host, $api_key); try { $api->paymentStatusesList(); } catch (CurlException $e) { RCrmActions::eventLog( 'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::paymentStatusesList::CurlException', $e->getCode() . ': ' . $e->getMessage() ); $APPLICATION->RestartBuffer(); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); die(json_encode(['success' => false, 'errMsg' => $e->getCode()])); } $optionsDelivTypes = unserialize(COption::GetOptionString($mid, Constants::CRM_DELIVERY_TYPES_ARR, 0)); $arDeliveryServiceAll = Manager::getActiveList(); foreach ($optionsDelivTypes as $key => $deliveryType) { foreach ($arDeliveryServiceAll as $deliveryService) { if ($deliveryService['PARENT_ID'] != 0 && $deliveryService['PARENT_ID'] == $key) { try { $api->deliveryServicesEdit(RCrmActions::clearArr([ 'code' => 'bitrix-' . $deliveryService['ID'], 'name' => RCrmActions::toJSON($deliveryService['NAME']), 'deliveryType' => $deliveryType, ])); } catch (CurlException $e) { RCrmActions::eventLog( 'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::deliveryServiceEdit::CurlException', $e->getCode() . ': ' . $e->getMessage() ); } } } } $APPLICATION->RestartBuffer(); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); die(json_encode(['success' => true])); } //upload orders after install module if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') && isset($_POST['ajax']) && $_POST['ajax'] == 2) { $step = $_POST['step']; $orders = $_POST['orders']; $countStep = 50; // 50 orders on step if ($orders) { $ordersArr = explode(',', $orders); $orders = []; foreach ($ordersArr as $_ordersArr) { $ordersList = explode('-', trim($_ordersArr)); if (count($ordersList) > 1) { for ($i = (int) trim($ordersList[0]); $i <= (int) trim($ordersList[count($ordersList) - 1]); $i++) { $orders[] = $i; } } else { $orders[] = (int)$ordersList[0]; } } $splitedOrders = array_chunk($orders, $countStep); $stepOrders = $splitedOrders[$step]; RetailCrmOrder::uploadOrders($countStep, false, $stepOrders); $percent = round((($step * $countStep + count($stepOrders)) * 100 / count($orders)), 1); $step++; if (!$splitedOrders[$step]) { $step = 'end'; } $res = ["step" => $step, "percent" => $percent, 'stepOrders' => $stepOrders]; } else { $orders = []; for ($i = 1; $i <= $countStep; $i++) { $orders[] = $i + $step * $countStep; } RetailCrmOrder::uploadOrders($countStep, false, $orders); $step++; $countLeft = (int)CSaleOrder::GetList(["ID" => "ASC"], ['>ID' => $step * $countStep], []); $countAll = (int)CSaleOrder::GetList(["ID" => "ASC"], [], []); $percent = round(100 - ($countLeft * 100 / $countAll), 1); if ($countLeft === 0) { $step = 'end'; } $res = ["step" => $step, "percent" => $percent, 'stepOrders' => $orders]; } $APPLICATION->RestartBuffer(); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); die(json_encode($res)); } if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') && isset($_POST['ajax']) && $_POST['ajax'] == 3) { $dateAgent = new DateTime(); $intAgent = new DateInterval('PT60S'); $dateAgent->add($intAgent); CAgent::AddAgent( "RetailCrmUser::fixDateCustomer();", $mid, "N", 9999999, $dateAgent->format('d.m.Y H:i:s'), "Y", $dateAgent->format('d.m.Y H:i:s'), 30 ); $APPLICATION->RestartBuffer(); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); die(json_encode(['success' => true])); } $availableSites = RetailcrmConfigProvider::getSitesList(); if (!empty($availableSites)) { $availableSites = array_flip($availableSites); } else { $site = RetailcrmConfigProvider::getSitesAvailable(); $availableSites[$site] = $site; } //update connection settings if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $error = null; $api_host = htmlspecialchars(trim($_POST['api_host'])); $api_key = htmlspecialchars(trim($_POST['api_key'])); //bitrix site list $siteListArr = []; foreach ($arResult['arSites'] as $arSites) { if (count($arResult['arSites']) > 1) { if ($_POST['sites-id-' . $arSites['LID']]) { $siteListArr[$arSites['LID']] = htmlspecialchars(trim($_POST['sites-id-' . $arSites['LID']])); } else { $siteListArr[$arSites['LID']] = null; } } } if ($api_host && $api_key) { $api = new ClientAdapter($api_host, $api_key); try { $credentials = $api->getCredentials(); if (!empty($credentials->errorMsg)) { $uri .= '&errc=ERR_' . $credentials->errorMsg; LocalRedirect($uri); } ConfigProvider::setSitesAvailable( count($credentials->sitesAvailable) > 0 ? $credentials->sitesAvailable[0] : '' ); } catch (CurlException $e) { RCrmActions::eventLog( 'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::paymentStatusesList::CurlException', $e->getCode() . ': ' . $e->getMessage() ); $uri .= '&errc=ERR_' . $e->getCode(); LocalRedirect($uri); } COption::SetOptionString($mid, 'api_host', $api_host); COption::SetOptionString($mid, 'api_key', $api_key); } else { $uri .= '&errc=ERR_WRONG_CREDENTIALS'; LocalRedirect($uri); } //form order types ids arr $orderTypesList = RCrmActions::OrderTypesList($arResult['arSites']); $orderTypesArr = []; foreach ($orderTypesList as $orderType) { $orderTypesArr[$orderType['ID']] = htmlspecialchars(trim($_POST['order-type-' . $orderType['ID']])); } //form delivery types ids arr $arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList(); $deliveryTypesArr = []; foreach ($arResult['bitrixDeliveryTypesList'] as $delivery) { $deliveryTypesArr[$delivery['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $delivery['ID']])); } //form payment types ids arr $arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList(); $paymentTypesArr = []; foreach ($arResult['bitrixPaymentTypesList'] as $payment) { $paymentTypesArr[$payment['ID']] = htmlspecialchars(trim($_POST['payment-type-' . $payment['ID']])); } //form payment statuses ids arr $arResult['bitrixStatusesList'] = RCrmActions::StatusesList(); $paymentStatusesArr = []; $canselOrderArr = []; foreach ($arResult['bitrixStatusesList'] as $status) { $paymentStatusesArr[$status['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $status['ID']])); if (trim($_POST['order-cansel-' . $status['ID']]) === 'Y') { $canselOrderArr[] = $status['ID']; } } //form payment ids arr $paymentArr = []; $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); $previousDischarge = COption::GetOptionString($mid, Constants::CRM_ORDER_DISCHARGE, 0); //order discharge mode // 0 - agent // 1 - event $orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge'])); if (($orderDischarge != $previousDischarge) && ($orderDischarge === 0)) { // remove depenedencies UnRegisterModuleDependences('sale', 'OnOrderUpdate', $mid, 'RetailCrmEvent', "onUpdateOrder"); UnRegisterModuleDependences('sale', 'OnSaleOrderDeleted', $mid, 'RetailCrmEvent', "orderDelete"); } elseif (($orderDischarge != $previousDischarge) && ($orderDischarge === 1)) { // event dependencies RegisterModuleDependences('sale', 'OnOrderUpdate', $mid, 'RetailCrmEvent', "onUpdateOrder"); RegisterModuleDependences('sale', 'OnSaleOrderDeleted', $mid, 'RetailCrmEvent', "orderDelete"); } $optionCart = COption::GetOptionString($mid, Constants::CART, 'N'); $cart = htmlspecialchars(trim($_POST['cart'])); if ($cart != $optionCart) { if ($cart === 'Y') { $optionCart = 'Y'; RegisterModuleDependences('sale', 'OnSaleBasketSaved', $mid, 'RetailCrmEvent', 'onChangeBasket'); } else { $optionCart = 'N'; UnRegisterModuleDependences('sale', 'OnSaleBasketSaved', $mid, 'RetailCrmEvent', 'onChangeBasket'); } } $orderPropsArr = []; foreach ($orderTypesList as $orderType) { $propsCount = 0; $_orderPropsArr = []; 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 ) { break; } $_orderPropsArr[$orderProp['ID']] = htmlspecialchars( trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']]) ); $propsCount++; } $orderPropsArr[$orderType['ID']] = $_orderPropsArr; } //legal details props $legalDetailsArr = []; foreach ($orderTypesList as $orderType) { $_legalDetailsArr = []; foreach ($arResult['legalDetails'] as $legalDetails) { $_legalDetailsArr[$legalDetails['ID']] = htmlspecialchars(trim($_POST['legal-detail-' . $legalDetails['ID'] . '-' . $orderType['ID']])); } $legalDetailsArr[$orderType['ID']] = $_legalDetailsArr; } //contragents type list $contragentTypeArr = []; foreach ($orderTypesList as $orderType) { $contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']])); } //stores $bitrixStoresArr = []; $bitrixShopsArr = []; $bitrixIblocksInventories = []; if (htmlspecialchars(trim($_POST['inventories-upload'])) === 'Y') { $inventoriesUpload = 'Y'; $dateAgent = new DateTime(); $intAgent = new DateInterval('PT60S'); // PT60S - 60 sec; $dateAgent->add($intAgent); CAgent::AddAgent( "RetailCrmInventories::inventoriesUpload();", $mid, "N", 3600, // interval - 1 hour $dateAgent->format('d.m.Y H:i:s'), // date of first check "Y", // agent is active $dateAgent->format('d.m.Y H:i:s'), // date of first start 30 ); $arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList(); foreach ($arResult['bitrixStoresExportList'] as $bitrixStores) { $bitrixStoresArr[$bitrixStores['ID']] = htmlspecialchars(trim($_POST['stores-export-' . $bitrixStores['ID']])); } function maskInv($var) { return preg_match("/^shops-exoprt/", $var); } $bitrixShopsArr = array_values(array_filter($_POST, 'maskInv', ARRAY_FILTER_USE_KEY)); $arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList(); foreach ($arResult['bitrixIblocksExportList'] as $bitrixIblocks) { if (htmlspecialchars(trim($_POST['iblocks-stores-' . $bitrixIblocks['ID']])) === 'Y') { $bitrixIblocksInventories[] = $bitrixIblocks['ID']; } } } else { $inventoriesUpload = 'N'; CAgent::RemoveAgent("RetailCrmInventories::inventoriesUpload();", $mid); } //prices $bitrixPricesArr = []; $bitrixIblocksPrices = []; $bitrixPriceShopsArr = []; if (htmlspecialchars(trim($_POST['prices-upload'])) === 'Y') { $pricesUpload = 'Y'; $dateAgent = new DateTime(); $intAgent = new DateInterval('PT60S'); // PT60S - 60 sec; $dateAgent->add($intAgent); CAgent::AddAgent( "RetailCrmPrices::pricesUpload();", $mid, "N", 86400, // interval - 24 hours $dateAgent->format('d.m.Y H:i:s'), // date of first check "Y", // agent is active $dateAgent->format('d.m.Y H:i:s'), // date of first start 30 ); $arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList(); foreach ($arResult['bitrixPricesExportList'] as $bitrixPrices) { $bitrixPricesArr[$bitrixPrices['ID']] = htmlspecialchars(trim($_POST['price-type-export-' . $bitrixPrices['ID']])); } function maskPrice($var) { return preg_match("/^shops-price/", $var); } $bitrixPriceShopsArr = array_values(array_filter($_POST, 'maskPrice', ARRAY_FILTER_USE_KEY)); $arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList(); foreach ($arResult['bitrixIblocksExportList'] as $bitrixIblocks) { if (htmlspecialchars(trim($_POST['iblocks-prices-' . $bitrixIblocks['ID']])) === 'Y') { $bitrixIblocksPrices[] = $bitrixIblocks['ID']; } } } else { $pricesUpload = 'N'; CAgent::RemoveAgent("RetailCrmPrices::pricesUpload();", $mid); } $useCrmOrderMethods = htmlspecialchars(trim($_POST['use_crm_order_methods'])) === 'Y' ? 'Y' : 'N'; $crmOrderMethod = []; if ($useCrmOrderMethods === 'Y') { $crmOrderMethod = $_POST['crm_order_methods']; } //demon $collectorKeys = []; if (htmlspecialchars(trim($_POST['collector'])) === 'Y') { $collector = 'Y'; foreach ($arResult['arSites'] as $site) { $collectorKeys[$site['LID']] = trim($_POST['collector-id-' . $site['LID']]); } RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCollector", "add"); } else { $collector = 'N'; UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCollector", "add"); } //UA $uaKeys = []; if (htmlspecialchars(trim($_POST['ua-integration'])) === 'Y') { $ua = 'Y'; foreach ($arResult['arSites'] as $site) { $uaKeys[$site['LID']]['ID'] = trim($_POST['ua-id-' . $site['LID']]); $uaKeys[$site['LID']]['INDEX'] = trim($_POST['ua-index-' . $site['LID']]); } RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmUa", "add"); } else { $ua = 'N'; UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmUa", "add"); } //online_consultant if (htmlspecialchars(trim($_POST['online_consultant'] === 'Y'))) { $onlineConsultant = 'Y'; $onlineConsultantScript = trim($_POST['online_consultant_script']); RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmOnlineConsultant", "add"); } else { $onlineConsultant = 'N'; $onlineConsultantScript = RetailcrmConfigProvider::getOnlineConsultantScript(); UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmOnlineConsultant", "add"); } //discount_round if (htmlspecialchars(trim($_POST['discount_round'])) === 'Y') { $discount_round = 'Y'; } else { $discount_round = 'N'; } //shipment if (htmlspecialchars(trim($_POST['shipment_deducted'])) === 'Y') { $shipment_deducted = 'Y'; } else { $shipment_deducted = 'N'; } //corporate-cliente if (htmlspecialchars(trim($_POST['corp-client'])) === 'Y') { $cc = 'Y'; $bitrixCorpName = htmlspecialchars(trim($_POST['nickName-corporate'])); $bitrixCorpAdres = htmlspecialchars(trim($_POST['adres-corporate'])); function maskCorp($var) { return preg_match("/^shops-corporate/", $var); } $bitrixCorpShopsArr = array_values(array_filter($_POST, 'maskCorp', ARRAY_FILTER_USE_KEY)); } else { $cc = 'N'; } //purchasePrice_null if (htmlspecialchars(trim($_POST['purchasePrice_null'])) === 'Y') { $purchasePrice_null = 'Y'; } else { $purchasePrice_null = 'N'; } //version $version = COption::GetOptionString($mid, Constants::CRM_API_VERSION); if (htmlspecialchars(trim($_POST['api_version'])) != $version) { if (htmlspecialchars(trim($_POST['api_version'])) === 'v5') { $version = 'v5'; } else { LocalRedirect($uri); echo CAdminMessage::ShowMessage(GetMessage('API_NOT_FOUND')); } //api request with $version $crmUrl = htmlspecialchars(trim($_POST['api_host'])); $apiKey = htmlspecialchars(trim($_POST['api_key'])); if ('/' !== $crmUrl[strlen($crmUrl) - 1]) { $crmUrl .= '/'; } $crmUrl .= 'api/' . $version; $client = new RetailCrm\Http\Client($crmUrl, ['apiKey' => $apiKey]); $result = $client->makeRequest( '/reference/payment-statuses', 'GET' ); if ($result->getStatusCode() === 200) { COption::SetOptionString($mid, Constants::CRM_API_VERSION, $version); } else { LocalRedirect($uri); echo CAdminMessage::ShowMessage(GetMessage('API_NOT_WORK')); } } if ($_POST[Constants::CRM_CURRENCY]) { COption::SetOptionString($mid, Constants::CRM_CURRENCY, $_POST['currency']); } if (isset($_POST['loyalty_toggle']) && $_POST['loyalty_toggle'] === 'on') { try { $loyaltySetup->CopyFiles(); $loyaltySetup->addEvents(); $loyaltySetup->addAgreement(); $loyaltySetup->addUserFields(); $hlName = RetailCrmUtils::getHlClassByName(Constants::HL_LOYALTY_CODE); if (empty($hlName)) { OrderLoyaltyDataService::createLoyaltyHlBlock(); $service = new OrderLoyaltyDataService(); $service->addCustomersLoyaltyFields(); } } catch (Exception $exception) { RCrmActions::eventLog( 'intaro.retailcrm/options.php', 'Options_Loyalty_toggle::enable', $e->getCode() . ': ' . $exception->getMessage() ); } ConfigProvider::setLoyaltyProgramStatus('Y'); } else { try { ConfigProvider::setLoyaltyProgramStatus('N'); $loyaltySetup->deleteLPEvents(); } catch (Exception $exception) { RCrmActions::eventLog( 'intaro.retailcrm/options.php', 'Options_Loyalty_toggle::disable', $e->getCode() . ': ' . $exception->getMessage() ); } } try { $arResult['paymentTypesList'] = RetailCrmService::getAvailableTypes( $availableSites, $api->paymentTypesList()->paymentTypes ); $arResult['deliveryTypesList'] = RetailCrmService::getAvailableTypes( $availableSites, $api->deliveryTypesList()->deliveryTypes ); } catch (CurlException $e) { RCrmActions::eventLog( 'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::*List::CurlException', $e->getCode() . ': ' . $e->getMessage() ); CAdminMessage::ShowMessage(GetMessage('ERR_' . $e->getCode())); } $integrationPayments = RetailCrmService::selectIntegrationPayments($arResult['paymentTypesList']); $integrationDeliveries = RetailCrmService::selectIntegrationDeliveries($arResult['deliveryTypesList']); RetailcrmConfigProvider::setIntegrationPaymentTypes($integrationPayments); RetailcrmConfigProvider::setIntegrationDelivery($integrationDeliveries); $moduleDeactivateParam = htmlspecialchars(trim($_POST['module-deactivate'])) ?? 'N'; if ('Y' === $moduleDeactivateParam) { global $DB; $agents = $DB->Query("SELECT * FROM `b_agent` WHERE `MODULE_ID` = 'intaro.retailcrm';"); $events = $DB->Query("SELECT * FROM `b_module_to_module` WHERE `TO_MODULE_ID` = 'intaro.retailcrm';"); $deactivateAgents = []; $deactivateEvents = []; // Fetch - If the last record is reached (or there are no records as a result), the method returns false while ($agent = $agents->Fetch()) { $deactivateAgents[] = $agent; CAgent::RemoveAgent($agent['NAME'], $agent['MODULE_ID'], $agent['USER_ID']); } // Fetch - If the last record is reached (or there are no records as a result), the method returns false while ($event = $events->Fetch()) { $deactivateEvents[] = $event; UnRegisterModuleDependences( $event['FROM_MODULE_ID'], $event['MESSAGE_ID'], $event['TO_MODULE_ID'], $event['TO_CLASS'], $event['TO_METHOD'] ); } if ($deactivateAgents !== []) { COption::SetOptionString($mid, Constants::AGENTS_DEACTIVATE, serialize($deactivateAgents)); } if ($deactivateEvents !== []) { COption::SetOptionString($mid, Constants::EVENTS_DEACTIVATE, serialize($deactivateEvents)); } RCrmActions::sendConfiguration($api, false); } else { $deactivateAgents = unserialize(COption::GetOptionString($mid, Constants::AGENTS_DEACTIVATE, '')); $deactivateEvents = unserialize(COption::GetOptionString($mid, Constants::EVENTS_DEACTIVATE, '')); if (!empty($deactivateAgents)) { $dateAgent = new DateTime(); // PT60S - 60 sec; $dateAgent->add(new DateInterval('PT60S')); foreach ($deactivateAgents as $agent) { CAgent::AddAgent( $agent['NAME'], $agent['MODULE_ID'], 'N', $agent['AGENT_INTERVAL'], $dateAgent->format('d.m.Y H:i:s'), $agent['ACTIVE'], $dateAgent->format('d.m.Y H:i:s') ); } COption::SetOptionString($mid, Constants::AGENTS_DEACTIVATE, serialize([])); } if (!empty($deactivateEvents)) { $eventManager = EventManager::getInstance(); foreach ($deactivateEvents as $event) { if (strpos($event['TO_METHOD'], 'Handler') !== false) { $eventManager->registerEventHandler( $event['FROM_MODULE_ID'], $event['MESSAGE_ID'], $event['TO_MODULE_ID'], $event['TO_CLASS'], $event['TO_METHOD'] ); } else { RegisterModuleDependences( $event['FROM_MODULE_ID'], $event['MESSAGE_ID'], $event['TO_MODULE_ID'], $event['TO_CLASS'], $event['TO_METHOD'] ); } } COption::SetOptionString($mid, Constants::EVENTS_DEACTIVATE, serialize([])); } RCrmActions::sendConfiguration($api); } COption::SetOptionString( $mid, Constants::MODULE_DEACTIVATE, serialize($moduleDeactivateParam) ); COption::SetOptionString( $mid, Constants::CRM_ADDRESS_OPTIONS, serialize($addressDatailOptions) ); COption::SetOptionString( $mid, Constants::CRM_SITES_LIST, serialize($siteListArr) ); COption::SetOptionString( $mid, Constants::CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr(is_array($orderTypesArr) ? $orderTypesArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_DELIVERY_TYPES_ARR, serialize(RCrmActions::clearArr(is_array($deliveryTypesArr) ? $deliveryTypesArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_PAYMENT_TYPES, serialize(RCrmActions::clearArr(is_array($paymentTypesArr) ? $paymentTypesArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_PAYMENT_STATUSES, serialize(RCrmActions::clearArr(is_array($paymentStatusesArr) ? $paymentStatusesArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_PAYMENT, serialize(RCrmActions::clearArr(is_array($paymentArr) ? $paymentArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_ORDER_DISCHARGE, $orderDischarge ); COption::SetOptionString( $mid, Constants::CRM_ORDER_PROPS, serialize(RCrmActions::clearArr(is_array($orderPropsArr) ? $orderPropsArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_CONTRAGENT_TYPE, serialize(RCrmActions::clearArr(is_array($contragentTypeArr) ? $contragentTypeArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_LEGAL_DETAILS, serialize(RCrmActions::clearArr(is_array($legalDetailsArr) ? $legalDetailsArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_ORDER_NUMBERS, htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N' ); COption::SetOptionString( $mid, Constants::CRM_ORDER_VAT, htmlspecialchars(trim($_POST['order-vat'])) ?: 'N' ); ConfigProvider::setTrackNumberStatus(htmlspecialchars(trim($_POST['track-number'])) ?: 'N'); $syncIntegrationPayment = htmlspecialchars(trim($_POST['sync-integration-payment'])) ?: 'N'; if ($syncIntegrationPayment === 'Y') { $substitutionPaymentList = []; foreach (RetailcrmConfigProvider::getIntegrationPaymentTypes() as $integrationPayment) { if (in_array($integrationPayment, $paymentTypesArr)) { $originalPayment = $arResult['paymentTypesList'][$integrationPayment]; $codePayment = $integrationPayment . Constants::CRM_PART_SUBSTITUTED_PAYMENT_CODE; $response = $api->paymentTypesEdit([ 'name' => $originalPayment['name'] . ' ' . GetMessage('NO_INTEGRATION_PAYMENT'), 'code' => $codePayment, 'active' => true, 'description' => GetMessage('DESCRIPTION_AUTO_PAYMENT_TYPE'), 'sites' => $originalPayment['sites'], 'paymentStatuses' => $originalPayment['paymentStatuses'] ]); $statusCode = $response->getStatusCode(); if ($response->isSuccessful()) { $substitutionPaymentList[$integrationPayment] = $codePayment; foreach ($originalPayment['deliveryTypes'] as $codeDelivery) { if (!isset($arResult['deliveryTypesList'][$codeDelivery])) { continue; } $currentDelivery = $arResult['deliveryTypesList'][$codeDelivery]; $deliveryPaymentTypes = $currentDelivery['paymentTypes']; $deliveryPaymentTypes[] = $codePayment; $response = $api->deliveryTypesEdit([ 'code' => $codeDelivery, 'paymentTypes' => $deliveryPaymentTypes, 'name' => $currentDelivery['name'] ]); if (!$response->isSuccessful()) { RCrmActions::eventLog( 'Retailcrm::options.php', 'syncIntegrationPayment::UpdateDelivery', GetMessage('ERROR_LINK_INTEGRATION_PAYMENT') . ' : ' . $response->getResponseBody() ); $error = 'ERR_CHECK_JOURNAL'; } } } else { RCrmActions::eventLog( 'Retailcrm::options.php', 'syncIntegrationPayment', GetMessage('ERROR_LINK_INTEGRATION_PAYMENT') . ' : ' . $response->getResponseBody() ); $syncIntegrationPayment = 'N'; $error = 'ERR_CHECK_JOURNAL'; } } } RetailcrmConfigProvider::setSubstitutionPaymentList($substitutionPaymentList); } ConfigProvider::setSyncIntegrationPayment($syncIntegrationPayment); COption::SetOptionString( $mid, Constants::CRM_COUPON_FIELD, htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N' ); COption::SetOptionString( $mid, Constants::CRM_SEND_PICKUP_POINT_ADDRESS, htmlspecialchars(trim($_POST['send-pickup-point-address'])) ?: 'N' ); COption::SetOptionString( $mid, Constants::CRM_CANCEL_ORDER, serialize(RCrmActions::clearArr(is_array($canselOrderArr) ? $canselOrderArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_INVENTORIES_UPLOAD, $inventoriesUpload ); COption::SetOptionString( $mid, Constants::CRM_STORES, serialize(RCrmActions::clearArr(is_array($bitrixStoresArr) ? $bitrixStoresArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_SHOPS, serialize(RCrmActions::clearArr(is_array($bitrixShopsArr) ? $bitrixShopsArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_IBLOCKS_INVENTORIES, serialize(RCrmActions::clearArr(is_array($bitrixIblocksInventories) ? $bitrixIblocksInventories : [])) ); COption::SetOptionString( $mid, Constants::CRM_PRICES_UPLOAD, $pricesUpload ); COption::SetOptionString( $mid, Constants::USE_CRM_ORDER_METHODS, $useCrmOrderMethods ); COption::SetOptionString( $mid, Constants::CRM_ORDER_METHODS, serialize(RCrmActions::clearArr(is_array($crmOrderMethod) ? $crmOrderMethod : [])) ); COption::SetOptionString( $mid, Constants::CRM_PRICES, serialize(RCrmActions::clearArr(is_array($bitrixPricesArr) ? $bitrixPricesArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_PRICE_SHOPS, serialize(RCrmActions::clearArr(is_array($bitrixPriceShopsArr) ? $bitrixPriceShopsArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_IBLOCKS_PRICES, serialize(RCrmActions::clearArr(is_array($bitrixIblocksPrices) ? $bitrixIblocksPrices : [])) ); COption::SetOptionString( $mid, Constants::CRM_COLLECTOR, $collector ); COption::SetOptionString( $mid, Constants::CRM_COLL_KEY, serialize(RCrmActions::clearArr(is_array($collectorKeys) ? $collectorKeys : [])) ); RetailCrmConfigProvider::setOnlineConsultant($onlineConsultant); RetailCrmConfigProvider::setOnlineConsultantScript($onlineConsultantScript); COption::SetOptionString( $mid, Constants::CRM_UA, $ua ); COption::SetOptionString( $mid, Constants::CRM_UA_KEYS, serialize(RCrmActions::clearArr(is_array($uaKeys) ? $uaKeys : [])) ); COption::SetOptionString( $mid, Constants::CRM_DIMENSIONS, htmlspecialchars(trim($_POST[Constants::CRM_DIMENSIONS])) ?: 'N' ); RetailcrmConfigProvider::setSendPaymentAmount(htmlspecialchars(trim($_POST[Constants::SEND_PAYMENT_AMOUNT])) ?: 'N'); RetailCrmConfigProvider::setDiscountRound($discount_round); RetailcrmConfigProvider::setCart($optionCart); COption::SetOptionString( $mid, Constants::CRM_PURCHASE_PRICE_NULL, $purchasePrice_null ); COption::SetOptionString( $mid, RetailcrmConstants::CRM_SHIPMENT_DEDUCTED, $shipment_deducted); COption::SetOptionString( $mid, Constants::CRM_CC, $cc ); COption::SetOptionString( $mid, Constants::CRM_CORP_SHOPS, serialize(RCrmActions::clearArr(is_array($bitrixCorpShopsArr) ? $bitrixCorpShopsArr : [])) ); COption::SetOptionString( $mid, Constants::CRM_CORP_NAME, $bitrixCorpName ); COption::SetOptionString( $mid, Constants::CRM_CORP_ADDRESS, $bitrixCorpAdres ); if (isset($_POST['custom_fields_toggle']) && $_POST['custom_fields_toggle'] === 'on') { $counter = 1; $customOrderProps = []; $customUserFields = []; foreach ($arResult['bitrixOrdersCustomProp'] as $list) { foreach ($list as $code => $text) { if (!empty($_POST['bitrixOrderFields_' . $code]) && !empty($_POST['crmOrderFields_' . $code])) { $customOrderProps[htmlspecialchars($_POST['bitrixOrderFields_' . $code])] = htmlspecialchars($_POST['crmOrderFields_' . $code]); } } } foreach ($arResult['bitrixCustomUserFields'] as $list) { foreach ($list as $code => $text) { if (!empty($_POST['bitrixUserFields_' . $code]) && !empty($_POST['crmUserFields_' . $code])) { $customUserFields[htmlspecialchars($_POST['bitrixUserFields_' . $code])] = htmlspecialchars($_POST['crmUserFields_' . $code]); } } } ConfigProvider::setCustomFieldsStatus('Y'); ConfigProvider::setMatchedOrderProps($customOrderProps); ConfigProvider::setMatchedUserFields($customUserFields); } else { ConfigProvider::setCustomFieldsStatus('N'); } $request = Application::getInstance()->getContext()->getRequest(); if ($request->isHttps() === true) { COption::SetOptionString($mid, Constants::PROTOCOL, 'https://'); } else { COption::SetOptionString($mid, Constants::PROTOCOL, 'http://'); } if ($error !== null) { $uri .= '&errc=' . $error; } else { $uri .= '&ok=Y'; } LocalRedirect($uri); } else { $api_host = COption::GetOptionString($mid, Constants::CRM_API_HOST_OPTION, 0); $api_key = COption::GetOptionString($mid, Constants::CRM_API_KEY_OPTION , 0); $api = new RetailCrm\ApiClient($api_host, $api_key); // Prepare crm lists try { $credentialsApi = $api->getCredentials()->getResponseBody(); $requiredApiScopes = Constants::REQUIRED_API_SCOPES; if (ConfigProvider::getCustomFieldsStatus() === 'Y') { $requiredApiScopes = array_merge($requiredApiScopes, Constants::REQUIRED_API_SCOPES_CUSTOM); } $residualRight = array_diff($requiredApiScopes, $credentialsApi['scopes']); if (count($residualRight) !== 0) { throw new InvalidArgumentException(sprintf(GetMessage('ERR_403_LABEL'), implode(', ', $residualRight))); } $arResult['orderTypesList'] = $api->orderTypesList()->orderTypes; $arResult['deliveryTypesList'] = $api->deliveryTypesList()->deliveryTypes; $arResult['deliveryServicesList'] = $api->deliveryServicesList()->deliveryServices; $arResult['paymentTypesList'] = $api->paymentTypesList()->paymentTypes; $arResult['paymentStatusesList'] = $api->paymentStatusesList()->paymentStatuses; // --statuses $arResult['paymentList'] = $api->statusesList()->statuses; $arResult['paymentGroupList'] = $api->statusGroupsList()->statusGroups; // -- statuses groups $arResult['sitesList'] = $APPLICATION->ConvertCharsetArray($api->sitesList()->sites, 'utf-8', SITE_CHARSET); $arResult['inventoriesList'] = $APPLICATION->ConvertCharsetArray($api->storesList()->stores, 'utf-8', SITE_CHARSET); $arResult['priceTypeList'] = $APPLICATION->ConvertCharsetArray($api->pricesTypes()->priceTypes, 'utf-8', SITE_CHARSET); $arResult['crmCustomOrderFields'] = []; $arResult['crmCustomUserFields'] = []; if (count(array_diff(Constants::REQUIRED_API_SCOPES_CUSTOM, $credentialsApi['scopes'])) === 0) { $arResult['crmCustomOrderFields'] = $APPLICATION->ConvertCharsetArray( $api->customFieldsList(['entity' => 'order', 'type' => ['string','text', 'numeric', 'boolean', 'date']], 250)->customFields, 'utf-8', SITE_CHARSET ); $arResult['crmCustomUserFields'] = $APPLICATION->ConvertCharsetArray( $api->customFieldsList(['entity' => 'customer', 'type' => ['string', 'text', 'integer', 'numeric', 'boolean', 'date']], 250)->customFields, 'utf-8', SITE_CHARSET ); $enabledCustom = true; } $orderMethods = []; $getOrderMethods = $api->orderMethodsList(); if ($getOrderMethods !== null && $getOrderMethods->isSuccessful()) { foreach ($getOrderMethods->orderMethods as $method) { if (!$method['active']) { continue; } $orderMethods[$method['code']] = $method['name']; } } $arResult['orderMethods'] = $orderMethods; } catch (CurlException $e) { RCrmActions::eventLog( 'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::*List::CurlException', $e->getCode() . ': ' . $e->getMessage() ); echo CAdminMessage::ShowMessage(GetMessage('ERR_' . $e->getCode())); } catch (InvalidArgumentException $e) { $badKey = true; echo CAdminMessage::ShowMessage(['MESSAGE' => sprintf(GetMessage('ERR_403'), $e->getMessage()), 'HTML' => true]); } catch (\RetailCrm\Exception\InvalidJsonException $e) { $badJson = true; echo CAdminMessage::ShowMessage(GetMessage('ERR_JSON')); } $crmCustomOrderFieldsList = []; $crmCustomUserFieldsList = []; foreach ($arResult['crmCustomOrderFields'] as $customField) { $type = $customField['type']; if ($type === 'text') { $type = 'string'; } $crmCustomOrderFieldsList[strtoupper($type) . '_TYPE'][] = ['name' => $customField['name'], 'code' => $customField['code']]; } foreach ($arResult['crmCustomUserFields'] as $customField) { $type = $customField['type']; if ($type === 'text') { $type = 'string'; } $crmCustomUserFieldsList[strtoupper($type). '_TYPE'][] = ['name' => $customField['name'], 'code' => $customField['code']]; } ksort($crmCustomOrderFieldsList); ksort($crmCustomUserFieldsList); $arResult['crmCustomOrderFields'] = $crmCustomOrderFieldsList; $arResult['crmCustomUserFields'] = $crmCustomUserFieldsList; unset($crmCustomOrderFieldsList, $crmCustomUserFieldsList); $arResult['matchedOrderProps'] = ConfigProvider::getMatchedOrderProps(); $arResult['matchedUserFields'] = ConfigProvider::getMatchedUserFields(); $arResult['paymentTypesList'] = RetailCrmService::getAvailableTypes( $availableSites, $api->paymentTypesList()->paymentTypes ); $arResult['paymentTypesList'] = array_filter( $arResult['paymentTypesList'], function ($payment) { return strripos($payment['code'], Constants::CRM_PART_SUBSTITUTED_PAYMENT_CODE) === false; } ); $arResult['deliveryTypesList'] = RetailCrmService::getAvailableTypes( $availableSites, $api->deliveryTypesList()->deliveryTypes ); $integrationPayments = RetailCrmService::selectIntegrationPayments($arResult['paymentTypesList']); $integrationDeliveries = RetailCrmService::selectIntegrationDeliveries($arResult['deliveryTypesList']); RetailcrmConfigProvider::setIntegrationPaymentTypes($integrationPayments); RetailcrmConfigProvider::setIntegrationDelivery($integrationDeliveries); //bitrix orderTypesList -- personTypes $arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']); //bitrix deliveryTypesList $arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList(); //bitrix paymentTypesList $arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList(); //bitrix statusesList $arResult['bitrixPaymentStatusesList'] = RCrmActions::StatusesList(); //bitrix pyament Y/N $arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y'); $arResult['bitrixPaymentList'][0]['ID'] = 'Y'; $arResult['bitrixPaymentList'][1]['NAME'] = GetMessage('PAYMENT_N'); $arResult['bitrixPaymentList'][1]['ID'] = 'N'; //bitrix orderPropsList $arResult['arProp'] = RCrmActions::OrderPropsList(); $arResult['locationProp'] = RCrmActions::getLocationProps(); $arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList(); $arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList(); $arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList(); //saved params $useCrmOrderMethods = ConfigProvider::useCrmOrderMethods(); $crmOrderMethods = unserialize(COption::GetOptionString($mid, Constants::CRM_ORDER_METHODS, 0)); $moduleDeactivate = unserialize(COption::GetOptionString($mid, Constants::MODULE_DEACTIVATE, 'N')); $optionsOrderTypes = unserialize(COption::GetOptionString($mid, Constants::CRM_ORDER_TYPES_ARR, 0)); $optionsDelivTypes = unserialize(COption::GetOptionString($mid, Constants::CRM_DELIVERY_TYPES_ARR, 0)); $optionsPayTypes = unserialize(COption::GetOptionString($mid, Constants::CRM_PAYMENT_TYPES, 0)); $optionsPayStatuses = unserialize(COption::GetOptionString($mid, Constants::CRM_PAYMENT_STATUSES, 0)); $optionsPayment = unserialize(COption::GetOptionString($mid, Constants::CRM_PAYMENT, 0)); $optionsSitesList = unserialize(COption::GetOptionString($mid, Constants::CRM_SITES_LIST, 0)); $optionsDischarge = (int) COption::GetOptionString($mid, Constants::CRM_ORDER_DISCHARGE, 0); $optionsOrderProps = unserialize(COption::GetOptionString($mid, Constants::CRM_ORDER_PROPS, 0)); $optionsContragentType = unserialize(COption::GetOptionString($mid, Constants::CRM_CONTRAGENT_TYPE, 0)); $optionsLegalDetails = unserialize(COption::GetOptionString($mid, Constants::CRM_LEGAL_DETAILS, 0)); $optionsCustomFields = unserialize(COption::GetOptionString($mid, Constants::CRM_CUSTOM_FIELDS, 0)); $optionsOrderNumbers = COption::GetOptionString($mid, Constants::CRM_ORDER_NUMBERS, 0); $optionsOrderVat = COption::GetOptionString($mid, Constants::CRM_ORDER_VAT, 0); $optionsOrderTrackNumber = ConfigProvider::getTrackNumberStatus(); $optionsSyncIntegrationPayment = ConfigProvider::getSyncIntegrationPayment(); $canselOrderArr = unserialize(COption::GetOptionString($mid, Constants::CRM_CANCEL_ORDER, 0)); $sendPickupPointAddress = COption::GetOptionString($mid, Constants::CRM_SEND_PICKUP_POINT_ADDRESS, 'N'); $optionInventotiesUpload = COption::GetOptionString($mid, Constants::CRM_INVENTORIES_UPLOAD, 0); $optionStores = unserialize(COption::GetOptionString($mid, Constants::CRM_STORES, 0)); $optionShops = unserialize(COption::GetOptionString($mid, Constants::CRM_SHOPS, 0)); $optionIblocksInventories = unserialize(COption::GetOptionString($mid, Constants::CRM_IBLOCKS_INVENTORIES, 0)); $optionShopsCorporate = unserialize(COption::GetOptionString($mid, Constants::CRM_SHOPS, 0)); $optionPricesUpload = COption::GetOptionString($mid, Constants::CRM_PRICES_UPLOAD, 0); $optionPrices = unserialize(COption::GetOptionString($mid, Constants::CRM_PRICES, 0)); $optionPriceShops = unserialize(COption::GetOptionString($mid, Constants::CRM_PRICE_SHOPS, 0)); $optionIblocksPrices = unserialize(COption::GetOptionString($mid, Constants::CRM_IBLOCKS_PRICES, 0)); $optionCollector = COption::GetOptionString($mid, Constants::CRM_COLLECTOR, 0); $optionCollectorKeys = unserialize(COption::GetOptionString($mid, Constants::CRM_COLL_KEY)); $optionOnlineConsultant = RetailcrmConfigProvider::isOnlineConsultantEnabled(); $optionOnlineConsultantScript = RetailcrmConfigProvider::getOnlineConsultantScript(); $optionUa = COption::GetOptionString($mid, Constants::CRM_UA, 0); $optionUaKeys = unserialize(COption::GetOptionString($mid, Constants::CRM_UA_KEYS)); $optionDiscRound = COption::GetOptionString($mid, Constants::CRM_DISCOUNT_ROUND, 0); $optionPricePrchaseNull = COption::GetOptionString($mid, Constants::CRM_PURCHASE_PRICE_NULL, 0); $optionShipmentDeducted = RetailcrmConfigProvider::getShipmentDeducted(); //corporate-cliente $optionCorpClient = COption::GetOptionString($mid, Constants::CRM_CC, 0); $optionCorpShops = unserialize(COption::GetOptionString($mid, Constants::CRM_CORP_SHOPS, 0)); $optionsCorpComName = COption::GetOptionString($mid, Constants::CRM_CORP_NAME, 0); $optionsCorpAdres = COption::GetOptionString($mid, Constants::CRM_CORP_ADDRESS, 0); $version = COption::GetOptionString($mid, Constants::CRM_API_VERSION, 0); $optionsFixDateCustomer = COption::GetOptionString($mid, RetailcrmConstants::OPTION_FIX_DATE_CUSTOMER, 0); // Old functional $currencyOption = COption::GetOptionString($mid, Constants::CRM_CURRENCY, 0) ?: CCurrency::GetBaseCurrency(); //Validate currency $currencyList = CurrencyManager::getCurrencyList(); $errorsText = []; if (preg_match('/&errc=ERR_(.*)/is', $APPLICATION->GetCurUri(), $matches)) { $errorsText[] = GetMessage(urldecode($matches[1])); } if (empty($errorsText)) { if (count($arResult['arSites']) === 1 && count($arResult['sitesList']) > 1) { $errorsText[] = GetMessage('ERR_COUNT_SITES'); } if (count($arResult['arSites']) > 1) { foreach ($optionsSitesList as $LID => $crmCode) { if (empty($crmCode)) { continue; } $cmsCurrency = $arResult['arCurrencySites'][$LID] ?? null; $crmCurrency = $arResult['sitesList'][$crmCode]['currency'] ?? null; $crmSiteName = $arResult['sitesList'][$crmCode]['name'] ?? null; $errorCode = CurrencyService::validateCurrency($cmsCurrency, $crmCurrency); if ($errorCode === 'ERR_CMS_CURRENCY') { $errorsText[] = GetMessage($errorCode) . ' (' . $LID . ')'; } elseif($errorCode !== '') { $errorsText[] = GetMessage($errorCode) . ' (' . GetMessage('CRM_STORE') . $crmSiteName . ')'; } } } else { $LID = $arResult['arSites'][0]['LID'] ?? null; $cmsCurrency = $arResult['arCurrencySites'][$LID] ?? null; $crmSiteData = reset($arResult['sitesList']); $crmCurrency = $crmSiteData['currency'] ?? null; $errorsText[] = GetMessage(CurrencyService::validateCurrency($cmsCurrency, $crmCurrency)); } } $customFields = [['code' => '__default_empty_value__', 'name' => GetMessage('SELECT_VALUE')]]; $crmCouponFieldOption = COption::GetOptionString($mid, Constants::CRM_COUPON_FIELD, 0) ?: null; $page = 1; do { $getCustomFields = $api->customFieldsList(['entity' => 'order', 'type' => ['string', 'text']], 100, $page); if (!$getCustomFields->isSuccessful() && empty($getCustomFields['customFields'])) { break; } foreach ($getCustomFields['customFields'] as $customField) { $customFields[] = $customField; } $page++; } while($getCustomFields['pagination']['currentPage'] < $getCustomFields['pagination']['totalPageCount']); $optionsOrderDimensions = COption::GetOptionString($mid, Constants::CRM_DIMENSIONS, 'N'); $addressOptions = unserialize(COption::GetOptionString($mid, Constants::CRM_ADDRESS_OPTIONS, 0)); $optionCart = COption::GetOptionString($mid, Constants::CART, 'N'); //loyalty program options $loyaltyProgramToggle = ConfigProvider::getLoyaltyProgramStatus(); $aTabs = [ [ "DIV" => "edit1", "TAB" => GetMessage('ICRM_OPTIONS_GENERAL_TAB'), "ICON" => "", "TITLE" => GetMessage('ICRM_OPTIONS_GENERAL_CAPTION'), ], [ "DIV" => "edit2", "TAB" => GetMessage('ICRM_OPTIONS_CATALOG_TAB'), "ICON" => '', "TITLE" => GetMessage('ICRM_OPTIONS_CATALOG_CAPTION'), ], [ "DIV" => "edit3", "TAB" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_TAB'), "ICON" => '', "TITLE" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_CAPTION'), ], [ "DIV" => "edit4", "TAB" => GetMessage('LOYALTY_PROGRAM_TITLE'), "ICON" => '', "TITLE" => GetMessage('ICRM_OPTIONS_LOYALTY_PROGRAM_CAPTION'), ], [ "DIV" => "edit5", "TAB" => GetMessage('CUSTOM_FIELDS_TITLE'), "ICON" => '', "TITLE" => GetMessage('CUSTOM_FIELDS_CAPTION'), ], [ "DIV" => "edit6", "TAB" => GetMessage('UPLOAD_ORDERS_OPTIONS'), "ICON" => '', "TITLE" => GetMessage('ORDER_UPLOAD'), ], [ "DIV" => "edit7", "TAB" => GetMessage('OTHER_OPTIONS'), "ICON" => '', "TITLE" => GetMessage('ICRM_OPTIONS_OTHER_CAPTION'), ] ]; $tabControl = new CAdminTabControl("tabControl", $aTabs); $tabControl->Begin(); ?> getCode() . ': ' . $exception->getMessage() ); } ?>
BeginNextTab(); ?> 1): ?> BeginNextTab(); ?> >



BeginNextTab(); ?> 4) { echo 'class="address-detail-' . $bitrixOrderType['ID'] . '"'; } if (($countProps > 4) && ($addressOptions[$bitrixOrderType['ID']] === 0)) { echo 'style="display:none;"'; } ?>> > > BeginNextTab(); ?>
>


()


()



()

BeginNextTab(); ?>

>
$crmField) {?>
      

$crmField) {?>
      
              BeginNextTab(); ?>

0%
0%

BeginNextTab(); ?> ', $warningMessage); } ?>

0) : ?> > > > > > > 0) : ?> > > > > > > > > () > () > > > > > > > > >

Buttons(); ?> End(); ?>