26 protected \ILIAS\BookingManager\InternalRepoService
$repo;
28 protected int $id = 0;
43 $this->db = $DIC->database();
44 $this->
id = (
int) $a_id;
46 $this->repo = $DIC->bookingManager()->internal()->repo();
47 $this->objects_manager = $DIC->bookingManager()->internal()->domain()->objects($this->
getPoolId());
55 public function setTitle(
string $a_title): void
57 $this->title = $a_title;
67 $this->description = $a_value;
77 $this->pool_id = $a_pool_id;
87 $this->schedule_id = $a_schedule_id;
97 $this->nr_of_items = $a_value;
105 public function setFile(
string $a_value): void
107 $this->info_file = $a_value;
117 if ($this->
id && $this->info_file) {
118 return $this->objects_manager->getObjectInfoPath($this->
id);
125 $this->post_text = $a_value;
135 $this->post_file = $a_value;
145 if ($this->
id && $this->post_file) {
146 return $this->objects_manager->getBookingInfoPath($this->
id);
155 $this->objects_manager->deleteObjectInfo($this->
id);
156 $this->objects_manager->deleteBookingInfo($this->
id);
166 protected function read(): void
171 $set =
$ilDB->query(
'SELECT *' .
172 ' FROM booking_object' .
173 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
174 $row =
$ilDB->fetchAssoc($set);
175 $this->
setTitle((
string) $row[
'title']);
180 $this->
setFile((
string) $row[
'info_file']);
192 'title' => array(
'text', $this->
getTitle()),
196 'info_file' => array(
'text', $this->
getFile()),
197 'post_text' => array(
'text', $this->
getPostText()),
210 $this->
id =
$ilDB->nextId(
'booking_object');
213 $fields[
'booking_object_id'] = array(
'integer', $this->
id);
214 $fields[
'pool_id'] = array(
'integer', $this->
getPoolId());
216 return $ilDB->insert(
'booking_object', $fields);
229 return $ilDB->update(
232 array(
'booking_object_id' => array(
'integer', $this->
id))
241 ?
string $a_title =
null 245 $ilDB = $DIC->database();
248 ' FROM booking_object' .
249 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
252 $sql .=
' AND (' .
$ilDB->like(
'title',
'text',
'%' . $a_title .
'%') .
253 ' OR ' .
$ilDB->like(
'description',
'text',
'%' . $a_title .
'%') .
')';
256 $sql .=
' ORDER BY title';
258 $set =
$ilDB->query($sql);
260 while ($row =
$ilDB->fetchAssoc($set)) {
274 $ilDB = $DIC->database();
276 $sql =
'SELECT count(*) as count' .
277 ' FROM booking_object' .
278 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
279 $set =
$ilDB->query($sql);
280 $rec =
$ilDB->fetchAssoc($set);
282 return (
int) $rec[
"count"];
292 $ilDB = $DIC->database();
294 $set =
$ilDB->query(
"SELECT booking_object_id" .
295 " FROM booking_object" .
296 " WHERE pool_id = " .
$ilDB->quote($a_pool_id,
'integer'));
299 while ($row =
$ilDB->fetchAssoc($set)) {
300 $objects[] = (
int) $row[
'booking_object_id'];
310 public function delete():
int 317 return $ilDB->manipulate(
'DELETE FROM booking_object' .
318 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
325 $reservation_db = $this->repo->reservation();
326 $reservation_ids = $reservation_db->getReservationIdsByBookingObjectId($object_id);
328 foreach ($reservation_ids as $reservation_id) {
331 $reservation_db->delete($reservation_id);
346 $ilDB = $DIC->database();
350 $set =
$ilDB->query(
"SELECT booking_object_id,nr_items" .
351 " FROM booking_object" .
352 " WHERE " .
$ilDB->in(
"booking_object_id", $a_obj_ids,
"",
"integer"));
353 while ($row =
$ilDB->fetchAssoc($set)) {
354 $map[(
int) $row[
"booking_object_id"]] = (
int) $row[
"nr_items"];
362 ?array $a_schedule_map =
null 364 $new_obj =
new self();
365 $new_obj->setPoolId($a_pool_id);
366 $new_obj->setTitle($this->
getTitle());
369 $new_obj->setFile($this->
getFile());
373 if ($a_schedule_map) {
376 $new_obj->setScheduleId($a_schedule_map[$schedule_id] ??
null);
382 $this->objects_manager->cloneTo($this->
getId(), $new_obj->getId());
389 $db = $DIC->database();
391 "SELECT pool_id FROM booking_object " .
392 " WHERE booking_object_id = %s ",
397 return (
int) $rec[
"pool_id"];
404 $db = $DIC->database();
406 "SELECT title FROM booking_object " .
407 " WHERE booking_object_id = %s ",
412 return $rec[
"title"];
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setPostText(string $a_value)
fetchAssoc(ilDBStatement $statement)
ILIAS BookingManager Objects ObjectsManager $objects_manager
static getNumberOfObjectsForPool(int $a_pool_id)
Get number of booking objects for given booking pool id.
setNrOfItems(int $a_value)
ILIAS BookingManager InternalRepoService $repo
setDescription(string $a_value)
static getObjectsForPool(int $a_pool_id)
Get all booking pool object ids from an specific booking pool.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items for a set of object ids.
__construct(?int $a_id=null)
setScheduleId(?int $a_schedule_id)
deleteReservationsAndCalEntries(int $object_id)
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
setPostFile(string $a_value)
queryF(string $query, array $types, array $values)
static lookupTitle(int $object_id)
doClone(int $a_pool_id, ?array $a_schedule_map=null)
read()
Init file system storage.
setTitle(string $a_title)
static lookupPoolId(int $object_id)
setPoolId(int $a_pool_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...