3namespace Sale\Handlers\DiscountPreset;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Sale\Discount\Preset\ArrayHelper;
9use Bitrix\Sale\Discount\Preset\HtmlHelper;
10use Bitrix\Sale\Discount\Preset\Manager;
11use Bitrix\Sale\Discount\Preset\State;
12use Bitrix\Sale\Internals;
14class ProductDelivery
extends Delivery
18 return Loc::getMessage(
'SALE_HANDLERS_DISCOUNTPRESET_PRODUCTDELIVERY_NAME');
31 return Manager::CATEGORY_DELIVERY;
34 public function processShowInputAmount(State $state)
36 $lid = $state->get(
'discount_lid');
37 $currency = Internals\SiteCurrencyTable::getSiteCurrency($lid);
38 $deliverySystems = $this->getDeliverySystems($lid);
40 $forSelectData =
array();
41 foreach($deliverySystems as $id => $deliverySystem)
43 $forSelectData[$id] = $deliverySystem->getNameWithParent();
45 Main\Type\Collection::sortByColumn($forSelectData,
'NAME',
'',
null,
true);
47 $sectionCount =
count($state->get(
'discount_section',
array()));
50 <table width="100%" border="0" cellspacing="7" cellpadding="0">
52 ' . $this->renderDiscountValue($state,
$currency) .
'
54 <td class="adm-detail-content-cell-l" style="width:40%;"><strong>' . Loc::getMessage(
'SALE_HANDLERS_DISCOUNTPRESET_SHIPMENT_DELIVERY_LABEL') .
':</strong></td>
55 <td class="adm-detail-content-cell-r">
56 ' . HtmlHelper::generateMultipleSelect(
'discount_delivery[]', $forSelectData, $state->get(
'discount_delivery',
array())) .
'
62 <script type="application/javascript">
64 new BX.Sale.Admin.DiscountPreset.SelectProduct({
65 presetId: "' . \CUtil::JSEscape($this->
className()) .
'",
66 siteId: "' . \CUtil::JSEscape($lid) .
'",
67 sectionCount: ' . $sectionCount .
',
68 products: ' . \CUtil::PhpToJSObject($this->
generateProductsData($state->get(
'discount_product'), $lid)) .
'
78 public function processSaveInputAmount(State $state)
80 if(!trim($state->get(
'discount_value')))
82 $this->errorCollection[] =
new Error(Loc::getMessage(
'SALE_HANDLERS_DISCOUNTPRESET_ERROR_EMPTY_VALUE'));
85 if(!$state->get(
'discount_delivery'))
87 $this->errorCollection[] =
new Error(Loc::getMessage(
'SALE_HANDLERS_DISCOUNTPRESET_ERROR_EMPTY_DELIVERY'));
90 if(!$this->errorCollection->isEmpty())
92 return array($state,
'InputAmount');
95 return array($state,
'CommonSettings');
98 public function generateState(
array $discountFields)
103 'discount_lid' => $discountFields[
'LID'],
104 'discount_name' => $discountFields[
'NAME'],
106 'discount_value' => ArrayHelper::getByPath($discountFields,
'ACTIONS.CHILDREN.0.DATA.Value'),
107 'discount_type' => ArrayHelper::getByPath($discountFields,
'ACTIONS.CHILDREN.0.DATA.Unit'),
108 'discount_delivery' => ArrayHelper::getByPath($discountFields,
'CONDITIONS.CHILDREN.0.DATA.value'),
109 'discount_section' => $this->
getSectionsFromConditions(ArrayHelper::getByPath($discountFields,
'CONDITIONS.CHILDREN.1.CHILDREN.0.CHILDREN')),
110 'discount_product' => $this->
getProductsFromConditions(ArrayHelper::getByPath($discountFields,
'CONDITIONS.CHILDREN.1.CHILDREN.1.CHILDREN')),
113 return parent::generateState($discountFields)->append($stateFields);
116 public function generateDiscount(State $state)
122 parent::generateDiscount($state),
125 'CLASS_ID' =>
'CondGroup',
132 'CLASS_ID' =>
'CondSaleDelivery',
135 'value' => $state->get(
'discount_delivery'),
139 'CLASS_ID' =>
'CondGroup',
145 $generateSectionConditions? [
146 'CLASS_ID' =>
'CondBsktProductGroup',
151 'CHILDREN' => $generateSectionConditions,
153 $generateProductConditions? [
154 'CLASS_ID' =>
'CondBsktProductGroup',
159 'CHILDREN' => $generateProductConditions,
164 'CLASS_ID' =>
'CondBsktCntGroup',
170 'CHILDREN' => array_merge(
172 $this->generateProductConditions($state->get(
'discount_product'),
'Not')
178 'CLASS_ID' =>
'CondGroup',
184 'CLASS_ID' =>
'ActSaleDelivery',
186 'Type' => $this->getTypeOfDiscount(),
187 'Value' => $state->get(
'discount_value'),
188 'Unit' => $state->get(
'discount_type',
'Cur'),
normalizeDiscountFields(array $discountFields)
getUserGroupsByDiscount($discountId)
getSectionsFromConditions(array $conditions=null)
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')
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</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."%"