ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilBookingSchedule Class Reference

schedule for booking ressource More...

+ Collaboration diagram for ilBookingSchedule:

Public Member Functions

 __construct ($a_id=NULL)
 Constructor. More...
 
 setTitle ($a_title)
 Set object title. More...
 
 getTitle ()
 Get object title. More...
 
 setPoolId ($a_pool_id)
 Set booking pool id (aka parent obj ref id) More...
 
 getPoolId ()
 Get booking pool id. More...
 
 setRaster ($a_raster)
 Set booking raster (in minutes) More...
 
 getRaster ()
 Get booking raster. More...
 
 setMinRental ($a_min)
 Set minimum rental time. More...
 
 getMinRental ()
 Get minimum rental time. More...
 
 setMaxRental ($a_max)
 Set maximum rental time. More...
 
 getMaxRental ()
 Get maximum rental time. More...
 
 setAutoBreak ($a_break)
 Set break time. More...
 
 getAutoBreak ()
 Get break time. More...
 
 setDeadline ($a_deadline)
 Set deadline. More...
 
 getDeadline ()
 Get deadline. More...
 
 setDefinition ($a_definition)
 Set definition. More...
 
 getDefinition ()
 Get definition. More...
 
 setAvailabilityFrom (ilDateTime $a_date=null)
 Set availability start. More...
 
 getAvailabilityFrom ()
 Get availability start. More...
 
 setAvailabilityTo (ilDateTime $a_date=null)
 Set availability end. More...
 
 getAvailabilityTo ()
 Get availability end. More...
 
 save ()
 Create new entry in db. More...
 
 update ()
 Update entry in db. More...
 
 doClone ($a_pool_id)
 
 delete ()
 Delete single entry. More...
 
 getDefinitionBySlots ()
 Return definition grouped by slots (not days) More...
 
 setDefinitionBySlots (array $a_def)
 

Static Public Member Functions

static hasExistingSchedules ($a_pool_id)
 Check if given pool has any defined schedules. More...
 
static getList ($a_pool_id)
 Get list of booking objects for given pool. More...
 

Protected Member Functions

 read ()
 Get dataset from db. More...
 
 saveDefinition ()
 Save current definition. More...
 

Protected Attributes

 $id
 
 $title
 
 $pool_id
 
 $raster
 
 $rent_min
 
 $rent_max
 
 $auto_break
 
 $deadline
 
 $definition
 
 $av_from
 
 $av_to
 

Detailed Description

schedule for booking ressource

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.ilBookingSchedule.php.

Constructor & Destructor Documentation

◆ __construct()

ilBookingSchedule::__construct (   $a_id = NULL)

Constructor.

if id is given will read dataset from db

Parameters
int$a_id

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

References read().

34  {
35  $this->id = (int)$a_id;
36  $this->read();
37  }
read()
Get dataset from db.
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingSchedule::delete ( )

Delete single entry.

Returns
bool

Definition at line 435 of file class.ilBookingSchedule.php.

References $ilDB.

436  {
437  global $ilDB;
438 
439  if($this->id)
440  {
441  return $ilDB->manipulate('DELETE FROM booking_schedule'.
442  ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
443  }
444  }
global $ilDB

◆ doClone()

ilBookingSchedule::doClone (   $a_pool_id)

Definition at line 333 of file class.ilBookingSchedule.php.

References getAutoBreak(), getAvailabilityFrom(), getAvailabilityTo(), getDeadline(), getDefinition(), getMaxRental(), getMinRental(), getRaster(), and getTitle().

334  {
335  $new_obj = new self();
336  $new_obj->setPoolId($a_pool_id);
337  $new_obj->setTitle($this->getTitle());
338  $new_obj->setRaster($this->getRaster());
339  $new_obj->setMinRental($this->getMinRental());
340  $new_obj->setMaxRental($this->getMaxRental());
341  $new_obj->setAutoBreak($this->getAutoBreak());
342  $new_obj->setDeadline($this->getDeadline());
343  $new_obj->setDefinition($this->getDefinition());
344  $new_obj->setAvailabilityFrom($this->getAvailabilityFrom());
345  $new_obj->setAvailabilityTo($this->getAvailabilityTo());
346  return $new_obj->save();
347  }
getAutoBreak()
Get break time.
getAvailabilityFrom()
Get availability start.
getRaster()
Get booking raster.
getAvailabilityTo()
Get availability end.
getMinRental()
Get minimum rental time.
getDefinition()
Get definition.
getTitle()
Get object title.
getMaxRental()
Get maximum rental time.
+ Here is the call graph for this function:

◆ getAutoBreak()

ilBookingSchedule::getAutoBreak ( )

Get break time.

Returns
int

Definition at line 142 of file class.ilBookingSchedule.php.

References $auto_break.

Referenced by doClone(), and save().

143  {
144  return $this->auto_break;
145  }
+ Here is the caller graph for this function:

◆ getAvailabilityFrom()

ilBookingSchedule::getAvailabilityFrom ( )

Get availability start.

Returns
ilDateTime

Definition at line 198 of file class.ilBookingSchedule.php.

References $av_from.

Referenced by doClone(), ilBookingReservation\getAvailableObject(), ilBookingReservation\isObjectAvailableInPeriod(), save(), and update().

199  {
200  return $this->av_from;
201  }
+ Here is the caller graph for this function:

◆ getAvailabilityTo()

ilBookingSchedule::getAvailabilityTo ( )

Get availability end.

Returns
ilDateTime

Definition at line 218 of file class.ilBookingSchedule.php.

References $av_to.

Referenced by doClone(), ilBookingReservation\isObjectAvailableInPeriod(), save(), and update().

219  {
220  return $this->av_to;
221  }
+ Here is the caller graph for this function:

◆ getDeadline()

ilBookingSchedule::getDeadline ( )

Get deadline.

Returns
int

Definition at line 160 of file class.ilBookingSchedule.php.

References $deadline.

Referenced by doClone(), and save().

161  {
162  return $this->deadline;
163  }
+ Here is the caller graph for this function:

◆ getDefinition()

ilBookingSchedule::getDefinition ( )

Get definition.

Returns
array

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

References $definition.

Referenced by doClone(), getDefinitionBySlots(), ilBookingReservation\isObjectAvailableInPeriod(), and saveDefinition().

179  {
180  return $this->definition;
181  }
+ Here is the caller graph for this function:

◆ getDefinitionBySlots()

ilBookingSchedule::getDefinitionBySlots ( )

Return definition grouped by slots (not days)

Returns
array

Definition at line 451 of file class.ilBookingSchedule.php.

References array, and getDefinition().

452  {
453  $def = $this->getDefinition();
454  $slots = array();
455  foreach($def as $day => $times)
456  {
457  foreach($times as $time)
458  {
459  $slots[$time][] = $day;
460  }
461  }
462  foreach($slots as $time => $days)
463  {
464  $slots[$time] = array_unique($days);
465  }
466  ksort($slots);
467  return $slots;
468  }
getDefinition()
Get definition.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getList()

static ilBookingSchedule::getList (   $a_pool_id)
static

Get list of booking objects for given pool.

Parameters
int$a_pool_id
Returns
array

Definition at line 404 of file class.ilBookingSchedule.php.

References $ilDB, $res, $row, and array.

Referenced by ilObjBookingPool\cloneObject(), ilObjBookingPoolGUI\editObject(), ilBookingSchedulesTableGUI\getItems(), ilBookingReservationsTableGUI\initFilter(), and ilBookingObjectGUI\initForm().

405  {
406  global $ilDB;
407 
408  $set = $ilDB->query('SELECT s.booking_schedule_id,s.title,'.
409  'MAX(o.schedule_id) AS object_has_schedule'.
410  ' FROM booking_schedule s'.
411  ' LEFT JOIN booking_object o ON (s.booking_schedule_id = o.schedule_id)'.
412  ' WHERE s.pool_id = '.$ilDB->quote($a_pool_id, 'integer').
413  ' GROUP BY s.booking_schedule_id,s.title'.
414  ' ORDER BY s.title');
415  $res = array();
416  while($row = $ilDB->fetchAssoc($set))
417  {
418  if(!$row['object_has_schedule'])
419  {
420  $row['is_used'] = false;
421  }
422  else
423  {
424  $row['is_used'] = true;
425  }
426  $res[] = $row;
427  }
428  return $res;
429  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getMaxRental()

ilBookingSchedule::getMaxRental ( )

Get maximum rental time.

Returns
int

Definition at line 124 of file class.ilBookingSchedule.php.

References $rent_max.

Referenced by doClone(), and save().

125  {
126  return $this->rent_max;
127  }
+ Here is the caller graph for this function:

◆ getMinRental()

ilBookingSchedule::getMinRental ( )

Get minimum rental time.

Returns
int

Definition at line 106 of file class.ilBookingSchedule.php.

References $rent_min.

Referenced by doClone(), and save().

107  {
108  return $this->rent_min;
109  }
+ Here is the caller graph for this function:

◆ getPoolId()

ilBookingSchedule::getPoolId ( )

Get booking pool id.

Returns
int

Definition at line 70 of file class.ilBookingSchedule.php.

References $pool_id.

Referenced by save().

71  {
72  return $this->pool_id;
73  }
+ Here is the caller graph for this function:

◆ getRaster()

ilBookingSchedule::getRaster ( )

Get booking raster.

Returns
int

Definition at line 88 of file class.ilBookingSchedule.php.

References $raster.

Referenced by doClone(), ilObjBookingPoolGUI\renderSlots(), and save().

89  {
90  return $this->raster;
91  }
+ Here is the caller graph for this function:

◆ getTitle()

ilBookingSchedule::getTitle ( )

Get object title.

Returns
string

Definition at line 52 of file class.ilBookingSchedule.php.

References $title.

Referenced by doClone(), and save().

53  {
54  return $this->title;
55  }
+ Here is the caller graph for this function:

◆ hasExistingSchedules()

static ilBookingSchedule::hasExistingSchedules (   $a_pool_id)
static

Check if given pool has any defined schedules.

Parameters
int$a_pool_id
Returns
bool

Definition at line 389 of file class.ilBookingSchedule.php.

References $ilDB.

390  {
391  global $ilDB;
392 
393  $set = $ilDB->query("SELECT booking_schedule_id".
394  " FROM booking_schedule".
395  " WHERE pool_id = ".$ilDB->quote($a_pool_id, 'integer'));
396  return (bool)$ilDB->numRows($set);
397  }
global $ilDB

◆ read()

ilBookingSchedule::read ( )
protected

Get dataset from db.

Definition at line 226 of file class.ilBookingSchedule.php.

References $definition, $ilDB, $row, array, IL_CAL_UNIX, setAutoBreak(), setAvailabilityFrom(), setAvailabilityTo(), setDeadline(), setDefinition(), setMaxRental(), setMinRental(), setRaster(), and setTitle().

Referenced by __construct().

227  {
228  global $ilDB;
229 
230  if($this->id)
231  {
232  $set = $ilDB->query('SELECT title,raster,rent_min,rent_max,auto_break,'.
233  'deadline,av_from,av_to'.
234  ' FROM booking_schedule'.
235  ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
236  $row = $ilDB->fetchAssoc($set);
237  $this->setTitle($row['title']);
238  $this->setDeadline($row['deadline']);
239  $this->setAvailabilityFrom($row['av_from'] ? new ilDateTime($row['av_from'], IL_CAL_UNIX) : null);
240  $this->setAvailabilityTo($row['av_to'] ? new ilDateTime($row['av_to'], IL_CAL_UNIX) : null);
241  if($row['raster'])
242  {
243  $this->setRaster($row['raster']);
244  $this->setMinRental($row['rent_min']);
245  $this->setMaxRental($row['rent_max']);
246  $this->setAutoBreak($row['auto_break']);
247  }
248 
249  // load definition
250  $definition = array();
251  $set = $ilDB->query('SELECT day_id,slot_id,times'.
252  ' FROM booking_schedule_slot'.
253  ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
254  while($row = $ilDB->fetchAssoc($set))
255  {
256  $definition[$row["day_id"]][$row["slot_id"]] = $row["times"];
257  }
258  $this->setDefinition($definition);
259  }
260  }
setRaster($a_raster)
Set booking raster (in minutes)
setDefinition($a_definition)
Set definition.
setAvailabilityFrom(ilDateTime $a_date=null)
Set availability start.
setMinRental($a_min)
Set minimum rental time.
setAutoBreak($a_break)
Set break time.
const IL_CAL_UNIX
setMaxRental($a_max)
Set maximum rental time.
setDeadline($a_deadline)
Set deadline.
Date and time handling
Create styles array
The data for the language used.
global $ilDB
setTitle($a_title)
Set object title.
setAvailabilityTo(ilDateTime $a_date=null)
Set availability end.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilBookingSchedule::save ( )

Create new entry in db.

Returns
bool

Definition at line 266 of file class.ilBookingSchedule.php.

References $av_from, $av_to, $id, $ilDB, getAutoBreak(), getAvailabilityFrom(), getAvailabilityTo(), getDeadline(), getMaxRental(), getMinRental(), getPoolId(), getRaster(), getTitle(), IL_CAL_UNIX, and saveDefinition().

267  {
268  global $ilDB;
269 
270  if($this->id)
271  {
272  return false;
273  }
274 
275  $this->id = $ilDB->nextId('booking_schedule');
276 
277  $av_from = ($this->getAvailabilityFrom() && !$this->getAvailabilityFrom()->isNull())
278  ? $this->getAvailabilityFrom()->get(IL_CAL_UNIX)
279  : null;
280  $av_to = ($this->getAvailabilityTo() && !$this->getAvailabilityTo()->isNull())
281  ? $this->getAvailabilityTo()->get(IL_CAL_UNIX)
282  : null;
283 
284  $ilDB->manipulate('INSERT INTO booking_schedule'.
285  ' (booking_schedule_id,title,pool_id,raster,rent_min,rent_max,auto_break,'.
286  'deadline,av_from,av_to)'.
287  ' VALUES ('.$ilDB->quote($this->id, 'integer').','.$ilDB->quote($this->getTitle(), 'text').
288  ','.$ilDB->quote($this->getPoolId(), 'integer').','.$ilDB->quote($this->getRaster(), 'integer').
289  ','.$ilDB->quote($this->getMinRental(), 'integer').','.$ilDB->quote($this->getMaxRental(), 'integer').
290  ','.$ilDB->quote($this->getAutoBreak(), 'integer').','.$ilDB->quote($this->getDeadline(), 'integer').
291  ','.$ilDB->quote($av_from, 'integer').','.$ilDB->quote($av_to, 'integer').')');
292 
293  $this->saveDefinition();
294 
295  return $this->id;
296  }
getAutoBreak()
Get break time.
getAvailabilityFrom()
Get availability start.
getRaster()
Get booking raster.
getAvailabilityTo()
Get availability end.
getMinRental()
Get minimum rental time.
const IL_CAL_UNIX
getPoolId()
Get booking pool id.
saveDefinition()
Save current definition.
getTitle()
Get object title.
global $ilDB
getMaxRental()
Get maximum rental time.
+ Here is the call graph for this function:

◆ saveDefinition()

ilBookingSchedule::saveDefinition ( )
protected

Save current definition.

Definition at line 352 of file class.ilBookingSchedule.php.

References $definition, $ilDB, array, and getDefinition().

Referenced by save(), and update().

353  {
354  global $ilDB;
355 
356  if(!$this->id)
357  {
358  return false;
359  }
360 
361  $ilDB->manipulate('DELETE FROM booking_schedule_slot'.
362  ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
363 
364  $definition = $this->getDefinition();
365  if($definition)
366  {
367  foreach($definition as $day_id => $slots)
368  {
369  foreach($slots as $slot_id => $times)
370  {
371  $fields = array(
372  "booking_schedule_id" => array('integer', $this->id),
373  "day_id" => array('text', $day_id),
374  "slot_id" => array('integer', $slot_id),
375  "times" => array('text', $times)
376  );
377  $ilDB->insert('booking_schedule_slot', $fields);
378  }
379  }
380 
381  }
382  }
getDefinition()
Get definition.
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAutoBreak()

ilBookingSchedule::setAutoBreak (   $a_break)

Set break time.

Parameters
int$a_break

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

Referenced by read().

134  {
135  $this->auto_break = (int)$a_break;
136  }
+ Here is the caller graph for this function:

◆ setAvailabilityFrom()

ilBookingSchedule::setAvailabilityFrom ( ilDateTime  $a_date = null)

Set availability start.

Parameters
ilDateTime$a_date

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

Referenced by read().

189  {
190  $this->av_from = $a_date;
191  }
+ Here is the caller graph for this function:

◆ setAvailabilityTo()

ilBookingSchedule::setAvailabilityTo ( ilDateTime  $a_date = null)

Set availability end.

Parameters
ilDateTime$a_date

Definition at line 208 of file class.ilBookingSchedule.php.

Referenced by read().

209  {
210  $this->av_to = $a_date;
211  }
+ Here is the caller graph for this function:

◆ setDeadline()

ilBookingSchedule::setDeadline (   $a_deadline)

Set deadline.

Parameters
int$a_deadline

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

Referenced by read().

152  {
153  $this->deadline = (int)$a_deadline;
154  }
+ Here is the caller graph for this function:

◆ setDefinition()

ilBookingSchedule::setDefinition (   $a_definition)

Set definition.

Parameters
array$a_definition

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

Referenced by read(), and setDefinitionBySlots().

170  {
171  $this->definition = $a_definition;
172  }
+ Here is the caller graph for this function:

◆ setDefinitionBySlots()

ilBookingSchedule::setDefinitionBySlots ( array  $a_def)

Definition at line 470 of file class.ilBookingSchedule.php.

References array, and setDefinition().

471  {
472  $slots = array();
473  foreach($a_def as $time => $days)
474  {
475  foreach($days as $day)
476  {
477  $slots[$day][] = $time;
478  }
479  }
480  $this->setDefinition($slots);
481  }
setDefinition($a_definition)
Set definition.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ setMaxRental()

ilBookingSchedule::setMaxRental (   $a_max)

Set maximum rental time.

Parameters
int$a_max

Definition at line 115 of file class.ilBookingSchedule.php.

Referenced by read().

116  {
117  $this->rent_max = (int)$a_max;
118  }
+ Here is the caller graph for this function:

◆ setMinRental()

ilBookingSchedule::setMinRental (   $a_min)

Set minimum rental time.

Parameters
int$a_min

Definition at line 97 of file class.ilBookingSchedule.php.

Referenced by read().

98  {
99  $this->rent_min = (int)$a_min;
100  }
+ Here is the caller graph for this function:

◆ setPoolId()

ilBookingSchedule::setPoolId (   $a_pool_id)

Set booking pool id (aka parent obj ref id)

Parameters
int$a_pool_id

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

62  {
63  $this->pool_id = (int)$a_pool_id;
64  }

◆ setRaster()

ilBookingSchedule::setRaster (   $a_raster)

Set booking raster (in minutes)

Parameters
int$a_raster

Definition at line 79 of file class.ilBookingSchedule.php.

Referenced by read().

80  {
81  $this->raster = (int)$a_raster;
82  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBookingSchedule::setTitle (   $a_title)

Set object title.

Parameters
string$a_title

Definition at line 43 of file class.ilBookingSchedule.php.

Referenced by read().

44  {
45  $this->title = $a_title;
46  }
+ Here is the caller graph for this function:

◆ update()

ilBookingSchedule::update ( )

Update entry in db.

Returns
bool

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

References $av_from, $av_to, $ilDB, getAvailabilityFrom(), getAvailabilityTo(), IL_CAL_UNIX, and saveDefinition().

303  {
304  global $ilDB;
305 
306  if(!$this->id)
307  {
308  return false;
309  }
310 
311  $av_from = ($this->getAvailabilityFrom() && !$this->getAvailabilityFrom()->isNull())
312  ? $this->getAvailabilityFrom()->get(IL_CAL_UNIX)
313  : null;
314  $av_to = ($this->getAvailabilityTo() && !$this->getAvailabilityTo()->isNull())
315  ? $this->getAvailabilityTo()->get(IL_CAL_UNIX)
316  : null;
317 
318  $ilDB->manipulate('UPDATE booking_schedule'.
319  ' SET title = '.$ilDB->quote($this->getTitle(), 'text').
320  ', pool_id = '.$ilDB->quote($this->getPoolId(), 'integer').
321  ', raster = '.$ilDB->quote($this->getRaster(), 'integer').
322  ', rent_min = '.$ilDB->quote($this->getMinRental(), 'integer').
323  ', rent_max = '.$ilDB->quote($this->getMaxRental(), 'integer').
324  ', auto_break = '.$ilDB->quote($this->getAutoBreak(), 'integer').
325  ', deadline = '.$ilDB->quote($this->getDeadline(), 'integer').
326  ', av_from = '.$ilDB->quote($av_from, 'integer').
327  ', av_to = '.$ilDB->quote($av_to, 'integer').
328  ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
329 
330  $this->saveDefinition();
331  }
getAvailabilityFrom()
Get availability start.
getAvailabilityTo()
Get availability end.
const IL_CAL_UNIX
saveDefinition()
Save current definition.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $auto_break

ilBookingSchedule::$auto_break
protected

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

Referenced by getAutoBreak().

◆ $av_from

ilBookingSchedule::$av_from
protected

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

Referenced by getAvailabilityFrom(), save(), and update().

◆ $av_to

ilBookingSchedule::$av_to
protected

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

Referenced by getAvailabilityTo(), save(), and update().

◆ $deadline

ilBookingSchedule::$deadline
protected

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

Referenced by getDeadline().

◆ $definition

ilBookingSchedule::$definition
protected

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

Referenced by getDefinition(), read(), and saveDefinition().

◆ $id

ilBookingSchedule::$id
protected

Definition at line 14 of file class.ilBookingSchedule.php.

Referenced by save().

◆ $pool_id

ilBookingSchedule::$pool_id
protected

Definition at line 16 of file class.ilBookingSchedule.php.

Referenced by getPoolId().

◆ $raster

ilBookingSchedule::$raster
protected

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

Referenced by getRaster().

◆ $rent_max

ilBookingSchedule::$rent_max
protected

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

Referenced by getMaxRental().

◆ $rent_min

ilBookingSchedule::$rent_min
protected

Definition at line 18 of file class.ilBookingSchedule.php.

Referenced by getMinRental().

◆ $title

ilBookingSchedule::$title
protected

Definition at line 15 of file class.ilBookingSchedule.php.

Referenced by getTitle().


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