155 static $line =
array();
161 $keys = array_keys(
$arr);
167 $values =
$arr[$keys[$index]];
168 foreach($values as
$key => $value)
170 $line[$keys[$index]] = $value;
194 $arIBlockProperty[
'ID'] = (int)$arIBlockProperty[
'ID'];
195 $propertyType = $arIBlockProperty[
"PROPERTY_TYPE"];
196 $userType = (string)$arIBlockProperty[
"USER_TYPE"];
197 $isMultiply = ($arIBlockProperty[
"MULTIPLE"] ==
'Y');
200 if (
'L' != $propertyType &&
'F' != $propertyType && !(
'S' == $propertyType &&
'directory' == $userType))
202 if (
'S' == $propertyType &&
'directory' == $userType)
204 if (empty($arIBlockProperty[
'USER_TYPE_SETTINGS'][
'TABLE_NAME']))
212 if (
'F' == $propertyType)
217 elseif (
'L' == $propertyType)
219 $arIBlockProperty[
'VALUE'] =
array();
221 while($arIBlockPropertyEnum = $dbIBlockPropertyEnum->Fetch())
223 $arIBlockProperty[
'VALUE'][] = $arIBlockPropertyEnum;
225 if (!empty($arIBlockProperty[
'VALUE']))
232 $arIBlockProperty[
'VALUE'] =
array();
233 $arConvert =
array();
234 if (isset($arIBlockProperty[
"USER_TYPE_SETTINGS"][
"TABLE_NAME"]) && !empty($arIBlockProperty[
"USER_TYPE_SETTINGS"][
"TABLE_NAME"]))
236 $hlblock = HL\HighloadBlockTable::getList(
array(
'filter' =>
array(
'=TABLE_NAME' => $arIBlockProperty[
'USER_TYPE_SETTINGS'][
'TABLE_NAME'])))->fetch();
237 if (!empty($hlblock) && is_array($hlblock))
239 $entity = HL\HighloadBlockTable::compileEntity($hlblock);
240 $entity_data_class =
$entity->getDataClass();
241 $fieldsList = $entity_data_class::getEntity()->getFields();
243 if (isset($fieldsList[
'UF_SORT']))
244 $order[
'UF_SORT'] =
'ASC';
245 $order[
'UF_NAME'] =
'ASC';
248 while($arData =
$rsData->fetch())
250 $arData[
"VALUE"] = $arData[
"UF_NAME"];
251 $arData[
"PROPERTY_ID"] = $arIBlockProperty[
"ID"];
252 $arData[
"SORT"] = (isset($arData[
'UF_SORT']) ? $arData[
'UF_SORT'] : $arData[
'ID']);
253 $arIBlockProperty[
'VALUE'][] = $arData;
254 $arConvert[$arData[
"ID"]] = $arData[
"UF_XML_ID"];
256 unset(
$order, $fieldsList);
259 if (!empty($arIBlockProperty[
'VALUE']))
271 if($arParentIBlockProperty[
'PROPERTY_TYPE'] ==
'L' || $arParentIBlockProperty[
'PROPERTY_TYPE'] ==
'S')
279 $arImageCombinationResult = $arPropertyValueCombinationResult =
array();
280 if (isset($_FILES[
'PROP']) && is_array($_FILES[
'PROP']))
282 CFile::ConvertFilesToPost($_FILES[
'PROP'], $arImageCombinationResult);
284 if (!empty($arImageCombinationResult) && is_array($arImageCombinationResult))
286 $fileDescription =
array();
287 if (!empty($_POST[
'DESCRIPTION_PROP']) && is_array($_POST[
'DESCRIPTION_PROP']))
288 $fileDescription = $_POST[
'DESCRIPTION_PROP'];
289 elseif (!empty($_POST[
'PROP_descr']) && is_array($_POST[
'PROP_descr']))
290 $fileDescription = $_POST[
'PROP_descr'];
291 if (!empty($fileDescription))
293 foreach ($arImageCombinationResult as $fieldCode => $fieldValues)
295 if (empty($fieldValues) || !is_array($fieldValues))
297 if (empty($fileDescription[$fieldCode]))
299 foreach ($fieldValues as $valueCode => $valueData)
301 if (empty($valueData) || !is_array($valueData))
303 if (!isset($fileDescription[$fieldCode][$valueCode]))
305 if (array_key_exists(
'tmp_name', $valueData))
307 $arImageCombinationResult[$fieldCode][$valueCode][
'description'] = $fileDescription[$fieldCode][$valueCode];
311 foreach ($valueData as $valueIndex => $value)
313 if (empty($value) || !is_array($value))
315 if (!isset($fileDescription[$fieldCode][$valueCode][$valueIndex]))
317 if (!array_key_exists(
'tmp_name', $value))
319 $arImageCombinationResult[$fieldCode][$valueCode][$valueIndex][
'description'] = $fileDescription[$fieldCode][$valueCode][$valueIndex];
321 unset($valueIndex, $value);
324 unset($valueCode, $valueData);
326 unset($fieldCode, $fieldValues);
331 if (isset($_POST[
"PROP"]) && is_array($_POST[
"PROP"]))
333 foreach($_POST[
"PROP"] as $propKey => $arTmpProperty)
336 if (is_array($arTmpProperty))
338 foreach($arTmpProperty as $eachPropertyValue)
340 $arPropertyValueCombinationResult[$rowId][$propKey] = $eachPropertyValue;
346 $arCombinationResult = $arPropertyValue = $arPriceGroup =
array();
347 $idNewElement =
false;
348 $obIBlockElement =
new CIBlockElement();
349 $arPropertyValues = (isset($_POST[
"PROPERTY_VALUE"]) && is_array($_POST[
"PROPERTY_VALUE"])) ? $_POST[
"PROPERTY_VALUE"] :
array();
350 $arPropertyChecks = (isset($_POST[
"PROPERTY_CHECK"]) && is_array($_POST[
"PROPERTY_CHECK"])) ? $_POST[
"PROPERTY_CHECK"] :
array();
354 $title =
'{=this.property.CML2_LINK.NAME} ';
356 if (isset($_POST[
'IB_SEG_PRICETYPE']) && is_array($_POST[
'IB_SEG_PRICETYPE']))
358 foreach($_POST[
'IB_SEG_PRICETYPE'] as
$key => $priceTypeId)
360 $arPriceGroup[$priceTypeId] =
array(
"TYPE" => $_POST[
'IB_SEG_PRICETYPE'][
$key],
"PRICE" => $_POST[
'IB_SEG_PRICE'][
$key],
"CURRENCY" => $_POST[
'IB_SEG_CURRENCY'][
$key]);
363 foreach($arPropertyValues as $propertyId =>
$arValues)
365 if(isset($arPropertyChecks[$propertyId]))
366 $arPropertyValue[$propertyId]= array_intersect_key(
$arValues, $arPropertyChecks[$propertyId]);
370 if (
$request->getPost(
'AJAX_MODE') ===
'Y')
374 echo CUtil::PhpToJSObject(
array($arPropertyValue));
379 $arIBlockElement = $dbIBlockElement->Fetch();
381 if ((
string)
$request->getPost(
'save') !==
'')
384 $parentElement = new \Bitrix\Iblock\Template\Entity\Element($parentElementId);
385 if($parentElementId < 0)
393 $productData =
array(
394 'WEIGHT' => $_POST[
'IB_SEG_WEIGHT'],
395 'LENGTH' => $_POST[
'IB_SEG_BASE_LENGTH'],
396 'WIDTH' => $_POST[
'IB_SEG_BASE_WIDTH'],
397 'HEIGHT' => $_POST[
'IB_SEG_BASE_HEIGHT'],
398 'VAT_ID' => $_POST[
'IB_SEG_VAT_ID'],
399 'VAT_INCLUDED' => $_POST[
'IB_SEG_VAT_INCLUDED'],
400 'MEASURE' => $_POST[
'IB_SEG_MEASURE']
403 $productData[
'QUANTITY'] = $_POST[
'IB_SEG_QUANTITY'];
406 if (!empty($_POST[
'IB_SEG_PURCHASING_CURRENCY']) && $_POST[
'IB_SEG_PURCHASING_PRICE'] !==
'')
408 $productData[
'PURCHASING_PRICE'] = $_POST[
'IB_SEG_PURCHASING_PRICE'];
409 $productData[
'PURCHASING_CURRENCY'] = $_POST[
'IB_SEG_PURCHASING_CURRENCY'];
413 foreach($arCombinationResult as $arPropertySaveValues)
416 foreach($arPropertyValueCombinationResult as $keyRow => $propertyValueCombinationResult)
419 foreach ($arPropertySaveValues as $srcKey => $srcValue)
421 if (!isset($propertyValueCombinationResult[$srcKey]) || ($propertyValueCombinationResult[$srcKey] != $srcValue && $propertyValueCombinationResult[$srcKey] !=
'-1'))
427 unset($srcValue, $srcKey);
430 $imageRowId = $keyRow;
435 $arPropertySaveValues[
$arSKUInfo[
'SKU_PROPERTY_ID']] = $parentElementId;
445 if ($value[
"CODE"] != $acValue[
"CODE"])
454 $arIBlockElementAdd =
array(
"NAME" =>
null,
"IBLOCK_ID" =>
$subIBlockId,
"ACTIVE" =>
"Y");
456 $arIBlockElementAdd[
'TMP_ID'] =
$subTmpId;
458 if (is_array($arImageCombinationResult) && $imageRowId !==
null)
460 foreach($arImageCombinationResult as $propertyId => $arImageType)
462 if(CFile::CheckImageFile($arImageType[$imageRowId]) ==
'')
467 $arIBlockElementAdd[
'DETAIL_PICTURE'] = $arImageType[$imageRowId];
470 $arIBlockElementAdd[
'PREVIEW_PICTURE'] = $arImageType[$imageRowId];
473 $arPropertySaveValues[$propertyId] = $arImageType[$imageRowId];
483 if (isset($arPropertySaveValues[$arOneConvert[
'ID']]))
485 $arPropertySaveValues[$arOneConvert[
'ID']] = $arOneConvert[
'CONVERT'][$arPropertySaveValues[$arOneConvert[
'ID']]];
489 if ($imageRowId !==
null)
491 foreach ($arPropertyValueCombinationResult[$imageRowId] as $srcKey => $srcValue)
493 if ($srcValue ==
'-1')
500 $arIBlockElementAdd[
'PREVIEW_PICTURE'] = CIBlock::makeFileArray(
504 if ($arIBlockElementAdd[
'PREVIEW_PICTURE'][
'error'] == 0)
505 $arIBlockElementAdd[
'PREVIEW_PICTURE'][
'COPY_FILE'] =
'Y';
508 $arIBlockElementAdd[
'DETAIL_PICTURE'] = CIBlock::makeFileArray(
512 if ($arIBlockElementAdd[
'DETAIL_PICTURE'][
'error'] == 0)
513 $arIBlockElementAdd[
'DETAIL_PICTURE'][
'COPY_FILE'] =
'Y';
516 if (is_array($srcValue))
518 $arPropertySaveValues[$srcKey] =
array();
519 foreach ($srcValue as $fileID => $fileValue)
521 $arPropertySaveValues[$srcKey][$fileID] = CIBlock::makeFilePropArray(
529 $arPropertySaveValues[$srcKey] = CIBlock::makeFilePropArray(
539 $arPropertySaveValues[
"CML2_LINK"] = $parentElement;
540 $arIBlockElementAdd[
'PROPERTY_VALUES'] = $arPropertySaveValues;
541 $sku = new \Bitrix\Iblock\Template\Entity\Element(0);
542 $sku->setFields($arIBlockElementAdd);
544 unset($arIBlockElementAdd[
'PROPERTY_VALUES'][
"CML2_LINK"]);
545 $idNewElement = $obIBlockElement->Add($arIBlockElementAdd,
false,
true,
true);
548 $productData[
'ID'] = $idNewElement;
550 foreach($arPriceGroup as $price)
551 CPrice::Add(
array(
"PRODUCT_ID" => $idNewElement,
"CURRENCY" => $price[
"CURRENCY"],
"PRICE" => $price[
"PRICE"],
"CATALOG_GROUP_ID" => $price[
"TYPE"]));
552 $element = new \Bitrix\Iblock\InheritedProperty\ElementValues(
$subIBlockId, $idNewElement);
553 $template = new \Bitrix\Iblock\InheritedProperty\BaseTemplate($element);
571 var currentWindow =
top.window;
572 if (
top.BX.SidePanel &&
top.BX.SidePanel.Instance &&
top.BX.SidePanel.Instance.getTopSlider())
574 currentWindow =
top.BX.SidePanel.Instance.getTopSlider().getWindow();
576 currentWindow.BX.closeWait();
577 if (!!currentWindow.BX.WindowManager.Get())
579 currentWindow.BX.WindowManager.Get().AllowClose();
580 currentWindow.BX.WindowManager.Get().Close();
581 if (!!currentWindow.ReloadSubList)
582 currentWindow.ReloadSubList();
595require(
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/modules/main/include/prolog_admin_after.php");
602 "ONCLICK" =>
"obPropertyTable.addPropertyTable('".
$key.
"')",
612 "TEXT" => $property[
"NAME"],
613 "ONCLICK" =>
"obPropertyTable.addPropertyInTitle('{=this.property.".$property[
"ID"].
"}')",
614 "CODE" => $property[
"CODE"],
622 "ONCLICK" =>
"obPropertyTable.addPropertyInTitle('{=this.property.CML2_LINK.NAME}')",
628 "TEXT" => $property[
"NAME"],
629 "ONCLICK" =>
"obPropertyTable.addPropertyInTitle('{=this.property.CML2_LINK.property.".$property[
"CODE"].
"}')",
630 "CODE" => $property[
"CODE"],
653 <form enctype=
"multipart/form-data" method=
"POST" action=
"<?= $APPLICATION->GetCurPage() ?>" name=
"iblock_generator_form" id=
"iblock_generator_form">
654 <input type=
"hidden" name=
"lang" value=
"<?= LANGUAGE_ID ?>">
655 <input type=
"hidden" name=
"subIBlockId" value=
"<?= $subIBlockId ?>">
656 <input type=
"hidden" name=
"subPropValue" value=
"<?= $subPropValue ?>">
657 <input type=
"hidden" name=
"iBlockId" value=
"<?= $iBlockId ?>">
658 <input type=
"hidden" name=
"subTmpId" value=
"<?= $subTmpId ?>">
659 <input type=
"hidden" name=
"PRODUCT_NAME_HIDDEN" value=
"<?= htmlspecialcharsbx($parentProductName) ?>">
667 BX(
'edit_edit_table').className +=
' adm-shop-page-table';
673 ?>CellTPL[<?=
$key; ?>] =
'<?= $value; ?>';
682 ?>CellAttr[<?=
$key; ?>] =
'<?= $value; ?>';
686 var obPricesTable =
new JCCatTblEdit({
688 'TABLE_PROP_ID':
'generator_price_table',
689 'PROP_COUNT_ID':
'generator_price_table_max_id'
691 obPricesTable.SetCells(CellTPL, CellAttr);
693 var obPropertyTable =
new JCIBlockGenerator({
695 'TABLE_PROP_ID':
'generator_property_table',
696 'PROP_COUNT_ID':
'generator_price_table_max_id',
698 'IMAGE_TABLE_ID':
"adm-shop-table",
703 function addProperty(arFileProperties)
705 var fileProperties = eval(arFileProperties),
707 if(BX(
'ib_seg_max_property_id'))
709 id = BX(
'ib_seg_max_property_id').value;
710 if(
id >= obPropertyTable.AR_FILE_PROPERTIES.length + 2)
714 BX(
'ib_seg_max_property_id').value = Number(BX(
'ib_seg_max_property_id').value) + 1;
716 obPropertyTable.SELECTED_PROPERTIES[id] =
'DETAIL';
718 var propertySpan = BX(
'ib_seg_property_span');
722 for(var key in fileProperties)
724 if(fileProperties.hasOwnProperty(key))
725 options[options.length] = BX.create(
'OPTION', {
726 'props': {
'value':fileProperties[key][
"ID"],
'selected':(fileProperties[key][
"ID"] ==
'DETAIL')},
727 'text': fileProperties[key][
"NAME"]
731 var span = BX.create(
'span', {
733 className:
'adm-select-wrap'
736 var content = BX.create(
'select', {
738 name:
"SELECTED_PROPERTY[]",
739 id:
"SELECTED_PROPERTY[]",
740 className:
"adm-select ib_seg_add_property_but"
749 obPropertyTable.SELECTED_PROPERTIES[id] = this.value;
753 span.appendChild(content);
754 propertySpan.appendChild(span);
759 'PROPERTY_VALUES_EMPTY':
'<?=GetMessageJS('IB_SEG_PROPERTY_VALUES_EMPTY
'); ?>'
762<tr><td colspan=
"2" class=
"adm-detail-content-cell">
763 <div
class=
"adm-detail-content-item-block-view-tab"><div
class=
"adm-shop-block-wrap">
764 <table
width=
"100%" border=
"0" cellspacing=
"7" cellpadding=
"0">
766 <td
class=
"adm-detail-content-cell-l"><?=
GetMessage(
"IB_SEG_TITLE") ?>:</td>
767 <td
class=
"adm-detail-content-cell-r" style=
"white-space: nowrap !important;">
768 <input type=
"text" style=
"width: 637px;" class=
"adm-input" id=
"IB_SEG_TITLE" name=
"IB_SEG_TITLE" >
769 <input type=
"button" id=
"IB_SEG_ADD_PROP_IN_TITLE" title=
"..." value=
"<?=htmlspecialcharsbx(GetMessage("IB_SEG_SKU_PROPERTIES
")); ?>">
770 <input type=
"button" id=
"IB_SEG_ADD_PROP_IN_TITLE2" title=
"..." value=
"<?=htmlspecialcharsbx(GetMessage("IB_SEG_PARENT_PROPERTIES
")); ?>">
771 <a
class=
"adm-input-help-icon" onmouseover=
"BX.hint(this, '<?=htmlspecialcharsbx(CUtil::JSEscape(GetMessage('IB_SEG_TOOLTIP_TITLE'))); ?>')" href=
"#"></a>
775 <td
class=
"adm-detail-content-cell-l"><?=
GetMessage(
"IB_SEG_WEIGHT") ?>:</td>
776 <td
class=
"adm-detail-content-cell-r">
777 <input type=
"text" style=
"width: 120px; margin-right: 10px" class=
"adm-input" name=
"IB_SEG_WEIGHT">
779 <input type=
"text" id=
"CAT_BASE_LENGTH" name=
"IB_SEG_BASE_LENGTH" style=
"width: 120px; margin-right: 10px">
781 <input type=
"text" id=
"CAT_BASE_WIDTH" name=
"IB_SEG_BASE_WIDTH" style=
"width: 120px; margin-right: 10px">
783 <input type=
"text" id=
"CAT_BASE_HEIGHT" name=
"IB_SEG_BASE_HEIGHT" style=
"width: 120px;">
784 <a
class=
"adm-input-help-icon" onmouseover=
"BX.hint(this, '<?=htmlspecialcharsbx(CUtil::JSEscape(GetMessage('IB_SEG_TOOLTIP_WEIGHT'))); ?>')" href=
"#"></a>
789 <td
class=
"adm-detail-content-cell-r"><?php
792 ?><input type=
"text" style=
"width: 120px; margin-right: 10px" class=
"adm-input" name=
"IB_SEG_QUANTITY">
795 ?> <span
class=
"adm-select-wrap" style=
"vertical-align: middle !important;"><
select name=
"IB_SEG_MEASURE" class=
"adm-select" style=
"width: 169px;"><?php
797 array(),
array(),
false,
false,
array(
"ID",
"CODE",
"MEASURE_TITLE",
"SYMBOL_INTL",
"IS_DEFAULT")
801 ?><option value=
"<?=$measure['ID']?>"<?= ($measure[
'IS_DEFAULT'] ==
'Y' ?
' selected' :
'') ?>><?php
808 <td
class=
"adm-detail-content-cell-l"><?=
GetMessage(
"IB_SEG_VAT") ?>:</td>
809 <td
class=
"adm-detail-content-cell-r">
810 <span
class=
"adm-select-wrap" style=
"vertical-align: middle !important;">
819 <td
class=
"adm-detail-content-cell-l"><?=
GetMessage(
"IB_SEG_VAT_INCLUDED") ?></td>
820 <td
class=
"adm-detail-content-cell-r">
821 <input type=
"hidden" name=
"IB_SEG_VAT_INCLUDED" id=
"IB_SEG_VAT_INCLUDED_N" value=
"N"><?php
823 ?><input
class=
"adm-designed-checkbox" type=
"checkbox" name=
"IB_SEG_VAT_INCLUDED" id=
"IB_SEG_VAT_INCLUDED" value=
"Y"<?= (
$vatInclude ?
' checked' :
'') ?>>
824 <label
class=
"adm-designed-checkbox-label" for=
"IB_SEG_VAT_INCLUDED"></label>
830 $baseCurrency = Currency\CurrencyManager::getBaseCurrency();
833 <td
class=
"adm-detail-content-cell-l"><?=
GetMessage(
"IB_SEG_PURCHASING_PRICE") ?></td>
834 <td
class=
"adm-detail-content-cell-r">
835 <input type=
"text" name=
"IB_SEG_PURCHASING_PRICE" value=
"">
836 <span
class=
"adm-select-wrap" style=
"vertical-align: middle !important;"><
select name=
"IB_SEG_PURCHASING_CURRENCY" class=
"adm-select" style=
"width: 169px;">
839 foreach (
Currency\CurrencyManager::getCurrencyList() as $id =>
$title)
841 ?><option value=
"<?=$id; ?>"<?=($id == $baseCurrency ?
' selected' :
''); ?>><?=
htmlspecialcharsbx(
$title); ?></option><?php
854 <td
class=
"adm-detail-content-cell-l"><?=
GetMessage(
"IB_SEG_PRICE_SHORT") ?>:</td>
855 <td
class=
"adm-detail-content-cell-r">
856 <table
class=
"internal" id=
"generator_price_table" style=
"width: auto;">
858 <td><?=
GetMessage(
"IB_SEG_PRICE_TYPE") ?>:</td>
860 <td><?=
GetMessage(
"IB_SEG_CURRENCY") ?>:</td>
869 <span
class=
"adm-btn adm-btn-add" style=
"margin-top: 12px;" onclick=
"obPricesTable.addRow();"><?=
GetMessage(
"IB_SEG_PRICE_ROW_ADD") ?></span>
870 <input type=
"hidden" value=
"1" id=
"generator_price_table_max_id">
880 <td colspan=
"2" class=
"adm-detail-content-cell" style=
"padding-bottom: 0;">
881 <div
class=
"adm-shop-toolbar">
882 <span
class=
"adm-btn adm-btn-add" id=
"mnu_ADD_PROPERTY"><?=
GetMessage(
"IB_SEG_PROPERTY_ADD") ?></span><span
class=
"adm-btn adm-btn-download" id=
"mnu_ADD_ALL_PROPERTY" onclick=
"obPropertyTable.loadAllProperties()"><?=
GetMessage(
"IB_SEG_PROPERTY_ADD_ALL") ?></span><a
class=
"adm-input-help-icon" onmouseover=
"BX.hint(this, '<?=htmlspecialcharsbx(CUtil::JSEscape(GetMessage('IB_SEG_TOOLTIP_PROPERTIES'))); ?>')" href=
"#"></a>
887 <td colspan=
"2" class=
"adm-detail-content-cell" style=
"padding-top: 0;">
888 <div
class=
"adm-detail-content-item-block-view-tab">
889 <div
class=
"adm-detail-title-view-tab"><?=
GetMessage(
"IB_SEG_SELECTED_PROPERTIES") ?></div>
890 <input type=
"hidden" value=
"0" id=
"generator_property_table_max_id">
891 <div
class=
"adm-shop-table-block" id=
"generator_property_table">
897 obPropertyTable.addPropertyTable(<?=
$key?>);