Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
paysystem.php
1<?php
3
9
10Loc::loadMessages(__FILE__);
11
17{
18 public static $easeSort = 200;
19 protected static $preparedData = array();
20
24 public static function getClassTitle()
25 {
26 return Loc::getMessage("SALE_CASHBOX_RSTR_BY_PS_TITLE");
27 }
28
32 public static function getClassDescription()
33 {
34 return Loc::getMessage("SALE_CASHBOX_RSTR_BY_PS_DESC");
35 }
36
43 public static function check($params, array $restrictionParams, $serviceId = 0)
44 {
45 if (is_array($restrictionParams) && isset($restrictionParams['PAY_SYSTEMS']))
46 {
47 $diff = array_diff($params, $restrictionParams['PAY_SYSTEMS']);
48 return empty($diff);
49 }
50
51 return true;
52 }
53
58 protected static function extractParams(Entity $entity)
59 {
60 $result = array();
61
62 if ($entity instanceof Sale\Order)
63 {
64 $collection = $entity->getPaymentCollection();
65 if ($collection)
66 {
68 foreach ($collection as $item)
69 $result[] = $item->getPaymentSystemId();
70 }
71 }
72 elseif ($entity instanceof Sale\Shipment)
73 {
75 $shipmentCollection = $entity->getCollection();
76 if (!$shipmentCollection)
77 return $result;
78
79 $order = $shipmentCollection->getOrder();
80 if (!$order)
81 return $result;
82
83 $paymentCollection = $order->getPaymentCollection();
84 if (!$paymentCollection)
85 return $result;
86
88 foreach ($paymentCollection as $item)
89 $result[] = $item->getPaymentSystemId();
90 }
91 elseif ($entity instanceof Payment)
92 {
93 $result[] = $entity->getPaymentSystemId();
94 }
95
96 return $result;
97 }
98
102 protected static function getPaySystemsList()
103 {
104 static $result = null;
105
106 if($result !== null)
107 return $result;
108
109 $result = array();
110
111 $dbResultList = Sale\PaySystem\Manager::getList(array(
112 'select' => array("ID", "NAME", "ACTIVE"),
113 'filter' => array("ACTIVE" => "Y"),
114 'order' => array("SORT"=>"ASC", "NAME"=>"ASC")
115 ));
116
117 while ($arPayType = $dbResultList->fetch())
118 $result[$arPayType["ID"]] = $arPayType["NAME"];
119
120 return $result;
121 }
122
127 public static function getParamsStructure($entityId = 0)
128 {
129 $result = array(
130 "PAY_SYSTEMS" => array(
131 "TYPE" => "ENUM",
132 'MULTIPLE' => 'Y',
133 "LABEL" => Loc::getMessage("SALE_CASHBOX_RSTR_BY_PS"),
134 "OPTIONS" => self::getPaySystemsList()
135 )
136 );
137
138 return $result;
139 }
140
145 public static function getSeverity($mode)
146 {
147 return Manager::SEVERITY_STRICT;
148 }
149
150}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static check($params, array $restrictionParams, $serviceId=0)
Definition paysystem.php:43