1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
simpleproduct.php
См. документацию.
1<?php
2
3namespace Sale\Handlers\DiscountPreset;
4
5use Bitrix\Main\Localization\Loc;
6use Bitrix\Sale\Discount\Preset\ArrayHelper;
7use Bitrix\Sale\Discount\Preset\Manager;
8use Bitrix\Sale\Discount\Preset\SelectProductPreset;
9use Bitrix\Sale\Discount\Preset\State;
10use Bitrix\Sale\Internals;
11
12class SimpleProduct extends SelectProductPreset
13{
14 public function getTitle()
15 {
16 return Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_SIMPLEPRODUCT_NAME');
17 }
18
19 public function getDescription()
20 {
21 return '';
22 }
23
27 public function getCategory()
28 {
29 return Manager::CATEGORY_PRODUCTS;
30 }
31
32 public function getFirstStepName()
33 {
34 return 'InputName';
35 }
36
37 public function processShowInputName(State $state)
38 {
39 return $this->processShowInputNameInternal($state);
40 }
41
42 public function processSaveInputName(State $state)
43 {
44 return $this->processSaveInputNameInternal($state, 'InputAmount');
45 }
46
47 public function processShowInputAmount(State $state)
48 {
49 $lid = (string)$state->get('discount_lid');
50 $currency = Internals\SiteCurrencyTable::getSiteCurrency($lid);
51
52 $sectionCount = count($state->get('discount_section', []));
53
54 return '
55 <table width="100%" border="0" cellspacing="7" cellpadding="0">
56 <tbody>
57 ' . $this->renderDiscountValue($state, $currency) . '
58 </tbody>
59 </table>
60
61 <script type="application/javascript">
62 BX.ready(function(){
63 new BX.Sale.Admin.DiscountPreset.SelectProduct({
64 presetId: "' . \CUtil::JSEscape($this->className()) . '",
65 siteId: "' . \CUtil::JSEscape($lid) . '",
66 sectionCount: ' . $sectionCount . ',
67 products: ' . \CUtil::PhpToJSObject($this->generateProductsData($state->get('discount_product'), $lid)) . '
68 });
69 });
70 </script>
71
72 ' . $this->renderElementBlock($state) . '
73 ' . $this->renderSectionBlock($state) . '
74 ';
75 }
76
77 public function processSaveInputAmount(State $state)
78 {
79 if (!trim((string)$state->get('discount_value')))
80 {
82 }
83
84 $this->validateSectionsAndProductsState($state, $this->errorCollection);
85
86 if (!$this->errorCollection->isEmpty())
87 {
88 return [$state, 'InputAmount'];
89 }
90
91 return [$state, 'CommonSettings'];
92 }
93
94 public function processShowCommonSettings(State $state)
95 {
96 return $this->processShowCommonSettingsInternal($state);
97 }
98
99 public function processSaveCommonSettings(State $state)
100 {
101 return $this->processSaveCommonSettingsInternal($state);
102 }
103
104 public function generateState(array $discountFields)
105 {
106 $discountFields = $this->normalizeDiscountFields($discountFields);
107
108 $stateFields = [
109 'discount_value' => ArrayHelper::getByPath($discountFields, 'ACTIONS.CHILDREN.0.DATA.Value'),
110 'discount_type' => ArrayHelper::getByPath($discountFields, 'ACTIONS.CHILDREN.0.DATA.Unit'),
111 'discount_section' => $this->getSectionsFromConditions(ArrayHelper::getByPath($discountFields, 'CONDITIONS.CHILDREN.0.CHILDREN')),
112 'discount_product' => $this->getProductsFromConditions(ArrayHelper::getByPath($discountFields, 'CONDITIONS.CHILDREN.0.CHILDREN')),
113 ];
114
115 return parent::generateState($discountFields)->append($stateFields);
116 }
117
118 public function generateDiscount(State $state)
119 {
120 return array_merge(
121 parent::generateDiscount($state),
122 [
123 'CONDITIONS' => [
124 'CLASS_ID' => 'CondGroup',
125 'DATA' => [
126 'All' => 'AND',
127 'True' => 'True',
128 ],
129 'CHILDREN' => [
130 [
131 'CLASS_ID' => 'CondBsktProductGroup',
132 'DATA' => [
133 'Found' => 'Found',
134 'All' => 'OR',
135 ],
136 'CHILDREN' => array_merge(
137 $this->generateSectionConditions($state->get('discount_section')),
138 $this->generateProductConditions($state->get('discount_product'))
139 ),
140 ]
141 ],
142 ],
143 'ACTIONS' => [
144 'CLASS_ID' => 'CondGroup',
145 'DATA' => [
146 'All' => 'AND',
147 ],
148 'CHILDREN' => [
149 [
150 'CLASS_ID' => 'ActSaleBsktGrp',
151 'DATA' => [
152 'Type' => $this->getTypeOfDiscount(),
153 'Value' => $state->get('discount_value'),
154 'Unit' => $state->get('discount_type', 'CurAll'),
155 'Max' => 0,
156 'All' => 'OR',
157 'True' => 'True',
158 ],
159 'CHILDREN' => [
160 $this->generateSectionActions($state->get('discount_section')),
161 $this->generateProductActions($state->get('discount_product')),
162 ],
163 ],
164 ],
165 ],
166 ]
167 );
168 }
169}
normalizeDiscountFields(array $discountFields)
Определения basepreset.php:608
processSaveCommonSettingsInternal(State $state, $nextStep=self::FINAL_STEP)
Определения basepreset.php:923
processSaveInputNameInternal(State $state, $nextStep)
Определения basepreset.php:811
processShowInputNameInternal(State $state)
Определения basepreset.php:789
renderDiscountValue(State $state, $currency)
Определения basepreset.php:963
processShowCommonSettingsInternal(State $state)
Определения basepreset.php:836
getSectionsFromConditions(array $conditions=null)
Определения selectproductpreset.php:154
validateSectionsAndProductsState(State $state, ErrorCollection $errorCollection)
Определения selectproductpreset.php:315
generateSectionConditions($sectionIds, $logic='Equal')
Определения selectproductpreset.php:201
generateProductsData($productIds, $siteId)
Определения selectproductpreset.php:293
renderSectionBlock(State $state, $inputName='discount_section', $multi=true)
Определения selectproductpreset.php:79
renderElementBlock(State $state, $inputName='discount_product', $multi=true)
Определения selectproductpreset.php:35
getProductsFromConditions(array $conditions=null)
Определения selectproductpreset.php:174
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
</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
$currency
Определения template.php:266