1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
room.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Calendar\Rooms;
4
5
use Bitrix\Calendar\Internals\LocationTable;
6
use Bitrix\Calendar\Internals\SectionTable;
7
use Bitrix\Main\Localization\Loc;
8
use Bitrix\Main\Error;
9
use Bitrix\Main\Text\Emoji;
10
use Bitrix\Main\Type\DateTime;
11
12
Loc::loadMessages(__FILE__);
13
14
class
Room
15
{
16
public
const
TYPE
=
'location'
;
17
19
private
?
int
$id =
null
;
21
private
?int$locationId =
null
;
23
private
?
int
$capacity =
null
;
25
private
string
$necessity =
'N'
;
27
private
string
$name =
''
;
29
private
string
$type = self::TYPE;
31
private
string
$color =
'#9dcf00'
;
33
private
?
int
$ownerId =
null
;
35
private
?
int
$createdBy =
null
;
37
private
?
int
$categoryId =
null
;
39
private
?
array
$access = [];
41
private
?
Error
$error =
null
;
42
48
public
static
function
createInstanceFromParams
(
$params
):
Room
49
{
50
$params
= [
51
'ID'
=>
$params
[
'ID'
] ??
null
,
52
'LOCATION_ID'
=>
$params
[
'LOCATION_ID'
] ??
null
,
53
'CAPACITY'
=>
$params
[
'CAPACITY'
] ??
null
,
54
'NECESSITY'
=>
$params
[
'NECESSITY'
] ??
null
,
55
'NAME'
=>
$params
[
'NAME'
] ??
null
,
56
'COLOR'
=>
$params
[
'COLOR'
] ??
null
,
57
'OWNER_ID'
=>
$params
[
'OWNER_ID'
] ??
null
,
58
'ACCESS'
=>
$params
[
'ACCESS'
] ??
null
,
59
'CATEGORY_ID'
=>
$params
[
'CATEGORY_ID'
] ??
null
,
60
];
61
62
$room =
new
self
();
63
$room->setId(
$params
[
'ID'
])
64
->setLocationId(
$params
[
'LOCATION_ID'
])
65
->setCapacity(
$params
[
'CAPACITY'
])
66
->setNecessity(
$params
[
'NECESSITY'
])
67
->setName(
$params
[
'NAME'
])
68
->setColor(
$params
[
'COLOR'
])
69
->setOwnerId(
$params
[
'OWNER_ID'
])
70
->setCreatedBy()
71
->setAccess(
$params
[
'ACCESS'
])
72
->setCategoryId(
$params
[
'CATEGORY_ID'
])
73
;
74
75
return
$room;
76
}
77
81
public
function
createInstance
():
Room
82
{
83
return
new
self
();
84
}
85
91
public
function
setId
(?
int
$id =
null
):
Room
92
{
93
$this->
id
= $id;
94
95
return
$this;
96
}
97
103
public
function
setLocationId
(?
int
$locationId =
null
):
Room
104
{
105
$this->locationId = $locationId;
106
107
return
$this;
108
109
}
110
116
public
function
setCapacity
(?
int
$capacity =
null
):
Room
117
{
118
$this->capacity = $capacity;
119
120
return
$this;
121
}
122
128
public
function
setNecessity
(?
string
$necessity =
'N'
):
Room
129
{
130
$this->necessity = ($necessity ===
'Y'
) ?
'Y'
:
'N'
;
131
132
return
$this;
133
}
134
140
public
function
setName
(?
string
$name =
''
):
Room
141
{
142
$this->name =
Manager::checkRoomName
($name);
143
144
return
$this;
145
}
146
152
public
function
setColor
(?
string
$color =
''
):
Room
153
{
154
$this->
color
= \CCalendar::Color($color);
155
156
return
$this;
157
}
158
164
public
function
setOwnerId
(?
int
$ownerId =
null
):
Room
165
{
166
$this->ownerId = $ownerId;
167
168
return
$this;
169
}
170
174
public
function
setCreatedBy
():
Room
175
{
176
$this->createdBy = \CCalendar::GetCurUserId();
177
178
return
$this;
179
}
180
186
public
function
setAccess
(?
array
$access = []):
Room
187
{
188
$this->access = $access;
189
190
return
$this;
191
}
192
198
public
function
setCategoryId
(?
int
$categoryId =
null
):
Room
199
{
200
$this->categoryId = $categoryId ?:
null
;
201
202
return
$this;
203
}
204
210
private
function
addError(
$error
)
211
{
212
$this->error =
$error
;
213
}
214
218
public
function
getId
(): ?int
219
{
220
return
$this->id;
221
}
222
226
public
function
getLocationId
(): ?int
227
{
228
return
$this->locationId;
229
}
230
234
public
function
getCapacity
(): ?int
235
{
236
return
$this->capacity;
237
}
238
242
public
function
getNecessity
(): ?string
243
{
244
return
$this->necessity;
245
}
246
250
public
function
getName
(): ?string
251
{
252
return
$this->name
;
253
}
254
258
public
function
getType
(): ?string
259
{
260
return
$this->type
;
261
}
262
266
public
function
getColor
(): ?string
267
{
268
return
$this->color;
269
}
270
274
public
function
getOwnerId
(): ?int
275
{
276
return
$this->ownerId;
277
}
278
282
public
function
getCreatedBy
(): ?int
283
{
284
return
$this->createdBy;
285
}
286
290
public
function
getAccess
(): ?
array
291
{
292
return
$this->access
;
293
}
294
298
public
function
getCategoryId
(): ?int
299
{
300
return
$this->categoryId;
301
}
302
306
public
function
getError
(): ?
Error
307
{
308
return
$this->error
;
309
}
310
315
public
function
create
():
Room
316
{
317
$section = SectionTable::add([
318
'CAL_TYPE'
=> $this->type,
319
'NAME'
=> Emoji::encode($this->name),
320
'COLOR'
=> $this->
color
,
321
'OWNER_ID'
=> $this->ownerId,
322
'SORT'
=> 100,
323
'CREATED_BY'
=> $this->createdBy,
324
'DATE_CREATE'
=>
new
DateTime
(),
325
'TIMESTAMP_X'
=>
new
DateTime
(),
326
'ACTIVE'
=>
'Y'
,
327
]);
328
if
(!$section->isSuccess())
329
{
330
$this->addError(
new
Error
(Loc::getMessage(
'EC_ROOM_SAVE_ERROR'
)));
331
332
return
$this;
333
}
334
$this->
setId
($section->getId());
335
336
$location
= LocationTable::add(
337
[
338
'SECTION_ID'
=> $this->
id
,
339
'NECESSITY'
=> $this->necessity,
340
'CAPACITY'
=> $this->capacity,
341
'CATEGORY_ID'
=> $this->categoryId,
342
]
343
);
344
if
(!
$location
->isSuccess())
345
{
346
SectionTable::delete($this->
id
);
347
$this->addError(
new
Error
(Loc::getMessage(
'EC_ROOM_SAVE_ERROR'
)));
348
349
return
$this;
350
}
351
352
return
$this;
353
}
354
359
public
function
update
():
Room
360
{
361
$section = SectionTable::update(
362
$this->
id
,
363
[
364
'NAME'
=> Emoji::encode($this->name),
365
'COLOR'
=> $this->
color
,
366
'TIMESTAMP_X'
=>
new
DateTime
(),
367
]
368
);
369
if
(!$section->isSuccess())
370
{
371
$this->addError(
new
Error
(Loc::getMessage(
'EC_ROOM_SAVE_ERROR'
)));
372
373
return
$this;
374
}
375
$this->
setId
($section->getId());
376
377
$location
= LocationTable::update(
378
$this->locationId,
379
[
380
'NECESSITY'
=> $this->necessity,
381
'CAPACITY'
=> $this->capacity,
382
'CATEGORY_ID'
=> $this->categoryId,
383
]
384
);
385
if
(!
$location
->isSuccess())
386
{
387
$this->addError(
new
Error
(Loc::getMessage(
'EC_ROOM_SAVE_ERROR'
)));
388
389
return
$this;
390
}
391
392
return
$this;
393
}
394
399
public
function
delete
():
Room
400
{
401
$section = SectionTable::delete($this->
id
);
402
if
(!$section->isSuccess())
403
{
404
$this->addError(
new
Error
(Loc::getMessage(
'EC_ROOM_DELETE_ERROR'
)));
405
406
return
$this;
407
}
408
409
$location
= LocationTable::delete($this->locationId);
410
if
(!
$location
->isSuccess())
411
{
412
$this->addError(
new
Error
(Loc::getMessage(
'EC_ROOM_DELETE_ERROR'
)));
413
414
return
$this;
415
}
416
417
return
$this;
418
}
419
}
$type
$type
Определения
options.php:106
Bitrix\Calendar\Rooms\Manager\checkRoomName
static checkRoomName(?string $name)
Определения
manager.php:645
Bitrix\Calendar\Rooms\Room
Определения
room.php:15
Bitrix\Calendar\Rooms\Room\createInstanceFromParams
static createInstanceFromParams($params)
Определения
room.php:48
Bitrix\Calendar\Rooms\Room\getAccess
getAccess()
Определения
room.php:290
Bitrix\Calendar\Rooms\Room\setColor
setColor(?string $color='')
Определения
room.php:152
Bitrix\Calendar\Rooms\Room\getId
getId()
Определения
room.php:218
Bitrix\Calendar\Rooms\Room\setLocationId
setLocationId(?int $locationId=null)
Определения
room.php:103
Bitrix\Calendar\Rooms\Room\getError
getError()
Определения
room.php:306
Bitrix\Calendar\Rooms\Room\getCapacity
getCapacity()
Определения
room.php:234
Bitrix\Calendar\Rooms\Room\getName
getName()
Определения
room.php:250
Bitrix\Calendar\Rooms\Room\create
create()
Определения
room.php:315
Bitrix\Calendar\Rooms\Room\setName
setName(?string $name='')
Определения
room.php:140
Bitrix\Calendar\Rooms\Room\getCreatedBy
getCreatedBy()
Определения
room.php:282
Bitrix\Calendar\Rooms\Room\getNecessity
getNecessity()
Определения
room.php:242
Bitrix\Calendar\Rooms\Room\setId
setId(?int $id=null)
Определения
room.php:91
Bitrix\Calendar\Rooms\Room\setAccess
setAccess(?array $access=[])
Определения
room.php:186
Bitrix\Calendar\Rooms\Room\setNecessity
setNecessity(?string $necessity='N')
Определения
room.php:128
Bitrix\Calendar\Rooms\Room\getType
getType()
Определения
room.php:258
Bitrix\Calendar\Rooms\Room\update
update()
Определения
room.php:359
Bitrix\Calendar\Rooms\Room\getLocationId
getLocationId()
Определения
room.php:226
Bitrix\Calendar\Rooms\Room\TYPE
const TYPE
Определения
room.php:16
Bitrix\Calendar\Rooms\Room\setOwnerId
setOwnerId(?int $ownerId=null)
Определения
room.php:164
Bitrix\Calendar\Rooms\Room\setCategoryId
setCategoryId(?int $categoryId=null)
Определения
room.php:198
Bitrix\Calendar\Rooms\Room\getColor
getColor()
Определения
room.php:266
Bitrix\Calendar\Rooms\Room\setCapacity
setCapacity(?int $capacity=null)
Определения
room.php:116
Bitrix\Calendar\Rooms\Room\getOwnerId
getOwnerId()
Определения
room.php:274
Bitrix\Calendar\Rooms\Room\createInstance
createInstance()
Определения
room.php:81
Bitrix\Calendar\Rooms\Room\setCreatedBy
setCreatedBy()
Определения
room.php:174
Bitrix\Calendar\Rooms\Room\getCategoryId
getCategoryId()
Определения
room.php:298
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Type\DateTime
Определения
datetime.php:9
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
color
background color
Определения
file_new.php:745
$access
if(!is_array($deviceNotifyCodes)) $access
Определения
options.php:174
$name
$name
Определения
menu_edit.php:35
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$location
$location
Определения
options.php:2729
$error
$error
Определения
subscription_card_product.php:20
bitrix
modules
calendar
lib
rooms
room.php
Создано системой
1.14.0