ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBookingReservation Class Reference

a booking reservation More...

+ Collaboration diagram for ilBookingReservation:

Public Member Functions

 __construct ($a_id=null)
 Constructor. More...
 
 getId ()
 Get id. More...
 
 setObjectId ($a_object_id)
 Set object id. More...
 
 getObjectId ()
 Get object id. More...
 
 setUserId ($a_user_id)
 Set booking user id. More...
 
 getUserId ()
 Get booking user id. More...
 
 setAssignerId ($a_assigner_id)
 Set assigner user id. More...
 
 getAssignerId ()
 Get assigner user id. More...
 
 setFrom ($a_from)
 Set booking from date. More...
 
 getFrom ()
 Get booking from date. More...
 
 setTo ($a_to)
 Set booking to date. More...
 
 getTo ()
 Get booking to date. More...
 
 setStatus ($a_status)
 Set booking status. More...
 
 getStatus ()
 Get booking status. More...
 
 setGroupId ($a_group_id)
 Set group id. More...
 
 getGroupId ()
 Get group id. More...
 
 setContextObjId ($a_val)
 Set context object id. More...
 
 getContextObjId ()
 Get context object id. More...
 
 save ()
 Create new entry in db. More...
 
 update ()
 Update entry in db. More...
 
 delete ()
 Delete single entry. More...
 
 getCalendarEntry ()
 

Static Public Member Functions

static isValidStatus ($a_status)
 Check if given status is valid. More...
 
static getAvailableObject (array $a_ids, $a_from, $a_to, $a_return_single=true, $a_return_counter=false)
 Check if any of given objects are bookable. More...
 
static isObjectAvailableInPeriod ($a_obj_id, ilBookingSchedule $a_schedule, $a_from, $a_to)
 
static isBookingPoolLimitReachedByUser (int $a_user_id, int $a_pool_id)
 
static getMembersWithoutReservation (int $a_object_id)
 
static isObjectAvailableNoSchedule ($a_obj_id)
 
static numAvailableFromObjectNoSchedule ($a_obj_id)
 
static getNumAvailablesNoSchedule ($a_obj_id)
 
static getCurrentOrUpcomingReservation ($a_object_id)
 Get details about object reservation. More...
 
static getObjectReservationForUser ($a_object_id, $a_user_id, $a_multi=false)
 
static getList ($a_object_ids, $a_limit=10, $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, $a_status)
 Batch update reservation status. More...
 
static getCancelDetails ($a_obj_id, $a_user_id, $a_from, $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 ()
 Get dataset from db. More...
 

Protected Attributes

 $db
 
 $id
 
 $object_id
 
 $user_id
 
 $from
 
 $to
 
 $status
 
 $group_id
 
 $assigner_id
 
 $context_obj_id = 0
 
 $repo
 

Detailed Description

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilBookingReservation::__construct (   $a_id = null)

Constructor.

if id is given will read dataset from db

Parameters
int$a_id

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

49 {
50 global $DIC;
51
52 $this->db = $DIC->database();
53 $this->id = (int) $a_id;
54
56 $this->repo = $f->getRepo();
57
58 $this->read();
59 }
global $DIC
Definition: goto.php:24

References $DIC, Vendor\Package\$f, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ changeStatus()

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

Batch update reservation status.

Parameters
array$a_ids
int$a_status
Returns
bool

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

662 {
663 global $DIC;
664
665 $ilDB = $DIC->database();
666
667 if (self::isValidStatus($a_status)) {
668 return $ilDB->manipulate('UPDATE booking_reservation' .
669 ' SET status = ' . $ilDB->quote($a_status, 'integer') .
670 ' WHERE ' . $ilDB->in('booking_reservation_id', $a_ids, '', 'integer'));
671 }
672 }
global $ilDB

References $DIC, and $ilDB.

Referenced by ilBookingReservationsGUI\changeStatusObject().

+ Here is the caller graph for this function:

◆ delete()

ilBookingReservation::delete ( )

Delete single entry.

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

303 {
304 $this->repo->delete($this->id);
305 }

◆ getAssignerId()

ilBookingReservation::getAssignerId ( )

Get assigner user id.

Returns
int

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

References $assigner_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getAvailableObject()

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

Check if any of given objects are bookable.

Parameters
array$a_ids
int$a_from
int$a_to
int$a_return_single
Returns
int

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

317 {
319
321 $repo = $f->getRepo();
322
323 $blocked = $counter = array();
324 foreach ($repo->getNumberOfReservations($a_ids, $a_from, $a_to) as $row) {
325 if ($row['cnt'] >= $nr_map[$row['object_id']]) {
326 $blocked[] = $row['object_id'];
327 } elseif ($a_return_counter) {
328 $counter[$row['object_id']] = (int) $nr_map[$row['object_id']] - (int) $row['cnt'];
329 }
330 }
331
332 // #17868 - validate against schedule availability
333 foreach ($a_ids as $obj_id) {
334 $bobj = new ilBookingObject($obj_id);
335 if ($bobj->getScheduleId()) {
336 $schedule = new ilBookingSchedule($bobj->getScheduleId());
337
338 $av_from = ($schedule->getAvailabilityFrom() && !$schedule->getAvailabilityFrom()->isNull())
339 ? $schedule->getAvailabilityFrom()->get(IL_CAL_UNIX)
340 : null;
341 $av_to = ($schedule->getAvailabilityTo() && !$schedule->getAvailabilityTo()->isNull())
342 ? $schedule->getAvailabilityTo()->get(IL_CAL_UNIX)
343 : null;
344
345 if (($av_from && $a_from < $av_from) ||
346 ($av_to && $a_to > $av_to)) {
347 $blocked[] = $obj_id;
348 unset($counter[$obj_id]);
349 }
350 }
351 }
352
353 $available = array_diff($a_ids, $blocked);
354 if (sizeof($available)) {
355 if ($a_return_counter) {
356 foreach ($a_ids as $id) {
357 if (!isset($counter[$id])) {
358 $counter[$id] = (int) $nr_map[$id];
359 }
360 }
361 return $counter;
362 } elseif ($a_return_single) {
363 return array_shift($available);
364 } else {
365 return $available;
366 }
367 }
368 }
const IL_CAL_UNIX
a bookable ressource
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items.
schedule for booking ressource

References Vendor\Package\$f, $id, $repo, ilBookingObject\getNrOfItemsForObjects(), and IL_CAL_UNIX.

Referenced by ilBookingProcessGUI\confirmedBooking(), and ilBookingProcessGUI\confirmedBookingNumbers().

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

◆ getCalendarEntry()

ilBookingReservation::getCalendarEntry ( )

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

675 {
677
678
679 $set = $ilDB->query("SELECT ce.cal_id FROM cal_entries ce" .
680 " JOIN cal_cat_assignments cca ON ce.cal_id = cca.cal_id" .
681 " JOIN cal_categories cc ON cca.cat_id = cc.cat_id" .
682 " JOIN booking_reservation br ON ce.context_id = br.booking_reservation_id" .
683 " WHERE cc.obj_id = " . $ilDB->quote($this->getUserId(), 'integer') .
684 " AND br.user_id = " . $ilDB->quote($this->getUserId(), 'integer') .
685 " AND cc.type = " . $ilDB->quote(ilCalendarCategory::TYPE_BOOK, 'integer') .
686 " AND ce.context_id = " . $ilDB->quote($this->getId(), 'integer'));
687 $row = $ilDB->fetchAssoc($set);
688 return $row["cal_id"];
689 }

References $db, $ilDB, and ilCalendarCategory\TYPE_BOOK.

◆ getCancelDetails()

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

Get reservation ids from aggregated id for cancellation.

Parameters
int$a_obj_id
int$a_user_id
int$a_from
int$a_to
Returns
array

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

701 {
702 global $DIC;
703
704 $ilDB = $DIC->database();
705
706 $res = array();
707
708 $sql = "SELECT booking_reservation_id" .
709 " FROM booking_reservation" .
710 " WHERE object_id = " . $ilDB->quote($a_obj_id, "integer") .
711 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
712 " AND date_from = " . $ilDB->quote($a_from, "integer") .
713 " AND date_to = " . $ilDB->quote($a_to, "integer") .
714 " AND (status IS NULL" .
715 " OR status <> " . $ilDB->quote(self::STATUS_CANCELLED, "integer") . ")";
716 $set = $ilDB->query($sql);
717 while ($row = $ilDB->fetchAssoc($set)) {
718 $res[] = $row["booking_reservation_id"];
719 }
720
721 return $res;
722 }
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, and $res.

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

+ Here is the caller graph for this function:

◆ getContextObjId()

ilBookingReservation::getContextObjId ( )

Get context object id.

Returns
int context object id (e.g. course id)

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

References $context_obj_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getCurrentOrUpcomingReservation()

static ilBookingReservation::getCurrentOrUpcomingReservation (   $a_object_id)
static

Get details about object reservation.

Parameters
int$a_object_id
Returns
array

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

524 {
525 global $DIC;
526
527 $ilDB = $DIC->database();
528
529 $now = $ilDB->quote(time(), 'integer');
530
531 $ilDB->setLimit(1);
532 $set = $ilDB->query('SELECT user_id, status, date_from, date_to' .
533 ' FROM booking_reservation' .
534 ' WHERE ((date_from <= ' . $now . ' AND date_to >= ' . $now . ')' .
535 ' OR date_from > ' . $now . ')' .
536 ' AND (status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') .
537 ' OR STATUS IS NULL) AND object_id = ' . $ilDB->quote($a_object_id, 'integer') .
538 ' ORDER BY date_from');
539 $row = $ilDB->fetchAssoc($set);
540 return $row;
541 }

References $DIC, and $ilDB.

◆ getFrom()

ilBookingReservation::getFrom ( )

Get booking from date.

Returns
int

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

References $from.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getGroupId()

ilBookingReservation::getGroupId ( )

Get group id.

Returns
int

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

References $group_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getId()

ilBookingReservation::getId ( )

Get id.

Returns
int

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

66 {
67 return $this->id;
68 }

References $id.

◆ getList()

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

List all reservations.

Parameters
array$a_object_ids
int$a_limit
int$a_offset
array$a_offset
Returns
array

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

575 {
576 global $DIC;
577
578 $ilDB = $DIC->database();
579
580 $sql = 'SELECT r.*,o.title' .
581 ' FROM booking_reservation r' .
582 ' JOIN booking_object o ON (o.booking_object_id = r.object_id)';
583
584 $count_sql = 'SELECT COUNT(*) AS counter' .
585 ' FROM booking_reservation r' .
586 ' JOIN booking_object o ON (o.booking_object_id = r.object_id)';
587
588 $where = array($ilDB->in('r.object_id', $a_object_ids, '', 'integer'));
589 if ($filter['status']) {
590 if ($filter['status'] > 0) {
591 $where[] = 'status = ' . $ilDB->quote($filter['status'], 'integer');
592 } else {
593 $where[] = '(status != ' . $ilDB->quote(-$filter['status'], 'integer') .
594 ' OR status IS NULL)';
595 }
596 }
597 if ($filter['from']) {
598 $where[] = 'date_from >= ' . $ilDB->quote($filter['from'], 'integer');
599 }
600 if ($filter['to']) {
601 $where[] = 'date_to <= ' . $ilDB->quote($filter['to'], 'integer');
602 }
603 if (sizeof($where)) {
604 $sql .= ' WHERE ' . implode(' AND ', $where);
605 $count_sql .= ' WHERE ' . implode(' AND ', $where);
606 }
607
608 $set = $ilDB->query($count_sql);
609 $row = $ilDB->fetchAssoc($set);
610 $counter = $row['counter'];
611
612 $sql .= ' ORDER BY date_from DESC, booking_reservation_id DESC';
613
614 $ilDB->setLimit($a_limit, $a_offset);
615 $set = $ilDB->query($sql);
616 $res = array();
617 while ($row = $ilDB->fetchAssoc($set)) {
618 $res[] = $row;
619 }
620
621 return array('data' => $res, 'counter' => $counter);
622 }

References $DIC, $ilDB, and $res.

Referenced by ilBookingPrefBasedBookGatewayRepository\getBookings(), and ilBookingObjectsTableGUI\getItems().

+ Here is the caller graph for this function:

◆ getMembersWithoutReservation()

static ilBookingReservation::getMembersWithoutReservation ( int  $a_object_id)
static

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

461 : array
462 {
463 global $DIC;
464 $ilDB = $DIC->database();
465
466 $pool_id = ilBookingObject::lookupPoolId($a_object_id);
467
468 $res = array();
469 $query = 'SELECT DISTINCT bm.user_id user_id' .
470 ' FROM booking_member bm' .
471 ' WHERE bm.booking_pool_id = ' . $ilDB->quote($pool_id, 'integer') .
472 ' AND bm.user_id NOT IN (' .
473 'SELECT user_id' .
474 ' FROM booking_reservation' .
475 ' WHERE object_id = ' . $ilDB->quote($a_object_id, 'integer') .
476 ' AND (status IS NULL OR status <> ' . ilBookingReservation::STATUS_CANCELLED . '))';
477
478 $set = $ilDB->query($query);
479
480 while ($row = $ilDB->fetchAssoc($set)) {
481 $res[] = $row['user_id'];
482 }
483
484 return $res;
485 }
static lookupPoolId($object_id)
Lookup pool id.
$query

References $DIC, $ilDB, $query, $res, ilBookingObject\lookupPoolId(), and STATUS_CANCELLED.

Referenced by ilBookingParticipant\getAssignableParticipants().

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

◆ getNumAvailablesNoSchedule()

static ilBookingReservation::getNumAvailablesNoSchedule (   $a_obj_id)
static

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

499 {
500 global $DIC;
501
502 $ilDB = $DIC->database();
503
504 $all = ilBookingObject::getNrOfItemsForObjects(array($a_obj_id));
505 $all = (int) $all[$a_obj_id];
506
507 $set = $ilDB->query('SELECT COUNT(*) cnt' .
508 ' FROM booking_reservation r' .
509 ' JOIN booking_object o ON (o.booking_object_id = r.object_id)' .
510 ' WHERE (status IS NULL OR status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') . ')' .
511 ' AND r.object_id = ' . $ilDB->quote($a_obj_id, 'integer'));
512 $cnt = $ilDB->fetchAssoc($set);
513 $cnt = (int) $cnt['cnt'];
514
515 return (int) $all - $cnt; // #11864
516 }

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

Referenced by ilBookingPreferencesManager\calculateBookings(), isObjectAvailableNoSchedule(), and numAvailableFromObjectNoSchedule().

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

◆ getObjectId()

ilBookingReservation::getObjectId ( )

Get object id.

Returns
int

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

References $object_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getObjectReservationForUser()

static ilBookingReservation::getObjectReservationForUser (   $a_object_id,
  $a_user_id,
  $a_multi = false 
)
static

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

544 {
545 global $DIC;
546
547 $ilDB = $DIC->database();
548
549 $set = $ilDB->query('SELECT booking_reservation_id FROM booking_reservation' .
550 ' WHERE user_id = ' . $ilDB->quote($a_user_id, 'integer') .
551 ' AND object_id = ' . $ilDB->quote($a_object_id, 'integer') .
552 ' AND (status <> ' . $ilDB->quote(self::STATUS_CANCELLED, 'integer') .
553 ' OR STATUS IS NULL)');
554 if (!$a_multi) {
555 $row = $ilDB->fetchAssoc($set);
556 return $row['booking_reservation_id'];
557 } else {
558 $res = array();
559 while ($row = $ilDB->fetchAssoc($set)) {
560 $res[] = $row['booking_reservation_id'];
561 }
562 return $res;
563 }
564 }

References $DIC, $ilDB, and $res.

Referenced by ilBookingProcessGUI\confirmedBooking(), ilBookingProcessGUI\deliverPostFile(), ilBookingProcessGUI\displayPostInfo(), ilBookingAssignObjectsTableGUI\getItems(), ilBookingParticipant\isParticipantAssigned(), ilBookingReservationsGUI\rsvCancelUser(), and ilBookingPrefBasedBookGatewayRepository\storeBookings().

+ Here is the caller graph for this function:

◆ getStatus()

ilBookingReservation::getStatus ( )

Get booking status.

Returns
int

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

References $status.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getTo()

ilBookingReservation::getTo ( )

Get booking to date.

Returns
int

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

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
array$a_object_ids
Returns
array

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

632 {
633 global $DIC;
634
635 $ilDB = $DIC->database();
636
637 $res = array();
638
639 $sql = "SELECT ud.usr_id,ud.lastname,ud.firstname,ud.login" .
640 " FROM usr_data ud " .
641 " LEFT JOIN booking_reservation r ON (r.user_id = ud.usr_id)" .
642 " WHERE ud.usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID, "integer") .
643 " AND " . $ilDB->in("r.object_id", $a_object_ids, "", "integer") .
644 " ORDER BY ud.lastname,ud.firstname";
645 $set = $ilDB->query($sql);
646 while ($row = $ilDB->fetchAssoc($set)) {
647 $res[$row["usr_id"]] = $row["lastname"] . ", " . $row["firstname"] .
648 " (" . $row["login"] . ")";
649 }
650
651 return $res;
652 }
const ANONYMOUS_USER_ID
Definition: constants.php:25

References $DIC, $ilDB, $res, and ANONYMOUS_USER_ID.

Referenced by ilBookingReservationsTableGUI\initFilter().

+ Here is the caller graph for this function:

◆ getUserId()

ilBookingReservation::getUserId ( )

Get booking user id.

Returns
int

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

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 443 of file class.ilBookingReservation.php.

443 : int
444 {
445 global $DIC;
446 $ilDB = $DIC->database();
447
448 $booking_pool_objects = ilBookingObject::getObjectsForPool($a_pool_id);
449
450 $query = "SELECT count(user_id) total" .
451 " FROM booking_reservation" .
452 " WHERE " . $ilDB->in('object_id', $booking_pool_objects, false, 'integer') .
453 " AND user_id = " . $a_user_id .
454 " AND (status IS NULL OR status <> " . ilBookingReservation::STATUS_CANCELLED . ')';
455 $res = $ilDB->query($query);
456 $row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
457
458 return (int) $row['total'];
459 }
static getObjectsForPool(int $a_pool_id)
Get all booking pool object ids from an specific booking pool.

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_ASSOC, ilBookingObject\getObjectsForPool(), and STATUS_CANCELLED.

Referenced by ilBookingParticipant\getAssignableParticipants().

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

◆ isObjectAvailableInPeriod()

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

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

371 {
372 global $DIC;
373
374 $ilDB = $DIC->database();
375
376 if (!$a_from) {
377 $a_from = time();
378 }
379 if (!$a_to) {
380 $a_to = strtotime("+1year", $a_from);
381 }
382
383 if ($a_from > $a_to) {
384 return;
385 }
386
387 // all nr of reservations in period that are not over yet (to >= now)
389 $repo = $f->getRepo();
390 $res = $repo->getNumberOfReservations([$a_obj_id], $a_from, $a_to, true);
391 $booked_in_period = (int) $res[$a_obj_id]["cnt"];
392
393 $per_slot = ilBookingObject::getNrOfItemsForObjects(array($a_obj_id));
394 $per_slot = $per_slot[$a_obj_id];
395
396 // max available nr of items per (week)day
397 $schedule_slots = array();
398 $definition = $a_schedule->getDefinition();
399 $map = array_flip(array("su", "mo", "tu", "we", "th", "fr", "sa"));
400 foreach ($definition as $day => $day_slots) {
401 $schedule_slots[$map[$day]] = $day_slots;
402 }
403
404 $av_from = ($a_schedule->getAvailabilityFrom() && !$a_schedule->getAvailabilityFrom()->isNull())
405 ? $a_schedule->getAvailabilityFrom()->get(IL_CAL_UNIX)
406 : null;
407 $av_to = ($a_schedule->getAvailabilityTo() && !$a_schedule->getAvailabilityTo()->isNull())
408 ? strtotime($a_schedule->getAvailabilityTo()->get(IL_CAL_DATE) . " 23:59:59")
409 : null;
410
411 // sum up max available (to >= now) items in period per (week)day
412 $available_in_period = 0;
413 $loop = 0;
414 while ($a_from < $a_to &&
415 ++$loop < 1000) {
416 // any slots for current weekday?
417 $day_slots = $schedule_slots[date("w", $a_from)];
418 if ($day_slots) {
419 foreach ($day_slots as $slot) {
420 // convert slot to current datetime
421 $slot = explode("-", $slot);
422 $slot_from = strtotime(date("Y-m-d", $a_from) . " " . $slot[0]);
423 $slot_to = strtotime(date("Y-m-d", $a_from) . " " . $slot[1]);
424 // slot has to be in the future and part of schedule availability
425 if ($slot_to > time() &&
426 $slot_from >= $av_from &&
427 ($slot_to <= $av_to || is_null($av_to))) {
428 $available_in_period += $per_slot;
429 }
430 }
431 }
432
433 $a_from += (60 * 60 * 24);
434 }
435 if ($available_in_period - $booked_in_period > 0) {
436 return true;
437 }
438
439 return false;
440 }
const IL_CAL_DATE
getAvailabilityTo()
Get availability end.
getAvailabilityFrom()
Get availability start.
getDefinition()
Get definition.

References $DIC, Vendor\Package\$f, $ilDB, $repo, $res, ilBookingSchedule\getAvailabilityFrom(), ilBookingSchedule\getAvailabilityTo(), ilBookingSchedule\getDefinition(), ilBookingObject\getNrOfItemsForObjects(), IL_CAL_DATE, and IL_CAL_UNIX.

Referenced by ilBookingObjectsTableGUI\getItems().

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

◆ isObjectAvailableNoSchedule()

static ilBookingReservation::isObjectAvailableNoSchedule (   $a_obj_id)
static

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

488 {
489 $available = self::getNumAvailablesNoSchedule($a_obj_id);
490 return (bool) $available; // #11864
491 }
static getNumAvailablesNoSchedule($a_obj_id)

References getNumAvailablesNoSchedule().

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

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

◆ isValidStatus()

static ilBookingReservation::isValidStatus (   $a_status)
static

Check if given status is valid.

Parameters
int$a_status
Returns
bool

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

189 {
190 if (in_array($a_status, array(self::STATUS_IN_USE, self::STATUS_CANCELLED))) {
191 return true;
192 }
193 return false;
194 }

Referenced by setStatus().

+ Here is the caller graph for this function:

◆ numAvailableFromObjectNoSchedule()

static ilBookingReservation::numAvailableFromObjectNoSchedule (   $a_obj_id)
static

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

493 {
494 $available = self::getNumAvailablesNoSchedule($a_obj_id);
495 return (int) $available;
496 }

References getNumAvailablesNoSchedule().

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

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

◆ read()

ilBookingReservation::read ( )
protected

Get dataset from db.

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

239 {
240 if ($this->id) {
241 $row = $this->repo->getForId($this->id);
242 $this->setUserId($row['user_id']);
243 $this->setAssignerId($row['assigner_id']);
244 $this->setObjectId($row['object_id']);
245 $this->setFrom($row['date_from']);
246 $this->setTo($row['date_to']);
247 $this->setStatus($row['status']);
248 $this->setGroupId($row['group_id']);
249 $this->setContextObjId($row['context_obj_id']);
250 }
251 }
setTo($a_to)
Set booking to date.
setObjectId($a_object_id)
Set object id.
setAssignerId($a_assigner_id)
Set assigner user id.
setFrom($a_from)
Set booking from date.
setGroupId($a_group_id)
Set group id.
setContextObjId($a_val)
Set context object id.
setStatus($a_status)
Set booking status.
setUserId($a_user_id)
Set booking user id.

References setAssignerId(), setContextObjId(), setFrom(), setGroupId(), 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 ( )

Create new entry in db.

Returns
bool

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

258 {
259 if ($this->id) {
260 return false;
261 }
262
263 $this->id = $this->repo->create(
264 $this->getUserId(),
265 $this->getAssignerId(),
266 $this->getObjectId(),
267 $this->getContextObjId(),
268 $this->getFrom(),
269 $this->getTo(),
270 $this->getStatus(),
271 $this->getGroupId()
272 );
273 return ($this->id > 0);
274 }
getFrom()
Get booking from date.
getContextObjId()
Get context object id.
getUserId()
Get booking user id.
getAssignerId()
Get assigner user id.

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

+ Here is the call graph for this function:

◆ setAssignerId()

ilBookingReservation::setAssignerId (   $a_assigner_id)

Set assigner user id.

Parameters
$a_assigner_id

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

111 {
112 $this->assigner_id = (int) $a_assigner_id;
113 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContextObjId()

ilBookingReservation::setContextObjId (   $a_val)

Set context object id.

Parameters
int$a_valcontext object id (e.g. course id)

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

220 {
221 $this->context_obj_id = $a_val;
222 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setFrom()

ilBookingReservation::setFrom (   $a_from)

Set booking from date.

Parameters
int$a_from

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

129 {
130 $this->from = (int) $a_from;
131 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setGroupId()

ilBookingReservation::setGroupId (   $a_group_id)

Set group id.

Parameters
int$a_group_id

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

201 {
202 $this->group_id = $a_group_id;
203 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjectId()

ilBookingReservation::setObjectId (   $a_object_id)

Set object id.

Parameters
int$a_object_id

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

75 {
76 $this->object_id = $a_object_id;
77 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setStatus()

ilBookingReservation::setStatus (   $a_status)

Set booking status.

Parameters
int$a_status

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

165 {
166 if ($a_status === null) {
167 $this->status = null;
168 }
169 if ($this->isValidStatus((int) $a_status)) {
170 $this->status = (int) $a_status;
171 }
172 }
static isValidStatus($a_status)
Check if given status is valid.

References isValidStatus().

Referenced by read().

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

◆ setTo()

ilBookingReservation::setTo (   $a_to)

Set booking to date.

Parameters
int$a_to

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

147 {
148 $this->to = (int) $a_to;
149 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setUserId()

ilBookingReservation::setUserId (   $a_user_id)

Set booking user id.

Parameters
int$a_user_id

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

93 {
94 $this->user_id = (int) $a_user_id;
95 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilBookingReservation::update ( )

Update entry in db.

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

280 {
281 if (!$this->id) {
282 return false;
283 }
284
285 $this->repo->update(
286 $this->id,
287 $this->getUserId(),
288 $this->getAssignerId(),
289 $this->getObjectId(),
290 $this->getContextObjId(),
291 $this->getFrom(),
292 $this->getTo(),
293 $this->getStatus(),
294 $this->getGroupId()
295 );
296 return true;
297 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $assigner_id

ilBookingReservation::$assigner_id
protected

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

Referenced by getAssignerId().

◆ $context_obj_id

ilBookingReservation::$context_obj_id = 0
protected

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

Referenced by getContextObjId().

◆ $db

ilBookingReservation::$db
protected

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

Referenced by getCalendarEntry().

◆ $from

ilBookingReservation::$from
protected

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

Referenced by getFrom().

◆ $group_id

ilBookingReservation::$group_id
protected

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

Referenced by getGroupId().

◆ $id

ilBookingReservation::$id
protected

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

Referenced by getAvailableObject(), and getId().

◆ $object_id

ilBookingReservation::$object_id
protected

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

Referenced by getObjectId().

◆ $repo

ilBookingReservation::$repo
protected

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

Referenced by getAvailableObject(), and isObjectAvailableInPeriod().

◆ $status

ilBookingReservation::$status
protected

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

Referenced by getStatus().

◆ $to

ilBookingReservation::$to
protected

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

Referenced by getTo().

◆ $user_id

ilBookingReservation::$user_id
protected

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

Referenced by getUserId().

◆ STATUS_CANCELLED

◆ STATUS_IN_USE


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