21 if(!Loader::includeModule(
'iblock'))
26 \CJSCore::RegisterExt(
'select_product_preset', array(
27 'js' =>
'/bitrix/js/sale/admin/discountpreset/select_product_preset.js',
28 'lang' =>
'/bitrix/modules/sale/lang/' . LANGUAGE_ID .
'/admin/js/discountpreset/select_product_preset.php',
29 'rel' => array(
'core'),
32 \CUtil::InitJSCore(array(
'select_product_preset'));
43 <div class="sale-discount-container-box">
44 <div class="sale-discount-title-container">
45 <div class="sale-discount-title-text">' .
Loc::getMessage(
'SALE_BASE_PRESET_SUB_TITLE_PRODUCTS') .
'</div>
46 <div class="clb"></div>
48 <div class="adm-sl-content-container">
49 <div class="sale-discount-btn-container">
50 <a href="#" class="adm-btn adm-btn-save adm-btn-add" title="" id="sale_discount_preset_product_add">' .
Loc::getMessage(
'SALE_BASE_PRESET_ADD_ELEMENTS') .
'</a>
53 <div class="sale-discount-content-container">
54 <input type="hidden" name="' . $inputName .
'" value="">
55 <div class="adm-s-order-table-ddi" style="margin-top:20px">
56 <table class="adm-s-order-table-ddi-table" style="width: 100%;" id="sale_discount_preset_product_table">
57 <thead style="text-align: left;">
65 <tbody style="border: 1px solid rgb(221, 221, 221);" id="sale_discount_preset_product_table_empty_row">
67 <td colspan="4" style="padding: 20px;">
81 $fromInputName = $inputName;
84 $fromInputName .=
'[]';
88 <div class="sale-discount-container-box">
89 <div class="sale-discount-title-container">
90 <div class="sale-discount-title-text">' .
Loc::getMessage(
'SALE_BASE_PRESET_SUB_TITLE_SECTION') .
'</div>
91 <div class="clb"></div>
93 <div class="adm-sl-content-container">
94 <div class="sale-discount-btn-container">
95 <a href="#" class="adm-btn adm-btn-save adm-btn-add" title="" id="sale_discount_preset_section_add">' .
Loc::getMessage(
'SALE_BASE_PRESET_ADD_ELEMENTS') .
'</a>
98 <div class="sale-discount-content-container" style="margin-top:20px;">
99 <table class="sale-discount-detail-content-sale-table bdrb" style="margin: 0 auto;" border="0" cellspacing="7" cellpadding="0">
100 <tbody id="sale_discount_preset_section_tbody">
101 <input type="hidden" name="' . $fromInputName .
'" value="">
114 $currentValue = array();
116 $sectionIds = $state->get($inputName);
119 $sectionsIterator = SectionTable::getList(array(
120 'select' => array(
'ID',
'NAME'),
121 'filter' => array(
'@ID' => $sectionIds),
124 while($row = $sectionsIterator->fetch())
126 $currentValue[] =
"{$row['NAME']} [{$row['ID']}]";
131 $APPLICATION->IncludeComponent(
132 'bitrix:main.lookup.input',
135 'CONTROL_ID' =>
'select_section',
136 'INPUT_NAME' => $inputName .
'[]',
137 'INPUT_NAME_STRING' =>
'inp_'. $inputName,
138 'INPUT_VALUE_STRING' => implode(
"\n", $currentValue),
140 'MULTIPLE' => $multi?
'Y' :
'N',
141 'MAX_WIDTH' =>
'200',
142 'MIN_HEIGHT' =>
'100',
143 'WITHOUT_IBLOCK' =>
'Y',
146 ),
null, array(
'HIDE_ICONS' =>
'Y')
148 $htmlResult = ob_get_contents();
161 $sectionIds = array();
162 foreach($conditions as $condition)
164 if($condition[
'CLASS_ID'] !==
'CondIBSection')
168 $sectionIds[] = $condition[
'DATA'][
'value'];
171 return array_unique($sectionIds);
181 $productIds = array();
182 foreach($conditions as $condition)
184 if($condition[
'CLASS_ID'] !==
'CondIBElement')
189 $value = $condition[
'DATA'][
'value'];
190 if(!is_array($value))
192 $value = array($value);
195 $productIds = array_merge($productIds, $value);
198 return array_unique($productIds);
203 $sectionIds = $this->cleanIds($sectionIds);
204 if(empty($sectionIds))
210 foreach($sectionIds as $sectionId)
212 if(empty($sectionId))
218 'CLASS_ID' =>
'CondIBSection',
221 'value' => (
int)$sectionId,
232 $productIds = $this->cleanIds($productIds);
233 if(empty($productIds))
240 'CLASS_ID' =>
'CondIBElement',
243 'value' => array_filter(array_map(
'intval', $productIds)),
251 $sectionIds = $this->cleanIds($sectionIds);
252 if(empty($sectionIds))
258 'CLASS_ID' =>
'ActSaleSubGrp',
269 $productIds = $this->cleanIds($productIds);
270 if(empty($productIds))
276 'CLASS_ID' =>
'ActSaleSubGrp',
283 'CLASS_ID' =>
'CondIBElement',
286 'value' => array_map(
'intval', $productIds),
295 $productData = array();
297 $productIds = $this->cleanIds($productIds);
298 if(empty($productIds))
303 foreach($productIds as $productId)
306 'productId' => $productId,
317 if(!is_array($state->get(
'discount_section', array())))
322 if(!is_array($state->get(
'discount_product', array())))
328 private function cleanIds($ids)
340 return array_filter($ids);
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
processAjaxActionGetProductDetails(array $params=array())
renderSections(State $state, $inputName, $multi=true)
getSectionsFromConditions(array $conditions=null)
validateSectionsAndProductsState(State $state, ErrorCollection $errorCollection)
generateSectionActions($sectionIds)
generateProductActions($productIds)
generateSectionConditions($sectionIds, $logic='Equal')
generateProductsData($productIds, $siteId)
renderSectionBlock(State $state, $inputName='discount_section', $multi=true)
renderElementBlock(State $state, $inputName='discount_product', $multi=true)
getProductsFromConditions(array $conditions=null)
generateProductConditions($productIds, $logic='Equal')