Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
entitytype.php
1<?php
3
5{
6 const UNDEFINED = 0;
7 const DEAL = 2;
8 const CONTACT = 3;
9 const COMPANY = 4;
10 const ACTIVITY = 6;
11 const ORDER = 14;
12 const ORDER_SHIPMENT = 16;
13 const ORDER_PAYMENT = 17;
14
15 const DEAL_NAME = 'DEAL';
16 const CONTACT_NAME = 'CONTACT';
17 const COMPANY_NAME = 'COMPANY';
18 const ACTIVITY_NAME = 'ACTIVITY';
19 const ORDER_NAME = 'ORDER';
20 const ORDER_SHIPMENT_NAME = 'ORDER_SHIPMENT';
21 const ORDER_PAYMENT_NAME = 'ORDER_PAYMENT';
22
23 public static function isDefined($typeId)
24 {
25 if(!is_int($typeId))
26 {
27 $typeId = (int)$typeId;
28 }
29
30 return ($typeId == static::DEAL
31 || $typeId == static::COMPANY
32 || $typeId == static::COMPANY
33 || $typeId == static::ACTIVITY
34 || $typeId == static::ORDER
35 || $typeId == static::ORDER_SHIPMENT
36 || $typeId == static::ORDER_PAYMENT);
37 }
38
39 public static function resolveId($name)
40 {
41 if($name == '')
42 {
43 return self::UNDEFINED;
44 }
45
46 switch($name)
47 {
48 case self::DEAL_NAME:
49 return self::DEAL;
51 return self::CONTACT;
53 return self::COMPANY;
55 return self::ACTIVITY;
57 return self::ORDER;
62
63 default:
64 return self::UNDEFINED;
65 }
66 }
67
68 public static function resolveName($typeId)
69 {
70 if(!is_numeric($typeId))
71 {
72 return '';
73 }
74
75 $typeId = intval($typeId);
76 if($typeId <= 0)
77 {
78 return '';
79 }
80
81 switch($typeId)
82 {
83 case self::DEAL:
84 return self::DEAL_NAME;
85 case self::CONTACT:
86 return self::CONTACT_NAME;
87 case self::COMPANY:
88 return self::COMPANY_NAME;
89 case self::ACTIVITY:
91 case self::ORDER:
92 return self::ORDER_NAME;
97
98 case self::UNDEFINED:
99 default:
100 return '';
101 }
102 }
103}