Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
shipment.php
1<?php
9
10use Bitrix\Main;
12
13Loc::loadMessages(__FILE__);
14
15
66class ShipmentTable extends Main\Entity\DataManager
67{
73 public static function getFilePath()
74 {
75 return __FILE__;
76 }
77
78 public static function getUfId()
79 {
80 return 'SHIPMENT';
81 }
82
89 public static function deleteWithItems($id)
90 {
91 $id = intval($id);
92 if ($id <= 0)
93 throw new Main\ArgumentNullException("id");
94
95 $itemsList = ShipmentItemTable::getList(
96 array(
97 "filter" => array("ORDER_DELIVERY_ID" => $id),
98 "select" => array("ID")
99 )
100 );
101 while ($item = $itemsList->fetch())
103
104 return ShipmentTable::delete($id);
105 }
106
112 public static function getTableName()
113 {
114 return 'b_sale_order_delivery';
115 }
116
122 public static function getMap()
123 {
124 global $DB;
125
126 return array(
127 'ID' => array(
128 'data_type' => 'integer',
129 'primary' => true,
130 'autocomplete' => true,
131 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_ID_FIELD'),
132 ),
133 'ORDER_ID' => array(
134 'data_type' => 'integer',
135 'required' => true,
136 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_ORDER_ID_FIELD'),
137 ),
138 new Main\Entity\StringField(
139 'ACCOUNT_NUMBER',
140 array(
141 'size' => 100
142 )
143 ),
144 'ORDER' => array(
145 'data_type' => 'Order',
146 'reference' => array(
147 '=ref.ID' => 'this.ORDER_ID'
148 )
149 ),
150 'DATE_INSERT' => array(
151 'data_type' => 'datetime'
152 ),
153 'DATE_UPDATE' => array(
154 'data_type' => 'datetime'
155 ),
156
157 new Main\Entity\ExpressionField(
158 'DATE_INSERT_SHORT',
159 $DB->datetimeToDateFunction('%s'),
160 array('DATE_INSERT')
161 ),
162
163 new Main\Entity\StringField(
164 'STATUS_ID',
165 array('size' => 2)
166 ),
167
168 new Main\Entity\StringField(
169 'DELIVERY_LOCATION',
170 array('size' => 50)
171 ),
172
173 new Main\Entity\FloatField(
174 'BASE_PRICE_DELIVERY'
175 ),
176
177 new Main\Entity\FloatField(
178 'PRICE_DELIVERY'
179 ),
180
181 new Main\Entity\FloatField(
182 'WEIGHT',
183 [
184 'default_value' => 0
185 ]
186 ),
187
188 new Main\Entity\BooleanField(
189 'CUSTOM_PRICE_DELIVERY',
190 array(
191 'values' => array('N','Y'),
192 'default_value' => 'N'
193 )
194 ),
195
196
197 new Main\Entity\StringField(
198 'CURRENCY',
199 array(
200 'size' => 3
201 )
202 ),
203
204 new Main\Entity\FloatField(
205 'DISCOUNT_PRICE'
206 ),
207
208 new Main\Entity\BooleanField(
209 'ALLOW_DELIVERY',
210 array(
211 'values' => array('N','Y'),
212 'default_value' => 'N'
213 )
214 ),
215
216 new Main\Entity\DatetimeField('DATE_ALLOW_DELIVERY'),
217
218 new Main\Entity\ExpressionField(
219 'DATE_ALLOW_DELIVERY_SHORT',
220 $DB->datetimeToDateFunction('%s'),
221 array('DATE_ALLOW_DELIVERY')
222 ),
223
224 'EMP_ALLOW_DELIVERY_ID' => array(
225 'data_type' => 'integer',
226 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_EMP_ALLOW_DELIVERY_FIELD'),
227 ),
228 'EMP_ALLOW_DELIVERY_BY' => array(
229 'data_type' => 'Bitrix\Main\User',
230 'reference' => array(
231 '=this.EMP_ALLOW_DELIVERY_ID' => 'ref.ID'
232 )
233 ),
234
235 new Main\Entity\BooleanField(
236 'DEDUCTED',
237 array(
238 'values' => array('N','Y'),
239 'default_value' => 'N'
240 )
241 ),
242
243 'DATE_DEDUCTED' => array(
244 'data_type' => 'datetime',
245 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_DATE_DEDUCTED_FIELD'),
246 ),
247 new Main\Entity\ExpressionField(
248 'DATE_DEDUCTED_SHORT',
249 $DB->datetimeToDateFunction('%s'),
250 array('DATE_DEDUCTED')
251 ),
252 'EMP_DEDUCTED_ID' => array(
253 'data_type' => 'integer',
254 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_EMP_DEDUCTED_ID_FIELD'),
255 ),
256 'EMP_DEDUCTED_BY' => array(
257 'data_type' => 'Bitrix\Main\User',
258 'reference' => array(
259 '=this.EMP_DEDUCTED_ID' => 'ref.ID'
260 )
261 ),
262 'REASON_UNDO_DEDUCTED' => array(
263 'data_type' => 'string',
264 'validation' => array(__CLASS__, 'validateReasonUndoDeducted'),
265 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_REASON_UNDO_DEDUCTED_FIELD'),
266 ),
267
268 new Main\Entity\BooleanField(
269 'RESERVED',
270 array(
271 'values' => array('N','Y'),
272 'default_value' => 'N'
273 )
274 ),
275
276 new Main\Entity\IntegerField(
277 'DELIVERY_ID',
278 array(
279 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_DELIVERY_ID_FIELD'),
280 )
281 ),
282
283 'DELIVERY' => array(
284 'data_type' => '\Bitrix\Sale\Delivery\Services\Table',
285 'reference' => array(
286 '=this.DELIVERY_ID' => 'ref.ID'
287 )
288 ),
289 'DELIVERY_DOC_NUM' => array(
290 'data_type' => 'string',
291 'validation' => array(__CLASS__, 'validateDeliveryDocNum'),
292 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_DELIVERY_DOC_NUM_FIELD'),
293 ),
294
295 new Main\Entity\DatetimeField('DELIVERY_DOC_DATE'),
296
297 new Main\Entity\ExpressionField(
298 'DELIVERY_DOC_DATE_SHORT',
299 $DB->datetimeToDateFunction('%s'),
300 array('DELIVERY_DOC_DATE')
301 ),
302
303 'TRACKING_NUMBER' => array(
304 'data_type' => 'string',
305 'validation' => array(__CLASS__, 'validateTrackingNumber'),
306 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_TRACKING_NUMBER_FIELD'),
307 ),
308 'TRACKING_STATUS' => array(
309 'data_type' => 'integer',
310 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_TRACKING_STATUS_FIELD'),
311 ),
312 'TRACKING_DESCRIPTION' => array(
313 'data_type' => 'string',
314 'validation' => array(__CLASS__, 'validateTrackingDescription'),
315 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_TRACKING_DESCRIPTION_FIELD'),
316 ),
317 'TRACKING_LAST_CHECK' => array(
318 'data_type' => 'datetime',
319 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_TRACKING_LAST_CHECK_FIELD'),
320 ),
321 'TRACKING_LAST_CHANGE' => array(
322 'data_type' => 'datetime',
323 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_TRACKING_LAST_CHANGE_FIELD'),
324 ),
325
326 'XML_ID' => array(
327 'data_type' => 'string',
328 'validation' => array(__CLASS__, 'validateXmlId'),
329 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_XML_ID_FIELD'),
330 ),
331 'PARAMS' => array(
332 'data_type' => 'text',
333 'serialized' => true,
334 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_PARAMETERS_FIELD'),
335 ),
336 'DELIVERY_NAME' => array(
337 'data_type' => 'string',
338// 'required' => true,
339 'validation' => array(__CLASS__, 'validateDeliveryName'),
340 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_DELIVERY_NAME_FIELD'),
341 ),
342
343 new Main\Entity\BooleanField(
344 'CANCELED',
345 array(
346 'values' => array('N','Y'),
347 'default_value' => 'N'
348 )
349 ),
350 'DATE_CANCELED' => array(
351 'data_type' => 'datetime',
352 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_DATE_CANCELED_FIELD'),
353 ),
354 'EMP_CANCELED_ID' => array(
355 'data_type' => 'integer',
356 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_EMP_CANCELED_ID_FIELD'),
357 ),
358 'REASON_CANCELED' => array(
359 'data_type' => 'string',
360 'validation' => array(__CLASS__, 'validateReasonCanceled'),
361 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_REASON_CANCELED_FIELD'),
362 ),
363 'EMP_CANCELED_BY' => array(
364 'data_type' => 'Bitrix\Main\User',
365 'reference' => array(
366 '=this.EMP_CANCELED_ID' => 'ref.ID'
367 )
368 ),
369 new Main\Entity\BooleanField(
370 'MARKED',
371 array(
372 'values' => array('N','Y'),
373 'default_value' => 'N'
374 )
375 ),
376 'DATE_MARKED' => array(
377 'data_type' => 'datetime',
378 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_DATE_MARKED_FIELD'),
379 ),
380 'EMP_MARKED_ID' => array(
381 'data_type' => 'integer',
382 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_EMP_MARKED_ID_FIELD'),
383 ),
384 'EMP_MARKED_BY' => array(
385 'data_type' => 'Bitrix\Main\User',
386 'reference' => array(
387 '=this.EMP_MARKED_ID' => 'ref.ID'
388 )
389 ),
390 'REASON_MARKED' => array(
391 'data_type' => 'string',
392 'validation' => array(__CLASS__, 'validateReasonMarked'),
393 'title' => Loc::getMessage('ORDER_SHIPMENT_ENTITY_REASON_MARKED_FIELD'),
394 ),
395
396 new Main\Entity\BooleanField(
397 'SYSTEM',
398 array(
399 'values' => array('N','Y'),
400 'default_value' => 'N'
401 )
402 ),
403
404 'RESPONSIBLE_ID' => array(
405 'data_type' => 'integer',
406 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_RESPONSIBLE_ID_FIELD')
407 ),
408 'RESPONSIBLE_BY' => array(
409 'data_type' => 'Bitrix\Main\User',
410 'reference' => array(
411 '=this.RESPONSIBLE_ID' => 'ref.ID'
412 )
413 ),
414 'EMP_RESPONSIBLE_ID' => array(
415 'data_type' => 'integer',
416 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_EMP_RESPONSIBLE_ID_FIELD')
417 ),
418 'EMP_RESPONSIBLE_BY' => array(
419 'data_type' => 'Bitrix\Main\User',
420 'reference' => array(
421 '=this.EMP_RESPONSIBLE_ID' => 'ref.ID'
422 )
423 ),
424 'DATE_RESPONSIBLE_ID' => array(
425 'data_type' => 'datetime',
426 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_DATE_RESPONSIBLE_ID_FIELD')
427 ),
428 'COMMENTS' => array(
429 'data_type' => 'string',
430 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_COMMENTS_FIELD')
431 ),
432 'COMPANY_ID' => array(
433 'data_type' => 'integer',
434 'title' => Loc::getMessage('ORDER_PAYMENT_ENTITY_COMPANY_ID_FIELD')
435 ),
436 'COMPANY_BY' => array(
437 'data_type' => 'Bitrix\Sale\Internals\Company',
438 'reference' => array(
439 '=this.COMPANY_ID' => 'ref.ID'
440 )
441 ),
442 'STATUS' => array(
443 'data_type' => 'Bitrix\Sale\Internals\StatusTable',
444 'reference' => array(
445 '=this.STATUS_ID' => 'ref.ID'
446 )
447 ),
448 'SHIPMENT_ITEM' => array(
449 'data_type' => 'ShipmentItem',
450 'reference' => array(
451 'this.ID' => 'ref.ORDER_DELIVERY_ID',
452 )
453 ),
454 new Main\Entity\BooleanField(
455 'UPDATED_1C',
456 array(
457 'values' => array('N', 'Y')
458 )
459 ),
460
461 new Main\Entity\StringField('ID_1C'),
462
463 new Main\Entity\StringField('VERSION_1C'),
464
465 new Main\Entity\BooleanField(
466 'EXTERNAL_DELIVERY',
467 array(
468 'values' => array('N', 'Y')
469 )
470 ),
471 );
472 }
478 public static function validateAllowDelivery()
479 {
480 return array(
481 new Main\Entity\Validator\Length(null, 1),
482 );
483 }
489 public static function validateDeducted()
490 {
491 return array(
492 new Main\Entity\Validator\Length(null, 1),
493 );
494 }
500 public static function validateReasonUndoDeducted()
501 {
502 return array(
503 new Main\Entity\Validator\Length(null, 255),
504 );
505 }
511 public static function validateReserved()
512 {
513 return array(
514 new Main\Entity\Validator\Length(null, 1),
515 );
516 }
522 public static function validateDeliveryDocNum()
523 {
524 return array(
525 new Main\Entity\Validator\Length(null, 20),
526 );
527 }
533 public static function validateTrackingNumber()
534 {
535 return array(
536 new Main\Entity\Validator\Length(null, 255),
537 );
538 }
544 public static function validateXmlId()
545 {
546 return array(
547 new Main\Entity\Validator\Length(null, 255),
548 );
549 }
555 public static function validateDeliveryName()
556 {
557 return array(
558 new Main\Entity\Validator\Length(null, 255),
559 );
560 }
566 public static function validateCanceled()
567 {
568 return array(
569 new Main\Entity\Validator\Length(null, 1),
570 );
571 }
577 public static function validateReasonCanceled()
578 {
579 return array(
580 new Main\Entity\Validator\Length(null, 255),
581 );
582 }
588 public static function validateMarked()
589 {
590 return array(
591 new Main\Entity\Validator\Length(null, 1),
592 );
593 }
599 public static function validateReasonMarked()
600 {
601 return array(
602 new Main\Entity\Validator\Length(null, 255),
603 );
604 }
610 public static function validateSystem()
611 {
612 return array(
613 new Main\Entity\Validator\Length(null, 1),
614 );
615 }
621 public static function validateTrackingDescription()
622 {
623 return array(
624 new Main\Entity\Validator\Length(null, 255),
625 );
626 }
627
628}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29