26     protected int $id = 0;
    43         $this->db = $DIC->database();
    44         $this->
id = (
int) $a_id;
    51         $this->title = $a_title;
    62         $this->pool_id = $a_pool_id;
    76         $this->raster = $a_raster;
    90         $this->rent_min = $a_min;
   104         $this->rent_max = $a_max;
   115         $this->auto_break = $a_break;
   128         $this->deadline = $a_deadline;
   142         $this->definition = $a_definition;
   153         $this->av_from = $a_date;
   164         $this->av_to = $a_date;
   172     protected function read(): void
   177             $set = 
$ilDB->query(
'SELECT title,raster,rent_min,rent_max,auto_break,' .
   178                 'deadline,av_from,av_to' .
   179                 ' FROM booking_schedule' .
   180                 ' WHERE booking_schedule_id = ' . 
$ilDB->quote($this->id, 
'integer'));
   181             $row = 
$ilDB->fetchAssoc($set);
   182             $this->
setTitle($row[
'title'] ?? 
"");
   186             if ($row[
'raster']) {
   194             $definition = array();
   195             $set = 
$ilDB->query(
'SELECT day_id,slot_id,times' .
   196                 ' FROM booking_schedule_slot' .
   197                 ' WHERE booking_schedule_id = ' . 
$ilDB->quote($this->id, 
'integer'));
   198             while ($row = 
$ilDB->fetchAssoc($set)) {
   199                 $definition[$row[
"day_id"]][$row[
"slot_id"]] = $row[
"times"];
   213         $this->
id = 
$ilDB->nextId(
'booking_schedule');
   222         $ilDB->manipulate(
'INSERT INTO booking_schedule' .
   223             ' (booking_schedule_id,title,pool_id,raster,rent_min,rent_max,auto_break,' .
   224             'deadline,av_from,av_to)' .
   225             ' VALUES (' . 
$ilDB->quote($this->id, 
'integer') . 
',' . 
$ilDB->quote($this->
getTitle(), 
'text') .
   229             ',' . 
$ilDB->quote($av_from, 
'integer') . 
',' . 
$ilDB->quote($av_to, 
'integer') . 
')');
   251         $ilDB->manipulate(
'UPDATE booking_schedule' .
   252             ' SET title = ' . 
$ilDB->quote($this->getTitle(), 
'text') .
   253             ', pool_id = ' . 
$ilDB->quote($this->getPoolId(), 
'integer') .
   254             ', raster = ' . 
$ilDB->quote($this->getRaster(), 
'integer') .
   255             ', rent_min = ' . 
$ilDB->quote($this->getMinRental(), 
'integer') .
   256             ', rent_max = ' . 
$ilDB->quote($this->getMaxRental(), 
'integer') .
   257             ', auto_break = ' . 
$ilDB->quote($this->getAutoBreak(), 
'integer') .
   258             ', deadline = ' . 
$ilDB->quote($this->getDeadline(), 
'integer') .
   259             ', av_from = ' . 
$ilDB->quote($av_from, 
'integer') .
   260             ', av_to = ' . 
$ilDB->quote($av_to, 
'integer') .
   261             ' WHERE booking_schedule_id = ' . 
$ilDB->quote($this->
id, 
'integer'));
   269         $new_obj = 
new self();
   270         $new_obj->setPoolId($a_pool_id);
   271         $new_obj->setTitle($this->
getTitle());
   280         return $new_obj->save();
   294         $ilDB->manipulate(
'DELETE FROM booking_schedule_slot' .
   295             ' WHERE booking_schedule_id = ' . 
$ilDB->quote($this->id, 
'integer'));
   299             foreach ($definition as $day_id => $slots) {
   300                 foreach ($slots as $slot_id => $times) {
   302                         "booking_schedule_id" => array(
'integer', $this->
id),
   303                         "day_id" => array(
'text', $day_id),
   304                         "slot_id" => array(
'integer', $slot_id),
   305                         "times" => array(
'text', $times)
   307                     $ilDB->insert(
'booking_schedule_slot', $fields);
   321         $ilDB = $DIC->database();
   323         $set = 
$ilDB->query(
"SELECT booking_schedule_id" .
   324             " FROM booking_schedule" .
   325             " WHERE pool_id = " . 
$ilDB->quote($a_pool_id, 
'integer'));
   326         return (
bool) 
$ilDB->numRows($set);
   332     public static function getList(
int $a_pool_id): array
   336         $ilDB = $DIC->database();
   338         $set = 
$ilDB->query(
'SELECT s.booking_schedule_id,s.title,' .
   339             'MAX(o.schedule_id) AS object_has_schedule' .
   340             ' FROM booking_schedule s' .
   341             ' LEFT JOIN booking_object o ON (s.booking_schedule_id = o.schedule_id)' .
   342             ' WHERE s.pool_id = ' . 
$ilDB->quote($a_pool_id, 
'integer') .
   343             ' GROUP BY s.booking_schedule_id,s.title' .
   344             ' ORDER BY s.title');
   346         while ($row = 
$ilDB->fetchAssoc($set)) {
   347             if (!$row[
'object_has_schedule']) {
   348                 $row[
'is_used'] = 
false;
   350                 $row[
'is_used'] = 
true;
   357     public function delete(): 
int   362             return $ilDB->manipulate(
'DELETE FROM booking_schedule' .
   363                 ' WHERE booking_schedule_id = ' . 
$ilDB->quote($this->id, 
'integer'));
   375         foreach ($def as $day => $times) {
   376             foreach ($times as $time) {
   377                 $slots[$time][] = $day;
   380         foreach ($slots as $time => $days) {
   381             $slots[$time] = array_unique($days);
   390         foreach ($a_def as $time => $days) {
   391             foreach ($days as $day) {
   392                 $slots[$day][] = $time;
 
setDeadline(int $a_deadline)
Set deadline. 
 
getDefinitionBySlots()
Return definition grouped by slots (not days) 
 
__construct(int $a_id=null)
 
setDefinition(array $a_definition)
Set definition. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static getList(int $a_pool_id)
Get list of booking objects for given pool. 
 
setMaxRental(int $a_max)
Set maximum rental time. 
 
static hasExistingSchedules(int $a_pool_id)
Check if given pool has any defined schedules. 
 
setDefinitionBySlots(array $a_def)
 
saveDefinition()
Save current definition (slots) 
 
setMinRental(int $a_min)
Set minimum rental time. 
 
setAvailabilityTo(?ilDateTime $a_date=null)
 
setAvailabilityFrom(?ilDateTime $a_date=null)
 
setRaster(int $a_raster)
Set booking raster (in minutes) 
 
setAutoBreak(int $a_break)
 
setTitle(string $a_title)
 
setPoolId(int $a_pool_id)