1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
group.php
См. документацию.
1
<?php
8
namespace
Bitrix\Sale\Location;
9
10
use Bitrix\Main;
11
use Bitrix\Main\Entity;
12
use Bitrix\Main\Config;
13
use Bitrix\Main\Localization\Loc;
14
15
use Bitrix\Sale\Location\Name;
16
use Bitrix\Sale\Location\Util\Assert;
17
18
Loc::loadMessages(__FILE__);
19
36
class
GroupTable
extends
Entity\DataManager
37
{
38
const
PROJECT_USES_GROUPS_OPT
=
'project_uses_groups'
;
39
40
public
static
function
getFilePath
()
41
{
42
return
__FILE__;
43
}
44
45
public
static
function
getTableName
()
46
{
47
return
'b_sale_location_group'
;
48
}
49
50
public
static
function
add
(
array
$data
)
51
{
52
if
(isset(
$data
[
'NAME'
]))
53
{
54
$name
=
$data
[
'NAME'
];
55
unset(
$data
[
'NAME'
]);
56
}
57
58
$addResult = parent::add(
$data
);
59
60
// add connected data
61
if
($addResult->isSuccess())
62
{
63
$primary = $addResult->getId();
64
65
// names
66
if
(isset(
$name
))
67
Name\GroupTable::addMultipleForOwner
($primary,
$name
);
68
69
// set flag that indicates whether project still uses groups or not
70
self::setGroupUsage();
71
}
72
73
return
$addResult;
74
}
75
76
public
static
function
update
($primary,
array
$data
)
77
{
78
$primary = Assert::expectIntegerPositive($primary,
'$primary'
);
79
80
// first update parent, and if it succeed, do updates of the connected data
81
82
if
(isset(
$data
[
'NAME'
]))
83
{
84
$name
=
$data
[
'NAME'
];
85
unset(
$data
[
'NAME'
]);
86
}
87
88
$updResult = parent::update($primary,
$data
);
89
90
// update connected data
91
if
($updResult->isSuccess())
92
{
93
// names
94
if
(isset(
$name
))
95
Name\GroupTable::updateMultipleForOwner
($primary,
$name
);
96
}
97
98
return
$updResult;
99
}
100
101
public
static
function
delete
($primary)
102
{
103
$primary = Assert::expectIntegerPositive($primary,
'$primary'
);
104
105
$delResult = parent::delete($primary);
106
107
// delete connected data
108
if
($delResult->isSuccess())
109
{
110
Name\GroupTable::deleteMultipleForOwner
($primary);
111
GroupLocationTable::deleteByGroupId
($primary);
112
113
// set flag that indicates whether project still uses groups or not
114
self::checkGroupUsage();
115
}
116
117
return
$delResult;
118
}
119
120
public
static
function
checkGroupUsage
()
121
{
122
$optValue =
Config\Option::get
(
"sale"
, self::PROJECT_USES_GROUPS_OPT,
''
,
''
);
123
if
(!$optValue)
// option is undefined, we are not sure if there are groups or not
124
return
self::getGroupUsage();
125
126
return
$optValue ==
'Y'
;
127
}
128
129
public
static
function
getGroupUsage
()
130
{
131
$isUsing = !!
GroupTable::getList
(
array
(
'limit'
=> 1,
'select'
=>
array
(
'ID'
)))->fetch();
132
Config\Option::set
(
"sale"
, self::PROJECT_USES_GROUPS_OPT, $isUsing ?
'Y'
:
'N'
,
''
);
133
134
return
$isUsing;
135
}
136
137
public
static
function
setGroupUsage
()
138
{
139
Config\Option::set
(
"sale"
, self::PROJECT_USES_GROUPS_OPT,
'Y'
);
140
}
141
142
public
static
function
getCodeValidators
()
143
{
144
return
array
(
145
new
Entity
\
Validator
\Unique(),
146
);
147
}
148
149
public
static
function
getMap
()
150
{
151
return
array
(
152
153
'ID'
=>
array
(
154
'data_type'
=>
'integer'
,
155
'primary'
=>
true
,
156
'autocomplete'
=>
true
,
157
),
158
'CODE'
=>
array
(
159
'data_type'
=>
'string'
,
160
'required'
=>
true
,
161
'title'
=> Loc::getMessage(
'SALE_LOCATION_GROUP_ENTITY_CODE_FIELD'
),
162
'validation'
=>
array
(__CLASS__,
'getCodeValidators'
)
163
),
164
'SORT'
=>
array
(
165
'data_type'
=>
'integer'
,
166
'title'
=> Loc::getMessage(
'SALE_LOCATION_GROUP_ENTITY_SORT_FIELD'
),
167
'default_value'
=>
'100'
168
),
169
170
// virtual
171
'NAME'
=>
array
(
172
'data_type'
=>
'\Bitrix\Sale\Location\Name\Group'
,
173
'reference'
=>
array
(
174
'=this.ID'
=>
'ref.LOCATION_GROUP_ID'
175
)
176
),
177
'LOCATION'
=>
array
(
178
'data_type'
=>
'\Bitrix\Sale\Location\Location'
,
179
'reference'
=>
array
(
180
'=this.ID'
=>
'ref.LOCATION_GROUP_ID'
181
)
182
)
183
);
184
}
185
}
Bitrix\Main\Config\Option\get
static get($moduleId, $name, $default="", $siteId=false)
Определения
option.php:30
Bitrix\Main\Config\Option\set
static set($moduleId, $name, $value="", $siteId="")
Определения
option.php:261
Bitrix\Main\GroupTable
Определения
group.php:32
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Main\ORM\Fields\Validators\Validator
Определения
validator.php:18
Bitrix\Sale\Location\GroupLocationTable\deleteByGroupId
static deleteByGroupId($groupId)
Определения
grouplocation.php:101
Bitrix\Sale\Location\GroupTable\getGroupUsage
static getGroupUsage()
Определения
group.php:129
Bitrix\Sale\Location\GroupTable\PROJECT_USES_GROUPS_OPT
const PROJECT_USES_GROUPS_OPT
Определения
group.php:38
Bitrix\Sale\Location\GroupTable\getMap
static getMap()
Определения
group.php:149
Bitrix\Sale\Location\GroupTable\getCodeValidators
static getCodeValidators()
Определения
group.php:142
Bitrix\Sale\Location\GroupTable\getFilePath
static getFilePath()
Определения
group.php:40
Bitrix\Sale\Location\GroupTable\checkGroupUsage
static checkGroupUsage()
Определения
group.php:120
Bitrix\Sale\Location\GroupTable\add
static add(array $data)
Определения
group.php:50
Bitrix\Sale\Location\GroupTable\setGroupUsage
static setGroupUsage()
Определения
group.php:137
Bitrix\Sale\Location\GroupTable\update
static update($primary, array $data)
Определения
group.php:76
Bitrix\Sale\Location\GroupTable\getTableName
static getTableName()
Определения
group.php:45
Bitrix\Sale\Location\Name\NameEntity\deleteMultipleForOwner
static deleteMultipleForOwner($primaryOwner)
Определения
nameentity.php:165
Bitrix\Sale\Location\Name\NameEntity\addMultipleForOwner
static addMultipleForOwner($primaryOwner, $names=array())
Определения
nameentity.php:34
Bitrix\Sale\Location\Name\NameEntity\updateMultipleForOwner
static updateMultipleForOwner($primaryOwner, $names)
Определения
nameentity.php:93
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$name
$name
Определения
menu_edit.php:35
Bitrix\Main\Entity
Определения
ufield.php:9
bitrix
modules
sale
lib
location
group.php
Создано системой
1.14.0