1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
orderperday.php
См. документацию.
1<?php
2
3namespace Sale\Handlers\DiscountPreset;
4
5use Bitrix\Main\Error;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Sale\Discount\Preset\ArrayHelper;
8use Bitrix\Sale\Discount\Preset\BasePreset;
9use Bitrix\Sale\Discount\Preset\HtmlHelper;
10use Bitrix\Sale\Discount\Preset\Manager;
11use Bitrix\Sale\Discount\Preset\State;
12
13class OrderPerDay extends BasePreset
14{
15 public function getSort()
16 {
17 return 200;
18 }
19
20 public function getTitle()
21 {
22 return Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_NAME');
23 }
24
25 public function getDescription()
26 {
27 return '';
28 }
29
33 public function getCategory()
34 {
35 return Manager::CATEGORY_PRODUCTS;
36 }
37
38 public function getFirstStepName()
39 {
40 return 'InputName';
41 }
42
43 public function processShowInputName(State $state)
44 {
45 return $this->processShowInputNameInternal($state);
46 }
47
48 public function processSaveInputName(State $state)
49 {
50 return $this->processSaveInputNameInternal($state, 'InputAmount');
51 }
52
53 public function processShowInputAmount(State $state)
54 {
55 $lid = $state->get('discount_lid');
56 $currency = \Bitrix\Sale\Internals\SiteCurrencyTable::getSiteCurrency($lid);
57
58 $days = array(
59 1 => Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_OF_WEEK_1'),
60 2 => Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_OF_WEEK_2'),
61 3 => Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_OF_WEEK_3'),
62 4 => Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_OF_WEEK_4'),
63 5 => Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_OF_WEEK_5'),
64 6 => Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_OF_WEEK_6'),
65 7 => Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_OF_WEEK_7')
66 );
67
68 $sectionCount = count($state->get('discount_section', array()));
69
70 return '
71 <table width="100%" border="0" cellspacing="7" cellpadding="0">
72 <tbody>
73 <tr>
74 <td class="adm-detail-content-cell-l" style="width:40%;"><strong>' . Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_ORDER_DISCOUNT_VALUE') . ':</strong></td>
75 <td class="adm-detail-content-cell-r" style="width:60%;">
76 <input type="text" name="discount_value" value="' . htmlspecialcharsbx($state->get('discount_value')) . '" maxlength="100" style="width: 100px;"> <span>' . $currency . '</span>
77 </td>
78 </tr>
79 <tr>
80 <td class="adm-detail-content-cell-l" style="width:40%;"><strong>' . Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ORDER_PERDAY_DAY_LABEL') . ':</strong></td>
81 <td class="adm-detail-content-cell-r">
82 ' . HtmlHelper::generateMultipleSelect('discount_days[]', $days, $state->get('discount_days', array()), array('size=7')) . '
83 </td>
84 </tr>
85 </tbody>
86 </table>
87 ';
88 }
89
90 public function processSaveInputAmount(State $state)
91 {
92 if(!trim($state->get('discount_value')))
93 {
95 }
96
97 if(!$state->get('discount_days'))
98 {
99 $this->errorCollection[] = new Error(Loc::getMessage('SALE_HANDLERS_DISCOUNTPRESET_ERROR_EMPTY_VALUE_DAYS'));
100 }
101
102 if(!$this->errorCollection->isEmpty())
103 {
104 return array($state, 'InputAmount');
105 }
106
107 return array($state, 'CommonSettings');
108 }
109
110 public function processShowCommonSettings(State $state)
111 {
112 return $this->processShowCommonSettingsInternal($state);
113 }
114
115 public function processSaveCommonSettings(State $state)
116 {
117 return $this->processSaveCommonSettingsInternal($state);
118 }
119
120 public function generateState(array $discountFields)
121 {
122 $discountFields = $this->normalizeDiscountFields($discountFields);
123
124 $stateFields = [
125 'discount_lid' => $discountFields['LID'],
126 'discount_name' => $discountFields['NAME'],
127 'discount_groups' => $this->getUserGroupsByDiscount($discountFields['ID']),
128 'discount_value' => ArrayHelper::getByPath($discountFields, 'ACTIONS.CHILDREN.0.DATA.Value'),
129 'discount_type' => ArrayHelper::getByPath($discountFields, 'ACTIONS.CHILDREN.0.DATA.Unit'),
130 'discount_days' => ArrayHelper::getByPath($discountFields, 'CONDITIONS.CHILDREN.0.DATA.value'),
131 ];
132
133 return parent::generateState($discountFields)->append($stateFields);
134 }
135
136 public function generateDiscount(State $state)
137 {
138 return array_merge(
139 parent::generateDiscount($state),
140 [
141 'CONDITIONS' => [
142 'CLASS_ID' => 'CondGroup',
143 'DATA' => [
144 'All' => 'AND',
145 'True' => 'True',
146 ],
147 'CHILDREN' => [
148 [
149 'CLASS_ID' => 'CondSaleCmnDayOfWeek',
150 'DATA' => [
151 'logic' => 'Equal',
152 'value' => $state->get('discount_days'),
153 ],
154 ],
155 ],
156 ],
157 'ACTIONS' => [
158 'CLASS_ID' => 'CondGroup',
159 'DATA' => [
160 'All' => 'AND',
161 ],
162 'CHILDREN' => [
163 [
164 'CLASS_ID' => 'ActSaleBsktGrp',
165 'DATA' => [
166 'Type' => 'Discount',
167 'Value' => $state->get('discount_value'),
168 'Unit' => $state->get('discount_type', 'CurAll'),
169 'Max' => 0,
170 'All' => 'AND',
171 'True' => 'True',
172 ],
173 'CHILDREN' => [],
174 ],
175 ],
176 ],
177 ]
178 );
179 }
180}
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
processShowCommonSettingsInternal(State $state)
Определения basepreset.php:836
getUserGroupsByDiscount($discountId)
Определения basepreset.php:703
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
trait Error
Определения error.php:11
</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