Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
contractortable.php
1
<?php
2
namespace
Bitrix\Catalog
;
3
4
use
Bitrix\Main\Localization\Loc
;
5
use
Bitrix\Main\ORM\Data\DataManager
;
6
use
Bitrix\Main\ORM\Fields\DatetimeField
;
7
use
Bitrix\Main\ORM\Fields\EnumField
;
8
use
Bitrix\Main\ORM\Fields\IntegerField
;
9
use
Bitrix\Main\ORM\Fields\StringField
;
10
use
Bitrix\Main\ORM\Fields\Validators\LengthValidator
;
11
use
Bitrix\Main\Type\DateTime
;
12
54
class
ContractorTable
extends
DataManager
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
[
368
self::TYPE_INDIVIDUAL
,
369
self::TYPE_COMPANY
,
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
}
Bitrix\Catalog\ContractorTable
Definition
contractortable.php:55
Bitrix\Catalog\ContractorTable\validateKpp
static validateKpp()
Definition
contractortable.php:337
Bitrix\Catalog\ContractorTable\getMap
static getMap()
Definition
contractortable.php:74
Bitrix\Catalog\ContractorTable\validatePersonMiddlename
static validatePersonMiddlename()
Definition
contractortable.php:241
Bitrix\Catalog\ContractorTable\validatePhone
static validatePhone()
Definition
contractortable.php:265
Bitrix\Catalog\ContractorTable\getTypes
static getTypes()
Definition
contractortable.php:374
Bitrix\Catalog\ContractorTable\validateAddress
static validateAddress()
Definition
contractortable.php:349
Bitrix\Catalog\ContractorTable\TYPE_INDIVIDUAL
const TYPE_INDIVIDUAL
Definition
contractortable.php:56
Bitrix\Catalog\ContractorTable\getTypeDescriptions
static getTypeDescriptions()
Definition
contractortable.php:379
Bitrix\Catalog\ContractorTable\TYPE_COMPANY
const TYPE_COMPANY
Definition
contractortable.php:57
Bitrix\Catalog\ContractorTable\validatePostIndex
static validatePostIndex()
Definition
contractortable.php:277
Bitrix\Catalog\ContractorTable\validatePersonLastname
static validatePersonLastname()
Definition
contractortable.php:229
Bitrix\Catalog\ContractorTable\validateCity
static validateCity()
Definition
contractortable.php:301
Bitrix\Catalog\ContractorTable\validateCompany
static validateCompany()
Definition
contractortable.php:313
Bitrix\Catalog\ContractorTable\validateCountry
static validateCountry()
Definition
contractortable.php:289
Bitrix\Catalog\ContractorTable\validateEmail
static validateEmail()
Definition
contractortable.php:253
Bitrix\Catalog\ContractorTable\getTypeList
static getTypeList(bool $description=false)
Definition
contractortable.php:356
Bitrix\Catalog\ContractorTable\validateInn
static validateInn()
Definition
contractortable.php:325
Bitrix\Catalog\ContractorTable\validatePersonName
static validatePersonName()
Definition
contractortable.php:217
Bitrix\Catalog\ContractorTable\getTableName
static getTableName()
Definition
contractortable.php:64
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\EnumField
Definition
enumfield.php:20
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\ORM\Fields\Validators\LengthValidator
Definition
lengthvalidator.php:19
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Catalog
modules
catalog
lib
contractortable.php
Создано системой
1.10.0