Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
excludelocation.php
1<?php
3
8
9Loc::loadMessages(__FILE__);
10
17{
18 public static $easeSort = 200;
19
20
21 public static function getClassTitle()
22 {
23 return Loc::getMessage("SALE_DLVR_RSTR_EX_LOCATION_NAME");
24 }
25
26 public static function getClassDescription()
27 {
28 return Loc::getMessage("SALE_DLVR_RSTR_EX_LOCATION_DESCRIPT");
29 }
30
31 protected static function getD2LClass()
32 {
33 return '\Bitrix\Sale\Delivery\DeliveryLocationExcludeTable';
34 }
35
40 public static function check($locationCode, array $restrictionParams, $deliveryId = 0)
41 {
42 return !parent::check($locationCode, $restrictionParams, $deliveryId);
43 }
44
45 public static function getParamsStructure($deliveryId = 0)
46 {
47 $result = array(
48 "LOCATION" => array(
49 "TYPE" => "LOCATION_MULTI_EXCLUDE"
50 )
51 );
52
53 if($deliveryId > 0 )
54 {
55 $result["LOCATION"]["DELIVERY_ID"] = $deliveryId;
56 }
57
58 return $result;
59 }
60
66 public static function filterServicesArray(Shipment $shipment, array $restrictionFields)
67 {
68 if(empty($restrictionFields))
69 return array();
70
71 $shpLocCode = self::extractParams($shipment);
72
73 //if location not defined in shipment
74 if($shpLocCode === '')
75 return array_keys($restrictionFields);
76
77 $res = LocationTable::getList(array(
78 'filter' => array('=CODE' => $shpLocCode),
79 'select' => array('CODE', 'LEFT_MARGIN', 'RIGHT_MARGIN')
80 ));
81
82 //if location doesn't exists
83 if(!$shpLocParams = $res->fetch())
84 return array_keys($restrictionFields);
85
86 $srvLocCodesCompat = static::getLocationsCompat($restrictionFields, $shpLocParams['LEFT_MARGIN'], $shpLocParams['RIGHT_MARGIN']);
87
88 foreach($srvLocCodesCompat as $locCode => $deliveries)
89 {
90 foreach($deliveries as $deliveryId)
91 {
92 if(isset($restrictionFields[$deliveryId]))
93 {
94 unset($restrictionFields[$deliveryId]);
95 }
96 }
97 }
98
99 return array_keys($restrictionFields);
100 }
101}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static filterServicesArray(Shipment $shipment, array $restrictionFields)
static check($locationCode, array $restrictionParams, $deliveryId=0)