1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
iblock_subelement_generator.php
См. документацию.
1<?php
4
10use Bitrix\Highloadblock as HL;
11
12require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
13IncludeModuleLangFile(__FILE__);
14
15if (!Main\Loader::includeModule('catalog'))
16{
17 die();
18}
20
21Main\Page\Asset::getInstance()->addJs('/bitrix/js/catalog/tbl_edit.js');
22
24 'js' => '/bitrix/js/catalog/sub_generator.js',
25 'css' => '/bitrix/panel/catalog/sub-generator.css',
26 'lang' => '/bitrix/modules/catalog/lang/'.LANGUAGE_ID.'/tools/iblock_subelement_generator.php'
27);
28CJSCore::RegisterExt('iblock_generator', $arJSDescription);
30 'iblock_generator',
31 'file_input',
32]);
33
34const IB_SEG_ROW_PREFIX = 'IB_SEG_';
35
36$request = Main\Context::getCurrent()->getRequest();
37
38$subIBlockId = (int)$request->get('subIBlockId');
39if ($subIBlockId <= 0)
40{
41 die();
42}
43$subPropValue = (int)$request->get('subPropValue');
44$subTmpId = (int)$request->get('subTmpId');
45$iBlockId = (int)$request->get('iBlockId');
46$arSKUInfo = CCatalogSku::GetInfoByOfferIBlock($subIBlockId);
47$parentProductName = trim($_POST['PRODUCT_NAME']);
48
50
51$accessController = AccessController::getCurrent();
52
53$allowProductAdd = $accessController->check(ActionDictionary::ACTION_PRODUCT_ADD);
55 CIBlockSectionRights::UserHasRightTo($subIBlockId, 0, 'section_element_bind')
57;
58
59if (empty($arSKUInfo))
60{
61 ShowError("SKU error!");
62}
63
64$APPLICATION->SetTitle(GetMessage("IB_SEG_MAIN_TITLE"));
65
71function __AddCellPriceType($intRangeID, $strPrefix): string
72{
73 $priceTypeCellOption = '';
74 foreach (Catalog\GroupTable::getTypeList() as $arCatalogGroup)
75 {
76 $priceTypeCellOption .= "<option value=".$arCatalogGroup['ID'].">".htmlspecialcharsbx($arCatalogGroup["NAME"])."</option>";
77 }
78
79 return <<<"PRICETYPECELL"
80 <td width="30%">
81 <span class="adm-select-wrap">
82 <select id="IB_SEG_PRICE_TYPE" class="adm-select" style="width: 169px; max-width: 300px;" name="{$strPrefix}PRICETYPE[{$intRangeID}]" />
83 $priceTypeCellOption
84 </select>
85 </span>
86 </td>
87PRICETYPECELL;
88}
89
95function __AddCellPrice($intRangeID, $strPrefix): string
96{
97 return <<<"PRICECELL"
98 <td width="30%">
99 <input type="text" name="{$strPrefix}PRICE[{$intRangeID}]" />
100 </td>
101PRICECELL;
102}
103
109function __AddCellCurrency($intRangeID, $strPrefix): string
110{
111 $currencySelectbox = CCurrency::SelectBox("{$strPrefix}CURRENCY[{$intRangeID}]", '', "", true, "", "class=\"adm-select\" style=\"width: 169px;\"");
112
113 return <<<"CURRENCYCELL"
114 <td width="30%">
115 <span class="adm-select-wrap">
116 $currencySelectbox
117 </span>
118 </td>
119CURRENCYCELL;
120}
121
122function __showPopup($element_id, $items)
123{
124 echo
125 '<script>
126 var currentWindow = top.window;
127 if (top.BX.SidePanel && top.BX.SidePanel.Instance && top.BX.SidePanel.Instance.getTopSlider())
128 {
129 currentWindow = top.BX.SidePanel.Instance.getTopSlider().getWindow();
130 }
131 currentWindow.BX.ready(function(){
132 currentWindow.BX.bind(currentWindow.BX("'.$element_id.'"), "click", function() {
133 currentWindow.BX.adminShowMenu(this, '.CAdminPopup::PhpToJavaScript($items).');
134 });
135 });
136 </script>';
137}
138
143function __AddRangeRow($intRangeID, $strPrefix): string
144{
145 return '<tr id="'.$strPrefix.$intRangeID.'">'.__AddCellPriceType($intRangeID, $strPrefix).__AddCellPrice($intRangeID, $strPrefix).__AddCellCurrency($intRangeID, $strPrefix).'</tr>';
146}
147
153function arraysCombination (&$arr, $index = 0): array
154{
155 static $line = array();
156 static $keys;
157 static $max;
158 static $results;
159 if($index == 0)
160 {
161 $keys = array_keys($arr);
162 $max = count($arr);
163 $results = array();
164 }
165 if($index < $max)
166 {
167 $values = $arr[$keys[$index]];
168 foreach($values as $key => $value)
169 {
170 $line[$keys[$index]] = $value;
171 arraysCombination($arr, $index + 1);
172 array_pop($line);
173 }
174 }
175 else
176 {
177 $results[] = $line;
178 }
179 if($index == 0)
180 return $results;
181 return array();
182}
183
191$dbIBlockProperty = CIBlockProperty::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("IBLOCK_ID" => $subIBlockId, "ACTIVE" => 'Y'));
192while($arIBlockProperty = $dbIBlockProperty->Fetch())
193{
194 $arIBlockProperty['ID'] = (int)$arIBlockProperty['ID'];
195 $propertyType = $arIBlockProperty["PROPERTY_TYPE"];
196 $userType = (string)$arIBlockProperty["USER_TYPE"];
197 $isMultiply = ($arIBlockProperty["MULTIPLE"] == 'Y');
198 $arAllProperties[] = $arIBlockProperty;
199
200 if ('L' != $propertyType && 'F' != $propertyType && !('S' == $propertyType && 'directory' == $userType))
201 continue;
202 if ('S' == $propertyType && 'directory' == $userType)
203 {
204 if (empty($arIBlockProperty['USER_TYPE_SETTINGS']['TABLE_NAME']))
205 continue;
206 if (null === $boolHighLoad)
207 $boolHighLoad = CModule::IncludeModule('highloadblock');
208 if (!$boolHighLoad)
209 continue;
210 }
211
212 if ('F' == $propertyType)
213 {
214 $arFileProperties[] = $arIBlockProperty;
215 $arFilePropertiesExt[$arIBlockProperty['ID']] = $arIBlockProperty;
216 }
217 elseif ('L' == $propertyType)
218 {
219 $arIBlockProperty['VALUE'] = array();
220 $dbIBlockPropertyEnum = CIBlockPropertyEnum::GetList(array("SORT" => "ASC"), array("PROPERTY_ID" => $arIBlockProperty["ID"]));
221 while($arIBlockPropertyEnum = $dbIBlockPropertyEnum->Fetch())
222 {
223 $arIBlockProperty['VALUE'][] = $arIBlockPropertyEnum;
224 }
225 if (!empty($arIBlockProperty['VALUE']))
226 {
227 $arResult[] = $arIBlockProperty;
228 }
229 }
230 else
231 {
232 $arIBlockProperty['VALUE'] = array();
233 $arConvert = array();
234 if (isset($arIBlockProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"]) && !empty($arIBlockProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"]))
235 {
236 $hlblock = HL\HighloadBlockTable::getList(array('filter' => array('=TABLE_NAME' => $arIBlockProperty['USER_TYPE_SETTINGS']['TABLE_NAME'])))->fetch();
237 if (!empty($hlblock) && is_array($hlblock))
238 {
239 $entity = HL\HighloadBlockTable::compileEntity($hlblock);
240 $entity_data_class = $entity->getDataClass();
241 $fieldsList = $entity_data_class::getEntity()->getFields();
242 $order = array();
243 if (isset($fieldsList['UF_SORT']))
244 $order['UF_SORT'] = 'ASC';
245 $order['UF_NAME'] = 'ASC';
246 $order['ID'] = 'ASC';
247 $rsData = $entity_data_class::getList(array('order' => $order));
248 while($arData = $rsData->fetch())
249 {
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"];
255 }
256 unset($order, $fieldsList);
257 }
258 }
259 if (!empty($arIBlockProperty['VALUE']))
260 {
261 $arResult[] = $arIBlockProperty;
262 $arDirProperties[$arIBlockProperty['ID']] = $arIBlockProperty;
263 $arDirProperties[$arIBlockProperty['ID']]['CONVERT'] = $arConvert;
264 }
265 }
266}
267
268$dbParentIBlockProperty = CIBlockProperty::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("IBLOCK_ID" => $iBlockId, "ACTIVE" => 'Y'));
269while($arParentIBlockProperty = $dbParentIBlockProperty->Fetch())
270{
271 if($arParentIBlockProperty['PROPERTY_TYPE'] == 'L' || $arParentIBlockProperty['PROPERTY_TYPE'] == 'S')
272 $arAllParentProperties[] = $arParentIBlockProperty;
273}
274
276
277if ($_SERVER['REQUEST_METHOD'] == 'POST' && $elementAdd && check_bitrix_sessid())
278{
279 $arImageCombinationResult = $arPropertyValueCombinationResult = array();
280 if (isset($_FILES['PROP']) && is_array($_FILES['PROP']))
281 {
282 CFile::ConvertFilesToPost($_FILES['PROP'], $arImageCombinationResult);
283 // this code for fill description
284 if (!empty($arImageCombinationResult) && is_array($arImageCombinationResult))
285 {
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))
292 {
293 foreach ($arImageCombinationResult as $fieldCode => $fieldValues)
294 {
295 if (empty($fieldValues) || !is_array($fieldValues))
296 continue;
297 if (empty($fileDescription[$fieldCode]))
298 continue;
299 foreach ($fieldValues as $valueCode => $valueData)
300 {
301 if (empty($valueData) || !is_array($valueData))
302 continue;
303 if (!isset($fileDescription[$fieldCode][$valueCode]))
304 continue;
305 if (array_key_exists('tmp_name', $valueData))
306 {
307 $arImageCombinationResult[$fieldCode][$valueCode]['description'] = $fileDescription[$fieldCode][$valueCode];
308 }
309 else
310 {
311 foreach ($valueData as $valueIndex => $value)
312 {
313 if (empty($value) || !is_array($value))
314 continue;
315 if (!isset($fileDescription[$fieldCode][$valueCode][$valueIndex]))
316 continue;
317 if (!array_key_exists('tmp_name', $value))
318 continue;
319 $arImageCombinationResult[$fieldCode][$valueCode][$valueIndex]['description'] = $fileDescription[$fieldCode][$valueCode][$valueIndex];
320 }
321 unset($valueIndex, $value);
322 }
323 }
324 unset($valueCode, $valueData);
325 }
326 unset($fieldCode, $fieldValues);
327 }
328 }
329 }
330
331 if (isset($_POST["PROP"]) && is_array($_POST["PROP"]))
332 {
333 foreach($_POST["PROP"] as $propKey => $arTmpProperty)
334 {
335 $rowId = 0;
336 if (is_array($arTmpProperty))
337 {
338 foreach($arTmpProperty as $eachPropertyValue)
339 {
340 $arPropertyValueCombinationResult[$rowId][$propKey] = $eachPropertyValue;
341 $rowId++;
342 }
343 }
344 }
345 }
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();
351 $title = trim((string)$request->getPost('IB_SEG_TITLE'));
352 if ($title === '')
353 {
354 $title = '{=this.property.CML2_LINK.NAME} ';
355 }
356 if (isset($_POST['IB_SEG_PRICETYPE']) && is_array($_POST['IB_SEG_PRICETYPE']))
357 {
358 foreach($_POST['IB_SEG_PRICETYPE'] as $key => $priceTypeId)
359 {
360 $arPriceGroup[$priceTypeId] = array("TYPE" => $_POST['IB_SEG_PRICETYPE'][$key], "PRICE" => $_POST['IB_SEG_PRICE'][$key], "CURRENCY" => $_POST['IB_SEG_CURRENCY'][$key]);
361 }
362 }
363 foreach($arPropertyValues as $propertyId => $arValues)
364 {
365 if(isset($arPropertyChecks[$propertyId]))
366 $arPropertyValue[$propertyId]= array_intersect_key($arValues, $arPropertyChecks[$propertyId]);
367 }
368 $arCombinationResult = arraysCombination($arPropertyValue);
369
370 if ($request->getPost('AJAX_MODE') === 'Y')
371 {
372 $APPLICATION->RestartBuffer();
373
374 echo CUtil::PhpToJSObject(array($arPropertyValue));
375 exit;
376 }
377 $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $subPropValue));
378
379 $arIBlockElement = $dbIBlockElement->Fetch();
380
381 if ((string)$request->getPost('save') !== '')
382 {
383 $parentElementId = (0 < $subPropValue ? $subPropValue : -$subTmpId);
384 $parentElement = new \Bitrix\Iblock\Template\Entity\Element($parentElementId);
385 if($parentElementId < 0)
386 {
388 "NAME" => htmlspecialcharsbx($_POST['PRODUCT_NAME_HIDDEN']),
389 );
390 $parentElement->setFields($arFields);
391 }
392
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']
401 );
402 if (!$useStoreControl)
403 $productData['QUANTITY'] = $_POST['IB_SEG_QUANTITY'];
404 if ($accessController->check(ActionDictionary::ACTION_PRODUCT_PURCHASE_INFO_VIEW) && !$useStoreControl)
405 {
406 if (!empty($_POST['IB_SEG_PURCHASING_CURRENCY']) && $_POST['IB_SEG_PURCHASING_PRICE'] !== '')
407 {
408 $productData['PURCHASING_PRICE'] = $_POST['IB_SEG_PURCHASING_PRICE'];
409 $productData['PURCHASING_CURRENCY'] = $_POST['IB_SEG_PURCHASING_CURRENCY'];
410 }
411 }
412
413 foreach($arCombinationResult as $arPropertySaveValues)
414 {
415 $imageRowId = null;
416 foreach($arPropertyValueCombinationResult as $keyRow => $propertyValueCombinationResult)
417 {
418 $compare = true;
419 foreach ($arPropertySaveValues as $srcKey => $srcValue)
420 {
421 if (!isset($propertyValueCombinationResult[$srcKey]) || ($propertyValueCombinationResult[$srcKey] != $srcValue && $propertyValueCombinationResult[$srcKey] != '-1'))
422 {
423 $compare = false;
424 break;
425 }
426 }
427 unset($srcValue, $srcKey);
428 if ($compare)
429 {
430 $imageRowId = $keyRow;
431 break;
432 }
433 }
434
435 $arPropertySaveValues[$arSKUInfo['SKU_PROPERTY_ID']] = $parentElementId;
436
437 if (!empty($arPropertyPopup) && is_array($arPropertyPopup))
438 {
439 foreach ($arPropertyPopup as $action => $acValue)
440 {
441 if ($action != 'CODE')
442 continue;
443 foreach ($arAllProperties as $key => $value)
444 {
445 if ($value["CODE"] != $acValue["CODE"])
446 continue;
447 $arReplace['#'.$acValue["CODE"].'#'] = $arPropertySaveValues[$arAllProperties[$key]['ID']];
448 }
449 unset($key, $value);
450 }
451 unset($action, $acValue);
452 }
453
454 $arIBlockElementAdd = array("NAME" => null, "IBLOCK_ID" => $subIBlockId, "ACTIVE" => "Y");
455 if (0 >= $subPropValue)
456 $arIBlockElementAdd['TMP_ID'] = $subTmpId;
457
458 if (is_array($arImageCombinationResult) && $imageRowId !== null)
459 {
460 foreach($arImageCombinationResult as $propertyId => $arImageType)
461 {
462 if(CFile::CheckImageFile($arImageType[$imageRowId]) == '')
463 {
464 switch($propertyId)
465 {
466 case 'DETAIL' :
467 $arIBlockElementAdd['DETAIL_PICTURE'] = $arImageType[$imageRowId];
468 break;
469 case 'ANNOUNCE' :
470 $arIBlockElementAdd['PREVIEW_PICTURE'] = $arImageType[$imageRowId];
471 break;
472 default :
473 $arPropertySaveValues[$propertyId] = $arImageType[$imageRowId];
474 }
475 }
476 }
477 }
478
479 if (!empty($arDirProperties))
480 {
481 foreach ($arDirProperties as $arOneConvert)
482 {
483 if (isset($arPropertySaveValues[$arOneConvert['ID']]))
484 {
485 $arPropertySaveValues[$arOneConvert['ID']] = $arOneConvert['CONVERT'][$arPropertySaveValues[$arOneConvert['ID']]];
486 }
487 }
488 }
489 if ($imageRowId !== null)
490 {
491 foreach ($arPropertyValueCombinationResult[$imageRowId] as $srcKey => $srcValue)
492 {
493 if ($srcValue == '-1')
494 continue;
495 if (!isset($arFilePropertiesExt[$srcKey]) && $srcKey != 'DETAIL' && $srcKey != 'ANNOUNCE')
496 continue;
497 switch ($srcKey)
498 {
499 case 'ANNOUNCE':
500 $arIBlockElementAdd['PREVIEW_PICTURE'] = CIBlock::makeFileArray(
501 $srcValue,
502 false
503 );
504 if ($arIBlockElementAdd['PREVIEW_PICTURE']['error'] == 0)
505 $arIBlockElementAdd['PREVIEW_PICTURE']['COPY_FILE'] = 'Y';
506 break;
507 case 'DETAIL':
508 $arIBlockElementAdd['DETAIL_PICTURE'] = CIBlock::makeFileArray(
509 $srcValue,
510 false
511 );
512 if ($arIBlockElementAdd['DETAIL_PICTURE']['error'] == 0)
513 $arIBlockElementAdd['DETAIL_PICTURE']['COPY_FILE'] = 'Y';
514 break;
515 default:
516 if (is_array($srcValue))
517 {
518 $arPropertySaveValues[$srcKey] = array();
519 foreach ($srcValue as $fileID => $fileValue)
520 {
521 $arPropertySaveValues[$srcKey][$fileID] = CIBlock::makeFilePropArray(
522 $srcValue[$fileID],
523 false
524 );
525 }
526 }
527 else
528 {
529 $arPropertySaveValues[$srcKey] = CIBlock::makeFilePropArray(
530 $srcValue,
531 false
532 );
533 }
534 break;
535 }
536 }
537 }
538
539 $arPropertySaveValues["CML2_LINK"] = $parentElement;
540 $arIBlockElementAdd['PROPERTY_VALUES'] = $arPropertySaveValues;
541 $sku = new \Bitrix\Iblock\Template\Entity\Element(0);
542 $sku->setFields($arIBlockElementAdd);
543 $arIBlockElementAdd["NAME"] = htmlspecialcharsback(\Bitrix\Iblock\Template\Engine::process($sku, $title));
544 unset($arIBlockElementAdd['PROPERTY_VALUES']["CML2_LINK"]);
545 $idNewElement = $obIBlockElement->Add($arIBlockElementAdd, false, true, true);
546 if($idNewElement)
547 {
548 $productData['ID'] = $idNewElement;
549 CCatalogProduct::Add($productData, false);
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);
554 $template->set(array(
555 "MY_TEMPLATE" => $title,
556 ));
557 CCatalogMeasureRatio::add(array('PRODUCT_ID' => $idNewElement, 'RATIO' => 1, 'IS_DEFAULT' => 'Y'));
558 }
559 else
560 {
561 $errorMessage .= $obIBlockElement->LAST_ERROR;
562 break;
563 }
564 }
565 unset($productData);
566
567 if($idNewElement)
568 {
569 ?>
570 <script>
571 var currentWindow = top.window;
572 if (top.BX.SidePanel && top.BX.SidePanel.Instance && top.BX.SidePanel.Instance.getTopSlider())
573 {
574 currentWindow = top.BX.SidePanel.Instance.getTopSlider().getWindow();
575 }
576 currentWindow.BX.closeWait();
577 if (!!currentWindow.BX.WindowManager.Get())
578 {
579 currentWindow.BX.WindowManager.Get().AllowClose();
580 currentWindow.BX.WindowManager.Get().Close();
581 if (!!currentWindow.ReloadSubList)
582 currentWindow.ReloadSubList();
583 }
584 </script>
585 <?php
586 die();
587 }
588 if ($ex = $APPLICATION->GetException())
589 {
590 $errorMessage .= $ex->GetString()."<br>";
591 }
592 }
593}
594
595require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
596
598foreach($arResult as $key => $property)
599{
601 "TEXT" => htmlspecialcharsbx($property["NAME"]),
602 "ONCLICK" => "obPropertyTable.addPropertyTable('".$key."')",
603 );
604}
605if(count($arPropertyPopup) > 0)
606 __showPopup("mnu_ADD_PROPERTY", $arPropertyPopup);
607
609foreach($arResult as $key => $property)
610{
611 $arPropertyPopupIB1[$property["CODE"]] = array(
612 "TEXT" => $property["NAME"],
613 "ONCLICK" => "obPropertyTable.addPropertyInTitle('{=this.property.".$property["ID"]."}')",
614 "CODE" => $property["CODE"],
615 );
616}
617if(!empty($arPropertyPopupIB1))
618 __showPopup("IB_SEG_ADD_PROP_IN_TITLE", $arPropertyPopupIB1);
619
621 "TEXT" => GetMessage("IB_SEG_TITLE"),
622 "ONCLICK" => "obPropertyTable.addPropertyInTitle('{=this.property.CML2_LINK.NAME}')",
623 "CODE" => 'NAME',
624));
625foreach($arAllParentProperties as $key => $property)
626{
627 $arPropertyPopupIB2[$property["CODE"]] = array(
628 "TEXT" => $property["NAME"],
629 "ONCLICK" => "obPropertyTable.addPropertyInTitle('{=this.property.CML2_LINK.property.".$property["CODE"]."}')",
630 "CODE" => $property["CODE"],
631 );
632}
633if(!empty($arPropertyPopupIB2))
634 __showPopup("IB_SEG_ADD_PROP_IN_TITLE2", $arPropertyPopupIB2);
635
637{
639}
640else
641{
643 $arCellTemplates[] = CUtil::JSEscape(__AddCellPriceType('tmp_xxx', 'PREFIX'));
644 $arCellTemplates[] = CUtil::JSEscape(__AddCellPrice('tmp_xxx', 'PREFIX'));
645 $arCellTemplates[] = CUtil::JSEscape(__AddCellCurrency('tmp_xxx', 'PREFIX'));
646
648 array("DIV" => "edit", "TAB" => GetMessage("IB_SEG_TAB_TITLE")),
649 );
650
652 ?>
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) ?>">
661
662 $tabControl = new CAdminTabControl("tabControl", $aTabs, true, true);
663 $tabControl->Begin();
664 $tabControl->BeginNextTab();
665 ?>
666<script>
667 BX('edit_edit_table').className += ' adm-shop-page-table';
668
669 var CellTPL = [];
670 <?php
671 foreach ($arCellTemplates as $key => $value)
672 {
673 ?>CellTPL[<?= $key; ?>] = '<?= $value; ?>';
674 <?php
675 }
676 ?>
677
678 var CellAttr = [];
679 <?php
680 foreach ($arCellTemplates as $key => $value)
681 {
682 ?>CellAttr[<?= $key; ?>] = '<?= $value; ?>';
683 <?php
684 }
685 ?>
686 var obPricesTable = new JCCatTblEdit({
687 'PREFIX': 'IB_SEG_',
688 'TABLE_PROP_ID': 'generator_price_table',
689 'PROP_COUNT_ID': 'generator_price_table_max_id'
690 });
691 obPricesTable.SetCells(CellTPL, CellAttr);
692
693 var obPropertyTable = new JCIBlockGenerator({
694 'PREFIX': 'IB_SEG_',
695 'TABLE_PROP_ID': 'generator_property_table',
696 'PROP_COUNT_ID': 'generator_price_table_max_id',
697 'AR_ALL_PROPERTIES': <?=CUtil::PhpToJSObject($arResult)?>,
698 'IMAGE_TABLE_ID': "adm-shop-table",
699 'AR_FILE_PROPERTIES': <?=CUtil::PhpToJSObject($arFileProperties)?>,
700 'subIBlockId': <?= $subIBlockId; ?>
701 });
702
703 function addProperty(arFileProperties)
704 {
705 var fileProperties = eval(arFileProperties),
706 id = 0;
707 if(BX('ib_seg_max_property_id'))
708 {
709 id = BX('ib_seg_max_property_id').value;
710 if(id >= obPropertyTable.AR_FILE_PROPERTIES.length + 2)
711 {
712 return;
713 }
714 BX('ib_seg_max_property_id').value = Number(BX('ib_seg_max_property_id').value) + 1;
715 }
716 obPropertyTable.SELECTED_PROPERTIES[id] = 'DETAIL';
717
718 var propertySpan = BX('ib_seg_property_span');
719 if(propertySpan)
720 {
721 var options = [];
722 for(var key in fileProperties)
723 {
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"]
728 }
729 );
730 }
731 var span = BX.create('span', {
732 props: {
733 className: 'adm-select-wrap'
734 }
735 });
736 var content = BX.create('select', {
737 props: {
738 name:"SELECTED_PROPERTY[]",
739 id:"SELECTED_PROPERTY[]",
740 className:"adm-select ib_seg_add_property_but"
741 },
742 style : {
743 width : '130px'
744 },
745 children : options,
746 'events': {
747 change : function()
748 {
749 obPropertyTable.SELECTED_PROPERTIES[id] = this.value;
750 }
751 }
752 });
753 span.appendChild(content);
754 propertySpan.appendChild(span);
755 }
756 }
757
758 BX.message({
759 'PROPERTY_VALUES_EMPTY': '<?=GetMessageJS('IB_SEG_PROPERTY_VALUES_EMPTY'); ?>'
760 });
761</script>
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">
765 <tr>
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>
772 </td>
773 </tr>
774 <tr>
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">
778 <?= GetMessage("IB_SEG_BASE_LENGTH") ?>:
779 <input type="text" id="CAT_BASE_LENGTH" name="IB_SEG_BASE_LENGTH" style="width: 120px; margin-right: 10px">
780 <?= GetMessage("IB_SEG_BASE_WIDTH") ?>:
781 <input type="text" id="CAT_BASE_WIDTH" name="IB_SEG_BASE_WIDTH" style="width: 120px; margin-right: 10px">
782 <?= GetMessage("IB_SEG_BASE_HEIGHT") ?>:
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>
785 </td>
786 </tr>
787 <tr>
788 <td class="adm-detail-content-cell-l"><?= GetMessage((!$useStoreControl ? 'IB_SEG_QUANTITY' : 'IB_SEG_MEASURE')); ?></td>
789 <td class="adm-detail-content-cell-r"><?php
790 if (!$useStoreControl)
791 {
792 ?><input type="text" style="width: 120px; margin-right: 10px" class="adm-input" name="IB_SEG_QUANTITY">
793 <?= GetMessage('IB_SEG_MEASURE');
794 }
795 ?> <span class="adm-select-wrap" style="vertical-align: middle !important;"><select name="IB_SEG_MEASURE" class="adm-select" style="width: 169px;"><?php
796 $measureIterator = CCatalogMeasure::getList(
797 array(), array(), false, false, array("ID", "CODE", "MEASURE_TITLE", "SYMBOL_INTL", "IS_DEFAULT")
798 );
799 while($measure = $measureIterator->Fetch())
800 {
801 ?><option value="<?=$measure['ID']?>"<?= ($measure['IS_DEFAULT'] == 'Y' ? ' selected' : '') ?>><?php
802 echo htmlspecialcharsEx($measure['MEASURE_TITLE']); ?></option><?php
803 }
804 unset($measure, $measureIterator);
805 ?></select></span></td>
806 </tr>
807 <tr>
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;">
811 <?php
813 echo SelectBoxFromArray('IB_SEG_VAT_ID', $arVATRef, '', "", (!$elementAdd ? "disabled readonly" : '').'class="adm-select" style="width: 169px;"');
814 ?>
815 </span>
816 </td>
817 </tr>
818 <tr>
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
822 $vatInclude = (Main\Config\Option::get('catalog', 'default_product_vat_included') === 'Y');
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>
825 </td>
826 </tr>
827 <?php
828 if ($accessController->check(ActionDictionary::ACTION_PRODUCT_PURCHASE_INFO_VIEW) && !$useStoreControl)
829 {
830 $baseCurrency = Currency\CurrencyManager::getBaseCurrency();
831 ?>
832 <tr>
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;">
837 <option value=""><?=htmlspecialcharsbx(GetMessage('IB_SEG_EMPTY_VALUE'))?></option>
838 <?php
839 foreach (Currency\CurrencyManager::getCurrencyList() as $id => $title)
840 {
841 ?><option value="<?=$id; ?>"<?=($id == $baseCurrency ? ' selected' : ''); ?>><?=htmlspecialcharsbx($title); ?></option><?php
842 }
843 unset($id, $title);
844 ?>
845 </select></span>
846 </td>
847 </tr>
848 <?php
849 }
851 if (!empty($priceTypeList)):
852 ?>
853 <tr>
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;">
857 <tr class="heading">
858 <td><?= GetMessage("IB_SEG_PRICE_TYPE") ?>:</td>
859 <td><?= GetMessage("IB_SEG_PRICE") ?>:</td>
860 <td><?= GetMessage("IB_SEG_CURRENCY") ?>:</td>
861 </tr>
862 <tbody>
863 <?php
864 $intCount = 0;
865 echo __AddRangeRow($intCount, IB_SEG_ROW_PREFIX);
866 ?>
867 </tbody>
868 </table>
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">
871 </td>
872 </tr>
873 <?php
875 ?>
876 </table>
877 </div></div>
878</td></tr>
879<tr>
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>
883 </div>
884 </td>
885</tr>
886<tr>
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">
892 <script>
893 <?php
894 foreach($arResult as $key => $arProperty)
895 {
896 ?>
897 obPropertyTable.addPropertyTable(<?=$key?>);
898 <?php
899 }
900 ?>
901 </script>
902 </div>
903 </div>
904 </td>
905</tr>
906<tr>
907 <td colspan="2" class="adm-detail-content-cell">
908 <div class="adm-detail-content-item-block-view-tab">
909 <div class="adm-detail-title-view-tab"><?= GetMessage("IB_SEG_PICTURES") ?></div>
910 <div class="adm-shop-block-wrap">
911 <div class="adm-shop-select-bar" id="ib_seg_select_prop_bar">
912 <input type="hidden" value="0" id="ib_seg_max_property_id">
913 <input type="hidden" value="0" id="ib_seg_max_image_row_id">
914 <?php
916 'ID' => 'DETAIL',
917 'NAME' => GetMessage('IB_SEG_DETAIL'),
918 'SELECTED' => 'Y',
919 ];
921 'ID' => 'ANNOUNCE',
922 'NAME' => GetMessage('IB_SEG_ANNOUNCE'),
923 ];
924 ?>
925 <span class="adm-btn" onclick="obPropertyTable.addPropertyImages();" id="ib_seg_add_images_button"><?= GetMessage("IB_SEG_ADD_PICTURES") ?></span>
926 <span class="adm-shop-bar-btn-wrap" id="ib_seg_property_span">
927 <script>
928 addProperty(<?=CUtil::PhpToJSObject($arFileProperties)?>);
929 </script>
930 </span>
931 <span id="ib_seg_property_add_button_span">
932 <span id="ib_seg_property_add_button_span_click" class="adm-btn adm-btn-add" onclick="addProperty(<?=CUtil::PhpToJSObject($arFileProperties)?>)"></span>
933 </span>
934 </div>
935 <table class="internal adm-shop-page-internal" id="adm-shop-table">
936 </table>
937 </div>
938 </div>
939 </td>
940</tr>
941 <?php
942 $tabControl->EndTab();
943 $tabControl->End();
944 ?>
945 </form>
946 <?php
947}
948require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
return select
Определения access_edit.php:440
CatalogGetVATArray($arFilter=array(), $bInsertEmptyLine=false)
Определения include.php:2154
global $APPLICATION
Определения include.php:80
$arVATRef
Определения options.php:1882
$accessController
Определения options.php:23
$arResult
Определения generate_coupon.php:16
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static isUsedInventoryManagement()
Определения state.php:42
static getTypeList()
Определения group.php:273
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
static includeModule($moduleName)
Определения loader.php:67
static ShowMessage($message)
Определения admin_lib.php:2351
static PhpToJavaScript($items)
Определения admin_lib.php:1448
static Add($fields, $checkExist=true)
Определения product.php:516
static SelectBox($sFieldName, $sValue, $sDefaultValue='', $bFullName=true, $JavaFunc='', $sAdditionalParams='')
Определения currency.php:522
static Add($fields, $recount=false)
Определения price.php:187
static add($arFields)
Определения measure_ratio.php:95
static GetList($arOrder=array("SORT"=>"ASC", "VALUE"=>"ASC"), $arFilter=array())
Определения iblockpropertyenum.php:18
static Init($arExt=array(), $bReturn=false)
Определения jscore.php:66
static RegisterExt($name, $arPaths)
Определения jscore.php:28
static PhpToJSObject($arData, $bWS=false, $bSkipTilda=false, $bExtType=false)
Определения util.php:66
$arValues
Определения component_props.php:25
$arFields
Определения dblapprove.php:5
$template
Определения file_edit.php:49
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
$arr
Определения file_new.php:624
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
$entity
$arDirProperties
$subTmpId
Определения iblock_subelement_generator.php:44
$arPropertyPopupIB2
$elementAdd
Определения iblock_subelement_generator.php:54
if($subIBlockId<=0) $subPropValue
Определения iblock_subelement_generator.php:43
$arFilePropertiesExt
$boolHighLoad
$allowProductAdd
Определения iblock_subelement_generator.php:53
__AddRangeRow($intRangeID, $strPrefix)
$arPropertyPopupIB1
$iBlockId
Определения iblock_subelement_generator.php:45
$arFileProperties
$parentProductName
Определения iblock_subelement_generator.php:47
$arAllProperties
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
__AddCellCurrency($intRangeID, $strPrefix)
$useStoreControl
Определения iblock_subelement_generator.php:49
$arCellTemplates[]
const IB_SEG_ROW_PREFIX
Определения iblock_subelement_generator.php:34
__showPopup($element_id, $items)
__AddCellPrice($intRangeID, $strPrefix)
Определения iblock_subelement_generator.php:95
while($arIBlockProperty=$dbIBlockProperty->Fetch()) $dbParentIBlockProperty
$vatInclude
$arPropertyPopup
__AddCellPriceType($intRangeID, $strPrefix)
Определения iblock_subelement_generator.php:71
$arAllParentProperties
$arSKUInfo
Определения iblock_subelement_generator.php:46
if(! $useStoreControl) $measureIterator
$arJSDescription
Определения iblock_subelement_generator.php:23
$dbIBlockProperty
arraysCombination(&$arr, $index=0)
$subIBlockId
Определения iblock_subelement_generator.php:38
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$tabControl
Определения csv_new_setup.php:244
$aTabs
Определения csv_new_setup.php:238
endif
Определения csv_new_setup.php:990
bitrix_sessid_post($varname='sessid', $returnInvocations=false)
Определения tools.php:4700
check_bitrix_sessid($varname='sessid')
Определения tools.php:4686
htmlspecialcharsback($str)
Определения tools.php:2693
ShowError($strError, $cls="errortext")
Определения tools.php:4499
htmlspecialcharsEx($str)
Определения tools.php:2685
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
SelectBoxFromArray( $strBoxName, $db_array, $strSelectedVal="", $strDetText="", $field1="class='typeselect'", $go=false, $form="form1")
Определения tools.php:216
$order
Определения payment.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
font style
Определения invoice.php:442
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$items
Определения template.php:224
$title
Определения pdf.php:123
$max
Определения template_copy.php:262
$action
Определения file_dialog.php:21
if(file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater.log") &&is_file($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater.log") &&is_readable($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/updater.log")) $rsData
Определения update_log.php:102
if(!empty($XML_DATA['PRICE'])) $priceTypeList
Определения yandex_run.php:872