45 public static function check($locationCode, array $restrictionParams, $deliveryId = 0)
47 if(intval($deliveryId) <= 0)
50 if($locationCode ==
'')
55 $class = static::getD2LClass();
56 return $class::checkConnectionExists(
60 'LOCATION_LINK_TYPE' =>
'AUTO'
101 $class = static::getD2LClass();
104 $arLocation = array();
106 if(!!\CSaleLocation::isLocationProEnabled())
108 if($params[
"LOCATION"][$class::DB_LOCATION_FLAG] <>
'')
110 $LOCATION1 = explode(
':', $params[
"LOCATION"][$class::DB_LOCATION_FLAG]);
113 if($params[
"LOCATION"][$class::DB_GROUP_FLAG] <>
'')
115 $LOCATION2 = explode(
':', $params[
"LOCATION"][$class::DB_GROUP_FLAG]);
119 if (isset($LOCATION1) && is_array($LOCATION1) && count($LOCATION1) > 0)
121 $arLocation[$class::DB_LOCATION_FLAG] = array();
122 $locationCount = count($LOCATION1);
124 for ($i = 0; $i<$locationCount; $i++)
125 if($LOCATION1[$i] <>
'')
127 $arLocation[$class::DB_LOCATION_FLAG][] = $LOCATION1[$i];
131 if (isset($LOCATION2) && is_array($LOCATION2) && count($LOCATION2) > 0)
133 $arLocation[$class::DB_GROUP_FLAG] = array();
134 $locationCount = count($LOCATION2);
136 for ($i = 0; $i<$locationCount; $i++)
137 if($LOCATION2[$i] <>
'')
139 $arLocation[$class::DB_GROUP_FLAG][] = $LOCATION2[$i];
144 $class::resetMultipleForOwner($deliveryId, $arLocation);
172 public static function delete($restrictionId, $deliveryId = 0)
174 $class = static::getD2LClass();
175 $class::resetMultipleForOwner($deliveryId);
176 return parent::delete($restrictionId);
186 if(empty($restrictionFields))
189 $shpLocCode = self::extractParams($shipment);
192 if($shpLocCode ===
'')
193 return array_keys($restrictionFields);
195 $res = LocationTable::getList(array(
196 'filter' => array(
'=CODE' => $shpLocCode),
197 'select' => array(
'CODE',
'LEFT_MARGIN',
'RIGHT_MARGIN')
201 if(!$shpLocParams = $res->fetch())
202 return array_keys($restrictionFields);
205 $srvLocCodesCompat = static::getLocationsCompat($restrictionFields, $shpLocParams[
'LEFT_MARGIN'], $shpLocParams[
'RIGHT_MARGIN']);
207 foreach($srvLocCodesCompat as $locCode => $deliveries)
208 foreach($deliveries as $deliveryId)
209 if(!in_array($deliveryId, $result))
210 $result[] = $deliveryId;
225 $class = static::getD2LClass();
227 $res = $class::getList(array(
229 '=DELIVERY_ID' => array_keys($restrictionFields),
234 '=LOCATION_TYPE' => $class::DB_LOCATION_FLAG,
235 '<=LOCATION.LEFT_MARGIN' => $leftMargin,
236 '>=LOCATION.RIGHT_MARGIN' => $rightMargin
240 '=LOCATION_TYPE' => $class::DB_GROUP_FLAG
246 while($d2l = $res->fetch())
248 if($d2l[
'LOCATION_TYPE'] == $class::DB_LOCATION_FLAG)
250 if (!isset($result[$d2l[
'LOCATION_CODE']]))
252 $result[$d2l[
'LOCATION_CODE']] = [];
255 if(!in_array($d2l[
'DELIVERY_ID'] ,$result[$d2l[
'LOCATION_CODE']]))
256 $result[$d2l[
'LOCATION_CODE']][] = $d2l[
'DELIVERY_ID'];
258 elseif($d2l[
'LOCATION_TYPE'] == $class::DB_GROUP_FLAG)
260 if (!isset($groups[$d2l[
'LOCATION_CODE']]))
262 $groups[$d2l[
'LOCATION_CODE']] = [];
265 if(!in_array($d2l[
'DELIVERY_ID'] ,$groups[$d2l[
'LOCATION_CODE']]))
266 $groups[$d2l[
'LOCATION_CODE']][] = $d2l[
'DELIVERY_ID'];
273 $res = GroupLocationTable::getList(array(
275 '=GROUP.CODE' => array_keys($groups),
276 '<=LOCATION.LEFT_MARGIN' => $leftMargin,
277 '>=LOCATION.RIGHT_MARGIN' => $rightMargin
280 'LOCATION_ID',
'LOCATION_GROUP_ID',
281 'LOCATION_CODE' =>
'LOCATION.CODE',
282 'GROUP_CODE' =>
'GROUP.CODE'
286 while($loc = $res->fetch())
288 if(!is_array($result[$loc[
'LOCATION_CODE']]))
289 $result[$loc[
'LOCATION_CODE']] = array();
291 foreach($groups[$loc[
'GROUP_CODE']] as $srvId)
292 if(!in_array($srvId, $result[$loc[
'LOCATION_CODE']]))
293 $result[$loc[
'LOCATION_CODE']][] = $srvId;