3namespace Bitrix\Calendar\Rooms\Categories;
5use Bitrix\Calendar\Integration\Bitrix24Manager;
6use Bitrix\Calendar\Integration\Pull\PushCommand;
7use Bitrix\Calendar\Internals\LocationTable;
8use Bitrix\Calendar\Internals\RoomCategoryTable;
9use Bitrix\Calendar\UserSettings;
11use Bitrix\Main\Localization\Loc;
12use Bitrix\Main\Text\Emoji;
35 $this->category = $category;
49 return $this->category;
69 $this->category->create();
71 if($this->category->getError())
73 $this->addError($this->category->getError());
76 $createdCategoryId = $this->category->getId();
77 $rooms = $this->category->getRooms();
78 if(!empty($rooms) && $createdCategoryId)
80 foreach ($rooms as &$room)
86 $roomsIds = implode(
',', $rooms);
90 SET CATEGORY_ID = $createdCategoryId
91 WHERE SECTION_ID IN ($roomsIds)
96 $this->category->delete();
97 $this->addError(
new Error(
'An error occurred while saving the category'));
116 $this->category->update();
118 if ($this->category->getError())
120 $this->addError($this->category->getError());
125 $categoryId = $this->category->getId();
126 $rooms = $this->category->getRooms();
130 if(isset($rooms[
'toAddCategory']))
132 foreach ($rooms[
'toAddCategory'] as &$toAddId)
134 $toAddId = (int)$toAddId;
136 $toAddIds = implode(
',', $rooms[
'toAddCategory']);
139 SET CATEGORY_ID = $categoryId
140 WHERE SECTION_ID IN ($toAddIds)
145 if(
$result && isset($rooms[
'toRemoveCategory']))
147 foreach ($rooms[
'toRemoveCategory'] as &$toRemoveId)
149 $toRemoveId = (int)$toRemoveId;
151 $toRemoveIds = implode(
',', $rooms[
'toRemoveCategory']);
154 SET CATEGORY_ID = null
155 WHERE SECTION_ID IN ($toRemoveIds)
162 $this->addError(
new Error(
'An error occurred while saving the category'));
180 $this->category->delete();
182 if ($this->category->getError())
184 $this->addError($this->category->getError());
189 $categoryId = $this->category->getId();
193 SET CATEGORY_ID = null
194 WHERE CATEGORY_ID = $categoryId
210 $categories = RoomCategoryTable::query()
211 ->setSelect([
'ID',
'NAME'])
212 ->setOrder([
'ID' =>
'ASC'])
217 while ($category = $categories->fetch())
219 $category[
'NAME'] = Emoji::decode($category[
'NAME']);
254 \CCalendar::GetCurUserId(),
256 'ID' => $this->category->getId()
266 RoomCategoryTable::cleanCache();
setCategory(Category $category)
addPullEvent(PushCommand $event)
static checkCategoryName(?string $name)
static createInstance(Category $category)
static addPullEvent(PushCommand $command, int $userId, array $params=[])
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)