1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sale_act.php
См. документацию.
1<?
5
6if (!Loader::includeModule('catalog'))
7 return;
8
9Loc::loadMessages(__FILE__);
10
16{
20
23
24 const ORDER_MANUAL_MODE_FIELD = 'ORDER_MANUAL_MODE';
26
28
29 protected static $getPercentFromBasePrice = null;
30
40 public static function isManualMode($order)
41 {
43 }
44
54 public static function setManualMode(&$order)
55 {
56 if (empty($order) || empty($order['ID']))
57 return;
60 array(
61 'USE_BASE_PRICE' => $order['USE_BASE_PRICE'],
62 'SITE_ID' => $order['SITE_ID'],
63 'CURRENCY' => $order['CURRENCY']
64 )
65 );
66 }
67
77 public static function clearManualMode(&$order)
78 {
79 if (empty($order) || !is_array($order))
80 return;
82 }
83
92 public static function filterApplied($row)
93 {
94 /* @noinspection PhpDeprecationInspection */
95 return (isset($row[self::BASKET_APPLIED_FIELD]));
96 }
97
107 public static function fillBasketApplied(&$order, $basket)
108 {
109 if (empty($order) || empty($order['ID']) || empty($order['BASKET_ITEMS']) || !is_array($order['BASKET_ITEMS']))
110 return;
111 if (empty($basket) || !is_array($basket))
112 return;
113 $founded = false;
114 foreach ($basket as $itemId => $value)
115 {
116 foreach ($order['BASKET_ITEMS'] as &$basketRow)
117 {
118 if (isset($basketRow['ID']) && $basketRow['ID'] == $itemId)
119 {
120 $founded = true;
121 /* @noinspection PhpDeprecationInspection */
122 $basketRow[self::BASKET_APPLIED_FIELD] = $value;
123 break;
124 }
125 }
126 unset($basketRow);
127 }
128 unset($value, $itemId);
129 if ($founded)
130 /* @noinspection PhpDeprecationInspection */
131 self::setManualMode($order);
132 }
133
142 public static function clearBasketApplied(&$order)
143 {
144 if (empty($order) || empty($order['ID']) || empty($order['BASKET_ITEMS']) || !is_array($order['BASKET_ITEMS']))
145 return;
146 foreach ($order['BASKET_ITEMS'] as &$basketRow)
147 {
148 /* @noinspection PhpDeprecationInspection */
149 if (array_key_exists(self::BASKET_APPLIED_FIELD, $basketRow))
150 /* @noinspection PhpDeprecationInspection */
151 unset($basketRow[self::BASKET_APPLIED_FIELD]);
152 }
153 unset($basketRow);
154 }
155
165 public static function ClearBasket($row)
166 {
168 }
169
182 public static function ApplyDelivery(&$order, $value, $unit, $extMode = false)
183 {
184 $extMode = ($extMode === true);
185 $params = array(
186 'VALUE' => $value,
187 'UNIT' => $unit,
188 );
189 if ($extMode)
190 $params['MAX_BOUND'] = 'Y';
192 $order,
193 $params
194 );
195 unset($params);
196 }
197
210 public static function ApplyBasketDiscount(&$order, $func, $value, $unit)
211 {
213 $order,
214 array(
215 'VALUE' => $value,
216 'UNIT' => $unit
217 ),
218 $func
219 );
220 }
221
232 public static function ApplyGiftDiscount(&$order, $callableFilter)
233 {
235 }
236}
237
239{
240 public static function GetConditionShow($arParams)
241 {
242 if (!isset($arParams['ID']))
243 return false;
244 if ($arParams['ID'] != static::GetControlID())
245 return false;
246 $arControl = array(
247 'ID' => $arParams['ID'],
248 'ATOMS' => static::GetAtomsEx(false, true),
249 );
250
251 return static::CheckAtoms($arParams['DATA'], $arParams, $arControl, true);
252 }
253
254 public static function Parse($arOneCondition)
255 {
256 if (!isset($arOneCondition['controlId']))
257 return false;
258 if ($arOneCondition['controlId'] != static::GetControlID())
259 return false;
260 $arControl = array(
261 'ID' => $arOneCondition['controlId'],
262 'ATOMS' => static::GetAtomsEx(false, true),
263 );
264
265 return static::CheckAtoms($arOneCondition, $arOneCondition, $arControl, false);
266 }
267}
268
270{
271 public static function GetControlID()
272 {
273 return 'CumulativeAction';
274 }
275
277 {
278 return new \Bitrix\Main\EventResult(
279 \Bitrix\Main\EventResult::SUCCESS,
280 static::getControlDescr() + array('GROUP' => 'Y', 'EXECUTE_MODULE' => 'sale'),
281 'sale'
282 );
283 }
284
285 public static function IsGroup($strControlID = false)
286 {
287 return 'Y';
288 }
289
290 public static function Generate($oneCondition, $params, $control, $subs = false)
291 {
292 if (empty($oneCondition['ranges']) || !is_array($oneCondition['ranges']))
293 {
294 return '';
295 }
296
297 $filterCode = 'null';
298 if ($subs && is_array($subs))
299 {
300 $filterCode = static::buildSubsCode($subs, $oneCondition);
301 }
302
303 $rangesAsString = var_export($oneCondition['ranges'], true);
304
305 static::convertSumConfigurationDateToInt($oneCondition['sum_period_data']);
306
307 $configurationAsString = var_export(
308 array(
309 'sum' => $oneCondition,
310 'apply_if_more_profitable' => $oneCondition['apply_if_more_profitable'],
311 ),
312 true
313 );
314
316 return "\\Bitrix\\Sale\\Discount\\Actions::applyCumulativeToBasket({$params['ORDER']}, {$rangesAsString}, {$configurationAsString}, {$filterCode})";
317 }
318
319 protected static function buildSubsCode(array $subs, array $oneCondition)
320 {
321 if ($oneCondition['All'] == 'AND')
322 {
323 $prefix = '';
324 $logic = ' && ';
325 $itemPrefix = ($oneCondition['True'] == 'True' ? '' : '!');
326 }
327 else
328 {
329 $itemPrefix = '';
330 if ($oneCondition['True'] == 'True')
331 {
332 $prefix = '';
333 $logic = ' || ';
334 }
335 else
336 {
337 $prefix = '!';
338 $logic = ' && ';
339 }
340 }
341
342 $commandLine = $itemPrefix . implode($logic . $itemPrefix, $subs);
343 if ($prefix != '')
344 {
345 $commandLine = $prefix . '(' . $commandLine . ')';
346 }
347
348 $code = "function(\$row){
349 return ({$commandLine});
350 }";
351
352 return $code;
353 }
354
355 protected static function convertSumConfigurationDateToInt(&$periodData = array())
356 {
360
361 if (isset($periodData['discount_sum_order_start']))
362 {
363 static::ConvertDateTime2Int(
364 $periodData['discount_sum_order_start'],
365 'FULL',
366 \CTimeZone::getOffset()
367 );
368 }
369
370 if (isset($periodData['discount_sum_order_end']))
371 {
372 static::ConvertDateTime2Int(
373 $periodData['discount_sum_order_end'],
374 'FULL',
375 \CTimeZone::getOffset()
376 );
377 }
378 }
379}
380
385
387{
388 public static function GetShowIn($arControls)
389 {
390 $arControls = array();
391 return $arControls;
392 }
393
394 public static function GetControlShow($arParams)
395 {
397 'controlId' => static::GetControlID(),
398 'group' => true,
399 'label' => '',
400 'defaultText' => '',
401 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
402 'control' => array(
403 Loc::getMessage('BT_SALE_ACT_GROUP_GLOBAL_PREFIX')
404 )
405 );
406
407 return $arResult;
408 }
409
410 public static function GetConditionShow($arParams)
411 {
412 return array(
413 'id' => $arParams['COND_NUM'],
414 'controlId' => static::GetControlID(),
415 'values' => array()
416 );
417 }
418
419 public static function Parse($arOneCondition)
420 {
421 return array(
422 'All' => 'AND'
423 );
424 }
425
426 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
427 {
428 if (!empty($arSubs) && is_array($arSubs))
429 return 'function (&'.$arParams['ORDER'].'){'.implode('; ',$arSubs).';};';
430 return '';
431 }
432}
433
435{
436 public static function GetShowIn($arControls)
437 {
438 $arControls = array(
439 'CondGroup'
440 );
441 return $arControls;
442 }
443
444 public static function GetControlID()
445 {
446 return 'GiftCondGroup';
447 }
448
449 public static function GetAtoms()
450 {
451 return static::GetAtomsEx(false, false);
452 }
453
454 public static function GetAtomsEx($strControlID = false, $boolEx = false)
455 {
456 $boolEx = (true === $boolEx ? true : false);
457 $arAtomList = array();
458
459 if (!$boolEx)
460 {
461 foreach ($arAtomList as &$arOneAtom)
462 {
463 $arOneAtom = $arOneAtom['JS'];
464 }
465 if (isset($arOneAtom))
466 unset($arOneAtom);
467 }
468
469 return $arAtomList;
470 }
471
472 public static function GetControlDescr()
473 {
474 $controlDescr = parent::GetControlDescr();
475 $controlDescr['FORCED_SHOW_LIST'] = array(
476 'GifterCondIBElement',
477 'GifterCondIBSection',
478 );
479 $controlDescr['SORT'] = 300;
480
481 return $controlDescr;
482 }
483
484 public static function GetControlShow($arParams)
485 {
486 return array(
487 'controlId' => static::GetControlID(),
488 'group' => true,
489 'containsOneAction' => true,
490 'label' => Loc::getMessage('BT_SALE_ACT_GIFT_LABEL'),
491 'defaultText' => '',
492 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
493 'control' => array(
494 Loc::getMessage('BT_SALE_ACT_GIFT_GROUP_PRODUCT_PREFIX'),
495 ),
496 'mess' => array(
497 'ADD_CONTROL' => Loc::getMessage('BT_SALE_SUBACT_ADD_CONTROL'),
498 'SELECT_CONTROL' => Loc::getMessage('BT_SALE_SUBACT_SELECT_CONTROL'),
499 'DELETE_CONTROL' => Loc::getMessage('BT_SALE_ACT_GROUP_DELETE_CONTROL')
500 )
501 );
502 }
503
504 public static function Parse($arOneCondition)
505 {
506 return array(
507 'All' => 'AND'
508 );
509 }
510
511 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
512 {
513 //I have to notice current method can work only with Gifter's. For example, it is CCatalogGifterProduct.
514 //Probably in future we'll add another gifter's and create interface or class, which will tell about attitude to CSaleActionGiftCtrlGroup.
515 $mxResult = '';
516 $boolError = false;
517
518 if (!isset($arSubs) || !is_array($arSubs) || empty($arSubs))
519 {
520 $boolError = true;
521 }
522 else
523 {
524 $mxResult = '\Bitrix\Sale\Discount\Actions::applySimpleGift(' . $arParams['ORDER'] . ', ' . implode('; ',$arSubs) . ');';
525 }
526 return $mxResult;
527 }
528
529 public static function ProvideGiftProductData(array $fields)
530 {
531 if(isset($fields['ACTIONS']) && is_array($fields['ACTIONS']))
532 {
533 $fields['ACTIONS_LIST'] = $fields['ACTIONS'];
534 }
535
536 if (
537 (empty($fields['ACTIONS_LIST']) || !is_array($fields['ACTIONS_LIST']))
538 && CheckSerializedData($fields['ACTIONS']))
539 {
540 $actions = unserialize($fields['ACTIONS'], ['allowed_classes' => false]);
541 }
542 else
543 {
544 $actions = $fields['ACTIONS_LIST'];
545 }
546
547 if (!is_array($actions) || empty($actions) || empty($actions['CHILDREN']))
548 {
549 return array();
550 }
551
552 $giftCondGroups = array();
553 foreach($actions['CHILDREN'] as $child)
554 {
555 if(isset($child['CLASS_ID']) && isset($child['DATA']) && $child['CLASS_ID'] === static::GetControlID())
556 {
557 //we know that in GiftCondGroup may be only once child. See 'containsOneAction' option in method GetControlShow().
558 $giftCondGroups[] = reset($child['CHILDREN']);
559 }
560 }
561 unset($child);
562
563 $giftsData = array();
564 foreach($giftCondGroups as $child)
565 {
566 //todo so hard, but we can't made abstraction every time.
567 if(isset($child['CLASS_ID']) && isset($child['DATA']))
568 {
569 $gifter = static::getGifter($child);
570 if(!$gifter)
571 {
572 continue;
573 }
574 $giftsData[] = $gifter->ProvideGiftData($child);
575 }
576 }
577 unset($child);
578
579 return $giftsData;
580 }
581
582 protected static function getGifter(array $data)
583 {
584 if(in_array($data['CLASS_ID'], array('GifterCondIBElement', 'GifterCondIBSection')))
585 {
586 return new CCatalogGifterProduct;
587 }
588 return null;
589 }
590
597 public static function ExtendProductIds(array $productIds)
598 {
599 return CCatalogGifterProduct::ExtendProductIds($productIds);
600 }
601}
602
604{
605 public static function GetConditionShow($arParams)
606 {
607 if (!isset($arParams['ID']))
608 return false;
609 if ($arParams['ID'] != static::GetControlID())
610 return false;
611 $arControl = array(
612 'ID' => $arParams['ID'],
613 'ATOMS' => static::GetAtomsEx(false, true)
614 );
615
616 return static::CheckAtoms($arParams['DATA'], $arParams, $arControl, true);
617 }
618
619 public static function Parse($arOneCondition)
620 {
621 if (!isset($arOneCondition['controlId']))
622 return false;
623 if ($arOneCondition['controlId'] != static::GetControlID())
624 return false;
625 $arControl = array(
626 'ID' => $arOneCondition['controlId'],
627 'ATOMS' => static::GetAtomsEx(false, true)
628 );
629
630 return static::CheckAtoms($arOneCondition, $arOneCondition, $arControl, false);
631 }
632
633 public static function GetVisual()
634 {
635 return array(
636 'controls' => array(
637 'All'
638 ),
639 'values' => array(
640 array(
641 'All' => 'AND'
642 ),
643 array(
644 'All' => 'OR'
645 )
646 ),
647 'logic' => array(
648 array(
649 'style' => 'condition-logic-and',
650 'message' => Loc::getMessage('BT_SALE_ACT_GROUP_LOGIC_AND')
651 ),
652 array(
653 'style' => 'condition-logic-or',
654 'message' => Loc::getMessage('BT_SALE_ACT_GROUP_LOGIC_OR')
655 )
656 )
657 );
658 }
659}
660
662{
663 public static function GetControlDescr()
664 {
665 $description = parent::GetControlDescr();
666 $description['EXECUTE_MODULE'] = 'sale';
667 $description['SORT'] = 200;
668 return $description;
669 }
670
671 public static function GetControlID()
672 {
673 return 'ActSaleDelivery';
674 }
675
676 public static function GetControlShow($arParams)
677 {
678 $arAtoms = static::GetAtomsEx(false, false);
679 $boolCurrency = false;
680 if (static::$boolInit)
681 {
682 if (isset(static::$arInitParams['CURRENCY']))
683 {
684 $arAtoms['Unit']['values']['Cur'] = static::$arInitParams['CURRENCY'];
685 $boolCurrency = true;
686 }
687 elseif (isset(static::$arInitParams['SITE_ID']))
688 {
689 $strCurrency = Sale\Internals\SiteCurrencyTable::getSiteCurrency(static::$arInitParams['SITE_ID']);
690 if (!empty($strCurrency))
691 {
692 $arAtoms['Unit']['values']['Cur'] = $strCurrency;
693 $boolCurrency = true;
694 }
695 }
696 }
697 if (!$boolCurrency)
698 {
699 unset($arAtoms['Unit']['values']['Cur']);
700 }
702 'controlId' => static::GetControlID(),
703 'group' => false,
704 'label' => Loc::getMessage('BT_SALE_ACT_DELIVERY_LABEL'),
705 'defaultText' => Loc::getMessage('BT_SALE_ACT_DELIVERY_DEF_TEXT'),
706 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
707 'control' => array(
708 Loc::getMessage('BT_SALE_ACT_DELIVERY_GROUP_PRODUCT_PREFIX'),
709 $arAtoms['Type'],
710 $arAtoms['Value'],
711 $arAtoms['Unit']
712 ),
713 'mess' => array(
714 'DELETE_CONTROL' => Loc::getMessage('BT_SALE_ACT_GROUP_DELETE_CONTROL')
715 )
716 );
717
718 return $arResult;
719 }
720
721 public static function GetAtoms()
722 {
723 return static::GetAtomsEx(false, false);
724 }
725
726 public static function GetAtomsEx($strControlID = false, $boolEx = false)
727 {
728 $boolEx = (true === $boolEx ? true : false);
729 $arAtomList = array(
730 'Type' => array(
731 'JS' => array(
732 'id' => 'Type',
733 'name' => 'extra',
734 'type' => 'select',
735 'values' => array(
736 'Discount' => Loc::getMessage('BT_SALE_ACT_DELIVERY_SELECT_TYPE_DISCOUNT'),
737 'DiscountZero' => Loc::getMessage('BT_SALE_ACT_DELIVERY_SELECT_TYPE_DISCOUNT_ZERO'),
738 'Extra' => Loc::getMessage('BT_SALE_ACT_DELIVERY_SELECT_TYPE_EXTRA'),
739 ),
740 'defaultText' => Loc::getMessage('BT_SALE_ACT_DELIVERY_SELECT_TYPE_DEF'),
741 'defaultValue' => 'Discount',
742 'first_option' => '...'
743 ),
744 'ATOM' => array(
745 'ID' => 'Type',
746 'FIELD_TYPE' => 'string',
747 'FIELD_LENGTH' => 255,
748 'MULTIPLE' => 'N',
749 'VALIDATE' => 'list'
750 )
751 ),
752 'Value' => array(
753 'JS' => array(
754 'id' => 'Value',
755 'name' => 'extra_size',
756 'type' => 'input'
757 ),
758 'ATOM' => array(
759 'ID' => 'Value',
760 'FIELD_TYPE' => 'double',
761 'MULTIPLE' => 'N',
762 'VALIDATE' => ''
763 )
764 ),
765 'Unit' => array(
766 'JS' => array(
767 'id' => 'Unit',
768 'name' => 'extra_unit',
769 'type' => 'select',
770 'values' => array(
771 'Perc' => Loc::getMessage('BT_SALE_ACT_DELIVERY_SELECT_PERCENT'),
772 'Cur' => Loc::getMessage('BT_SALE_ACT_DELIVERY_SELECT_CUR')
773 ),
774 'defaultText' => Loc::getMessage('BT_SALE_ACT_DELIVERY_SELECT_UNIT_DEF'),
775 'defaultValue' => 'Perc',
776 'first_option' => '...'
777 ),
778 'ATOM' => array(
779 'ID' => 'Unit',
780 'FIELD_TYPE' => 'string',
781 'FIELD_LENGTH' => 255,
782 'MULTIPLE' => 'N',
783 'VALIDATE' => ''
784 )
785 )
786 );
787
788 if (!$boolEx)
789 {
790 foreach ($arAtomList as &$arOneAtom)
791 {
792 $arOneAtom = $arOneAtom['JS'];
793 }
794 if (isset($arOneAtom))
795 unset($arOneAtom);
796 }
797
798 return $arAtomList;
799 }
800
801 public static function GetShowIn($arControls)
802 {
804 }
805
806 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
807 {
808 $mxResult = '';
809
810 if (is_string($arControl))
811 {
812 if ($arControl == static::GetControlID())
813 {
814 $arControl = array(
815 'ID' => static::GetControlID(),
816 'ATOMS' => static::GetAtoms()
817 );
818 }
819 }
820 $boolError = !is_array($arControl);
821
822 if (!$boolError)
823 {
824 $arOneCondition['Value'] = (float)$arOneCondition['Value'];
826 'VALUE' => ($arOneCondition['Type'] == 'Extra' ? $arOneCondition['Value'] : -$arOneCondition['Value']),
827 'UNIT' => ($arOneCondition['Unit'] == 'Cur' ? Sale\Discount\Actions::VALUE_TYPE_FIX : Sale\Discount\Actions::VALUE_TYPE_PERCENT)
828 );
829 if ($arOneCondition['Type'] == 'DiscountZero' && $arOneCondition['Unit'] == 'Cur')
830 $actionParams['MAX_BOUND'] = 'Y';
831
832 $mxResult = '\Bitrix\Sale\Discount\Actions::applyToDelivery('.$arParams['ORDER'].', '.var_export($actionParams, true).')';
833 unset($actionParams);
834 }
835
836 return $mxResult;
837 }
838}
839
841{
842 public static function GetControlDescr()
843 {
844 $controlDescr = parent::GetControlDescr();
845
846 $controlDescr['PARENT'] = true;
847 $controlDescr['EXIST_HANDLER'] = 'Y';
848 $controlDescr['MODULE_ID'] = 'catalog';
849 $controlDescr['MODULE_ENTITY'] = 'iblock';
850 $controlDescr['ENTITY'] = 'ELEMENT';
851 $controlDescr['FIELD'] = 'ID';
852
853 return $controlDescr;
854 }
855
856 public static function GetControlID()
857 {
858 return 'ActSaleGift';
859 }
860
861 public static function GetControlShow($arParams)
862 {
863 $arAtoms = static::GetAtomsEx(false, false);
864 if (static::$boolInit)
865 {
866 //here initialize
867 }
869 'controlId' => static::GetControlID(),
870 'group' => false,
871 'label' => Loc::getMessage('BT_SALE_ACT_GIFT_LABEL'),
872 'defaultText' => Loc::getMessage('BT_SALE_ACT_GIFT_DEF_TEXT'),
873 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
874 'control' => array(
875 Loc::getMessage('BT_SALE_ACT_GIFT_GROUP_PRODUCT_PREFIX'),
876 $arAtoms['Type'],
877 $arAtoms['GiftValue'],
878 ),
879 );
880
881 return $arResult;
882 }
883
884 public static function GetAtoms()
885 {
886 return static::GetAtomsEx(false, false);
887 }
888
889 public static function GetAtomsEx($strControlID = false, $boolEx = false)
890 {
891 $boolEx = (true === $boolEx ? true : false);
892 $arAtomList = array(
893 'Type' => array(
894 'JS' => array(
895 'id' => 'Type',
896 'name' => 'extra',
897 'type' => 'select',
898 'values' => array(
899 Sale\Discount\Actions::GIFT_SELECT_TYPE_ONE => Loc::getMessage('BT_SALE_ACT_GIFT_SELECT_TYPE_SELECT_ONE'),
900 Sale\Discount\Actions::GIFT_SELECT_TYPE_ALL => Loc::getMessage('BT_SALE_ACT_GIFT_SELECT_TYPE_SELECT_ALL'),
901 ),
902 'defaultText' => Loc::getMessage('BT_SALE_ACT_GIFT_SELECT_TYPE_SELECT_DEF'),
903 'defaultValue' => 'one',
904 'first_option' => '...'
905 ),
906 'ATOM' => array(
907 'ID' => 'Type',
908 'FIELD_TYPE' => 'string',
909 'FIELD_LENGTH' => 255,
910 'MULTIPLE' => 'N',
911 'VALIDATE' => 'list'
912 )
913 ),
914 'GiftValue' => array(
915 'JS' => array(
916 'id' => 'GiftValue',
917 'name' => 'gifts_value',
918 'type' => 'multiDialog',
919 'popup_url' => '/bitrix/tools/sale/product_search_dialog.php',
920 'popup_params' => array(
921 'lang' => LANGUAGE_ID,
922 'caller' => 'discount'
923 ),
924 'param_id' => 'n',
925 'show_value' => 'Y'
926 ),
927 'ATOM' => array(
928 'ID' => 'GiftValue',
929
930 'PARENT' => true,
931 'EXIST_HANDLER' => 'Y',
932 'MODULE_ID' => 'catalog',
933 'MODULE_ENTITY' => 'iblock',
934 'ENTITY' => 'ELEMENT',
935 'FIELD' => 'ID',
936
937 'FIELD_TYPE' => 'int',
938 'VALIDATE' => 'element',
939 'PHP_VALUE' => array(
940 'VALIDATE' => 'element'
941 )
942 )
943 ),
944 );
945
946 if (!$boolEx)
947 {
948 foreach ($arAtomList as &$arOneAtom)
949 {
950 $arOneAtom = $arOneAtom['JS'];
951 }
952 if (isset($arOneAtom))
953 unset($arOneAtom);
954 }
955
956 return $arAtomList;
957 }
958
959 public static function GetShowIn($arControls)
960 {
962 }
963
964 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
965 {
966 $mxResult = '';
967 if (is_string($arControl) && $arControl == static::GetControlID())
968 {
969 $arControl = array(
970 'ID' => static::GetControlID(),
971 'ATOMS' => static::GetAtoms()
972 );
973 }
974 $boolError = !is_array($arControl);
975
976 if (!$boolError)
977 {
978 $arControl['ATOMS'] = static::GetAtomsEx($arControl['ID'], true);
979 $arValues = static::CheckAtoms($arOneCondition, $arParams, $arControl, true);
980 $boolError = ($arValues === false);
981 }
982
983 if (!$boolError)
984 {
985 $stringArray = 'array(' . implode(',', array_map('intval', $arOneCondition['GiftValue'])) . ')';
986 $type = $arOneCondition['Type'];
987
988 $mxResult = "CSaleDiscountActionApply::ApplyGiftDiscount({$arParams['ORDER']}, $stringArray, '{$type}');";
989 }
990
991 return $mxResult;
992 }
993
994 public static function getGiftDataByDiscount($fields)
995 {
996 if (
997 (empty($fields['ACTIONS_LIST']) || !is_array($fields['ACTIONS_LIST']))
998 && CheckSerializedData($fields['ACTIONS']))
999 {
1000 $actions = unserialize($fields['ACTIONS'], ['allowed_classes' => false]);
1001 }
1002 else
1003 {
1004 $actions = $fields['ACTIONS_LIST'];
1005 }
1006
1007 if (!is_array($actions) || empty($actions) || empty($actions['CHILDREN']))
1008 {
1009 return null;
1010 }
1011
1012 $result = null;
1013 foreach($actions['CHILDREN'] as $child)
1014 {
1015 if(isset($child['CLASS_ID']) && isset($child['DATA']) && $child['CLASS_ID'] === CSaleActionGift::GetControlID())
1016 {
1017 $result[] = $child['DATA'];
1018 }
1019 }
1020 unset($child);
1021
1022 return $result;
1023 }
1024}
1025
1027{
1028 const ACTION_TYPE_DISCOUNT = 'Discount';
1029 const ACTION_TYPE_EXTRA = 'Extra';
1030 const ACTION_TYPE_CLOSEOUT = 'Closeout';
1031
1032 const VALUE_UNIT_PERCENT = 'Perc';
1033 const VALUE_UNIT_CURRENCY = 'CurEach';
1034 const VALUE_UNIT_SUMM = 'CurAll';
1035
1036 public static function GetControlDescr()
1037 {
1038 $description = parent::GetControlDescr();
1039 $description['SORT'] = 100;
1040 return $description;
1041 }
1042
1043 public static function GetControlID()
1044 {
1045 return 'ActSaleBsktGrp';
1046 }
1047
1048 public static function GetControlShow($arParams)
1049 {
1050 $arAtoms = static::GetAtomsEx(false, false);
1051 $boolCurrency = false;
1052 if (static::$boolInit)
1053 {
1054 if (isset(static::$arInitParams['CURRENCY']))
1055 {
1056 $arAtoms['Unit']['values'][self::VALUE_UNIT_CURRENCY] = str_replace(
1057 '#CUR#',
1058 static::$arInitParams['CURRENCY'],
1059 $arAtoms['Unit']['values'][self::VALUE_UNIT_CURRENCY]
1060 );
1061 $arAtoms['Unit']['values'][self::VALUE_UNIT_SUMM] = str_replace(
1062 '#CUR#',
1063 static::$arInitParams['CURRENCY'],
1064 $arAtoms['Unit']['values'][self::VALUE_UNIT_SUMM]
1065 );
1066 $boolCurrency = true;
1067 }
1068 elseif (isset(static::$arInitParams['SITE_ID']))
1069 {
1070 $strCurrency = Sale\Internals\SiteCurrencyTable::getSiteCurrency(static::$arInitParams['SITE_ID']);
1071 if (!empty($strCurrency))
1072 {
1073 $arAtoms['Unit']['values'][self::VALUE_UNIT_CURRENCY] = str_replace(
1074 '#CUR#',
1075 $strCurrency,
1076 $arAtoms['Unit']['values'][self::VALUE_UNIT_CURRENCY]
1077 );
1078 $arAtoms['Unit']['values'][self::VALUE_UNIT_SUMM] = str_replace(
1079 '#CUR#',
1080 $strCurrency,
1081 $arAtoms['Unit']['values'][self::VALUE_UNIT_SUMM]
1082 );
1083 $boolCurrency = true;
1084 }
1085 }
1086 }
1087 if (!$boolCurrency)
1088 {
1089 unset($arAtoms['Unit']['values'][self::VALUE_UNIT_CURRENCY]);
1090 unset($arAtoms['Unit']['values'][self::VALUE_UNIT_SUMM]);
1091 }
1092 return array(
1093 'controlId' => static::GetControlID(),
1094 'group' => true,
1095 'label' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_LABEL'),
1096 'defaultText' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_DEF_TEXT'),
1097 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
1098 'visual' => static::GetVisual(),
1099 'control' => array(
1100 Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_PREFIX'),
1101 $arAtoms['Type'],
1102 $arAtoms['Value'],
1103 $arAtoms['Unit'],
1104 Loc::getMessage('BT_SALE_ACT_MAX_DISCOUNT_GROUP_BASKET_DESCR'),
1105 $arAtoms['Max'],
1106 Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_DESCR_EXT'),
1107 $arAtoms['All'],
1108 $arAtoms['True']
1109 ),
1110 'mess' => array(
1111 'ADD_CONTROL' => Loc::getMessage('BT_SALE_SUBACT_ADD_CONTROL'),
1112 'SELECT_CONTROL' => Loc::getMessage('BT_SALE_SUBACT_SELECT_CONTROL'),
1113 'DELETE_CONTROL' => Loc::getMessage('BT_SALE_ACT_GROUP_DELETE_CONTROL')
1114 )
1115 );
1116 }
1117
1118 public static function CheckAtoms($arOneCondition, $arParams, $arControl, $boolShow)
1119 {
1120 //TODO: remove this after refactoring control
1121 if (!isset($arOneCondition['Max']))
1122 {
1123 $arOneCondition['Max'] = 0;
1124 }
1125
1126 $result = parent::CheckAtoms($arOneCondition, $arParams, $arControl, $boolShow);
1127 if ($result === false)
1128 return false;
1129 if ($boolShow)
1130 {
1131 if ($result['values']['Unit'] === self::VALUE_UNIT_SUMM && !empty($result['values']['Max']))
1132 {
1133 $result['err_cond'] = 'Y';
1134 $result['fatal_err_cond'] = 'Y';
1135 if (!isset($result['err_cond_mess']))
1136 $result['err_cond_mess'] = Loc::getMessage('BT_SALE_ACT_MAX_DISCOUNT_ON_GROUP_BASKET_ERROR_CONDITION');
1137 else
1138 $result['err_cond_mess'] .= '. '.Loc::getMessage('BT_SALE_ACT_MAX_DISCOUNT_ON_GROUP_BASKET_ERROR_CONDITION');
1139 }
1140 return $result;
1141 }
1142 else
1143 {
1144 return ($result['Unit'] === self::VALUE_UNIT_SUMM && !empty($result['Max']) ? false : $result);
1145 }
1146 }
1147
1148 public static function GetConditionShow($arParams)
1149 {
1150 if (!isset($arParams['DATA']['True']))
1151 $arParams['DATA']['True'] = 'True';
1152
1153 return parent::GetConditionShow($arParams);
1154 }
1155
1156 public static function GetVisual()
1157 {
1158 return array(
1159 'controls' => array(
1160 'All',
1161 'True'
1162 ),
1163 'values' => array(
1164 array(
1165 'All' => 'AND',
1166 'True' => 'True'
1167 ),
1168 array(
1169 'All' => 'AND',
1170 'True' => 'False'
1171 ),
1172 array(
1173 'All' => 'OR',
1174 'True' => 'True'
1175 ),
1176 array(
1177 'All' => 'OR',
1178 'True' => 'False'
1179 ),
1180 ),
1181 'logic' => array(
1182 array(
1183 'style' => 'condition-logic-and',
1184 'message' => Loc::getMessage('BT_SALE_ACT_GROUP_LOGIC_AND')
1185 ),
1186 array(
1187 'style' => 'condition-logic-and',
1188 'message' => Loc::getMessage('BT_SALE_ACT_GROUP_LOGIC_NOT_AND')
1189 ),
1190 array(
1191 'style' => 'condition-logic-or',
1192 'message' => Loc::getMessage('BT_SALE_ACT_GROUP_LOGIC_OR')
1193 ),
1194 array(
1195 'style' => 'condition-logic-or',
1196 'message' => Loc::getMessage('BT_SALE_ACT_GROUP_LOGIC_NOT_OR')
1197 )
1198 )
1199 );
1200 }
1201
1202 public static function GetShowIn($arControls)
1203 {
1205 }
1206
1207 public static function GetAtoms()
1208 {
1209 return static::GetAtomsEx(false, false);
1210 }
1211
1212 public static function GetAtomsEx($strControlID = false, $boolEx = false)
1213 {
1214 $boolEx = (true === $boolEx ? true : false);
1215 $arAtomList = array(
1216 'Type' => array(
1217 'JS' => array(
1218 'id' => 'Type',
1219 'name' => 'extra',
1220 'type' => 'select',
1221 'values' => array(
1222 self::ACTION_TYPE_DISCOUNT => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_TYPE_DISCOUNT'),
1223 self::ACTION_TYPE_EXTRA => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_TYPE_EXTRA'),
1224 self::ACTION_TYPE_CLOSEOUT => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_TYPE_CLOSEOUT_EXT')
1225 ),
1226 'defaultText' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_TYPE_DEF'),
1227 'defaultValue' => self::ACTION_TYPE_DISCOUNT,
1228 'first_option' => '...'
1229 ),
1230 'ATOM' => array(
1231 'ID' => 'Type',
1232 'FIELD_TYPE' => 'string',
1233 'FIELD_LENGTH' => 255,
1234 'MULTIPLE' => 'N',
1235 'VALIDATE' => 'list'
1236 )
1237 ),
1238 'Value' => array(
1239 'JS' => array(
1240 'id' => 'Value',
1241 'name' => 'extra_size',
1242 'type' => 'input'
1243 ),
1244 'ATOM' => array(
1245 'ID' => 'Value',
1246 'FIELD_TYPE' => 'double',
1247 'MULTIPLE' => 'N',
1248 'VALIDATE' => ''
1249 )
1250 ),
1251 'Unit' => array(
1252 'JS' => array(
1253 'id' => 'Unit',
1254 'name' => 'extra_unit',
1255 'type' => 'select',
1256 'values' => array(
1257 self::VALUE_UNIT_PERCENT => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_PERCENT'),
1258 self::VALUE_UNIT_CURRENCY => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_CUR_EACH'),
1259 self::VALUE_UNIT_SUMM => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_CUR_ALL')
1260 ),
1261 'defaultText' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_UNIT_DEF'),
1262 'defaultValue' => self::VALUE_UNIT_PERCENT,
1263 'first_option' => '...'
1264 ),
1265 'ATOM' => array(
1266 'ID' => 'Unit',
1267 'FIELD_TYPE' => 'string',
1268 'FIELD_LENGTH' => 255,
1269 'MULTIPLE' => 'N',
1270 'VALIDATE' => 'list'
1271 )
1272 ),
1273 'Max' => array(
1274 'JS' => array(
1275 'id' => 'Max',
1276 'name' => 'max_value',
1277 'type' => 'input',
1278 ),
1279 'ATOM' => array(
1280 'ID' => 'Max',
1281 'FIELD_TYPE' => 'int',
1282 'MULTIPLE' => 'N',
1283 'VALIDATE' => ''
1284 )
1285 ),
1286 'All' => array(
1287 'JS' => array(
1288 'id' => 'All',
1289 'name' => 'aggregator',
1290 'type' => 'select',
1291 'values' => array(
1292 'AND' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_ALL_EXT'),
1293 'OR' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_ANY_EXT')
1294 ),
1295 'defaultText' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_DEF'),
1296 'defaultValue' => 'AND',
1297 'first_option' => '...'
1298 ),
1299 'ATOM' => array(
1300 'ID' => 'All',
1301 'FIELD_TYPE' => 'string',
1302 'FIELD_LENGTH' => 255,
1303 'MULTIPLE' => 'N',
1304 'VALIDATE' => 'list'
1305 )
1306 ),
1307 'True' => array(
1308 'JS' => array(
1309 'id' => 'True',
1310 'name' => 'value',
1311 'type' => 'select',
1312 'values' => array(
1313 'True' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_TRUE'),
1314 'False' => Loc::getMessage('BT_SALE_ACT_GROUP_BASKET_SELECT_FALSE')
1315 ),
1316 'defaultText' => Loc::getMessage('BT_CLOBAL_COND_GROUP_SELECT_DEF'),
1317 'defaultValue' => 'True',
1318 'first_option' => '...'
1319 ),
1320 'ATOM' => array(
1321 'ID' => 'True',
1322 'FIELD_TYPE' => 'string',
1323 'FIELD_LENGTH' => 255,
1324 'MULTIPLE' => 'N',
1325 'VALIDATE' => 'list'
1326 )
1327 )
1328 );
1329
1330 if (!$boolEx)
1331 {
1332 foreach ($arAtomList as &$arOneAtom)
1333 $arOneAtom = $arOneAtom['JS'];
1334 unset($arOneAtom);
1335 }
1336
1337 return $arAtomList;
1338 }
1339
1340 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
1341 {
1342 $mxResult = '';
1343 $boolError = false;
1344
1345 //TODO: remove this after refactoring control
1346 if (!isset($arOneCondition['Max']))
1347 $arOneCondition['Max'] = 0;
1348
1349 foreach (static::GetAtomsEx(false, false) as $atom)
1350 {
1351 //TODO: add full check (type, list values, etc)
1352 if (!isset($arOneCondition[$atom['id']]) )
1353 $boolError = true;
1354 }
1355 unset($atom);
1356
1357 if (!isset($arSubs) || !is_array($arSubs))
1358 {
1359 $boolError = true;
1360 }
1361
1362 $unit = '';
1363 if (!$boolError)
1364 {
1365 switch ($arOneCondition['Unit'])
1366 {
1367 case self::VALUE_UNIT_PERCENT:
1369 break;
1370 case self::VALUE_UNIT_CURRENCY:
1372 break;
1373 case self::VALUE_UNIT_SUMM:
1375 break;
1376 default:
1377 $boolError = true;
1378 break;
1379 }
1380 }
1381
1382 $discountParams = [];
1383 if (!$boolError)
1384 {
1385 $arOneCondition['Value'] = (float)$arOneCondition['Value'];
1386 switch ($arOneCondition['Type'])
1387 {
1388 case self::ACTION_TYPE_DISCOUNT:
1389 $discountParams = [
1390 'VALUE' => -$arOneCondition['Value'],
1391 'UNIT' => $unit,
1392 'LIMIT_VALUE' => $arOneCondition['Max'],
1393 ];
1394 break;
1395 case self::ACTION_TYPE_EXTRA:
1396 $discountParams = [
1397 'VALUE' => $arOneCondition['Value'],
1398 'UNIT' => $unit,
1399 'LIMIT_VALUE' => 0,
1400 ];
1401 break;
1402 case self::ACTION_TYPE_CLOSEOUT:
1404 {
1405 $discountParams = [
1406 'VALUE' => $arOneCondition['Value'],
1408 'LIMIT_VALUE' => 0,
1409 ];
1410 }
1411 else
1412 {
1413 $boolError = true;
1414 }
1415 break;
1416 default:
1417 $boolError = true;
1418 break;
1419 }
1420 }
1421
1422 if (!$boolError)
1423 {
1424 if (!empty($arSubs))
1425 {
1426 $filter = '$saleact'.$arParams['FUNC_ID'];
1427
1428 if ($arOneCondition['All'] == 'AND')
1429 {
1430 $prefix = '';
1431 $logic = ' && ';
1432 $itemPrefix = ($arOneCondition['True'] == 'True' ? '' : '!');
1433 }
1434 else
1435 {
1436 $itemPrefix = '';
1437 if ($arOneCondition['True'] == 'True')
1438 {
1439 $prefix = '';
1440 $logic = ' || ';
1441 }
1442 else
1443 {
1444 $prefix = '!';
1445 $logic = ' && ';
1446 }
1447 }
1448
1449 $commandLine = $itemPrefix.implode($logic.$itemPrefix, $arSubs);
1450 if ($prefix != '')
1451 $commandLine = $prefix.'('.$commandLine.')';
1452
1453 $mxResult = $filter.'=function($row){';
1454 $mxResult .= 'return ('.$commandLine.');';
1455 $mxResult .= '};';
1456 $mxResult .= '\Bitrix\Sale\Discount\Actions::applyToBasket('.$arParams['ORDER'].', '.var_export($discountParams, true).', '.$filter.');';
1457 unset($filter);
1458 }
1459 else
1460 {
1461 $mxResult = '\Bitrix\Sale\Discount\Actions::applyToBasket('.$arParams['ORDER'].', '.var_export($discountParams, true).', "");';
1462 }
1463 unset($discountParams, $unit);
1464 }
1465
1466
1467 if($boolError)
1468 {
1469 return false;
1470 }
1471
1472 $result = array(
1473 'COND' => $mxResult,
1474 );
1475
1476 if($arOneCondition['Unit'] === self::VALUE_UNIT_SUMM)
1477 {
1478 $result['OVERWRITE_CONTROL'] = array('EXECUTE_MODULE' => 'sale');
1479 }
1480
1481 return $result;
1482 }
1483}
1484
1486{
1487 public static function GetControlDescr()
1488 {
1489 $description = parent::GetControlDescr();
1490 $description['SORT'] = 100;
1491 return $description;
1492 }
1493
1494 public static function GetControlID()
1495 {
1496 return 'ActSaleSubGrp';
1497 }
1498
1499 public static function GetShowIn($arControls)
1500 {
1502 return $arControls;
1503 }
1504
1505 public static function GetControlShow($params)
1506 {
1507 $result = parent::GetControlShow($params);
1508
1509 $result['mess'] = array(
1510 'ADD_CONTROL' => Loc::getMessage('BT_SALE_SUBACT_ADD_CONTROL'),
1511 'SELECT_CONTROL' => Loc::getMessage('BT_SALE_SUBACT_SELECT_CONTROL'),
1512 'DELETE_CONTROL' => Loc::getMessage('BT_SALE_SUBACT_DELETE_CONTROL')
1513 );
1514
1515 return $result;
1516 }
1517}
1518
1520{
1522
1523 public static function GetControlDescr()
1524 {
1525 $description = parent::GetControlDescr();
1526 $description['SORT'] = 150;
1527 return $description;
1528 }
1529
1530 public static function GetControls($strControlID = false)
1531 {
1532 $arControlList = CSaleCondCtrlBasketFields::GetControls(false);
1533 foreach ($arControlList as &$control)
1534 {
1536 $control['EXECUTE_MODULE'] = 'sale';
1537 }
1538 unset($control);
1539 return static::searchControl($arControlList, $strControlID);
1540 }
1541
1542 public static function GetShowIn($arControls)
1543 {
1545 return $arControls;
1546 }
1547}
1548
1550{
1551 protected $arExecuteFunc = array();
1552 protected $executeModule = array();
1553
1554 public function __construct()
1555 {
1556 parent::__construct();
1557 }
1558
1559 public function __destruct()
1560 {
1561 parent::__destruct();
1562 }
1563
1564 public function Init($mode, $event, $params = array())
1565 {
1566 if (!isset($params['SYSTEM_MESSAGES']) || !is_array($params['SYSTEM_MESSAGES']))
1567 $params['SYSTEM_MESSAGES'] = [];
1568 if (!isset($params['SYSTEM_MESSAGES']['SELECT_CONTROL']))
1569 $params['SYSTEM_MESSAGES']['SELECT_CONTROL'] = Loc::getMessage('BT_SALE_ACT_GROUP_SELECT_CONTROL');
1570 if (!isset($params['SYSTEM_MESSAGES']['ADD_CONTROL']))
1571 $params['SYSTEM_MESSAGES']['ADD_CONTROL'] = Loc::getMessage('BT_SALE_ACT_GROUP_ADD_CONTROL');
1572
1573 return parent::Init($mode, $event, $params);
1574 }
1575
1577 {
1578 $strFinal = '';
1579 $this->arExecuteFunc = array();
1580 $this->usedModules = array();
1581 $this->usedExtFiles = array();
1582 $this->usedEntity = array();
1583 $this->executeModule = array();
1584 if (!$this->boolError)
1585 {
1586 $strResult = '';
1587 if (!empty($arConditions) && is_array($arConditions))
1588 {
1589 $arParams['FUNC_ID'] = '';
1591 if (empty($arResult))
1592 {
1593 $strResult = '';
1594 $this->boolError = true;
1595 }
1596 else
1597 {
1598 $strResult = current($arResult);
1599 }
1600 }
1601 else
1602 {
1603 $this->boolError = true;
1604 }
1605 if (!$this->boolError)
1606 {
1607 $strFinal = preg_replace("#;{2,}#",";", $strResult);
1608 }
1609 return $strFinal;
1610 }
1611 else
1612 {
1613 return '';
1614 }
1615 }
1616
1617 public function GenerateLevel(&$arLevel, $arParams, $boolFirst = false)
1618 {
1619 $arResult = array();
1620 $boolFirst = ($boolFirst === true);
1621 if (empty($arLevel) || !is_array($arLevel))
1622 {
1623 return $arResult;
1624 }
1625 if (!isset($arParams['FUNC_ID']))
1626 {
1627 $arParams['FUNC_ID'] = '';
1628 }
1629 $intRowNum = 0;
1630 if ($boolFirst)
1631 {
1632 $arParams['ROW_NUM'] = $intRowNum;
1633 if (!empty($arLevel['CLASS_ID']))
1634 {
1635 $defaultBlock = $this->GetDefaultConditions();
1636 if ($arLevel['CLASS_ID'] !== $defaultBlock['CLASS_ID'])
1637 {
1638 return false;
1639 }
1640 if (isset($this->arControlList[$arLevel['CLASS_ID']]))
1641 {
1642 $arOneControl = $this->arControlList[$arLevel['CLASS_ID']];
1643 if ($arOneControl['GROUP'] == 'Y')
1644 {
1645 $arSubParams = $arParams;
1646 $arSubParams['FUNC_ID'] .= '_'.$intRowNum;
1647 $arSubEval = $this->GenerateLevel($arLevel['CHILDREN'], $arSubParams);
1648 if ($arSubEval === false || !is_array($arSubEval))
1649 return false;
1650 $arGroupParams = $arParams;
1651 $arGroupParams['FUNC_ID'] .= '_'.$intRowNum;
1652 $mxEval = call_user_func_array($arOneControl['Generate'],
1653 array($arLevel['DATA'], $arGroupParams, $arLevel['CLASS_ID'], $arSubEval)
1654 );
1655 if (is_array($mxEval))
1656 {
1657 if (isset($mxEval['FUNC']))
1658 {
1659 $this->arExecuteFunc[] = $mxEval['FUNC'];
1660 }
1661 $strEval = (isset($mxEval['COND']) ? $mxEval['COND'] : false);
1662 }
1663 else
1664 {
1665 $strEval = $mxEval;
1666 }
1667 }
1668 else
1669 {
1670 $strEval = call_user_func_array($arOneControl['Generate'],
1671 array($arLevel['DATA'], $arParams, $arLevel['CLASS_ID'])
1672 );
1673 }
1674 if ($strEval === false || !is_string($strEval) || $strEval === 'false')
1675 {
1676 return false;
1677 }
1678 $arResult[] = $strEval;
1679 $this->fillUsedData($arOneControl);
1680 }
1681 }
1682 }
1683 else
1684 {
1685 foreach ($arLevel as $arOneCondition)
1686 {
1687 $arParams['ROW_NUM'] = $intRowNum;
1688 if (!empty($arOneCondition['CLASS_ID']))
1689 {
1690 if (isset($this->arControlList[$arOneCondition['CLASS_ID']]))
1691 {
1692 $arOneControl = $this->arControlList[$arOneCondition['CLASS_ID']];
1693 if ($arOneControl['GROUP'] == 'Y')
1694 {
1695 $arSubParams = $arParams;
1696 $arSubParams['FUNC_ID'] .= '_'.$intRowNum;
1697 $arSubEval = $this->GenerateLevel($arOneCondition['CHILDREN'], $arSubParams);
1698 if ($arSubEval === false || !is_array($arSubEval))
1699 return false;
1700 $arGroupParams = $arParams;
1701 $arGroupParams['FUNC_ID'] .= '_'.$intRowNum;
1702 $mxEval = call_user_func_array($arOneControl['Generate'],
1703 array($arOneCondition['DATA'], $arGroupParams, $arOneCondition['CLASS_ID'], $arSubEval)
1704 );
1705 if (is_array($mxEval))
1706 {
1707 if (isset($mxEval['FUNC']))
1708 {
1709 $this->arExecuteFunc[] = $mxEval['FUNC'];
1710 }
1711 $strEval = (isset($mxEval['COND']) ? $mxEval['COND'] : false);
1712 }
1713 else
1714 {
1715 $strEval = $mxEval;
1716 }
1717 }
1718 else
1719 {
1720 $strEval = call_user_func_array($arOneControl['Generate'],
1721 array($arOneCondition['DATA'], $arParams, $arOneCondition['CLASS_ID'])
1722 );
1723 }
1724 if ($strEval === false || !is_string($strEval) || $strEval === 'false')
1725 {
1726 return false;
1727 }
1728 $arResult[] = $strEval;
1729
1730 if(!empty($mxEval['OVERWRITE_CONTROL']) && is_array($mxEval['OVERWRITE_CONTROL']))
1731 {
1732 $arOneControl = array_merge($arOneControl, array_intersect_key($mxEval['OVERWRITE_CONTROL'], array(
1733 'EXECUTE_MODULE' => true,
1734 )));
1735 }
1736
1737 $this->fillUsedData($arOneControl);
1738 }
1739 }
1740 $intRowNum++;
1741 }
1742 unset($arOneCondition);
1743 }
1744
1745 if (!empty($arResult))
1746 {
1747 foreach ($arResult as $key => $value)
1748 {
1749 if ($value == '' || $value == '()')
1750 unset($arResult[$key]);
1751 }
1752 }
1753 if (!empty($arResult))
1754 $arResult = array_values($arResult);
1755
1756 return $arResult;
1757 }
1758
1759 public function GetExecuteModule()
1760 {
1761 return (!empty($this->executeModule) ? array_keys($this->executeModule) : array());
1762 }
1763
1764 protected function fillUsedData(&$control)
1765 {
1766 parent::fillUsedData($control);
1767 if (!empty($control['EXECUTE_MODULE']))
1768 $this->executeModule[$control['EXECUTE_MODULE']] = true;
1769 }
1770}
$arParams
Определения access_dialog.php:21
$type
Определения options.php:106
$arResult
Определения generate_coupon.php:16
Определения loader.php:13
static getMessage($code, $replace=null, $language=null)
Определения loc.php:30
static filterBasketForAction(array $item)
Определения actions.php:307
const VALUE_EPS
Определения actions.php:22
static applyToDelivery(array &$order, array $action)
Определения actions.php:852
static isManualMode()
Определения actions.php:160
const GIFT_SELECT_TYPE_ALL
Определения actions.php:18
const BASKET_APPLIED_FIELD
Определения actions.php:20
const VALUE_TYPE_FIX
Определения actions.php:12
const MODE_MANUAL
Определения actions.php:25
static applySimpleGift(array &$order, $filter)
Определения actions.php:942
static setUseMode($mode, array $config=array())
Определения actions.php:91
static applyToBasket(array &$order, array $action, $filter)
Определения actions.php:455
const VALUE_TYPE_SUMM
Определения actions.php:14
const MODE_CALCULATE
Определения actions.php:24
const GIFT_SELECT_TYPE_ONE
Определения actions.php:17
const VALUE_TYPE_CLOSEOUT
Определения actions.php:15
const VALUE_TYPE_PERCENT
Определения actions.php:13
static getSiteCurrency($siteId)
Определения sitecurrency.php:96
static ExtendProductIds(array $giftedProductIds)
Определения sale_act.php:637
Определения catalog_cond.php:29
static GetControlID()
Определения catalog_cond.php:95
GetDefaultConditions()
Определения catalog_cond.php:4554
$arConditions
Определения catalog_cond.php:3835
static GetControlDescr()
Определения sale_act.php:1523
static GetShowIn($arControls)
Определения sale_act.php:1542
const CONTROL_ID_APPLIED_DISCOUNT
Определения sale_act.php:1521
static GetControls($strControlID=false)
Определения sale_act.php:1530
static GetConditionShow($arParams)
Определения sale_act.php:605
static Parse($arOneCondition)
Определения sale_act.php:619
static GetVisual()
Определения sale_act.php:633
static GetControlDescr()
Определения sale_act.php:1036
const VALUE_UNIT_CURRENCY
Определения sale_act.php:1033
const VALUE_UNIT_SUMM
Определения sale_act.php:1034
static GetConditionShow($arParams)
Определения sale_act.php:1148
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
Определения sale_act.php:1340
static CheckAtoms($arOneCondition, $arParams, $arControl, $boolShow)
Определения sale_act.php:1118
static GetControlID()
Определения sale_act.php:1043
static GetShowIn($arControls)
Определения sale_act.php:1202
const ACTION_TYPE_DISCOUNT
Определения sale_act.php:1028
static GetVisual()
Определения sale_act.php:1156
const VALUE_UNIT_PERCENT
Определения sale_act.php:1032
static GetAtomsEx($strControlID=false, $boolEx=false)
Определения sale_act.php:1212
const ACTION_TYPE_CLOSEOUT
Определения sale_act.php:1030
static GetControlShow($arParams)
Определения sale_act.php:1048
const ACTION_TYPE_EXTRA
Определения sale_act.php:1029
static GetAtoms()
Определения sale_act.php:1207
static GetControlDescr()
Определения sale_act.php:663
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
Определения sale_act.php:806
static GetControlID()
Определения sale_act.php:671
static GetShowIn($arControls)
Определения sale_act.php:801
static GetAtomsEx($strControlID=false, $boolEx=false)
Определения sale_act.php:726
static GetControlShow($arParams)
Определения sale_act.php:676
static GetAtoms()
Определения sale_act.php:721
static GetConditionShow($arParams)
Определения sale_act.php:410
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
Определения sale_act.php:426
static GetShowIn($arControls)
Определения sale_act.php:388
static Parse($arOneCondition)
Определения sale_act.php:419
static GetControlShow($arParams)
Определения sale_act.php:394
Определения sale_act.php:239
static GetConditionShow($arParams)
Определения sale_act.php:240
static Parse($arOneCondition)
Определения sale_act.php:254
static GetControlDescr()
Определения sale_act.php:1487
static GetControlID()
Определения sale_act.php:1494
static GetShowIn($arControls)
Определения sale_act.php:1499
static GetControlShow($params)
Определения sale_act.php:1505
static GetControlDescr()
Определения sale_act.php:472
static ProvideGiftProductData(array $fields)
Определения sale_act.php:529
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
Определения sale_act.php:511
static GetControlID()
Определения sale_act.php:444
static getGifter(array $data)
Определения sale_act.php:582
static ExtendProductIds(array $productIds)
Определения sale_act.php:597
static GetShowIn($arControls)
Определения sale_act.php:436
static Parse($arOneCondition)
Определения sale_act.php:504
static GetAtomsEx($strControlID=false, $boolEx=false)
Определения sale_act.php:454
static GetControlShow($arParams)
Определения sale_act.php:484
static GetAtoms()
Определения sale_act.php:449
Определения sale_act.php:841
static GetControlDescr()
Определения sale_act.php:842
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
Определения sale_act.php:964
static GetControlID()
Определения sale_act.php:856
static GetShowIn($arControls)
Определения sale_act.php:959
static getGiftDataByDiscount($fields)
Определения sale_act.php:994
static GetAtomsEx($strControlID=false, $boolEx=false)
Определения sale_act.php:889
static GetControlShow($arParams)
Определения sale_act.php:861
static GetAtoms()
Определения sale_act.php:884
Определения sale_act.php:1550
GenerateLevel(&$arLevel, $arParams, $boolFirst=false)
Определения sale_act.php:1617
__construct()
Определения sale_act.php:1554
__destruct()
Определения sale_act.php:1559
Generate($arConditions, $arParams)
Определения sale_act.php:1576
$executeModule
Определения sale_act.php:1552
fillUsedData(&$control)
Определения sale_act.php:1764
GetExecuteModule()
Определения sale_act.php:1759
Init($mode, $event, $params=array())
Определения sale_act.php:1564
$arExecuteFunc
Определения sale_act.php:1551
static GetControls($strControlID=false)
Определения sale_cond.php:1523
const ENTITY_BASKET_POSITION_ACTION_APPLIED
Определения sale_cond.php:1707
static convertSumConfigurationDateToInt(&$periodData=array())
Определения sale_act.php:355
static buildSubsCode(array $subs, array $oneCondition)
Определения sale_act.php:319
static onBuildDiscountActionInterfaceControls()
Определения sale_act.php:276
static GetControlID()
Определения sale_act.php:271
static IsGroup($strControlID=false)
Определения sale_act.php:285
static Generate($oneCondition, $params, $control, $subs=false)
Определения sale_act.php:290
static isManualMode($order)
Определения sale_act.php:40
static filterApplied($row)
Определения sale_act.php:92
static clearManualMode(&$order)
Определения sale_act.php:77
static setManualMode(&$order)
Определения sale_act.php:54
const GIFT_SELECT_TYPE_ALL
Определения sale_act.php:22
const BASKET_APPLIED_FIELD
Определения sale_act.php:25
const VALUE_TYPE_FIX
Определения sale_act.php:17
static ApplyDelivery(&$order, $value, $unit, $extMode=false)
Определения sale_act.php:182
static clearBasketApplied(&$order)
Определения sale_act.php:142
static ApplyBasketDiscount(&$order, $func, $value, $unit)
Определения sale_act.php:210
const VALUE_TYPE_SUMM
Определения sale_act.php:19
static $getPercentFromBasePrice
Определения sale_act.php:29
const EPS
Определения sale_act.php:27
const GIFT_SELECT_TYPE_ONE
Определения sale_act.php:21
static ClearBasket($row)
Определения sale_act.php:165
static fillBasketApplied(&$order, $basket)
Определения sale_act.php:107
const ORDER_MANUAL_MODE_FIELD
Определения sale_act.php:24
const VALUE_TYPE_PERCENT
Определения sale_act.php:18
static ApplyGiftDiscount(&$order, $callableFilter)
Определения sale_act.php:232
$arValues
Определения component_props.php:25
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
$control
Определения iblock_catalog_edit.php:61
$filter
Определения iblock_catalog_list.php:54
$actionParams
Определения csv_new_setup.php:230
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
CheckSerializedData($str, $max_depth=200)
Определения tools.php:4949
$order
Определения payment.php:8
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$fields
Определения yandex_run.php:501