Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
contractortable.php
1<?php
2namespace Bitrix\Catalog;
3
12
55{
56 public const TYPE_INDIVIDUAL = '1';
57 public const TYPE_COMPANY = '2';
58
64 public static function getTableName()
65 {
66 return 'b_catalog_contractor';
67 }
68
74 public static function getMap()
75 {
76 return [
77 'ID' => new IntegerField(
78 'ID',
79 [
80 'primary' => true,
81 'autocomplete' => true,
82 'title' => Loc::getMessage('CONTRACTOR_ENTITY_ID_FIELD'),
83 ]
84 ),
85 'PERSON_TYPE' => new EnumField(
86 'PERSON_TYPE',
87 [
88 'required' => true,
89 'values' => static::getTypes(),
90 'title' => Loc::getMessage('CONTRACTOR_ENTITY_PERSON_TYPE_FIELD'),
91 ]
92 ),
93 'PERSON_NAME' => new StringField(
94 'PERSON_NAME',
95 [
96 'validation' => [__CLASS__, 'validatePersonName'],
97 'title' => Loc::getMessage('CONTRACTOR_ENTITY_PERSON_NAME_FIELD'),
98 ]
99 ),
100 'PERSON_LASTNAME' => new StringField(
101 'PERSON_LASTNAME',
102 [
103 'validation' => [__CLASS__, 'validatePersonLastname'],
104 'title' => Loc::getMessage('CONTRACTOR_ENTITY_PERSON_LASTNAME_FIELD'),
105 ]
106 ),
107 'PERSON_MIDDLENAME' => new StringField(
108 'PERSON_MIDDLENAME',
109 [
110 'validation' => [__CLASS__, 'validatePersonMiddlename'],
111 'title' => Loc::getMessage('CONTRACTOR_ENTITY_PERSON_MIDDLENAME_FIELD'),
112 ]
113 ),
114 'EMAIL' => new StringField(
115 'EMAIL',
116 [
117 'validation' => [__CLASS__, 'validateEmail'],
118 'title' => Loc::getMessage('CONTRACTOR_ENTITY_EMAIL_FIELD'),
119 ]
120 ),
121 'PHONE' => new StringField(
122 'PHONE',
123 [
124 'validation' => [__CLASS__, 'validatePhone'],
125 'title' => Loc::getMessage('CONTRACTOR_ENTITY_PHONE_FIELD'),
126 ]
127 ),
128 'POST_INDEX' => new StringField(
129 'POST_INDEX',
130 [
131 'validation' => [__CLASS__, 'validatePostIndex'],
132 'title' => Loc::getMessage('CONTRACTOR_ENTITY_POST_INDEX_FIELD'),
133 ]
134 ),
135 'COUNTRY' => new StringField(
136 'COUNTRY',
137 [
138 'validation' => [__CLASS__, 'validateCountry'],
139 'title' => Loc::getMessage('CONTRACTOR_ENTITY_COUNTRY_FIELD'),
140 ]
141 ),
142 'CITY' => new StringField(
143 'CITY',
144 [
145 'validation' => [__CLASS__, 'validateCity'],
146 'title' => Loc::getMessage('CONTRACTOR_ENTITY_CITY_FIELD'),
147 ]
148 ),
149 'COMPANY' => new StringField(
150 'COMPANY',
151 [
152 'validation' => [__CLASS__, 'validateCompany'],
153 'title' => Loc::getMessage('CONTRACTOR_ENTITY_COMPANY_FIELD'),
154 ]
155 ),
156 'INN' => new StringField(
157 'INN',
158 [
159 'validation' => [__CLASS__, 'validateInn'],
160 'title' => Loc::getMessage('CONTRACTOR_ENTITY_INN_FIELD'),
161 ]
162 ),
163 'KPP' => new StringField(
164 'KPP',
165 [
166 'validation' => [__CLASS__, 'validateKpp'],
167 'title' => Loc::getMessage('CONTRACTOR_ENTITY_KPP_FIELD'),
168 ]
169 ),
170 'ADDRESS' => new StringField(
171 'ADDRESS',
172 [
173 'validation' => [__CLASS__, 'validateAddress'],
174 'title' => Loc::getMessage('CONTRACTOR_ENTITY_ADDRESS_FIELD'),
175 ]
176 ),
177 'DATE_MODIFY' => new DatetimeField(
178 'DATE_MODIFY',
179 [
180 'default' => function()
181 {
182 return new DateTime();
183 },
184 'title' => Loc::getMessage('CONTRACTOR_ENTITY_DATE_MODIFY_FIELD'),
185 ]
186 ),
187 'DATE_CREATE' => new DatetimeField(
188 'DATE_CREATE',
189 [
190 'default_value' => function()
191 {
192 return new DateTime();
193 },
194 'title' => Loc::getMessage('CONTRACTOR_ENTITY_DATE_CREATE_FIELD'),
195 ]
196 ),
197 'CREATED_BY' => new IntegerField(
198 'CREATED_BY',
199 [
200 'title' => Loc::getMessage('CONTRACTOR_ENTITY_CREATED_BY_FIELD'),
201 ]
202 ),
203 'MODIFIED_BY' => new IntegerField(
204 'MODIFIED_BY',
205 [
206 'title' => Loc::getMessage('CONTRACTOR_ENTITY_MODIFIED_BY_FIELD'),
207 ]
208 ),
209 ];
210 }
211
217 public static function validatePersonName(): array
218 {
219 return [
220 new LengthValidator(null, 100),
221 ];
222 }
223
229 public static function validatePersonLastname(): array
230 {
231 return [
232 new LengthValidator(null, 100),
233 ];
234 }
235
241 public static function validatePersonMiddlename(): array
242 {
243 return [
244 new LengthValidator(null, 100),
245 ];
246 }
247
253 public static function validateEmail(): array
254 {
255 return [
256 new LengthValidator(null, 100),
257 ];
258 }
259
265 public static function validatePhone(): array
266 {
267 return [
268 new LengthValidator(null, 45),
269 ];
270 }
271
277 public static function validatePostIndex(): array
278 {
279 return [
280 new LengthValidator(null, 45),
281 ];
282 }
283
289 public static function validateCountry(): array
290 {
291 return [
292 new LengthValidator(null, 45),
293 ];
294 }
295
301 public static function validateCity(): array
302 {
303 return [
304 new LengthValidator(null, 45),
305 ];
306 }
307
313 public static function validateCompany(): array
314 {
315 return [
316 new LengthValidator(null, 145),
317 ];
318 }
319
325 public static function validateInn(): array
326 {
327 return [
328 new LengthValidator(null, 145),
329 ];
330 }
331
337 public static function validateKpp(): array
338 {
339 return [
340 new LengthValidator(null, 145),
341 ];
342 }
343
349 public static function validateAddress(): array
350 {
351 return [
352 new LengthValidator(null, 255),
353 ];
354 }
355
356 public static function getTypeList(bool $description = false): array
357 {
358 if ($description)
359 {
360 return [
361 self::TYPE_INDIVIDUAL => Loc::getMessage('CONTRACTOR_ENTITY_TYPE_INDIVIDUAL'),
362 self::TYPE_COMPANY => Loc::getMessage('CONTRACTOR_ENTITY_TYPE_COMPANY'),
363 ];
364 }
365 else
366 {
367 return [
370 ];
371 }
372 }
373
374 public static function getTypes(): array
375 {
376 return static::getTypeList();
377 }
378
379 public static function getTypeDescriptions(): array
380 {
381 return static::getTypeList(true);
382 }
383}
static getTypeList(bool $description=false)
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29