Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
entitycollisiontype.php
1<?php
3
4
7
9{
10 const GROUP_E_ERROR = 1;
11 const GROUP_E_WARNING = 2;
12
13 const Undefined = 0;
14 const OrderIsPayed = 1;
15 const OrderIsShipped = 2;
24 const PaymentIsPayed = 11;
39
40 const First = 1;
41 const Last = 25;
42
43 const OrderIsPayedName = 'ORDER_IS_PAYED';
44 const OrderIsShippedName = 'ORDER_IS_SHIPPED';
45 const OrderFinalStatusName = 'ORDER_FINAL_STATUS';
46 const ShipmentIsShippedName = 'SHIPMENT_IS_SHIPPED';
47 const ShipmentBasketItemNotFoundName = 'SHIPMENT_BASKET_ITEM_NOT_FOUND';
48 const ShipmentBasketItemQuantityErrorName = 'SHIPMENT_BASKET_ITEM_QUANTITY_ERROR';
49 const ShipmentBasketItemsModifyName = 'SHIPMENT_BASKET_ITEMS_MODIFY';
50 const OrderShipmentItemsModifyName = 'ORDER_SHIPMENT_ITEMS_MODIFY';
51 const ShipmentBasketItemsModifyErrorName = 'SHIPMENT_BASKET_ITEMS_MODIFY_ERROR';
52 const OrderShipmentItemsModifyErrorName = 'ORDER_SHIPMENT_ITEMS_MODIFY_ERROR';
53 const PaymentIsPayedName = 'PAYMENT_IS_PAYED';
54 const OrderShipmentDeletedName = 'ORDER_SHIPMENT_DELETED';
55 const OrderShipmentDeletedErrorName = 'ORDER_SHIPMENT_DELETED_ERROR';
56 const OrderPaymentDeletedName = 'ORDER_PAYMENT_DELETED';
57 const OrderPaymentDeletedErrorName = 'ORDER_PAYMENT_DELETED_ERROR';
58 const OrderBasketItemTaxValueErrorName = 'ORDER_BASKET_ITEM_TAX_VALUE_ERROR';
59 const OrderSynchronizeBasketItemsModifyName = 'ORDER_SYNCHRONIZE_BASKET_ITEMS_MODIFY';
60 const OrderPayedByStatusErrorName = 'ORDER_PAYED_BY_STATUS_ERROR';
61 const OrderBasketItemTypeErrorName = 'ORDER_BASKET_ITEM_TYPE_ERROR';
62 const PaymentCashBoxCheckNotFoundName = 'PAYMENT_CASH_BOX_CHECK_NOT_FOUND';
63 const OrderSynchronizeBasketItemsModifyErrorName = 'ORDER_SYNCHRONIZE_BASKET_ITEMS_MODIFY_ERROR';
64 const BeforeUpdatePaymentDeletedErrorName = 'BEFORE_UPDATE_PAYMENT_DELETED_ERROR';
65 const BeforeUpdateShipmentDeletedErrorName = 'BEFORE_UPDATE_SHIPMENT_DELETED_ERROR';
66 const OrderShippedByStatusErrorName = 'ORDER_SHIPPED_BY_STATUS_ERROR';
67 const OrderBasketItemsCurrencyModifyName = 'ORDER_BASKET_ITEMS_CURRENCY_MODIFY';
68
69 private static $ALL_DESCRIPTIONS = array();
70 private static $ALL_ERROR_GROUPS = array();
71
76 public static function isDefined($typeId)
77 {
78 if(!is_int($typeId))
79 {
80 $typeId = (int)$typeId;
81 }
82 return $typeId >= self::First && $typeId <= self::Last;
83 }
84
89 public static function resolveID($name)
90 {
91 $name = mb_strtoupper(trim(strval($name)));
92 if($name == '')
93 {
94 return self::Undefined;
95 }
96
97 switch($name)
98 {
100 return self::OrderIsPayed;
149
150 default:
151 return self::Undefined;
152 }
153 }
154
159 public static function resolveName($typeId)
160 {
161 if(!is_numeric($typeId))
162 {
163 return '';
164 }
165
166 $typeId = intval($typeId);
167 if($typeId <= 0)
168 {
169 return '';
170 }
171
172 switch($typeId)
173 {
224
225 case self::Undefined:
226 default:
227 return '';
228 }
229 }
230
234 public static function getAllDescriptions()
235 {
236 if(!self::$ALL_DESCRIPTIONS[LANGUAGE_ID])
237 {
238 IncludeModuleLangFile(__FILE__);
239 self::$ALL_DESCRIPTIONS[LANGUAGE_ID] = array(
240 self::OrderIsPayed => GetMessage('SALE_COLLISION_TYPE_ORDER_IS_PAYED'),
241 self::OrderIsShipped => GetMessage('SALE_COLLISION_TYPE_ORDER_IS_SHIPPED'),
242 self::OrderFinalStatus => GetMessage('SALE_COLLISION_TYPE_ORDER_FINAL_STATUS'),
243 self::ShipmentIsShipped => GetMessage('SALE_COLLISION_TYPE_SHIPMENT_IS_SHIPPED'),
244 self::ShipmentBasketItemNotFound => GetMessage('SALE_COLLISION_TYPE_SHIPMENT_BASKET_ITEM_NOT_FOUND'),
245 self::ShipmentBasketItemQuantityError => GetMessage('SALE_COLLISION_TYPE_SHIPMENT_BASKET_ITEM_QUANTITY_ERROR'),
246 self::ShipmentBasketItemsModify => GetMessage('SALE_COLLISION_TYPE_SHIPMENT_BASKET_ITEMS_MODIFY'),
247 self::OrderShipmentItemsModify => GetMessage('SALE_COLLISION_TYPE_ORDER_SHIPMENT_ITEMS_MODIFY'),
248 self::ShipmentBasketItemsModifyError => GetMessage('SALE_COLLISION_TYPE_SHIPMENT_BASKET_ITEMS_MODIFY_ERROR'),
249 self::OrderShipmentItemsModifyError => GetMessage('SALE_COLLISION_TYPE_ORDER_SHIPMENT_ITEMS_MODIFY_ERROR'),
250 self::PaymentIsPayed => GetMessage('SALE_COLLISION_TYPE_PAYMENT_IS_PAYED'),
251 self::OrderShipmentDeleted => GetMessage('SALE_COLLISION_TYPE_ORDER_SHIPMENT_DELETED'),
252 self::OrderShipmentDeletedError => GetMessage('SALE_COLLISION_TYPE_ORDER_SHIPMENT_DELETED_ERROR'),
253 self::OrderPaymentDeleted => GetMessage('SALE_COLLISION_TYPE_ORDER_PAYMENT_DELETED'),
254 self::OrderPaymentDeletedError => GetMessage('SALE_COLLISION_TYPE_ORDER_PAYMENT_DELETED_ERROR'),
255 self::OrderBasketItemTaxValueError => GetMessage('SALE_COLLISION_TYPE_ORDER_BASKET_ITEM_TAX_VALUE_ERROR'),
256 self::OrderSynchronizeBasketItemsModify => GetMessage('SALE_COLLISION_TYPE_ORDER_SYNCHRONIZE_BASKET_ITEMS_MODIFY'),
257 self::OrderPayedByStatusError => GetMessage('SALE_COLLISION_TYPE_ORDER_PAYED_BY_STATUS_ERROR'),
258 self::OrderBasketItemTypeError => GetMessage('SALE_COLLISION_TYPE_ORDER_BASKET_ITEM_TYPE_ERROR'),
259 self::PaymentCashBoxCheckNotFound => GetMessage('SALE_COLLISION_TYPE_PAYMENT_CASH_BOX_CHECK_NOT_FOUND'),
260 self::OrderSynchronizeBasketItemsModifyError => GetMessage('SALE_COLLISION_TYPE_ORDER_SYNCHRONIZE_BASKET_ITEMS_MODIFY_ERROR'),
261 self::BeforeUpdatePaymentDeletedError => GetMessage('SALE_COLLISION_TYPE_BEFORE_UPDATE_PAYMENT_DELETED_ERROR'),
262 self::BeforeUpdateShipmentDeletedError => GetMessage('SALE_COLLISION_TYPE_BEFORE_UPDATE_SHIPMENT_DELETED_ERROR'),
263 self::OrderShippedByStatusError => GetMessage('SALE_COLLISION_TYPE_ORDER_SHIPPED_BY_STATUS_ERROR'),
264 self::OrderBasketItemsCurrencyModify => GetMessage('SALE_COLLISION_TYPE_ORDER_BASKET_ITEMS_CURRENCY_MODIFY'),
265 );
266 }
267 return self::$ALL_DESCRIPTIONS[LANGUAGE_ID];
268 }
269
274 public static function getDescription($typeId)
275 {
276 $typeId = intval($typeId);
278 return isset($all[$typeId]) ? $all[$typeId] : '';
279 }
280
285 public static function getDescriptions($types)
286 {
287 $result = array();
288 if(is_array($types))
289 {
290 foreach($types as $typeId)
291 {
292 $typeId = intval($typeId);
293 $descr = self::getDescription($typeId);
294 if($descr !== '')
295 {
296 $result[$typeId] = $descr;
297 }
298 }
299 }
300 return $result;
301 }
302
306 protected static function getAllErrorGroups()
307 {
308 if(!self::$ALL_ERROR_GROUPS)
309 {
310 self::$ALL_ERROR_GROUPS = array(
311 self::OrderIsPayed => self::GROUP_E_ERROR,
312 self::OrderIsShipped => self::GROUP_E_ERROR,
313 self::OrderFinalStatus => self::GROUP_E_ERROR,
314 self::ShipmentIsShipped => self::GROUP_E_ERROR,
315 self::ShipmentBasketItemNotFound => self::GROUP_E_WARNING,
316 self::ShipmentBasketItemQuantityError => self::GROUP_E_WARNING,
317 self::ShipmentBasketItemsModify => self::GROUP_E_WARNING,
318 self::OrderShipmentItemsModify => self::GROUP_E_WARNING,
319 self::ShipmentBasketItemsModifyError => self::GROUP_E_WARNING,
320 self::OrderShipmentItemsModifyError => self::GROUP_E_WARNING,
321 self::PaymentIsPayed => self::GROUP_E_ERROR,
322 self::OrderShipmentDeleted => self::GROUP_E_WARNING,
323 self::OrderShipmentDeletedError => self::GROUP_E_WARNING,
324 self::OrderPaymentDeleted => self::GROUP_E_WARNING,
325 self::OrderPaymentDeletedError => self::GROUP_E_WARNING,
326 self::OrderBasketItemTaxValueError => self::GROUP_E_WARNING,
327 self::OrderSynchronizeBasketItemsModify => self::GROUP_E_WARNING,
328 self::OrderPayedByStatusError => self::GROUP_E_WARNING,
329 self::OrderBasketItemTypeError => self::GROUP_E_WARNING,
330 self::PaymentCashBoxCheckNotFound => self::GROUP_E_WARNING,
331 self::OrderSynchronizeBasketItemsModifyError => self::GROUP_E_ERROR,
332 self::BeforeUpdatePaymentDeletedError => self::GROUP_E_ERROR,
333 self::BeforeUpdateShipmentDeletedError => self::GROUP_E_ERROR,
334 self::OrderShippedByStatusError => self::GROUP_E_WARNING,
335 self::OrderBasketItemsCurrencyModify => self::GROUP_E_WARNING,
336 );
337 }
338 return self::$ALL_ERROR_GROUPS;
339 }
340
345 public static function getErrorGroup($typeId)
346 {
347 $typeId = intval($typeId);
349 return isset($all[$typeId]) ? $all[$typeId] : null;
350 }
351}