Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
paysystemextraservice.php
1<?php
3
6Loc::loadMessages(__FILE__);
7
8class PaySystemExtraServiceTable extends Main\Entity\DataManager
9{
10 public static function getFilePath()
11 {
12 return __FILE__;
13 }
14
15 public static function getTableName()
16 {
17 return 'b_sale_pay_system_es';
18 }
19
20 public static function getMap()
21 {
22 return array(
23 'ID' => array(
24 'data_type' => 'integer',
25 'primary' => true,
26 'autocomplete' => true,
27 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_ID_FIELD'),
28 ),
29 'CODE' => array(
30 'data_type' => 'string',
31 'validation' => array(__CLASS__, 'validateCode'),
32 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_CODE_FIELD'),
33 ),
34 'NAME' => array(
35 'data_type' => 'string',
36 'required' => true,
37 'validation' => array(__CLASS__, 'validateName'),
38 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_NAME_FIELD'),
39 ),
40 'DESCRIPTION' => array(
41 'data_type' => 'string',
42 'validation' => array(__CLASS__, 'validateDescription'),
43 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_DESCRIPTION_FIELD'),
44 ),
45 'CLASS_NAME' => array(
46 'data_type' => 'string',
47 'required' => true,
48 'validation' => array(__CLASS__, 'validateClassName'),
49 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_CLASS_NAME_FIELD'),
50 ),
51 'PARAMS' => array(
52 'data_type' => 'text',
53 'serialized' => true,
54 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_PARAMS_FIELD'),
55 ),
56 'SHOW_MODE' => array(
57 'data_type' => 'string',
58 'required' => false,
59 'validation' => array(__CLASS__, 'validateShowMode'),
60 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_RIGHTS_FIELD'),
61 ),
62 'PAY_SYSTEM_ID' => array(
63 'data_type' => 'integer',
64 'required' => true,
65 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_PAY_SYSTEM_ID_FIELD'),
66 ),
67 'DEFAULT_VALUE' => array(
68 'data_type' => 'string',
69 'validation' => array(__CLASS__, 'validateDefaultValue'),
70 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_INITIAL_FIELD'),
71 ),
72 'ACTIVE' => array(
73 'data_type' => 'string',
74 'default_value'=> 'Y',
75 'validation' => array(__CLASS__, 'validateActive'),
76 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_ACTIVE_FIELD'),
77 ),
78 'SORT' => array(
79 'data_type' => 'integer',
80 'title' => Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_SORT_FIELD'),
81 ),
82 'PAYMENT' => array(
83 'data_type' => '\Bitrix\Sale\Internal\PaymentExtraServiceTable',
84 'reference' => array('this.ID' => 'ref.EXTRA_SERVICE_ID')
85 )
86 );
87 }
88 public static function validateCode()
89 {
90 return array(
91 new Main\Entity\Validator\Length(null, 50),
92 );
93 }
94 public static function validateName()
95 {
96 return array(
97 new Main\Entity\Validator\Length(null, 255),
98 );
99 }
100 public static function validateDescription()
101 {
102 return array(
103 new Main\Entity\Validator\Length(null, 255),
104 );
105 }
106 public static function validateClassName()
107 {
108 return array(
109 new Main\Entity\Validator\Length(null, 255),
110 );
111 }
112 public static function validateShowMode()
113 {
114 return array(
115 new Main\Entity\Validator\Length(null, 1),
116 );
117 }
118 public static function validateDefaultValue()
119 {
120 return array(
121 new Main\Entity\Validator\Length(null, 255),
122 );
123 }
124 public static function validateActive()
125 {
126 return array(
127 new Main\Entity\Validator\Length(null, 1),
128 );
129 }
130
131 public static function onBeforeDelete(Main\Entity\Event $event)
132 {
133 $result = new Main\Entity\EventResult;
134 $primary = $event->getParameter("primary");
135
136 if ((int)$primary['ID'] > 0)
137 {
138 $dbRes = \Bitrix\Sale\Internals\PaymentExtraServiceTable::getList(array(
139 'filter' => array(
140 '=EXTRA_SERVICE_ID' => $primary['ID']
141 )
142 ));
143
144 if ($row = $dbRes->fetch())
145 {
146 $result->addError(new Main\Entity\EntityError(
147 str_replace('#ID#', $primary['ID'], Loc::getMessage('PAY_SYSTEM_EXTRA_SERVICES_ENTITY_ERROR_DELETE'))
148 ));
149 }
150 }
151
152 return $result;
153 }
154}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29