78 static $dataPrepared =
false;
79 static $idsGrouppedByRestrictions =
array();
80 static $supportGroupFiltering =
array();
82 if($dataPrepared ===
false)
86 'DELIVERY_SERVICE.ACTIVE' =>
'Y'
93 '\Bitrix\Sale\Delivery\Services\Table',
95 '=this.SERVICE_ID' =>
'ref.ID',
96 '=this.SERVICE_TYPE' =>
array(
'?', self::SERVICE_TYPE_SHIPMENT)
98 array(
'join_type' =>
'inner')
102 'order' =>
array(
'SORT' =>
'ASC')
106 $checkedGroupFiltering =
array();
108 while($rstr =
$dbRes->fetch())
110 if(!isset(
$data[$rstr[
"SERVICE_ID"]]))
113 $data[$rstr[
"SERVICE_ID"]][$rstr[
'ID']] = $rstr;
115 if(!in_array($rstr[
'CLASS_NAME'], $checkedGroupFiltering))
117 $checkedGroupFiltering[] = $rstr[
'CLASS_NAME'];
119 if(method_exists($rstr[
'CLASS_NAME'],
'filterServicesArray'))
120 $supportGroupFiltering[] = $rstr[
'CLASS_NAME'];
123 if(in_array($rstr[
'CLASS_NAME'], $supportGroupFiltering))
125 if (!isset($idsGrouppedByRestrictions[$rstr[
'CLASS_NAME']]))
127 $idsGrouppedByRestrictions[$rstr[
'CLASS_NAME']] = [];
130 if (!in_array($rstr[
"SERVICE_ID"], $idsGrouppedByRestrictions[$rstr[
'CLASS_NAME']]))
132 $idsGrouppedByRestrictions[$rstr[
'CLASS_NAME']][$rstr[
"SERVICE_ID"]] = $rstr;
138 $dataPrepared =
true;
145 $filterResult =
array();
147 foreach($supportGroupFiltering as $rstrClass)
149 $passedServicesIds = $rstrClass::filterServicesArray($shipment, $idsGrouppedByRestrictions[$rstrClass]);
150 $notPassed = array_diff_key($idsGrouppedByRestrictions[$rstrClass], array_flip($passedServicesIds));
152 if($restrictionMode == self::MODE_MANAGER)
153 foreach($notPassed as $srvId => $rstr)
154 $filterResult[$srvId] = $rstrClass::getSeverity($restrictionMode);
159 foreach(
$data as $serviceId => $serviceRestrictions)
161 $srvRes = self::SEVERITY_NONE;
163 if($shipment !=
null)
165 foreach($serviceRestrictions as $restrictionId => $rstr)
167 if(in_array($rstr[
'CLASS_NAME'], $supportGroupFiltering))
170 if(!self::isClassValid($rstr[
'CLASS_NAME']))
174 $rstr[
'PARAMS'] =
array();
176 $res = $rstr[
'CLASS_NAME']::checkByEntity(
183 if(
$res == self::SEVERITY_STRICT)
186 if(
$res == self::SEVERITY_SOFT && $restrictionMode == self::MODE_CLIENT)
189 if(
$res == self::SEVERITY_SOFT && $srvRes == self::SEVERITY_NONE)
190 $srvRes = self::SEVERITY_SOFT;
197 return $filterResult +
$result;