ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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...
 
 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
 

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

32 {
33 $this->id = (int)$a_id;
34 $this->read();
35 }
read()
Get dataset from db.

References read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingSchedule::delete ( )

Delete single entry.

Returns
bool

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

373 {
374 global $ilDB;
375
376 if($this->id)
377 {
378 return $ilDB->manipulate('DELETE FROM booking_schedule'.
379 ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
380 }
381 }
global $ilDB

References $ilDB.

◆ doClone()

ilBookingSchedule::doClone (   $a_pool_id)

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

273 {
274 $new_obj = new self();
275 $new_obj->setPoolId($a_pool_id);
276 $new_obj->setTitle($this->getTitle());
277 $new_obj->setRaster($this->getRaster());
278 $new_obj->setMinRental($this->getMinRental());
279 $new_obj->setMaxRental($this->getMaxRental());
280 $new_obj->setAutoBreak($this->getAutoBreak());
281 $new_obj->setDeadline($this->getDeadline());
282 $new_obj->setDefinition($this->getDefinition());
283 return $new_obj->save();
284 }
getAutoBreak()
Get break time.
getRaster()
Get booking raster.
getMaxRental()
Get maximum rental time.
getMinRental()
Get minimum rental time.
getDefinition()
Get definition.
getTitle()
Get object title.

References getAutoBreak(), 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 140 of file class.ilBookingSchedule.php.

References $auto_break.

Referenced by doClone().

+ Here is the caller graph for this function:

◆ getDeadline()

ilBookingSchedule::getDeadline ( )

Get deadline.

Returns
int

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

159 {
160 return $this->deadline;
161 }

References $deadline.

Referenced by doClone().

+ Here is the caller graph for this function:

◆ getDefinition()

ilBookingSchedule::getDefinition ( )

Get definition.

Returns
array

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

References $definition.

Referenced by doClone(), getDefinitionBySlots(), 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 388 of file class.ilBookingSchedule.php.

389 {
390 $def = $this->getDefinition();
391 $slots = array();
392 foreach($def as $day => $times)
393 {
394 foreach($times as $time)
395 {
396 $slots[$time][] = $day;
397 }
398 }
399 foreach($slots as $time => $days)
400 {
401 $slots[$time] = array_unique($days);
402 }
403 ksort($slots);
404 return $slots;
405 }

References 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 341 of file class.ilBookingSchedule.php.

342 {
343 global $ilDB;
344
345 $set = $ilDB->query('SELECT s.booking_schedule_id,s.title,'.
346 'MAX(o.schedule_id) AS object_has_schedule'.
347 ' FROM booking_schedule s'.
348 ' LEFT JOIN booking_object o ON (s.booking_schedule_id = o.schedule_id)'.
349 ' WHERE s.pool_id = '.$ilDB->quote($a_pool_id, 'integer').
350 ' GROUP BY s.booking_schedule_id,s.title'.
351 ' ORDER BY s.title');
352 $res = array();
353 while($row = $ilDB->fetchAssoc($set))
354 {
355 if(!$row['object_has_schedule'])
356 {
357 $row['is_used'] = false;
358 }
359 else
360 {
361 $row['is_used'] = true;
362 }
363 $res[] = $row;
364 }
365 return $res;
366 }

References $ilDB, $res, and $row.

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

+ Here is the caller graph for this function:

◆ getMaxRental()

ilBookingSchedule::getMaxRental ( )

Get maximum rental time.

Returns
int

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

123 {
124 return $this->rent_max;
125 }

References $rent_max.

Referenced by doClone().

+ Here is the caller graph for this function:

◆ getMinRental()

ilBookingSchedule::getMinRental ( )

Get minimum rental time.

Returns
int

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

105 {
106 return $this->rent_min;
107 }

References $rent_min.

Referenced by doClone().

+ Here is the caller graph for this function:

◆ getPoolId()

ilBookingSchedule::getPoolId ( )

Get booking pool id.

Returns
int

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

References $pool_id.

◆ getRaster()

ilBookingSchedule::getRaster ( )

Get booking raster.

Returns
int

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

References $raster.

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

+ Here is the caller graph for this function:

◆ getTitle()

ilBookingSchedule::getTitle ( )

Get object title.

Returns
string

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

References $title.

Referenced by doClone().

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

327 {
328 global $ilDB;
329
330 $set = $ilDB->query("SELECT booking_schedule_id".
331 " FROM booking_schedule".
332 " WHERE pool_id = ".$ilDB->quote($a_pool_id, 'integer'));
333 return (bool)$ilDB->numRows($set);
334 }

References $ilDB.

◆ read()

ilBookingSchedule::read ( )
protected

Get dataset from db.

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

185 {
186 global $ilDB;
187
188 if($this->id)
189 {
190 $set = $ilDB->query('SELECT title,raster,rent_min,rent_max,auto_break,'.
191 'deadline'.
192 ' FROM booking_schedule'.
193 ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
194 $row = $ilDB->fetchAssoc($set);
195 $this->setTitle($row['title']);
196 $this->setDeadline($row['deadline']);
197 if($row['raster'])
198 {
199 $this->setRaster($row['raster']);
200 $this->setMinRental($row['rent_min']);
201 $this->setMaxRental($row['rent_max']);
202 $this->setAutoBreak($row['auto_break']);
203 }
204
205 // load definition
206 $definition = array();
207 $set = $ilDB->query('SELECT day_id,slot_id,times'.
208 ' FROM booking_schedule_slot'.
209 ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
210 while($row = $ilDB->fetchAssoc($set))
211 {
212 $definition[$row["day_id"]][$row["slot_id"]] = $row["times"];
213 }
215 }
216 }
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.

References $definition, $ilDB, $row, setAutoBreak(), 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 222 of file class.ilBookingSchedule.php.

223 {
224 global $ilDB;
225
226 if($this->id)
227 {
228 return false;
229 }
230
231 $this->id = $ilDB->nextId('booking_schedule');
232
233 $ilDB->manipulate('INSERT INTO booking_schedule'.
234 ' (booking_schedule_id,title,pool_id,raster,rent_min,rent_max,auto_break,'.
235 'deadline)'.
236 ' VALUES ('.$ilDB->quote($this->id, 'integer').','.$ilDB->quote($this->getTitle(), 'text').
237 ','.$ilDB->quote($this->getPoolId(), 'integer').','.$ilDB->quote($this->getRaster(), 'integer').
238 ','.$ilDB->quote($this->getMinRental(), 'integer').','.$ilDB->quote($this->getMaxRental(), 'integer').
239 ','.$ilDB->quote($this->getAutoBreak(), 'integer').','.$ilDB->quote($this->getDeadline(), 'integer').')');
240
241 $this->saveDefinition();
242
243 return $this->id;
244 }
saveDefinition()
Save current definition.

References $id, $ilDB, and saveDefinition().

+ Here is the call graph for this function:

◆ saveDefinition()

ilBookingSchedule::saveDefinition ( )
protected

Save current definition.

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

290 {
291 global $ilDB;
292
293 if(!$this->id)
294 {
295 return false;
296 }
297
298 $ilDB->manipulate('DELETE FROM booking_schedule_slot'.
299 ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
300
301 $definition = $this->getDefinition();
302 if($definition)
303 {
304 foreach($definition as $day_id => $slots)
305 {
306 foreach($slots as $slot_id => $times)
307 {
308 $fields = array(
309 "booking_schedule_id" => array('integer', $this->id),
310 "day_id" => array('text', $day_id),
311 "slot_id" => array('integer', $slot_id),
312 "times" => array('text', $times)
313 );
314 $ilDB->insert('booking_schedule_slot', $fields);
315 }
316 }
317
318 }
319 }

References $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 131 of file class.ilBookingSchedule.php.

132 {
133 $this->auto_break = (int)$a_break;
134 }

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

150 {
151 $this->deadline = (int)$a_deadline;
152 }

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

168 {
169 $this->definition = $a_definition;
170 }

Referenced by read(), and setDefinitionBySlots().

+ Here is the caller graph for this function:

◆ setDefinitionBySlots()

ilBookingSchedule::setDefinitionBySlots ( array  $a_def)

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

408 {
409 $slots = array();
410 foreach($a_def as $time => $days)
411 {
412 foreach($days as $day)
413 {
414 $slots[$day][] = $time;
415 }
416 }
417 $this->setDefinition($slots);
418 }

References 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 113 of file class.ilBookingSchedule.php.

114 {
115 $this->rent_max = (int)$a_max;
116 }

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

96 {
97 $this->rent_min = (int)$a_min;
98 }

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

60 {
61 $this->pool_id = (int)$a_pool_id;
62 }

◆ setRaster()

ilBookingSchedule::setRaster (   $a_raster)

Set booking raster (in minutes)

Parameters
int$a_raster

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

78 {
79 $this->raster = (int)$a_raster;
80 }

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

42 {
43 $this->title = $a_title;
44 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilBookingSchedule::update ( )

Update entry in db.

Returns
bool

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

251 {
252 global $ilDB;
253
254 if(!$this->id)
255 {
256 return false;
257 }
258
259 $ilDB->manipulate('UPDATE booking_schedule'.
260 ' SET title = '.$ilDB->quote($this->getTitle(), 'text').
261 ', pool_id = '.$ilDB->quote($this->getPoolId(), 'integer').
262 ', raster = '.$ilDB->quote($this->getRaster(), 'integer').
263 ', rent_min = '.$ilDB->quote($this->getMinRental(), 'integer').
264 ', rent_max = '.$ilDB->quote($this->getMaxRental(), 'integer').
265 ', auto_break = '.$ilDB->quote($this->getAutoBreak(), 'integer').
266 ', deadline = '.$ilDB->quote($this->getDeadline(), 'integer').
267 ' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
268
269 $this->saveDefinition();
270 }

References $ilDB, and saveDefinition().

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

◆ $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: