Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
entitytype.php
1<?php
3
4
6{
7 const UNDEFINED = 0;
8 const ORDER = 1;
9 const SHIPMENT = 2;
10 const PAYMENT_CASH = 3;
13 const PROFILE = 6;
14 const USER_PROFILE = 7;
16 const INVOICE = 8;
21
22 const FIRST = 1;
23 const LAST = 13;
24
25 const ORDER_NAME = 'ORDER';
26 const SHIPMENT_NAME = 'SHIPMENT';
27 const PAYMENT_CASH_NAME = 'PAYMENT_CASH';
28 const PAYMENT_CASH_LESS_NAME = 'PAYMENT_CASH_LESS';
29 const PAYMENT_CARD_TRANSACTION_NAME = 'PAYMENT_CARD_TRANSACTION';
30 const PROFILE_NAME = 'PROFILE';
31 const USER_PROFILE_NAME = 'USER_PROFILE';
32 const USER_PROFILE_CONTACT_COMPANY_NAME = 'USER_PROFILE_CONTACT_COMPANY';
33 const INVOICE_NAME = 'INVOICE';
34 const INVOICE_SHIPMENT_NAME = 'INVOICE_SHIPMENT';
35 const INVOICE_PAYMENT_CASH_NAME = 'INVOICE_PAYMENT_CASH';
36 const INVOICE_PAYMENT_CASH_LESS_NAME = 'INVOICE_PAYMENT_CASH_LESS';
37 const INVOICE_PAYMENT_CARD_TRANSACTION_NAME = 'INVOICE_PAYMENT_CARD_TRANSACTION';
38
39
40 private static $ALL_DESCRIPTIONS = array();
41
46 public static function isDefined($typeID)
47 {
48 if(!is_int($typeID))
49 {
50 $typeID = (int)$typeID;
51 }
52 return $typeID >= self::FIRST && $typeID <= self::LAST;
53 }
54
59 public static function resolveID($name)
60 {
61 $name = mb_strtoupper(trim(strval($name)));
62 if($name == '')
63 {
64 return self::UNDEFINED;
65 }
66
67 switch($name)
68 {
70 return self::ORDER;
71
73 return self::SHIPMENT;
74
76 return self::PAYMENT_CASH;
77
80
83
85 return self::PROFILE;
86
88 return self::USER_PROFILE;
89
92
94 return self::INVOICE;
95
98
101
104
107
108 default:
109 return self::UNDEFINED;
110 }
111 }
112
117 public static function resolveName($typeID)
118 {
119 if(!is_numeric($typeID))
120 {
121 return '';
122 }
123
124 $typeID = intval($typeID);
125 if($typeID <= 0)
126 {
127 return '';
128 }
129
130 switch($typeID)
131 {
132 case self::ORDER:
133 return self::ORDER_NAME;
134
135 case self::SHIPMENT:
136 return self::SHIPMENT_NAME;
137
140
143
146
147 case self::PROFILE:
148 return self::PROFILE_NAME;
149
152
155
156 case self::INVOICE:
157 return self::INVOICE_NAME;
158
161
164
167
170
171 case self::UNDEFINED:
172 default:
173 return '';
174 }
175 }
176
180 public static function getAllDescriptions()
181 {
182 if(!self::$ALL_DESCRIPTIONS[LANGUAGE_ID])
183 {
184 IncludeModuleLangFile(__FILE__);
185 self::$ALL_DESCRIPTIONS[LANGUAGE_ID] = array(
186 self::ORDER => GetMessage('SALE_TYPE_ORDER'),
187 self::SHIPMENT => GetMessage('SALE_TYPE_SHIPMENT'),
188 self::PAYMENT_CASH => GetMessage('SALE_TYPE_PAYMENT_CASH'),
189 self::PAYMENT_CASH_LESS => GetMessage('SALE_TYPE_PAYMENT_CASH_LESS'),
190 self::PAYMENT_CARD_TRANSACTION => GetMessage('SALE_TYPE_PAYMENT_CARD_TRANSACTION'),
191 self::PROFILE => GetMessage('SALE_TYPE_PROFILE'),
192 self::USER_PROFILE => GetMessage('SALE_TYPE_USER_PROFILE'),
193 self::USER_PROFILE_CONTACT_COMPANY => GetMessage('SALE_TYPE_USER_PROFILE'),
194 self::INVOICE => GetMessage('SALE_TYPE_INVOICE'),
195 self::INVOICE_SHIPMENT => GetMessage('SALE_TYPE_INVOICE_SHIPMENT'),
196 self::INVOICE_PAYMENT_CASH => GetMessage('SALE_TYPE_INVOICE_PAYMENT_CASH'),
197 self::INVOICE_PAYMENT_CASH_LESS => GetMessage('SALE_TYPE_INVOICE_PAYMENT_CASH_LESS'),
198 self::INVOICE_PAYMENT_CARD_TRANSACTION => GetMessage('SALE_TYPE_INVOICE_PAYMENT_CARD_TRANSACTION'),
199 );
200 }
201
202 return self::$ALL_DESCRIPTIONS[LANGUAGE_ID];
203 }
204
209 public static function getDescription($typeID)
210 {
211 $typeID = intval($typeID);
213 return isset($all[$typeID]) ? $all[$typeID] : '';
214 }
215
220 public static function getDescriptions($types)
221 {
222 $result = array();
223 if(is_array($types))
224 {
225 foreach($types as $typeID)
226 {
227 $typeID = intval($typeID);
228 $descr = self::getDescription($typeID);
229 if($descr !== '')
230 {
231 $result[$typeID] = $descr;
232 }
233 }
234 }
235 return $result;
236 }
237}