56 $con = \Bitrix\Main\Application::getConnection();
57 $sqlHelper = $con->getSqlHelper();
58 $strSql =
"DELETE FROM ".ServiceRestrictionTable::getTableName().
59 " WHERE SERVICE_ID=".$sqlHelper->forSql($deliveryId).
60 " AND SERVICE_TYPE=".$sqlHelper->forSql(Manager::SERVICE_TYPE_SHIPMENT).
61 " AND CLASS_NAME='".$sqlHelper->forSql($className).
"'";
63 $con->queryExecute($strSql);
78 static $dataPrepared =
false;
79 static $idsGrouppedByRestrictions = array();
80 static $supportGroupFiltering = array();
82 if($dataPrepared ===
false)
86 'DELIVERY_SERVICE.ACTIVE' =>
'Y'
89 $dbRes = ServiceRestrictionTable::getList(array(
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"]]))
111 $data[$rstr[
"SERVICE_ID"]] = array();
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;
137 self::prepareData(array_keys($data), $data);
138 $dataPrepared =
true;
142 $data = self::getCache(0, self::getServiceType());
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);
156 $data = array_diff_key($data, $notPassed);
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;
194 $result[$serviceId] = $srvRes;
197 return $filterResult + $result;