1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
group.php
См. документацию.
1<?php
8namespace Bitrix\Sale\Location;
9
10use Bitrix\Main;
11use Bitrix\Main\Entity;
12use Bitrix\Main\Config;
13use Bitrix\Main\Localization\Loc;
14
15use Bitrix\Sale\Location\Name;
16use Bitrix\Sale\Location\Util\Assert;
17
18Loc::loadMessages(__FILE__);
19
36class 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))
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))
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 {
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}
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
static set($moduleId, $name, $value="", $siteId="")
Определения option.php:261
Определения group.php:32
static getList(array $parameters=array())
Определения datamanager.php:431
static deleteByGroupId($groupId)
Определения grouplocation.php:101
static getGroupUsage()
Определения group.php:129
const PROJECT_USES_GROUPS_OPT
Определения group.php:38
static getMap()
Определения group.php:149
static getCodeValidators()
Определения group.php:142
static getFilePath()
Определения group.php:40
static checkGroupUsage()
Определения group.php:120
static add(array $data)
Определения group.php:50
static setGroupUsage()
Определения group.php:137
static update($primary, array $data)
Определения group.php:76
static getTableName()
Определения group.php:45
static deleteMultipleForOwner($primaryOwner)
Определения nameentity.php:165
static addMultipleForOwner($primaryOwner, $names=array())
Определения nameentity.php:34
static updateMultipleForOwner($primaryOwner, $names)
Определения nameentity.php:93
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
Определения ufield.php:9