1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
usertransacttable.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\Internals;
4
5use Bitrix\Main\ORM\Data\DataManager;
6use Bitrix\Main\ORM\Event;
7use Bitrix\Main\ORM\EventResult;
8use Bitrix\Main\ORM\Fields\BooleanField;
9use Bitrix\Main\ORM\Fields\DatetimeField;
10use Bitrix\Main\ORM\Fields\FloatField;
11use Bitrix\Main\ORM\Fields\IntegerField;
12use Bitrix\Main\ORM\Fields\Relations\Reference;
13use Bitrix\Main\ORM\Fields\StringField;
14use Bitrix\Main\ORM\Fields\TextField;
15use Bitrix\Main\ORM\Fields\Validators\LengthValidator;
16use Bitrix\Main\ORM\Query\Join;
17use Bitrix\Main\Type\DateTime;
18
54{
60 public static function getTableName()
61 {
62 return 'b_sale_user_transact';
63 }
64
70 public static function getMap()
71 {
72 return [
73 'ID' =>
74 (new IntegerField('ID'))
75 ->configurePrimary(true)
76 ->configureAutocomplete(true)
77 ,
78 'USER_ID' =>
79 (new IntegerField('USER_ID'))
80 ->configureRequired(true)
81 ,
82 'TIMESTAMP_X' =>
83 (new DatetimeField('TIMESTAMP_X'))
84 ->configureDefaultValue(
85 static function()
86 {
87 return new DateTime();
88 }
89 )
90 ,
91 'TRANSACT_DATE' =>
92 (new DatetimeField('TRANSACT_DATE'))
93 ->configureRequired(true)
94 ,
95 'AMOUNT' =>
96 (new FloatField('AMOUNT'))
97 ->configureDefaultValue(0.0000)
98 ,
99 'CURRENCY' =>
100 (new StringField('CURRENCY'))
101 ->configureRequired(true)
102 ->addValidator(new LengthValidator(null, 3))
103 ,
104 'DEBIT' => (new BooleanField('DEBIT'))
105 ->configureValues('N', 'Y')
106 ->configureDefaultValue('N')
107 ,
108 'ORDER_ID' => (new IntegerField('ORDER_ID')),
109 'DESCRIPTION' =>
110 (new StringField('DESCRIPTION'))
111 ->configureRequired(true)
112 ->addValidator(new LengthValidator(null, 255))
113 ,
114 'NOTES' => (new TextField('NOTES')),
115 'PAYMENT_ID' => (new IntegerField('PAYMENT_ID')),
116 'EMPLOYEE_ID' => (new IntegerField('EMPLOYEE_ID')),
117 //
118 new Reference(
119 'ORDER',
120 OrderTable::class,
121 Join::on('this.ORDER_ID', 'ref.ID')
122 ),
123 new Reference(
124 'PAYMENT',
125 PaymentTable::class,
126 Join::on('this.PAYMENT_ID', 'ref.ID')
127 ),
128 ];
129 }
130
137 public static function onBeforeAdd(Event $event): EventResult
138 {
139 $result = new EventResult;
140 $data = $event->getParameter('fields');
141 if (!isset($data['TIMESTAMP_X']))
142 {
143 $result->modifyFields([
144 'TIMESTAMP_X' => new DateTime(),
145 ]);
146 }
147
148 return $result;
149 }
150
157 public static function onBeforeUpdate(Event $event): EventResult
158 {
159 $result = new EventResult;
160 $data = $event->getParameter('fields');
161 if (!isset($data['TIMESTAMP_X']))
162 {
163 $result->modifyFields([
164 'TIMESTAMP_X' => new DateTime(),
165 ]);
166 }
167
168 return $result;
169 }
170}
static onBeforeAdd(Event $event)
Определения usertransacttable.php:137
static onBeforeUpdate(Event $event)
Определения usertransacttable.php:157
$data['IS_AVAILABLE']
Определения .description.php:13
$result
Определения get_property_values.php:14
Определения buffer.php:3
$event
Определения prolog_after.php:141