ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilBookingReservation Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilBookingReservation:

Public Member Functions

 __construct (?int $a_id=null)
 
 getId ()
 
 setObjectId (int $a_object_id)
 
 getObjectId ()
 
 setUserId (int $a_user_id)
 
 getUserId ()
 
 setMessage (string $message)
 
 getMessage ()
 
 setAssignerId (int $a_assigner_id)
 Set assigner user id. More...
 
 getAssignerId ()
 
 setFrom (int $a_from)
 Set booking from date. More...
 
 getFrom ()
 
 setTo (int $a_to)
 Set booking to date. More...
 
 getTo ()
 
 setStatus (?int $a_status)
 Set booking status. More...
 
 getStatus ()
 Get booking status. More...
 
 setGroupId (int $a_group_id)
 
 getGroupId ()
 
 setContextObjId (int $a_val)
 
 getContextObjId ()
 
 save ()
 
 update ()
 
 delete ()
 
 getCalendarEntry ()
 

Static Public Member Functions

static isValidStatus (int $a_status)
 
static getAvailableObject (array $a_ids, int $a_from, int $a_to, bool $a_return_single=true, bool $a_return_counter=false)
 Check if any of given objects are bookable. More...
 
static isObjectAvailableInPeriod (int $a_obj_id, ilBookingSchedule $a_schedule, ?int $a_from, ?int $a_to)
 
static isBookingPoolLimitReachedByUser (int $a_user_id, int $a_pool_id)
 
static getMembersWithoutReservation (int $a_object_id)
 
static isObjectAvailableNoSchedule (int $a_obj_id)
 
static numAvailableFromObjectNoSchedule (int $a_obj_id)
 
static getNumAvailablesNoSchedule (int $a_obj_id)
 
static getCurrentOrUpcomingReservation (int $a_object_id)
 Get details about object reservation. More...
 
static getObjectReservationForUser (int $a_object_id, int $a_user_id)
 
static getList (array $a_object_ids, int $a_limit=10, int $a_offset=0, array $filter=[])
 List all reservations. More...
 
static getUserFilter (array $a_object_ids)
 Get all users who have reservations for object(s) More...
 
static changeStatus (array $a_ids, int $a_status)
 Batch update reservation status. More...
 
static getCancelDetails (int $a_obj_id, int $a_user_id, int $a_from, int $a_to)
 Get reservation ids from aggregated id for cancellation. More...
 

Data Fields

const STATUS_IN_USE = 2
 
const STATUS_CANCELLED = 5
 

Protected Member Functions

 read ()
 

Protected Attributes

ilDBInterface $db
 
int $id = 0
 
int $object_id = 0
 
int $user_id = 0
 
int $from = 0
 
int $to = 0
 
int $status = 0
 
int $group_id = 0
 
int $assigner_id = 0
 
int $context_obj_id = 0
 
string $message = ""
 
ILIAS BookingManager Reservations ReservationDBRepository $repo
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning a booking reservation

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 23 of file class.ilBookingReservation.php.

Constructor & Destructor Documentation

◆ __construct()

ilBookingReservation::__construct ( ?int  $a_id = null)

Definition at line 41 of file class.ilBookingReservation.php.

43 {
44 global $DIC;
45
46 $this->db = $DIC->database();
47 $this->id = (int) $a_id;
48
49 $this->repo = $DIC->bookingManager()
50 ->internal()
51 ->repo()
52 ->reservation();
53 $this->read();
54 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\int(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ changeStatus()

static ilBookingReservation::changeStatus ( array  $a_ids,
int  $a_status 
)
static

Batch update reservation status.

Parameters
int[]$a_idsreservation ids
int$a_status
Returns
int number of changed entries

Definition at line 603 of file class.ilBookingReservation.php.

606 : int {
607 global $DIC;
608
609 $ilDB = $DIC->database();
610
611 if (self::isValidStatus($a_status)) {
612 return $ilDB->manipulate('UPDATE booking_reservation' .
613 ' SET status = ' . $ilDB->quote($a_status, 'integer') .
614 ' WHERE ' . $ilDB->in('booking_reservation_id', $a_ids, '', 'integer'));
615 }
616 return 0;
617 }

References $ilDB.

Referenced by ilBookingReservationsGUI\changeStatusObject().

+ Here is the caller graph for this function:

◆ delete()

ilBookingReservation::delete ( )

Definition at line 238 of file class.ilBookingReservation.php.

238 : void
239 {
240 $this->repo->delete($this->id);
241 }

◆ getAssignerId()

ilBookingReservation::getAssignerId ( )

Definition at line 99 of file class.ilBookingReservation.php.

99 : int
100 {
101 return $this->assigner_id;
102 }

References $assigner_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getAvailableObject()

static ilBookingReservation::getAvailableObject ( array  $a_ids,
int  $a_from,
int  $a_to,
bool  $a_return_single = true,
bool  $a_return_counter = false 
)
static

Check if any of given objects are bookable.

Definition at line 247 of file class.ilBookingReservation.php.

253 : array {
254 global $DIC;
255
257
258 $repo = $DIC->bookingManager()->internal()->repo()->reservation();
259
260 $blocked = $counter = array();
261 foreach ($repo->getNumberOfReservations($a_ids, $a_from, $a_to) as $row) {
262 if ($row['cnt'] >= $nr_map[$row['object_id']]) {
263 $blocked[] = $row['object_id'];
264 } elseif ($a_return_counter) {
265 $counter[$row['object_id']] = $nr_map[$row['object_id']] - (int) $row['cnt'];
266 }
267 }
268
269 // #17868 - validate against schedule availability
270 foreach ($a_ids as $obj_id) {
271 $bobj = new ilBookingObject($obj_id);
272 if ($bobj->getScheduleId()) {
273 $schedule = new ilBookingSchedule($bobj->getScheduleId());
274
275 $av_from = ($schedule->getAvailabilityFrom() && !$schedule->getAvailabilityFrom()->isNull())
276 ? $schedule->getAvailabilityFrom()->get(IL_CAL_UNIX)
277 : null;
278 $av_to = ($schedule->getAvailabilityTo() && !$schedule->getAvailabilityTo()->isNull())
279 ? $schedule->getAvailabilityTo()->get(IL_CAL_UNIX)
280 : null;
281
282 if (($av_from && $a_from < $av_from) ||
283 ($av_to && $a_to > $av_to)) {
284 $blocked[] = $obj_id;
285 unset($counter[$obj_id]);
286 }
287 }
288 }
289
290 $available = array_diff($a_ids, $blocked);
291 if (count($available)) {
292 if ($a_return_counter) {
293 foreach ($a_ids as $id) {
294 if (!isset($counter[$id])) {
295 $counter[$id] = $nr_map[$id];
296 }
297 }
298 return $counter;
299 }
300 if ($a_return_single) {
301 return array_shift($available);
302 }
303 return $available;
304 }
305 return [];
306 }
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items for a set of object ids.
ILIAS BookingManager Reservations ReservationDBRepository $repo
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$counter

Referenced by ILIAS\BookingManager\BookingProcess\BookingProcessManager\getRecurrenceMissingAvailability().

+ Here is the caller graph for this function:

◆ getCalendarEntry()

ilBookingReservation::getCalendarEntry ( )

Definition at line 620 of file class.ilBookingReservation.php.

620 : int
621 {
623
624 $set = $ilDB->query("SELECT ce.cal_id FROM cal_entries ce" .
625 " JOIN cal_cat_assignments cca ON ce.cal_id = cca.cal_id" .
626 " JOIN cal_categories cc ON cca.cat_id = cc.cat_id" .
627 " JOIN booking_reservation br ON ce.context_id = br.booking_reservation_id" .
628 " WHERE cc.obj_id = " . $ilDB->quote($this->getUserId(), 'integer') .
629 " AND br.user_id = " . $ilDB->quote($this->getUserId(), 'integer') .
630 " AND cc.type = " . $ilDB->quote(ilCalendarCategory::TYPE_BOOK, 'integer') .
631 " AND ce.context_id = " . $ilDB->quote($this->getId(), 'integer'));
632 $row = $ilDB->fetchAssoc($set);
633 return (int) ($row["cal_id"] ?? 0);
634 }

References $ilDB, and ilCalendarCategory\TYPE_BOOK.

◆ getCancelDetails()

static ilBookingReservation::getCancelDetails ( int  $a_obj_id,
int  $a_user_id,
int  $a_from,
int  $a_to 
)
static

Get reservation ids from aggregated id for cancellation.

Returns
int[]

Definition at line 640 of file class.ilBookingReservation.php.

645 : array {
646 global $DIC;
647
648 $ilDB = $DIC->database();
649
650 $res = array();
651
652 $sql = "SELECT booking_reservation_id" .
653 " FROM booking_reservation" .
654 " WHERE object_id = " . $ilDB->quote($a_obj_id, "integer") .
655 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
656 " AND date_from = " . $ilDB->quote($a_from, "integer") .
657 " AND date_to = " . $ilDB->quote($a_to, "integer") .
658 " AND (status IS NULL" .
659 " OR status <> " . $ilDB->quote(self::STATUS_CANCELLED, "integer") . ")";
660 $set = $ilDB->query($sql);
661 while ($row = $ilDB->fetchAssoc($set)) {
662 $res[] = (int) $row["booking_reservation_id"];
663 }
664
665 return $res;
666 }
$res
Definition: ltiservices.php:69

Referenced by ilBookingReservationsGUI\redirectMailToBooker(), ilBookingReservationsGUI\rsvConfirmCancel(), ilBookingReservationsGUI\rsvConfirmDelete(), and ilBookingReservationsGUI\rsvDelete().

+ Here is the caller graph for this function:

◆ getContextObjId()

ilBookingReservation::getContextObjId ( )
Returns
int context object id (e.g. course id)

Definition at line 177 of file class.ilBookingReservation.php.

177 : int
178 {
180 }

References $context_obj_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getCurrentOrUpcomingReservation()

static ilBookingReservation::getCurrentOrUpcomingReservation ( int  $a_object_id)
static

Get details about object reservation.

Definition at line 464 of file class.ilBookingReservation.php.

466 : array {
467 global $DIC;
468
469 $ilDB = $DIC->database();
470
471 $now = $ilDB->quote(time(), 'integer');
472
473 $ilDB->setLimit(1);
474 $set = $ilDB->query('SELECT user_id, status, date_from, date_to' .
475 ' FROM booking_reservation' .
476 ' WHERE ((date_from <= ' . $now . ' AND date_to >= ' . $now . ')' .
477 ' OR date_from > ' . $now . ')' .
478 ' AND (status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') .
479 ' OR STATUS IS NULL) AND object_id = ' . $ilDB->quote($a_object_id, 'integer') .
480 ' ORDER BY date_from');
481 return $ilDB->fetchAssoc($set);
482 }

◆ getFrom()

ilBookingReservation::getFrom ( )

Definition at line 112 of file class.ilBookingReservation.php.

112 : int
113 {
114 return $this->from;
115 }

References $from.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getGroupId()

ilBookingReservation::getGroupId ( )

Definition at line 161 of file class.ilBookingReservation.php.

161 : int
162 {
163 return $this->group_id;
164 }

References $group_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getId()

ilBookingReservation::getId ( )

Definition at line 56 of file class.ilBookingReservation.php.

56 : int
57 {
58 return $this->id;
59 }

References $id.

◆ getList()

static ilBookingReservation::getList ( array  $a_object_ids,
int  $a_limit = 10,
int  $a_offset = 0,
array  $filter = [] 
)
static

List all reservations.

Returns
array<string, array>

Definition at line 511 of file class.ilBookingReservation.php.

516 : array {
517 global $DIC;
518
519 $ilDB = $DIC->database();
520
521 $sql = 'SELECT r.*,o.title' .
522 ' FROM booking_reservation r' .
523 ' JOIN booking_object o ON (o.booking_object_id = r.object_id)';
524
525 $count_sql = 'SELECT COUNT(*) AS counter' .
526 ' FROM booking_reservation r' .
527 ' JOIN booking_object o ON (o.booking_object_id = r.object_id)';
528
529 $where = array($ilDB->in('r.object_id', $a_object_ids, '', 'integer'));
530 if (isset($filter['status'])) {
531 if ($filter['status'] > 0) {
532 $where[] = 'status = ' . $ilDB->quote($filter['status'], 'integer');
533 } else {
534 $where[] = '(status != ' . $ilDB->quote(-$filter['status'], 'integer') .
535 ' OR status IS NULL)';
536 }
537 }
538 if (isset($filter['from'])) {
539 $where[] = 'date_from >= ' . $ilDB->quote($filter['from'], 'integer');
540 }
541 if (isset($filter['to'])) {
542 $where[] = 'date_to <= ' . $ilDB->quote($filter['to'], 'integer');
543 }
544 if (count($where)) {
545 $sql .= ' WHERE ' . implode(' AND ', $where);
546 $count_sql .= ' WHERE ' . implode(' AND ', $where);
547 }
548
549 $set = $ilDB->query($count_sql);
550 $row = $ilDB->fetchAssoc($set);
551 $counter = $row['counter'];
552
553 $sql .= ' ORDER BY date_from DESC, booking_reservation_id DESC';
554
555 $ilDB->setLimit($a_limit, $a_offset);
556 $set = $ilDB->query($sql);
557 $res = array();
558 while ($row = $ilDB->fetchAssoc($set)) {
559 $res[] = $row;
560 }
561
562 return array('data' => $res, 'counter' => $counter);
563 }

Referenced by ilBookingObjectsTableGUI\getItems().

+ Here is the caller graph for this function:

◆ getMembersWithoutReservation()

static ilBookingReservation::getMembersWithoutReservation ( int  $a_object_id)
static
Returns
int[]

Definition at line 403 of file class.ilBookingReservation.php.

405 : array {
406 global $DIC;
407 $ilDB = $DIC->database();
408
409 $pool_id = ilBookingObject::lookupPoolId($a_object_id);
410
411 $res = array();
412 $query = 'SELECT DISTINCT bm.user_id user_id' .
413 ' FROM booking_member bm' .
414 ' WHERE bm.booking_pool_id = ' . $ilDB->quote($pool_id, 'integer') .
415 ' AND bm.user_id NOT IN (' .
416 'SELECT user_id' .
417 ' FROM booking_reservation' .
418 ' WHERE object_id = ' . $ilDB->quote($a_object_id, 'integer') .
419 ' AND (status IS NULL OR status <> ' . self::STATUS_CANCELLED . '))';
420
421 $set = $ilDB->query($query);
422
423 while ($row = $ilDB->fetchAssoc($set)) {
424 $res[] = (int) $row['user_id'];
425 }
426
427 return $res;
428 }
static lookupPoolId(int $object_id)

◆ getMessage()

ilBookingReservation::getMessage ( )

Definition at line 86 of file class.ilBookingReservation.php.

86 : string
87 {
88 return $this->message;
89 }

References $message.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getNumAvailablesNoSchedule()

static ilBookingReservation::getNumAvailablesNoSchedule ( int  $a_obj_id)
static

Definition at line 441 of file class.ilBookingReservation.php.

441 : int
442 {
443 global $DIC;
444
445 $ilDB = $DIC->database();
446
447 $all = ilBookingObject::getNrOfItemsForObjects(array($a_obj_id));
448 $all = $all[$a_obj_id];
449
450 $set = $ilDB->query('SELECT COUNT(*) cnt' .
451 ' FROM booking_reservation r' .
452 ' JOIN booking_object o ON (o.booking_object_id = r.object_id)' .
453 ' WHERE (status IS NULL OR status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') . ')' .
454 ' AND r.object_id = ' . $ilDB->quote($a_obj_id, 'integer'));
455 $cnt = $ilDB->fetchAssoc($set);
456 $cnt = (int) $cnt['cnt'];
457
458 return $all - $cnt; // #11864
459 }

References $DIC, $ilDB, ilBookingObject\getNrOfItemsForObjects(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getObjectId()

ilBookingReservation::getObjectId ( )

Definition at line 66 of file class.ilBookingReservation.php.

66 : int
67 {
68 return $this->object_id;
69 }

References $object_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getObjectReservationForUser()

static ilBookingReservation::getObjectReservationForUser ( int  $a_object_id,
int  $a_user_id 
)
static
Returns
int[] booking reservation ids

Definition at line 487 of file class.ilBookingReservation.php.

490 : ?array {
491 global $DIC;
492
493 $ilDB = $DIC->database();
494
495 $set = $ilDB->query('SELECT booking_reservation_id FROM booking_reservation' .
496 ' WHERE user_id = ' . $ilDB->quote($a_user_id, 'integer') .
497 ' AND object_id = ' . $ilDB->quote($a_object_id, 'integer') .
498 ' AND (status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') .
499 ' OR STATUS IS NULL)');
500 $res = array();
501 while ($row = $ilDB->fetchAssoc($set)) {
502 $res[] = (int) $row['booking_reservation_id'];
503 }
504 return $res;
505 }

Referenced by ilBookingProcessWithoutScheduleGUI\confirmedBooking(), ilBookingAssignObjectsTableGUI\getItems(), ilBookingReservationsGUI\rsvCancelUser(), and ilBookingPrefBasedBookGatewayRepository\storeBookings().

+ Here is the caller graph for this function:

◆ getStatus()

ilBookingReservation::getStatus ( )

Get booking status.

Definition at line 146 of file class.ilBookingReservation.php.

146 : ?int
147 {
148 return $this->status;
149 }

References $status.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getTo()

ilBookingReservation::getTo ( )

Definition at line 125 of file class.ilBookingReservation.php.

125 : int
126 {
127 return $this->to;
128 }

References $to.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getUserFilter()

static ilBookingReservation::getUserFilter ( array  $a_object_ids)
static

Get all users who have reservations for object(s)

Parameters
int[]$a_object_ids
Returns
array<int,string> user id => user name

Definition at line 572 of file class.ilBookingReservation.php.

574 : array {
575 global $DIC;
576
577 $ilDB = $DIC->database();
578
579 $res = array();
580
581 $sql = "SELECT ud.usr_id,ud.lastname,ud.firstname,ud.login" .
582 " FROM usr_data ud " .
583 " LEFT JOIN booking_reservation r ON (r.user_id = ud.usr_id)" .
584 " WHERE ud.usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID, "integer") .
585 " AND " . $ilDB->in("r.object_id", $a_object_ids, "", "integer") .
586 " ORDER BY ud.lastname,ud.firstname";
587 $set = $ilDB->query($sql);
588 while ($row = $ilDB->fetchAssoc($set)) {
589 $res[$row["usr_id"]] = $row["lastname"] . ", " . $row["firstname"] .
590 " (" . $row["login"] . ")";
591 }
592
593 return $res;
594 }
const ANONYMOUS_USER_ID
Definition: constants.php:27

◆ getUserId()

ilBookingReservation::getUserId ( )

Definition at line 76 of file class.ilBookingReservation.php.

76 : int
77 {
78 return $this->user_id;
79 }

References $user_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ isBookingPoolLimitReachedByUser()

static ilBookingReservation::isBookingPoolLimitReachedByUser ( int  $a_user_id,
int  $a_pool_id 
)
static

Definition at line 378 of file class.ilBookingReservation.php.

381 : int {
382 global $DIC;
383 $ilDB = $DIC->database();
384 $object_manager = $DIC->bookingManager()->internal()->domain()
385 ->objects($a_pool_id);
386
387 $booking_pool_objects = $object_manager->getObjectIds();
388
389 $query = "SELECT count(user_id) total" .
390 " FROM booking_reservation" .
391 " WHERE " . $ilDB->in('object_id', $booking_pool_objects, false, 'integer') .
392 " AND user_id = " . $a_user_id .
393 " AND (status IS NULL OR status <> " . self::STATUS_CANCELLED . ')';
394 $res = $ilDB->query($query);
395 $row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
396
397 return (int) $row['total'];
398 }

◆ isObjectAvailableInPeriod()

static ilBookingReservation::isObjectAvailableInPeriod ( int  $a_obj_id,
ilBookingSchedule  $a_schedule,
?int  $a_from,
?int  $a_to 
)
static

Definition at line 308 of file class.ilBookingReservation.php.

313 : bool {
314 global $DIC;
315
316 if (!$a_from) {
317 $a_from = time();
318 }
319 if (!$a_to) {
320 $a_to = strtotime("+1year", $a_from);
321 }
322
323 if ($a_from > $a_to) {
324 return false;
325 }
326
327 // all nr of reservations in period that are not over yet (to >= now)
328 $repo = $DIC->bookingManager()->internal()->repo()->reservation();
329 $res = $repo->getNumberOfReservations([$a_obj_id], $a_from, $a_to, true);
330 $booked_in_period = (int) ($res[$a_obj_id]["cnt"] ?? 0);
331
332 $per_slot = ilBookingObject::getNrOfItemsForObjects(array($a_obj_id));
333 $per_slot = $per_slot[$a_obj_id];
334
335 // max available nr of items per (week)day
336 $schedule_slots = array();
337 $definition = $a_schedule->getDefinition();
338 $map = array_flip(array("su", "mo", "tu", "we", "th", "fr", "sa"));
339 foreach ($definition as $day => $day_slots) {
340 $schedule_slots[$map[$day]] = $day_slots;
341 }
342
343 $av_from = ($a_schedule->getAvailabilityFrom() && !$a_schedule->getAvailabilityFrom()->isNull())
344 ? $a_schedule->getAvailabilityFrom()->get(IL_CAL_UNIX)
345 : null;
346 $av_to = ($a_schedule->getAvailabilityTo() && !$a_schedule->getAvailabilityTo()->isNull())
347 ? strtotime($a_schedule->getAvailabilityTo()->get(IL_CAL_DATE) . " 23:59:59")
348 : null;
349
350 // sum up max available (to >= now) items in period per (week)day
351 $available_in_period = 0;
352 $loop = 0;
353 while ($a_from < $a_to &&
354 ++$loop < 1000) {
355 // any slots for current weekday?
356 $day_slots = $schedule_slots[date("w", $a_from)] ?? false;
357 if ($day_slots) {
358 foreach ($day_slots as $slot) {
359 // convert slot to current datetime
360 $slot = explode("-", $slot);
361 $slot_from = strtotime(date("Y-m-d", $a_from) . " " . $slot[0]);
362 $slot_to = strtotime(date("Y-m-d", $a_from) . " " . $slot[1]);
363 // slot has to be in the future and part of schedule availability
364 if ($slot_from >= $av_from &&
365 ($slot_to <= $av_to || is_null($av_to)) &&
366 $slot_to > time()) {
367 $available_in_period += $per_slot;
368 }
369 }
370 }
371
372 $a_from += (60 * 60 * 24);
373 }
374 return $available_in_period - $booked_in_period > 0;
375 }
const IL_CAL_DATE

Referenced by ilBookingObjectsTableGUI\getItems().

+ Here is the caller graph for this function:

◆ isObjectAvailableNoSchedule()

static ilBookingReservation::isObjectAvailableNoSchedule ( int  $a_obj_id)
static

Definition at line 430 of file class.ilBookingReservation.php.

430 : bool
431 {
432 $available = self::getNumAvailablesNoSchedule($a_obj_id);
433 return (bool) $available; // #11864
434 }
static getNumAvailablesNoSchedule(int $a_obj_id)

Referenced by ilBookingProcessWithoutScheduleGUI\confirmedBooking(), and ilBookingPrefBasedBookGatewayRepository\storeBookings().

+ Here is the caller graph for this function:

◆ isValidStatus()

static ilBookingReservation::isValidStatus ( int  $a_status)
static

Definition at line 151 of file class.ilBookingReservation.php.

151 : bool
152 {
153 return in_array($a_status, array(self::STATUS_IN_USE, self::STATUS_CANCELLED));
154 }

◆ numAvailableFromObjectNoSchedule()

static ilBookingReservation::numAvailableFromObjectNoSchedule ( int  $a_obj_id)
static

Definition at line 436 of file class.ilBookingReservation.php.

436 : int
437 {
438 return self::getNumAvailablesNoSchedule($a_obj_id);
439 }

Referenced by ilBookingAssignParticipantsTableGUI\__construct(), ilBookingProcessWithoutScheduleGUI\bookMultipleParticipants(), and ilBookingAssignObjectsTableGUI\getItems().

+ Here is the caller graph for this function:

◆ read()

ilBookingReservation::read ( )
protected

Definition at line 182 of file class.ilBookingReservation.php.

182 : void
183 {
184 if ($this->id && $row = $this->repo->getForId($this->id)) {
185 $this->setUserId($row['user_id']);
186 $this->setAssignerId((int) $row['assigner_id']);
187 $this->setObjectId($row['object_id']);
188 $this->setFrom($row['date_from']);
189 $this->setTo($row['date_to']);
190 $this->setStatus($row['status']);
191 $this->setGroupId((int) $row['group_id']);
192 $this->setContextObjId((int) $row['context_obj_id']);
193 $this->setMessage($row['message']);
194 }
195 }
setAssignerId(int $a_assigner_id)
Set assigner user id.
setTo(int $a_to)
Set booking to date.
setStatus(?int $a_status)
Set booking status.
setFrom(int $a_from)
Set booking from date.

References setAssignerId(), setContextObjId(), setFrom(), setGroupId(), setMessage(), setObjectId(), setStatus(), setTo(), and setUserId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilBookingReservation::save ( )

Definition at line 197 of file class.ilBookingReservation.php.

197 : bool
198 {
199 if ($this->id) {
200 return false;
201 }
202
203 $this->id = $this->repo->create(
204 $this->getUserId(),
205 $this->getAssignerId(),
206 $this->getObjectId(),
207 $this->getContextObjId(),
208 $this->getFrom(),
209 $this->getTo(),
210 $this->getStatus(),
211 $this->getGroupId(),
212 $this->getMessage()
213 );
214 return ($this->id > 0);
215 }

References getAssignerId(), getContextObjId(), getFrom(), getGroupId(), getMessage(), getObjectId(), getStatus(), getTo(), and getUserId().

+ Here is the call graph for this function:

◆ setAssignerId()

ilBookingReservation::setAssignerId ( int  $a_assigner_id)

Set assigner user id.

Definition at line 94 of file class.ilBookingReservation.php.

94 : void
95 {
96 $this->assigner_id = $a_assigner_id;
97 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContextObjId()

ilBookingReservation::setContextObjId ( int  $a_val)
Parameters
int$a_valcontext object id (e.g. course id)

Definition at line 169 of file class.ilBookingReservation.php.

169 : void
170 {
171 $this->context_obj_id = $a_val;
172 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setFrom()

ilBookingReservation::setFrom ( int  $a_from)

Set booking from date.

Definition at line 107 of file class.ilBookingReservation.php.

107 : void
108 {
109 $this->from = $a_from;
110 }

References ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGroupId()

ilBookingReservation::setGroupId ( int  $a_group_id)

Definition at line 156 of file class.ilBookingReservation.php.

156 : void
157 {
158 $this->group_id = $a_group_id;
159 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMessage()

ilBookingReservation::setMessage ( string  $message)

Definition at line 81 of file class.ilBookingReservation.php.

81 : void
82 {
83 $this->message = $message;
84 }

References $message.

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjectId()

ilBookingReservation::setObjectId ( int  $a_object_id)

Definition at line 61 of file class.ilBookingReservation.php.

61 : void
62 {
63 $this->object_id = $a_object_id;
64 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setStatus()

ilBookingReservation::setStatus ( ?int  $a_status)

Set booking status.

Definition at line 133 of file class.ilBookingReservation.php.

133 : void
134 {
135 if ($a_status === null) {
136 $this->status = 0;
137 }
138 if (self::isValidStatus((int) $a_status)) {
139 $this->status = (int) $a_status;
140 }
141 }

References ILIAS\Repository\int().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTo()

ilBookingReservation::setTo ( int  $a_to)

Set booking to date.

Definition at line 120 of file class.ilBookingReservation.php.

120 : void
121 {
122 $this->to = $a_to;
123 }
to(\GdImage $image, ?int $quality=null)
Currently this is the only way to make a FileStream from a GD image resource.

References ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\to().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUserId()

ilBookingReservation::setUserId ( int  $a_user_id)

Definition at line 71 of file class.ilBookingReservation.php.

71 : void
72 {
73 $this->user_id = $a_user_id;
74 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilBookingReservation::update ( )

Definition at line 217 of file class.ilBookingReservation.php.

217 : bool
218 {
219 if (!$this->id) {
220 return false;
221 }
222
223 $this->repo->update(
224 $this->id,
225 $this->getUserId(),
226 $this->getAssignerId(),
227 $this->getObjectId(),
228 $this->getContextObjId(),
229 $this->getFrom(),
230 $this->getTo(),
231 $this->getStatus(),
232 $this->getGroupId(),
233 $this->getMessage()
234 );
235 return true;
236 }

References getAssignerId(), getContextObjId(), getFrom(), getGroupId(), getMessage(), getObjectId(), getStatus(), getTo(), and getUserId().

+ Here is the call graph for this function:

Field Documentation

◆ $assigner_id

int ilBookingReservation::$assigner_id = 0
protected

Definition at line 36 of file class.ilBookingReservation.php.

Referenced by getAssignerId().

◆ $context_obj_id

int ilBookingReservation::$context_obj_id = 0
protected

Definition at line 37 of file class.ilBookingReservation.php.

Referenced by getContextObjId().

◆ $db

ilDBInterface ilBookingReservation::$db
protected

Definition at line 28 of file class.ilBookingReservation.php.

◆ $from

int ilBookingReservation::$from = 0
protected

Definition at line 32 of file class.ilBookingReservation.php.

Referenced by getFrom().

◆ $group_id

int ilBookingReservation::$group_id = 0
protected

Definition at line 35 of file class.ilBookingReservation.php.

Referenced by getGroupId().

◆ $id

int ilBookingReservation::$id = 0
protected

Definition at line 29 of file class.ilBookingReservation.php.

Referenced by getId().

◆ $message

string ilBookingReservation::$message = ""
protected

Definition at line 38 of file class.ilBookingReservation.php.

Referenced by getMessage(), and setMessage().

◆ $object_id

int ilBookingReservation::$object_id = 0
protected

Definition at line 30 of file class.ilBookingReservation.php.

Referenced by getObjectId().

◆ $repo

ILIAS BookingManager Reservations ReservationDBRepository ilBookingReservation::$repo
protected

Definition at line 39 of file class.ilBookingReservation.php.

◆ $status

int ilBookingReservation::$status = 0
protected

Definition at line 34 of file class.ilBookingReservation.php.

Referenced by getStatus().

◆ $to

int ilBookingReservation::$to = 0
protected

Definition at line 33 of file class.ilBookingReservation.php.

Referenced by getTo().

◆ $user_id

int ilBookingReservation::$user_id = 0
protected

Definition at line 31 of file class.ilBookingReservation.php.

Referenced by getUserId().

◆ STATUS_CANCELLED

◆ STATUS_IN_USE

const ilBookingReservation::STATUS_IN_USE = 2

The documentation for this class was generated from the following file: