1
0
mirror of synced 2024-11-22 13:26:10 +03:00
bitrix-module/intaro.retailcrm/export/export_setup.php

783 lines
39 KiB
PHP
Raw Normal View History

2021-09-08 10:05:09 +03:00
<?php
use Intaro\RetailCrm\Icml\SettingsService;
CModule::IncludeModule('intaro.retailcrm');
/**
* Документация по шаблонам экспорта:
* @link https://dev.1c-bitrix.ru/api_help/catalog/templates.php
*
* Предопределенные переменные:
*
* Ранее сохраненные настройки экспорта из SETUP_VARS b_catalog_export
* @var $arOldSetupVars
*
* @var $APPLICATION
* @var $ACTION
*
* 1 - вывод настроек, 2 - сохранение формы с настройками
* @var $STEP
* @var $PROFILE_ID
* @var $SETUP_FILE_NAME
* @var $SETUP_PROFILE_NAME
*/
//TODO заменить вызов на сервис-локатор, когда он приедет
$settingsService = SettingsService::getInstance(
$arOldSetupVars ?? [],
2021-09-08 10:05:09 +03:00
$ACTION
);
$isSetupModulePage = $settingsService->isSetupModulePage();
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/export_setup.php')) {
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/retailcrm/export_setup.php');
return;
}
2015-05-18 17:38:06 +03:00
2021-09-08 10:05:09 +03:00
if (!check_bitrix_sessid()) {
return;
}
2015-05-18 17:38:06 +03:00
2021-09-08 10:05:09 +03:00
__IncludeLang(GetLangFileName(
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/lang/',
'/icml_export_setup.php')
);
$basePriceId = RetailcrmConfigProvider::getCrmBasePrice($_REQUEST['PROFILE_ID']);
$priceTypes = $settingsService->priceTypes;
$iblockFieldsName = $settingsService->getIblockFieldsNames();
$units = $settingsService->getUnitsNames();
$hintUnit = $settingsService->getHintUnit();
//highloadblock
if (CModule::IncludeModule('highloadblock')) {
$hlblockModule = true;
$hlBlockList = $settingsService->getHlBlockList();
}
2015-05-18 17:38:06 +03:00
2021-09-08 10:05:09 +03:00
if (($ACTION === 'EXPORT' || $ACTION === 'EXPORT_EDIT' || $ACTION === 'EXPORT_COPY') && $STEP === 1) {
2022-06-14 12:00:14 +03:00
$SETUP_FILE_NAME = $settingsService->setupFileName;
$SETUP_PROFILE_NAME = $settingsService->setupProfileName;
2021-09-08 10:05:09 +03:00
$loadPurchasePrice = $settingsService->loadPurchasePrice;
$iblockExport = $settingsService->iblockExport;
$loadNonActivity = $settingsService->loadNonActivity;
2013-09-13 16:15:54 +04:00
2021-09-08 10:05:09 +03:00
if ($iblockExport) {
$maxOffersValue = $settingsService->getSingleSetting('maxOffersValue');
2015-05-18 17:38:06 +03:00
}
2021-09-08 10:05:09 +03:00
$settingsService->setProps();
2018-05-23 12:19:59 +03:00
2021-09-08 10:05:09 +03:00
$iblockPropertySku = $settingsService->iblockPropertySku;
$iblockPropertyUnitSku = $settingsService->iblockPropertyUnitSku;
$iblockPropertyProduct = $settingsService->iblockPropertyProduct;
$iblockPropertyUnitProduct = $settingsService->iblockPropertyUnitProduct;
2018-05-23 12:19:59 +03:00
2021-09-08 10:05:09 +03:00
$boolAll = false;
$intCountChecked = 0;
$intCountAvailIBlock = 0;
}
2013-08-20 12:53:32 +04:00
2021-09-08 10:05:09 +03:00
if (!isset($iblockExport) || !is_array($iblockExport)) {
$iblockExport = [];
}
2015-05-18 17:38:06 +03:00
2021-09-08 10:05:09 +03:00
[$arIBlockList, $intCountChecked, $intCountAvailIBlock, $isExportIblock]
= $settingsService->getSettingsForIblocks();
2015-05-18 17:38:06 +03:00
2021-09-08 10:05:09 +03:00
if (count($iblockExport) !== 0) {
if ($intCountChecked === $intCountAvailIBlock) {
$boolAll = true;
2013-08-20 12:53:32 +04:00
}
2021-09-08 10:05:09 +03:00
} else {
$intCountChecked = $intCountAvailIBlock;
$boolAll = true;
}
2013-08-20 12:53:32 +04:00
2021-09-08 10:05:09 +03:00
//Проверка на ошибки
$STEP = $settingsService->returnIfErrors($STEP, $SETUP_FILE_NAME, $SETUP_PROFILE_NAME);
2013-08-20 12:53:32 +04:00
2021-09-08 10:05:09 +03:00
//Отображение формы
if ($STEP === 1) {
2015-05-18 17:38:06 +03:00
?>
2021-09-08 10:05:09 +03:00
<style>
2015-05-18 17:38:06 +03:00
.iblock-export-table-display-none {
display: none;
}
</style>
2013-09-13 16:15:54 +04:00
2021-09-08 10:05:09 +03:00
<form method="post" action="<?=$APPLICATION->GetCurPage()?>">
<?php
if ($ACTION === 'EXPORT_EDIT' || $ACTION === 'EXPORT_COPY') {
2015-05-18 17:38:06 +03:00
?>
2021-09-08 10:05:09 +03:00
<input type="hidden" name="PROFILE_ID" value="<?=(int)$PROFILE_ID?>">
<?php
2015-05-18 17:38:06 +03:00
}
?>
2021-09-08 10:05:09 +03:00
<h3><?=GetMessage('SETTINGS_INFOBLOCK')?></h3>
<span class="text"><?=GetMessage('EXPORT_CATALOGS');?><br><br></span>
<span class="text" style="font-weight: bold;"><?=GetMessage('CHECK_ALL_INFOBLOCKS')?></span>
2015-05-18 17:38:06 +03:00
<input
style="vertical-align: middle;"
type="checkbox"
name="icml_export_all"
id="icml_export_all"
value="Y"
2021-09-08 10:05:09 +03:00
onclick="checkAll(this,<?=$intCountAvailIBlock?>);"
<?=($boolAll ? ' checked' : '')?>>
2015-05-18 17:38:06 +03:00
</br>
</br>
2013-09-13 16:15:54 +04:00
<div>
2021-09-08 10:05:09 +03:00
<?php
$checkBoxCounter = 0;
//Перебираем все торговые каталоги, формируя для каждого таблицу настроек
foreach ($arIBlockList as $arIBlock) {
?>
2015-05-18 17:38:06 +03:00
<div>
2021-09-08 10:05:09 +03:00
<div>
<span class="text" style="font-weight: bold;">
<?= htmlspecialcharsex('['
. $arIBlock['IBLOCK_TYPE_ID']
. '] '
. $arIBlock['NAME']
. ' '
. $arIBlock['SITE_LIST']) ?>
</span>
<input
type="checkbox"
name="iblockExport[<?=$arIBlock['ID']?>]"
id="iblockExport<?=++$checkBoxCounter?>"
value="<?=$arIBlock['ID']?>"
<?php
if ($arIBlock['iblockExport']) {
echo ' checked';
} ?>
onclick="checkOne(this,<?=$intCountAvailIBlock?>);"
>
</div>
<br>
<div id="iblockExportTable<?=$checkBoxCounter?>" class="iblockExportTable"
data-type="<?=$arIBlock['ID']?>">
<table class="adm-list-table" id="export_setup"
<?=($arIBlock['PROPERTIES_SKU'] === null ? 'style="width: 66%;"' : '')?>
>
<thead>
2015-05-18 17:38:06 +03:00
<tr class="adm-list-table-header">
2013-09-13 16:15:54 +04:00
<td class="adm-list-table-cell">
2021-09-08 10:05:09 +03:00
<div class="adm-list-table-cell-inner"><?=GetMessage('LOADED_PROPERTY');?></div>
2013-09-13 16:15:54 +04:00
</td>
2015-05-18 17:38:06 +03:00
<td class="adm-list-table-cell">
2021-09-08 10:05:09 +03:00
<div class="adm-list-table-cell-inner">
<?=GetMessage('PROPERTY_PRODUCT_HEADER_NAME')?>
</div>
2015-05-18 17:38:06 +03:00
</td>
2021-09-08 10:05:09 +03:00
<?php
if ($arIBlock['PROPERTIES_SKU'] !== null) {?>
2015-05-18 17:38:06 +03:00
<td class="adm-list-table-cell">
2021-09-08 10:05:09 +03:00
<div class="adm-list-table-cell-inner">
<?=GetMessage('PROPERTY_OFFER_HEADER_NAME');?>
</div>
2015-05-18 17:38:06 +03:00
</td>
2021-09-08 10:05:09 +03:00
<?php
} ?>
2015-05-18 17:38:06 +03:00
</tr>
2021-09-08 10:05:09 +03:00
</thead>
<tbody>
2014-04-15 20:31:11 +04:00
2021-09-08 10:05:09 +03:00
<?php
foreach ($settingsService->actrualPropList as $propertyKey => $property) {
2021-09-08 10:05:09 +03:00
$productSelected = false; ?>
2014-01-23 16:55:04 +04:00
2015-05-18 17:38:06 +03:00
<tr class="adm-list-table-row">
<td class="adm-list-table-cell">
2021-09-08 10:05:09 +03:00
<?=htmlspecialcharsex($property)?>
2015-05-18 17:38:06 +03:00
</td>
<td class="adm-list-table-cell">
2021-09-08 10:05:09 +03:00
<select
style="width: 200px;"
id="iblockPropertyProduct_<?=$propertyKey . $arIBlock['ID']?>"
name="iblockPropertyProduct_<?=$propertyKey?>[<?=$arIBlock['ID']?>]"
class="property-export"
data-type="<?=$propertyKey?>"
onchange="propertyChange(this);">
<option value=""></option>
<?php
if ($settingsService->isOptionHasPreset($propertyKey)) {
?>
<optgroup label="<?=GetMessage('SELECT_FIELD_NAME')?>">
<?php
foreach ($iblockFieldsName as $keyField => $field) {
if ($keyField === $propertyKey) { ?>
<option value="<?=$field['CODE']?>"
<?php
$productSelected = $settingsService->isOptionSelected(
$field,
$arIBlock['OLD_PROPERTY_PRODUCT_SELECT'],
$propertyKey
);
2015-05-18 17:38:06 +03:00
?>
2021-09-08 10:05:09 +03:00
<?= $productSelected ? ' selected' : ''?>
>
<?=$field['name']?>
2015-05-18 17:38:06 +03:00
</option>
2021-09-08 10:05:09 +03:00
<?php
}
} ?>
</optgroup>
<optgroup label="<?=GetMessage('SELECT_PROPERTY_NAME')?>">
<?php
}
$productHlTableName = '';
foreach ($arIBlock['PROPERTIES_PRODUCT'] as $prop) { ?>
<option value="<?=$prop['CODE']?>"
<?php
echo $settingsService->getOptionClass($prop, true);
$productSelected = $settingsService->isOptionSelected(
$prop,
$arIBlock['OLD_PROPERTY_PRODUCT_SELECT'],
$propertyKey
);
$productHlTableName
= $settingsService->getHlTableName($prop)
?? $productHlTableName;
echo $productSelected ? ' selected' : '';
?>
>
<?=$prop['NAME']?>
</option>
<?php
}
if ($settingsService->isOptionHasPreset($propertyKey)) {
?>
</optgroup>
<?php
} ?>
</select>
<?php
if ($settingsService->isHlSelected(
$propertyKey,
$arIBlock['ID'],
$productHlTableName,
'_product'
)
) {?>
<select name="highloadblock_product<?=$productHlTableName . '_' .
$propertyKey . '[' . $arIBlock['ID'] . ']' ?>" id="highloadblock"
style="width: 100px; margin-left: 50px;">
<?php
foreach ($hlBlockList[$productHlTableName]['FIELDS'] as $field) {
?>
<option value="<?=$field?>"
<?= $settingsService->getHlOptionStatus(
$productHlTableName,
$propertyKey,
$arIBlock['ID'],
(string) $field,
'highloadblock_product'
) ?>
>
<?=$field?>
</option>
<?php
} ?>
</select>
<?php
}
2015-05-18 17:38:06 +03:00
2021-09-08 10:05:09 +03:00
//Единицы измерения для товаров
if (array_key_exists($propertyKey, $iblockFieldsName)) :?>
<select
style="width: 100px; margin-left: 50px;"
id="iblockPropertyUnitProduct_<?=$propertyKey . $arIBlock['ID']?>"
name="iblockPropertyUnitProduct_<?=$propertyKey?>[<?=$arIBlock['ID']?>]"
>
<?php
foreach ($units as $unitTypeName => $unitType) { ?>
<?php
if ($unitTypeName == $iblockFieldsName[$propertyKey]['unit']): ?>
<?php
foreach ($unitType as $keyUnit => $unit): ?>
<option value="<?=$keyUnit?>"
<?=$settingsService->getUnitOptionStatus(
$arIBlock['OLD_PROPERTY_UNIT_PRODUCT_SELECT'],
$keyUnit,
$propertyKey,
(string) $unitTypeName
)
?>
>
<?=$unit?>
</option>
<?php
endforeach; ?>
<?php
endif; ?>
<?php
} ?>
2015-05-18 17:38:06 +03:00
</select>
2021-09-08 10:05:09 +03:00
<?php
endif; ?>
2015-05-18 17:38:06 +03:00
</td>
2021-09-08 10:05:09 +03:00
<?php
//Столбец со свойствами тороговых предложений
if ($arIBlock['PROPERTIES_SKU'] !== null) {?>
2015-05-18 17:38:06 +03:00
<td class="adm-list-table-cell">
<select
style="width: 200px;"
2021-09-08 10:05:09 +03:00
id="iblockPropertySku_<?=$propertyKey?><?=$arIBlock['ID']?>"
name="iblockPropertySku_<?=$propertyKey?>[<?=$arIBlock['ID']?>]"
2015-05-18 17:38:06 +03:00
class="property-export"
2021-09-08 10:05:09 +03:00
data-type="<?=$propertyKey?>"
2015-05-18 17:38:06 +03:00
onchange="propertyChange(this);">
2021-09-08 10:05:09 +03:00
<option value=""></option>
<?php
if ($settingsService->isOptionHasPreset($propertyKey)) {
?>
<optgroup label="<?=GetMessage('SELECT_FIELD_NAME');?>">
<?php
foreach ($iblockFieldsName as $keyField => $field) {
if ($keyField === $propertyKey) :?>
<option value="<?=$field['CODE']?>"
<?php
$isSelected = $settingsService->isOptionSelected(
$field,
$arIBlock['OLD_PROPERTY_SKU_SELECT'],
$propertyKey
);
echo $isSelected ? ' selected' : '';
?>
>
<?=$field['name']?>
</option>
<?php
endif;
} ?>
</optgroup>
<optgroup label="<?=GetMessage('SELECT_PROPERTY_NAME');?>">
<?php
}
$skuHlTableName = '';
foreach ($arIBlock['PROPERTIES_SKU'] as $prop) { ?>
<option value="<?=$prop['CODE']?>"
<?php
echo $settingsService->getOptionClass($prop, false);
2015-05-18 17:38:06 +03:00
if (!$productSelected) {
2021-09-08 10:05:09 +03:00
$isSelected = $settingsService->isOptionSelected(
$prop,
$arIBlock['OLD_PROPERTY_SKU_SELECT'],
$propertyKey
);
$skuHlTableName
= $settingsService->getHlTableName($prop)
?? $skuHlTableName;
echo $isSelected ? ' selected' : '';
2015-05-18 17:38:06 +03:00
}
?>
2021-09-08 10:05:09 +03:00
>
<?=$prop['NAME']?>
2015-05-18 17:38:06 +03:00
</option>
2021-09-08 10:05:09 +03:00
<?php
}
if ($settingsService->isOptionHasPreset($propertyKey)) {
?>
</optgroup>
<?php
} ?>
2014-01-23 16:55:04 +04:00
</select>
2021-09-08 10:05:09 +03:00
<?php
if (
$settingsService->isHlSelected(
$propertyKey,
$arIBlock['ID'],
$skuHlTableName
)
) { ?>
<select
name="highloadblock<?=$skuHlTableName . '_' . $propertyKey . '['
. $arIBlock['ID'] . ']'?>"
id="highloadblock"
style="width: 100px;
margin-left: 50px;"
>
<?php
foreach ($hlBlockList[$skuHlTableName]['FIELDS'] as $field)
: ?>
<option value="<?=$field?>"
<?=
$settingsService->getHlOptionStatus(
$skuHlTableName,
$propertyKey,
$arIBlock['ID'],
(string) $field,
'highloadblock'
)?>
>
<?=$field?>
</option>
<?php
endforeach; ?>
2018-03-22 16:11:04 +03:00
</select>
2021-09-08 10:05:09 +03:00
<?php
}
if (array_key_exists($propertyKey, $iblockFieldsName)) {?>
2015-05-18 17:38:06 +03:00
<select
style="width: 100px; margin-left: 50px;"
2021-09-08 10:05:09 +03:00
id="iblockPropertyUnitSku_<?=$propertyKey?><?=$arIBlock['ID']?>"
name="iblockPropertyUnitSku_<?=$propertyKey?>[<?=$arIBlock['ID']?>]"
>
<?php
foreach ($units as $unitTypeName => $unitType) {
if ($unitTypeName == $iblockFieldsName[$propertyKey]['unit']) {
foreach ($unitType as $keyUnit => $unit) { ?>
<option value="<?=$keyUnit?>"
<?php
echo $settingsService->getUnitOptionStatus(
$arIBlock['OLD_PROPERTY_UNIT_SKU_SELECT'],
$keyUnit,
$propertyKey,
$unitTypeName
);
2015-05-18 17:38:06 +03:00
?>
2021-09-08 10:05:09 +03:00
>
2015-05-18 17:38:06 +03:00
<?=$unit?>
</option>
2021-09-08 10:05:09 +03:00
<?php
}
}
} ?>
2015-05-18 17:38:06 +03:00
</select>
2021-09-08 10:05:09 +03:00
<?php
} ?>
2015-05-18 17:38:06 +03:00
</td>
2021-09-08 10:05:09 +03:00
<?php
} ?>
2015-05-18 17:38:06 +03:00
</tr>
2021-09-08 10:05:09 +03:00
<?php
} ?>
</tbody>
</table>
<br>
<br>
</div>
2015-05-18 17:38:06 +03:00
</div>
2021-09-08 10:05:09 +03:00
<?php
} ?>
2013-09-13 16:15:54 +04:00
</div>
2021-09-08 10:05:09 +03:00
<input type="hidden" name="count_checked" id="count_checked" value="<?=$intCountChecked?>">
2015-05-18 17:38:06 +03:00
<br>
2021-09-08 10:05:09 +03:00
<h3><?=GetMessage('SETTINGS_EXPORT')?></h3>
<span class="text"><?=GetMessage('FILENAME')?><br><br></span>
2022-06-14 12:00:14 +03:00
<input type="text" name="SETUP_FILE_NAME" value="<?=htmlspecialcharsbx(strlen($SETUP_FILE_NAME) > 0 ?
$SETUP_FILE_NAME : $settingsService->setupFileName); ?>" size="50"><br><br>
2021-09-08 10:05:09 +03:00
<span class="text"><?=GetMessage('LOAD_PURCHASE_PRICE')?>&nbsp;</span>
<input type="checkbox" name="loadPurchasePrice" value="Y" <?=$loadPurchasePrice === 'Y' ? 'checked' : ''?>>
<br><br>
<span class="text"><?=GetMessage('LOAD_NON_ACTIVITY')?>&nbsp;</span>
<input type="checkbox" name="loadNonActivity" value="Y" <?=$loadNonActivity === 'Y' ? 'checked' : ''?>>
<br><br>
2021-09-08 10:05:09 +03:00
<?php
if ($isSetupModulePage) { ?>
<span class="text"><?=GetMessage('AGENT_LOADING')?>&nbsp;</span>
<input id="add-agent" type="checkbox" name="NEED_CATALOG_AGENT" value="agent"><br><br>
<span class="text" style="font-weight: bold; font-size: 14px"><?=GetMessage('LOAD_NOW')?>&nbsp;</span>
<input id="load-now" type="checkbox" onchange="checkLoadStatus(this)" name="LOAD_NOW" value="now"><br>
2013-08-20 12:53:32 +04:00
<br>
<div id="loadMessageNow" hidden><?=GetMessage('LOAD_NOW_MSG')?></div>
2013-08-20 12:53:32 +04:00
<br>
2021-09-08 10:05:09 +03:00
<?php
}?>
2013-08-26 10:33:51 +04:00
2021-09-08 10:05:09 +03:00
<span class="text"><?=GetMessage('BASE_PRICE')?>&nbsp;</span>
2015-05-18 17:38:06 +03:00
<select name="price-types" class="typeselect">
<option value=""></option>
2021-09-08 10:05:09 +03:00
<?php
foreach ($priceTypes as $priceType) { ?>
<option value="<?=$priceType['ID']?>" <?= $priceType['ID'] == $basePriceId ? ' selected' : ''?>>
<?=$priceType['NAME']?>
2015-05-18 17:38:06 +03:00
</option>
2021-09-08 10:05:09 +03:00
<?php
} ?>
</select><br><br><br>
<?php
if ($ACTION === 'EXPORT_SETUP' || $ACTION === 'EXPORT_EDIT' || $ACTION === 'EXPORT_COPY') { ?>
<span class="text"><?=GetMessage('OFFERS_VALUE')?><br><br></span>
<label>
<input
type="text"
name="maxOffersValue"
value="<?=htmlspecialchars($maxOffersValue)?>"
size="15">
</label><br><br><br>
<span class="text"><?=GetMessage('PROFILE_NAME')?><br><br></span>
<label>
<input
type="text"
name="SETUP_PROFILE_NAME"
2022-06-14 12:00:14 +03:00
value="<?=htmlspecialchars(strlen($SETUP_PROFILE_NAME) > 0 ?
$SETUP_PROFILE_NAME : $settingsService->setupProfileName)?>"
2021-09-08 10:05:09 +03:00
size="50">
</label><br><br><br>
<?php
2022-06-14 12:00:14 +03:00
}
?>
2021-09-08 10:05:09 +03:00
<?=bitrix_sessid_post()?>
<?php
if ($isSetupModulePage) { ?>
<input type="hidden" name="lang" value="<?= LANG; ?>">
<input type="hidden" name="id" value="intaro.retailcrm">
<input type="hidden" name="install" value="Y">
<input type="hidden" name="step" value="6">
<input type="hidden" name="continue" value="5">
<div style="padding: 1px 13px 2px; height:28px;">
<div align="right" style="float:right; width:50%; position:relative;">
<input type="submit" name="inst" onclick="BX.showWait()" value="<?= GetMessage('MOD_NEXT_STEP'); ?>"
class="adm-btn-save">
</div>
<div align="left" style="float:right; width:50%; position:relative;">
<input type="submit" name="back" value="<?= GetMessage('MOD_PREV_STEP'); ?>" class="adm-btn-save">
</div>
</div>
2015-05-18 17:38:06 +03:00
2021-09-08 10:05:09 +03:00
<?php
} else {?>
<input type="hidden" name="lang" value="<?=LANGUAGE_ID?>">
<input type="hidden" name="ACT_FILE" value="<?=htmlspecialcharsbx($_REQUEST['ACT_FILE'])?>">
<input type="hidden" name="ACTION" value="<?=htmlspecialcharsbx($ACTION)?>">
<input type="hidden" name="STEP" value="<?=$STEP + 1?>">
<input type="hidden" name="SETUP_FIELDS_LIST" value="<?=
$settingsService->getSetupFieldsString(
array_keys($settingsService->actrualPropList) ?? [],
2021-09-08 10:05:09 +03:00
$hlblockModule === true,
$hlBlockList ?? []
)
?>">
<input type="submit" value="<?=($ACTION === 'EXPORT') ? GetMessage('EXPORT') : GetMessage('SAVE')?>">
<?php
} ?>
</form>
2015-05-18 17:38:06 +03:00
<?php CJSCore::Init(['jquery']);?>
2021-09-08 10:05:09 +03:00
<script type="text/javascript">
function checkLoadStatus(object)
{
if (object.checked) {
$('#loadMessageNow').show();
2021-09-08 10:05:09 +03:00
} else {
$('#loadMessageNow').hide();
2021-09-08 10:05:09 +03:00
}
}
function checkAll(obj, cnt) {
for (let i = 0; i < cnt; i++) {
if (obj.checked) {
BX.removeClass('iblockExportTable' + (i + 1), "iblock-export-table-display-none");
}
}
const table = BX(obj.id.replace('iblockExport', 'iblockExportTable'));
if (obj.checked) {
BX.removeClass(table, "iblock-export-table-display-none");
}
const easing = new BX.easing({
duration: 150,
start: {opacity: obj.checked ? 0 : 100},
finish: {opacity: obj.checked ? 100 : 0},
transition: BX.easing.transitions.linear,
step: function(state) {
for (let i = 0; i < cnt; i++) {
BX('iblockExportTable' + (i + 1)).style.opacity = state.opacity / 100;
2015-05-18 17:38:06 +03:00
}
2021-09-08 10:05:09 +03:00
},
complete: function() {
for (let i = 0; i < cnt; i++) {
if (!obj.checked) {
BX.addClass('iblockExportTable' + (i + 1), "iblock-export-table-display-none");
2018-03-22 16:11:04 +03:00
}
2015-05-18 17:38:06 +03:00
}
2021-09-08 10:05:09 +03:00
}
});
easing.animate();
const boolCheck = obj.checked;
for (let i = 0; i < cnt; i++) {
BX('iblockExport' + (i + 1)).checked = boolCheck;
}
BX('count_checked').value = (boolCheck ? cnt : 0);
}
function checkOne(obj, cnt) {
const table = BX(obj.id.replace('iblockExport', 'iblockExportTable'));
if (obj.checked) {
BX.removeClass(table, "iblock-export-table-display-none");
}
2018-05-23 12:19:59 +03:00
2021-09-08 10:05:09 +03:00
const easing = new BX.easing({
duration: 150,
start: {opacity: obj.checked ? 0 : 100},
finish: {opacity: obj.checked ? 100 : 0},
transition: BX.easing.transitions.linear,
step: function(state) {
table.style.opacity = state.opacity / 100;
},
complete: function() {
if (!obj.checked) {
BX.addClass(table, "iblock-export-table-display-none");
2018-05-23 12:19:59 +03:00
}
2021-09-08 10:05:09 +03:00
}
});
easing.animate();
const boolCheck = obj.checked;
let intCurrent = parseInt(BX('count_checked').value);
intCurrent += (boolCheck ? 1 : -1);
BX('icml_export_all').checked = (intCurrent >= cnt);
BX('count_checked').value = intCurrent;
}
function propertyChange(obj) {
let selectedOption = $(obj).find('option')[obj.selectedIndex];
if (selectedOption.className === 'not-highloadblock') {
let objId = '#' + obj.id;
$(objId).parent().children('#highloadblock').remove();
}
if (selectedOption.className === 'highloadblock') {
getHlTablesFromController(selectedOption, 'sku', obj.getAttribute('data-type'));
}
if (selectedOption.className === 'highloadblock-product') {
getHlTablesFromController(selectedOption, 'product', obj.getAttribute('data-type'));
}
}
2018-05-23 12:19:59 +03:00
2021-09-08 10:05:09 +03:00
function setHlFieldsInInstallPage(that, type, key){
const td = $(that).parents('td .adm-list-table-cell');
const select = $(that).parent('select').siblings('#highloadblock');
const iblock = $(that).parents('.iblockExportTable').attr('data-type');
const sessid = BX.bitrix_sessid();
const table_name = $(that).attr('id');
const step = $('input[name="continue"]').val();
const id = $('input[name="id"]').val();
const install = $('input[name="install"]').val();
const data = 'install=' + install + '&step=' + step + '&sessid=' + sessid +
'&id=' + id + '&ajax=1&table=' + table_name;
$.ajax({
url: '/bitrix/admin/partner_modules.php',
type: 'POST',
data: data,
dataType: "json",
success: function(res) {
$(select).remove();
$('#waiting').remove();
let new_options = '';
$.each(res.fields, function(key, value) {
new_options += '<option value="' + value + '">' + value + '</option>';
});
if (type === 'sku') {
$(td).append(getSelect(res, key, iblock, new_options, 'highloadblock'));
2018-05-23 12:19:59 +03:00
}
2021-09-08 10:05:09 +03:00
if (type === 'product') {
$(td).append(getSelect(res, key, iblock, new_options, 'highloadblock_product'));
2018-05-23 12:19:59 +03:00
}
2021-09-08 10:05:09 +03:00
},
beforeSend: function() {
$(td).append('<span style="margin-left:50px;" id="waiting"><?=GetMessage('WAIT')?></span>');
2018-03-22 16:11:04 +03:00
}
2021-09-08 10:05:09 +03:00
});
}
function setHlFieldsInSettingsPage(that, type, key){
const td = $(that).parents('td .adm-list-table-cell');
const select = $(that).parent('select').siblings('#highloadblock');
const table_name = $(that).attr('id');
const iblock = $(that).parents('.iblockExportTable').attr('data-type');
BX.ajax.runAction('intaro:retailcrm.api.icml.getHlTable',
{
method: 'POST',
data: {
sessid: BX.bitrix_sessid(),
tableName: table_name
}
2018-05-23 12:19:59 +03:00
}
2021-09-08 10:05:09 +03:00
).then((response) => {
$(select).remove();
$('#waiting').remove();
let new_options = '';
$.each(response.data.fields, function(key, value) {
new_options += '<option value="' + value + '">' + value + '</option>';
});
let typeValue = 'highloadblock';
2018-03-22 16:11:04 +03:00
2021-09-08 10:05:09 +03:00
if (type === 'product') {
typeValue += '_product'
}
$(td).append(getSelect (response.data, key, iblock, new_options, typeValue));
2018-05-23 12:19:59 +03:00
}
2021-09-08 10:05:09 +03:00
);
}
function getHlTablesFromController(that, type, key) {
const url = $('td .adm-list-table-cell').parents('form').attr('action');
if (url === '/bitrix/admin/partner_modules.php') {
setHlFieldsInInstallPage(that, type, key);
} else {
setHlFieldsInSettingsPage(that, type, key)
2018-03-22 16:11:04 +03:00
}
2015-05-18 17:38:06 +03:00
}
2014-04-15 20:31:11 +04:00
2021-09-08 10:05:09 +03:00
function getSelect (res, key, iblock, new_options, type){
let select = document.createElement('select');
let atrName = type + res.table + '_' + key + '[' + iblock + ']';
select.setAttribute('name', atrName);
select.setAttribute('id', 'highloadblock');
select.setAttribute('style','width: 100px; margin-left: 50px;');
select.innerHTML = new_options;
2013-08-20 12:53:32 +04:00
2021-09-08 10:05:09 +03:00
return select;
}
</script>
<?php
}
2013-08-20 12:53:32 +04:00
2021-09-08 10:05:09 +03:00
//Сохранение и выход
if ($STEP === 2) {
RetailcrmConfigProvider::setProfileBasePrice($_REQUEST['PROFILE_ID'], $_POST['price-types']);
$FINITE = true;
2013-08-20 12:53:32 +04:00
}
2018-05-23 12:19:59 +03:00
?>