Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
documenttype.php
1<?php
3
10{
11 const UNDEFINED = 0;
12 const ORDER = 1;
13 const SHIPMENT = 2;
14 const PAYMENT_CASH = 3;
17 const PROFILE = 6;
18 const USER_PROFILE = 7;
19
20 const FIRST = 1;
21 const LAST = 7;
22
23 const ORDER_NAME = 'ORDER';
24 const SHIPMENT_NAME = 'SHIPMENT';
25 const PAYMENT_CASH_NAME = 'PAYMENT_CASH';
26 const PAYMENT_CASH_LESS_NAME = 'PAYMENT_CASH_LESS';
27 const PAYMENT_CARD_TRANSACTION_NAME = 'PAYMENT_CARD_TRANSACTION';
28 const PROFILE_NAME = 'PROFILE';
29 const USER_PROFILE_NAME = 'USER_PROFILE';
30
31 private static $ALL_DESCRIPTIONS = array();
32
37 public static function isDefined($typeID)
38 {
39 if(!is_int($typeID))
40 {
41 $typeID = (int)$typeID;
42 }
43 return $typeID >= self::FIRST && $typeID <= self::LAST;
44 }
45
50 public static function resolveID($name)
51 {
52 $name = mb_strtoupper(trim(strval($name)));
53 if($name == '')
54 {
55 return self::UNDEFINED;
56 }
57
58 switch($name)
59 {
61 return self::ORDER;
62
64 return self::SHIPMENT;
65
67 return self::PAYMENT_CASH;
68
71
74
76 return self::PROFILE;
77
79 return self::USER_PROFILE;
80
81 default:
82 return self::UNDEFINED;
83 }
84 }
85
90 public static function resolveName($typeID)
91 {
92 if(!is_numeric($typeID))
93 {
94 return '';
95 }
96
97 $typeID = intval($typeID);
98 if($typeID <= 0)
99 {
100 return '';
101 }
102
103 switch($typeID)
104 {
105 case self::ORDER:
106 return self::ORDER_NAME;
107
108 case self::SHIPMENT:
109 return self::SHIPMENT_NAME;
110
113
116
119
120 case self::PROFILE:
121 return self::PROFILE_NAME;
122
125
126 case self::UNDEFINED:
127 default:
128 return '';
129 }
130 }
131
135 public static function getAllDescriptions()
136 {
137 if(!self::$ALL_DESCRIPTIONS[LANGUAGE_ID])
138 {
139 IncludeModuleLangFile(__FILE__);
140 self::$ALL_DESCRIPTIONS[LANGUAGE_ID] = array(
141 self::ORDER => GetMessage('SALE_TYPE_ORDER'),
142 self::SHIPMENT => GetMessage('SALE_TYPE_SHIPMENT'),
143 self::PAYMENT_CASH => GetMessage('SALE_TYPE_PAYMENT_CASH'),
144 self::PAYMENT_CASH_LESS => GetMessage('SALE_TYPE_PAYMENT_CASH_LESS'),
145 self::PAYMENT_CARD_TRANSACTION => GetMessage('SALE_TYPE_PAYMENT_CARD_TRANSACTION'),
146 self::PROFILE => GetMessage('SALE_TYPE_PROFILE'),
147 self::USER_PROFILE => GetMessage('SALE_TYPE_USER_PROFILE')
148 );
149 }
150
151 return self::$ALL_DESCRIPTIONS[LANGUAGE_ID];
152 }
153
158 public static function getDescription($typeID)
159 {
160 $typeID = intval($typeID);
162 return isset($all[$typeID]) ? $all[$typeID] : '';
163 }
164
169 public static function getDescriptions($types)
170 {
171 $result = array();
172 if(is_array($types))
173 {
174 foreach($types as $typeID)
175 {
176 $typeID = intval($typeID);
177 $descr = self::getDescription($typeID);
178 if($descr !== '')
179 {
180 $result[$typeID] = $descr;
181 }
182 }
183 }
184 return $result;
185 }
186}