26 protected \ILIAS\BookingManager\InternalRepoService
$repo;
28 protected int $id = 0;
45 $this->db =
$DIC->database();
46 $this->
id = (
int) $a_id;
48 $this->repo =
$DIC->bookingManager()->internal()->repo();
49 $this->objects_manager =
$DIC->bookingManager()->internal()->domain()->objects($this->
getPoolId());
57 public function setTitle(
string $a_title): void
59 $this->title = $a_title;
69 $this->description = $a_value;
79 $this->pool_id = $a_pool_id;
89 $this->schedule_id = $a_schedule_id;
99 $this->nr_of_items = $a_value;
107 public function setFile(
string $a_value): void
109 $this->info_file = $a_value;
119 if ($this->
id && $this->info_file) {
120 return $this->objects_manager->getObjectInfoPath($this->
id);
127 $this->post_text = $a_value;
137 $this->post_file = $a_value;
147 if ($this->
id && $this->post_file) {
148 return $this->objects_manager->getBookingInfoPath($this->
id);
157 $this->objects_manager->deleteObjectInfo($this->
id);
158 $this->objects_manager->deleteBookingInfo($this->
id);
164 protected function read(): void
170 $set = $this->db->queryF(
171 'SELECT * FROM booking_object WHERE booking_object_id = %s',
175 $row = $this->db->fetchAssoc($set);
177 if ($row ===
null || $row === []) {
181 $this->
setTitle((
string) $row[
'title']);
186 $this->
setFile((
string) $row[
'info_file']);
209 if ($this->
id !== 0) {
213 $this->
id = $this->db->nextId(
'booking_object');
219 return $this->db->insert(
'booking_object', $fields);
224 if ($this->
id === 0) {
228 return $this->db->update(
240 ?
string $a_title =
null
247 ' FROM booking_object' .
248 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
251 $sql .=
' AND (' .
$ilDB->like(
'title',
'text',
'%' . $a_title .
'%') .
252 ' OR ' .
$ilDB->like(
'description',
'text',
'%' . $a_title .
'%') .
')';
255 $sql .=
' ORDER BY title';
257 $set =
$ilDB->query($sql);
259 while ($row =
$ilDB->fetchAssoc($set)) {
275 $sql =
'SELECT count(*) as count' .
276 ' FROM booking_object' .
277 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
278 $set =
$ilDB->query($sql);
279 $rec =
$ilDB->fetchAssoc($set);
281 return (
int) $rec[
"count"];
293 $set =
$ilDB->query(
"SELECT booking_object_id" .
294 " FROM booking_object" .
295 " WHERE pool_id = " .
$ilDB->quote($a_pool_id,
'integer'));
298 while ($row =
$ilDB->fetchAssoc($set)) {
299 $objects[] = (
int) $row[
'booking_object_id'];
309 public function delete():
int
314 $this->deleteFiles();
316 return $ilDB->manipulate(
'DELETE FROM booking_object' .
317 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
324 $reservation_db = $this->repo->reservation();
325 $reservation_ids = $reservation_db->getReservationIdsByBookingObjectId($object_id);
327 foreach ($reservation_ids as $reservation_id) {
330 $reservation_db->delete($reservation_id);
349 $set =
$ilDB->query(
"SELECT booking_object_id,nr_items" .
350 " FROM booking_object" .
351 " WHERE " .
$ilDB->in(
"booking_object_id", $a_obj_ids,
"",
"integer"));
352 while ($row =
$ilDB->fetchAssoc($set)) {
353 $map[(
int) $row[
"booking_object_id"]] = (
int) $row[
"nr_items"];
361 ?array $a_schedule_map =
null
363 $new_obj = new self();
364 $new_obj->setPoolId($a_pool_id);
365 $new_obj->setTitle($this->
getTitle());
366 $new_obj->setDescription($this->getDescription());
367 $new_obj->setNrOfItems($this->getNrOfItems());
368 $new_obj->setFile($this->getFile());
369 $new_obj->setPostText($this->getPostText());
370 $new_obj->setPostFile($this->getPostFile());
372 if ($a_schedule_map) {
373 $schedule_id = $this->getScheduleId();
375 $new_obj->setScheduleId($a_schedule_map[$schedule_id] ??
null);
381 $this->objects_manager->cloneTo($this->
getId(), $new_obj->getId());
388 $db =
$DIC->database();
390 "SELECT pool_id FROM booking_object " .
391 " WHERE booking_object_id = %s ",
396 return (
int) $rec[
"pool_id"];
403 $db =
$DIC->database();
405 "SELECT title FROM booking_object " .
406 " WHERE booking_object_id = %s ",
411 return $rec[
"title"];
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNumberOfObjectsForPool(int $a_pool_id)
Get number of booking objects for given booking pool id.
ILIAS BookingManager InternalRepoService $repo
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
setPostText(string $a_value)
doClone(int $a_pool_id, ?array $a_schedule_map=null)
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items for a set of object ids.
setPoolId(int $a_pool_id)
setDescription(string $a_value)
__construct(?int $a_id=null)
static lookupTitle(int $object_id)
static lookupPoolId(int $object_id)
setNrOfItems(int $a_value)
ILIAS BookingManager Objects ObjectsManager $objects_manager
deleteReservationsAndCalEntries(int $object_id)
setScheduleId(?int $a_schedule_id)
static getObjectsForPool(int $a_pool_id)
Get all booking pool object ids from an specific booking pool.
setPostFile(string $a_value)
setTitle(string $a_title)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Model for a calendar entry.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
foreach($_POST as $key=> $value) $res