ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 $db
 
 $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 38 of file class.ilBookingSchedule.php.

39 {
40 global $DIC;
41
42 $this->db = $DIC->database();
43 $this->id = (int) $a_id;
44 $this->read();
45 }
read()
Get dataset from db.
global $DIC
Definition: saml.php:7

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingSchedule::delete ( )

Delete single entry.

Returns
bool

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

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

References $db, and $ilDB.

◆ doClone()

ilBookingSchedule::doClone (   $a_pool_id)

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

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

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

+ Here is the call graph for this function:

◆ getAutoBreak()

ilBookingSchedule::getAutoBreak ( )

Get break time.

Returns
int

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

References $auto_break.

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

+ Here is the caller graph for this function:

◆ getAvailabilityFrom()

ilBookingSchedule::getAvailabilityFrom ( )

Get availability start.

Returns
ilDateTime

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

207 {
208 return $this->av_from;
209 }

References $av_from.

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

+ Here is the caller graph for this function:

◆ getAvailabilityTo()

ilBookingSchedule::getAvailabilityTo ( )

Get availability end.

Returns
ilDateTime

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

227 {
228 return $this->av_to;
229 }

References $av_to.

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

+ Here is the caller graph for this function:

◆ getDeadline()

ilBookingSchedule::getDeadline ( )

Get deadline.

Returns
int

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

169 {
170 return $this->deadline;
171 }

References $deadline.

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

+ Here is the caller graph for this function:

◆ getDefinition()

ilBookingSchedule::getDefinition ( )

Get definition.

Returns
array

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

References $definition.

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

+ Here is the caller graph for this function:

◆ getDefinitionBySlots()

ilBookingSchedule::getDefinitionBySlots ( )

Return definition grouped by slots (not days)

Returns
array

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

449 {
450 $def = $this->getDefinition();
451 $slots = array();
452 foreach ($def as $day => $times) {
453 foreach ($times as $time) {
454 $slots[$time][] = $day;
455 }
456 }
457 foreach ($slots as $time => $days) {
458 $slots[$time] = array_unique($days);
459 }
460 ksort($slots);
461 return $slots;
462 }
$def
Definition: croninfo.php:21
$time
Definition: cron.php:21

References $def, $time, and getDefinition().

+ 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.

405 {
406 global $DIC;
407
408 $ilDB = $DIC->database();
409
410 $set = $ilDB->query('SELECT s.booking_schedule_id,s.title,' .
411 'MAX(o.schedule_id) AS object_has_schedule' .
412 ' FROM booking_schedule s' .
413 ' LEFT JOIN booking_object o ON (s.booking_schedule_id = o.schedule_id)' .
414 ' WHERE s.pool_id = ' . $ilDB->quote($a_pool_id, 'integer') .
415 ' GROUP BY s.booking_schedule_id,s.title' .
416 ' ORDER BY s.title');
417 $res = array();
418 while ($row = $ilDB->fetchAssoc($set)) {
419 if (!$row['object_has_schedule']) {
420 $row['is_used'] = false;
421 } else {
422 $row['is_used'] = true;
423 }
424 $res[] = $row;
425 }
426 return $res;
427 }
foreach($_POST as $key=> $value) $res

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

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

+ Here is the caller graph for this function:

◆ getMaxRental()

ilBookingSchedule::getMaxRental ( )

Get maximum rental time.

Returns
int

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

133 {
134 return $this->rent_max;
135 }

References $rent_max.

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

+ Here is the caller graph for this function:

◆ getMinRental()

ilBookingSchedule::getMinRental ( )

Get minimum rental time.

Returns
int

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

115 {
116 return $this->rent_min;
117 }

References $rent_min.

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

+ Here is the caller graph for this function:

◆ getPoolId()

ilBookingSchedule::getPoolId ( )

Get booking pool id.

Returns
int

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

References $pool_id.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getRaster()

ilBookingSchedule::getRaster ( )

Get booking raster.

Returns
int

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

References $raster.

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

+ Here is the caller graph for this function:

◆ getTitle()

ilBookingSchedule::getTitle ( )

Get object title.

Returns
string

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

References $title.

Referenced by doClone(), and save().

+ 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 387 of file class.ilBookingSchedule.php.

388 {
389 global $DIC;
390
391 $ilDB = $DIC->database();
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 }

References $DIC, and $ilDB.

◆ read()

ilBookingSchedule::read ( )
protected

Get dataset from db.

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

235 {
237
238 if ($this->id) {
239 $set = $ilDB->query('SELECT title,raster,rent_min,rent_max,auto_break,' .
240 'deadline,av_from,av_to' .
241 ' FROM booking_schedule' .
242 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
243 $row = $ilDB->fetchAssoc($set);
244 $this->setTitle($row['title']);
245 $this->setDeadline($row['deadline']);
246 $this->setAvailabilityFrom($row['av_from'] ? new ilDateTime($row['av_from'], IL_CAL_UNIX) : null);
247 $this->setAvailabilityTo($row['av_to'] ? new ilDateTime($row['av_to'], IL_CAL_UNIX) : null);
248 if ($row['raster']) {
249 $this->setRaster($row['raster']);
250 $this->setMinRental($row['rent_min']);
251 $this->setMaxRental($row['rent_max']);
252 $this->setAutoBreak($row['auto_break']);
253 }
254
255 // load definition
256 $definition = array();
257 $set = $ilDB->query('SELECT day_id,slot_id,times' .
258 ' FROM booking_schedule_slot' .
259 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
260 while ($row = $ilDB->fetchAssoc($set)) {
261 $definition[$row["day_id"]][$row["slot_id"]] = $row["times"];
262 }
264 }
265 }
const IL_CAL_UNIX
setTitle($a_title)
Set object title.
setDeadline($a_deadline)
Set deadline.
setRaster($a_raster)
Set booking raster (in minutes)
setDefinition($a_definition)
Set definition.
setAutoBreak($a_break)
Set break time.
setMaxRental($a_max)
Set maximum rental time.
setMinRental($a_min)
Set minimum rental time.
setAvailabilityFrom(ilDateTime $a_date=null)
Set availability start.
setAvailabilityTo(ilDateTime $a_date=null)
Set availability end.
@classDescription Date and time handling

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

Referenced by __construct().

+ 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 271 of file class.ilBookingSchedule.php.

272 {
274
275 if ($this->id) {
276 return false;
277 }
278
279 $this->id = $ilDB->nextId('booking_schedule');
280
281 $av_from = ($this->getAvailabilityFrom() && !$this->getAvailabilityFrom()->isNull())
282 ? $this->getAvailabilityFrom()->get(IL_CAL_UNIX)
283 : null;
284 $av_to = ($this->getAvailabilityTo() && !$this->getAvailabilityTo()->isNull())
285 ? $this->getAvailabilityTo()->get(IL_CAL_UNIX)
286 : null;
287
288 $ilDB->manipulate('INSERT INTO booking_schedule' .
289 ' (booking_schedule_id,title,pool_id,raster,rent_min,rent_max,auto_break,' .
290 'deadline,av_from,av_to)' .
291 ' VALUES (' . $ilDB->quote($this->id, 'integer') . ',' . $ilDB->quote($this->getTitle(), 'text') .
292 ',' . $ilDB->quote($this->getPoolId(), 'integer') . ',' . $ilDB->quote($this->getRaster(), 'integer') .
293 ',' . $ilDB->quote($this->getMinRental(), 'integer') . ',' . $ilDB->quote($this->getMaxRental(), 'integer') .
294 ',' . $ilDB->quote($this->getAutoBreak(), 'integer') . ',' . $ilDB->quote($this->getDeadline(), 'integer') .
295 ',' . $ilDB->quote($av_from, 'integer') . ',' . $ilDB->quote($av_to, 'integer') . ')');
296
297 $this->saveDefinition();
298
299 return $this->id;
300 }
saveDefinition()
Save current definition.
getPoolId()
Get booking pool id.

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

+ Here is the call graph for this function:

◆ saveDefinition()

ilBookingSchedule::saveDefinition ( )
protected

Save current definition.

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

356 {
358
359 if (!$this->id) {
360 return false;
361 }
362
363 $ilDB->manipulate('DELETE FROM booking_schedule_slot' .
364 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
365
366 $definition = $this->getDefinition();
367 if ($definition) {
368 foreach ($definition as $day_id => $slots) {
369 foreach ($slots as $slot_id => $times) {
370 $fields = array(
371 "booking_schedule_id" => array('integer', $this->id),
372 "day_id" => array('text', $day_id),
373 "slot_id" => array('integer', $slot_id),
374 "times" => array('text', $times)
375 );
376 $ilDB->insert('booking_schedule_slot', $fields);
377 }
378 }
379 }
380 }

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

Referenced by save(), and update().

+ 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 141 of file class.ilBookingSchedule.php.

142 {
143 $this->auto_break = (int) $a_break;
144 }

Referenced by read().

+ 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 196 of file class.ilBookingSchedule.php.

197 {
198 $this->av_from = $a_date;
199 }

Referenced by read().

+ 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 216 of file class.ilBookingSchedule.php.

217 {
218 $this->av_to = $a_date;
219 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setDeadline()

ilBookingSchedule::setDeadline (   $a_deadline)

Set deadline.

Parameters
int$a_deadline

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

160 {
161 $this->deadline = (int) $a_deadline;
162 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setDefinition()

ilBookingSchedule::setDefinition (   $a_definition)

Set definition.

Parameters
array$a_definition

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

178 {
179 $this->definition = $a_definition;
180 }

Referenced by read(), and setDefinitionBySlots().

+ Here is the caller graph for this function:

◆ setDefinitionBySlots()

ilBookingSchedule::setDefinitionBySlots ( array  $a_def)

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

465 {
466 $slots = array();
467 foreach ($a_def as $time => $days) {
468 foreach ($days as $day) {
469 $slots[$day][] = $time;
470 }
471 }
472 $this->setDefinition($slots);
473 }

References $time, and setDefinition().

+ Here is the call graph for this function:

◆ setMaxRental()

ilBookingSchedule::setMaxRental (   $a_max)

Set maximum rental time.

Parameters
int$a_max

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

124 {
125 $this->rent_max = (int) $a_max;
126 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMinRental()

ilBookingSchedule::setMinRental (   $a_min)

Set minimum rental time.

Parameters
int$a_min

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

106 {
107 $this->rent_min = (int) $a_min;
108 }

Referenced by read().

+ 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 69 of file class.ilBookingSchedule.php.

70 {
71 $this->pool_id = (int) $a_pool_id;
72 }

◆ setRaster()

ilBookingSchedule::setRaster (   $a_raster)

Set booking raster (in minutes)

Parameters
int$a_raster

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

88 {
89 $this->raster = (int) $a_raster;
90 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilBookingSchedule::setTitle (   $a_title)

Set object title.

Parameters
string$a_title

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

52 {
53 $this->title = $a_title;
54 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilBookingSchedule::update ( )

Update entry in db.

Returns
bool

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

307 {
309
310 if (!$this->id) {
311 return false;
312 }
313
314 $av_from = ($this->getAvailabilityFrom() && !$this->getAvailabilityFrom()->isNull())
315 ? $this->getAvailabilityFrom()->get(IL_CAL_UNIX)
316 : null;
317 $av_to = ($this->getAvailabilityTo() && !$this->getAvailabilityTo()->isNull())
318 ? $this->getAvailabilityTo()->get(IL_CAL_UNIX)
319 : null;
320
321 $ilDB->manipulate('UPDATE booking_schedule' .
322 ' SET title = ' . $ilDB->quote($this->getTitle(), 'text') .
323 ', pool_id = ' . $ilDB->quote($this->getPoolId(), 'integer') .
324 ', raster = ' . $ilDB->quote($this->getRaster(), 'integer') .
325 ', rent_min = ' . $ilDB->quote($this->getMinRental(), 'integer') .
326 ', rent_max = ' . $ilDB->quote($this->getMaxRental(), 'integer') .
327 ', auto_break = ' . $ilDB->quote($this->getAutoBreak(), 'integer') .
328 ', deadline = ' . $ilDB->quote($this->getDeadline(), 'integer') .
329 ', av_from = ' . $ilDB->quote($av_from, 'integer') .
330 ', av_to = ' . $ilDB->quote($av_to, 'integer') .
331 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
332
333 $this->saveDefinition();
334 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $auto_break

ilBookingSchedule::$auto_break
protected

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

Referenced by getAutoBreak().

◆ $av_from

ilBookingSchedule::$av_from
protected

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

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

◆ $av_to

ilBookingSchedule::$av_to
protected

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

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

◆ $db

ilBookingSchedule::$db
protected

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

Referenced by delete(), read(), save(), saveDefinition(), and update().

◆ $deadline

ilBookingSchedule::$deadline
protected

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

Referenced by getDeadline().

◆ $definition

ilBookingSchedule::$definition
protected

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

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

◆ $id

ilBookingSchedule::$id
protected

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

Referenced by save().

◆ $pool_id

ilBookingSchedule::$pool_id
protected

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

Referenced by getPoolId().

◆ $raster

ilBookingSchedule::$raster
protected

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

Referenced by getRaster().

◆ $rent_max

ilBookingSchedule::$rent_max
protected

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

Referenced by getMaxRental().

◆ $rent_min

ilBookingSchedule::$rent_min
protected

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

Referenced by getMinRental().

◆ $title

ilBookingSchedule::$title
protected

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

Referenced by getTitle().


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