Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
shipment.php
1<?php
3
6
7Loc::loadMessages(__FILE__);
8
37class ShipmentTable extends Entity\DataManager
38{
44 public static function getTableName()
45 {
46 return 'b_sale_delivery_req_shp';
47 }
48
54 public static function getMap()
55 {
56 return array(
57 'ID' => array(
58 'data_type' => 'integer',
59 'primary' => true,
60 'autocomplete' => true,
61 'title' => Loc::getMessage('SALE_DLVR_REQ_SHP_TBL_ID_FIELD'),
62 ),
63 'SHIPMENT_ID' => array(
64 'data_type' => 'integer',
65 'required' => true,
66 'title' => Loc::getMessage('SALE_DLVR_REQ_SHP_TBL_SHIPMENT_ID_FIELD'),
67 ),
68 'REQUEST_ID' => array(
69 'data_type' => 'integer',
70 'title' => Loc::getMessage('SALE_DLVR_REQ_SHP_TBL_REQUEST_ID_FIELD'),
71 ),
72 'EXTERNAL_ID' => array(
73 'data_type' => 'string',
74 'validation' => array(__CLASS__, 'validateType'),
75 'title' => Loc::getMessage('SALE_DLVR_REQ_SHP_TBL_EXTERNAL_ID_FIELD'),
76 ),
77 'ERROR_DESCRIPTION' => array(
78 'data_type' => 'string',
79 'validation' => array(__CLASS__, 'validateErrorDescription'),
80 'title' => Loc::getMessage('SALE_DLVR_REQ_SHP_TBL_ERROR_DESCRIPTION_FIELD'),
81 ),
82 'SHIPMENT' => array(
83 'data_type' => '\Bitrix\Sale\Internals\ShipmentTable',
84 'reference' => array('=this.SHIPMENT_ID' => 'ref.ID'),
85 ),
86 'REQUEST' => array(
87 'data_type' => '\Bitrix\Sale\Delivery\Requests\RequestTable',
88 'reference' => array('=this.REQUEST_ID' => 'ref.ID'),
89 )
90 );
91 }
92
96 public static function validateType()
97 {
98 return array(
99 new Entity\Validator\Length(null, 50),
100 );
101 }
102
106 public static function validateErrorDescription()
107 {
108 return array(
109 new Entity\Validator\Length(null, 2048),
110 );
111 }
112
113 public static function setShipment(array $fields)
114 {
115 $res = self::getList(array('filter' => array('=SHIPMENT_ID' => $fields['SHIPMENT_ID'])));
116
117 if($row = $res->fetch())
118 $result = self::update($row['ID'], $fields);
119 else
120 $result = self::add($fields);
121
122 return $result;
123 }
124}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29