54 public static function check($params, array $restrictionParams, $serviceId = 0)
56 if(intval($serviceId) <= 0)
62 $deliveries = self::getDeliveryByPaySystemsId($serviceId);
64 if(empty($deliveries))
67 $diff = array_diff($params, $deliveries);
76 protected static function extractParams(
Entity $entity)
78 $shipmentCollection =
null;
84 $paymentCollection = $entity->getCollection();
87 $order = $paymentCollection->getOrder();
90 $shipmentCollection = $order->getShipmentCollection();
93 elseif ($entity instanceof
Order)
95 $shipmentCollection = $entity->getShipmentCollection();
98 if ($shipmentCollection)
101 foreach ($shipmentCollection as $shipment)
103 if (!$shipment->isSystem())
105 $deliveryId = $shipment->getDeliveryId();
107 $result[] = $deliveryId;
120 static $result =
null;
122 if ($result !==
null)
125 $serviceList = array();
126 $dbRes = Services\Table::getList(array(
'select' => array(
'ID',
'NAME',
'PARENT_ID',
'CLASS_NAME')));
127 while ($service = $dbRes->fetch())
128 $serviceList[$service[
'ID']] = $service;
130 foreach ($serviceList as $service)
132 if (is_callable($service[
'CLASS_NAME'].
'::canHasChildren') && $service[
'CLASS_NAME']::canHasChildren())
135 if ((
int)$service[
'PARENT_ID'] > 0 && array_key_exists($service[
'PARENT_ID'], $serviceList))
137 $parentService = $serviceList[$service[
'PARENT_ID']];
139 if (is_callable($parentService[
'CLASS_NAME'].
'::canHasChildren') && $parentService[
'CLASS_NAME']::canHasChildren())
140 $name = $service[
'NAME'].
' ['.$service[
'ID'].
']';
142 $name = $parentService[
'NAME'].
': '.$service[
'NAME'].
' ['.$service[
'ID'].
']';
146 $name = $service[
'NAME'].
' ['.$service[
'ID'].
']';
149 $result[$service[
'ID']] = $name;
166 "OPTIONS" => self::getDeliveryServiceList()
180 if ($paySystemId == 0)
196 if(intval($paySystemId) <= 0)
199 if(isset($params[
"DELIVERY"]) && is_array($params[
"DELIVERY"]))
208 unset($params[
"DELIVERY"]);
219 public static function save(array $fields, $restrictionId = 0)
221 $params = $fields[
"PARAMS"];
222 $fields[
"PARAMS"] = array();
224 $result = parent::save($fields, $restrictionId);
226 self::prepareParamsForSaving($params, $fields[
"SERVICE_ID"]);
237 return array(
"DELIVERY" => self::getDeliveryByPaySystemsId($entityId));
247 public static function delete($restrictionId, $entityId = 0)
256 return parent::delete($restrictionId);
265 if(empty($servicesIds))
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
static setLinks($entityId, $entityType, array $linkedIds=array(), $actualizeRestrictions=true)
const ENTITY_TYPE_PAYSYSTEM
static prepareData(array $entityIds, $entityType)
static getLinks($entityId, $entityType, array $preparedData=array(), $considerParent=true)
static prepareParamsValues(array $paramsValues, $entityId=0)
static getDeliveryServiceList()
static check($params, array $restrictionParams, $serviceId=0)
static prepareParamsForSaving(array $params=array(), $paySystemId=0)
static save(array $fields, $restrictionId=0)
static prepareData(array $servicesIds)
static getClassDescription()
static getOnApplyErrorMessage()
static getDeliveryByPaySystemsId($paySystemId=0)
static getParamsStructure($entityId=0)