68 $this->category->create();
70 if($this->category->getError())
72 $this->addError($this->category->getError());
75 $createdCategoryId = $this->category->getId();
76 $rooms = $this->category->getRooms();
77 if(!empty($rooms) && $createdCategoryId)
79 foreach ($rooms as &$room)
85 $roomsIds = implode(
',', $rooms);
89 SET CATEGORY_ID = $createdCategoryId
90 WHERE SECTION_ID IN ($roomsIds)
92 $result = $DB->Query($sqlStr,
true);
95 $this->category->delete();
96 $this->addError(
new Error(
'An error occurred while saving the category'));
115 $this->category->update();
117 if ($this->category->getError())
119 $this->addError($this->category->getError());
124 $categoryId = $this->category->getId();
125 $rooms = $this->category->getRooms();
129 if(isset($rooms[
'toAddCategory']))
131 foreach ($rooms[
'toAddCategory'] as &$toAddId)
133 $toAddId = (int)$toAddId;
135 $toAddIds = implode(
',', $rooms[
'toAddCategory']);
138 SET CATEGORY_ID = $categoryId
139 WHERE SECTION_ID IN ($toAddIds)
141 $result = $DB->Query($sqlStr,
true);
144 if($result && isset($rooms[
'toRemoveCategory']))
146 foreach ($rooms[
'toRemoveCategory'] as &$toRemoveId)
148 $toRemoveId = (int)$toRemoveId;
150 $toRemoveIds = implode(
',', $rooms[
'toRemoveCategory']);
153 SET CATEGORY_ID = null
154 WHERE SECTION_ID IN ($toRemoveIds)
156 $result = $DB->Query($sqlStr,
true);
161 $this->addError(
new Error(
'An error occurred while saving the category'));