ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBookingSchedule Class Reference

schedule for booking ressource More...

+ Collaboration diagram for ilBookingSchedule:

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

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

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

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.

References read().

{
$this->id = (int)$a_id;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilBookingSchedule::delete ( )

Delete single entry.

Returns
bool

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

{
global $ilDB;
if($this->id)
{
return $ilDB->manipulate('DELETE FROM booking_schedule'.
' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
}
}
ilBookingSchedule::doClone (   $a_pool_id)

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

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

{
$new_obj = new self();
$new_obj->setPoolId($a_pool_id);
$new_obj->setTitle($this->getTitle());
$new_obj->setRaster($this->getRaster());
$new_obj->setMinRental($this->getMinRental());
$new_obj->setMaxRental($this->getMaxRental());
$new_obj->setAutoBreak($this->getAutoBreak());
$new_obj->setDeadline($this->getDeadline());
$new_obj->setDefinition($this->getDefinition());
return $new_obj->save();
}

+ Here is the call graph for this function:

ilBookingSchedule::getAutoBreak ( )

Get break time.

Returns
int

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

References $auto_break.

Referenced by doClone(), and save().

{
}

+ Here is the caller graph for this function:

ilBookingSchedule::getDeadline ( )

Get deadline.

Returns
int

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

References $deadline.

Referenced by doClone(), and save().

{
}

+ Here is the caller graph for this function:

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:

ilBookingSchedule::getDefinitionBySlots ( )

Return definition grouped by slots (not days)

Returns
array

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

References getDefinition().

{
$def = $this->getDefinition();
$slots = array();
foreach($def as $day => $times)
{
foreach($times as $time)
{
$slots[$time][] = $day;
}
}
foreach($slots as $time => $days)
{
$slots[$time] = array_unique($days);
}
ksort($slots);
return $slots;
}

+ Here is the call graph for this function:

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.

References $res, and $row.

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

{
global $ilDB;
$set = $ilDB->query('SELECT s.booking_schedule_id,s.title,'.
'MAX(o.schedule_id) AS object_has_schedule'.
' FROM booking_schedule s'.
' LEFT JOIN booking_object o ON (s.booking_schedule_id = o.schedule_id)'.
' WHERE s.pool_id = '.$ilDB->quote($a_pool_id, 'integer').
' GROUP BY s.booking_schedule_id,s.title'.
' ORDER BY s.title');
$res = array();
while($row = $ilDB->fetchAssoc($set))
{
if(!$row['object_has_schedule'])
{
$row['is_used'] = false;
}
else
{
$row['is_used'] = true;
}
$res[] = $row;
}
return $res;
}

+ Here is the caller graph for this function:

ilBookingSchedule::getMaxRental ( )

Get maximum rental time.

Returns
int

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

References $rent_max.

Referenced by doClone(), and save().

{
}

+ Here is the caller graph for this function:

ilBookingSchedule::getMinRental ( )

Get minimum rental time.

Returns
int

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

References $rent_min.

Referenced by doClone(), and save().

{
}

+ Here is the caller graph for this function:

ilBookingSchedule::getPoolId ( )

Get booking pool id.

Returns
int

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

References $pool_id.

Referenced by save().

{
}

+ Here is the caller graph for this function:

ilBookingSchedule::getRaster ( )

Get booking raster.

Returns
int

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

References $raster.

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

{
return $this->raster;
}

+ Here is the caller graph for this function:

ilBookingSchedule::getTitle ( )

Get object title.

Returns
string

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

References $title.

Referenced by doClone(), and save().

{
return $this->title;
}

+ Here is the caller graph for this function:

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.

{
global $ilDB;
$set = $ilDB->query("SELECT booking_schedule_id".
" FROM booking_schedule".
" WHERE pool_id = ".$ilDB->quote($a_pool_id, 'integer'));
return (bool)$ilDB->numRows($set);
}
ilBookingSchedule::read ( )
protected

Get dataset from db.

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

References $definition, $row, setAutoBreak(), setDeadline(), setDefinition(), setMaxRental(), setMinRental(), setRaster(), and setTitle().

Referenced by __construct().

{
global $ilDB;
if($this->id)
{
$set = $ilDB->query('SELECT title,raster,rent_min,rent_max,auto_break,'.
'deadline'.
' FROM booking_schedule'.
' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
$row = $ilDB->fetchAssoc($set);
$this->setTitle($row['title']);
$this->setDeadline($row['deadline']);
if($row['raster'])
{
$this->setRaster($row['raster']);
$this->setMinRental($row['rent_min']);
$this->setMaxRental($row['rent_max']);
$this->setAutoBreak($row['auto_break']);
}
// load definition
$definition = array();
$set = $ilDB->query('SELECT day_id,slot_id,times'.
' FROM booking_schedule_slot'.
' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
while($row = $ilDB->fetchAssoc($set))
{
$definition[$row["day_id"]][$row["slot_id"]] = $row["times"];
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingSchedule::save ( )

Create new entry in db.

Returns
bool

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

References $id, getAutoBreak(), getDeadline(), getMaxRental(), getMinRental(), getPoolId(), getRaster(), getTitle(), and saveDefinition().

{
global $ilDB;
if($this->id)
{
return false;
}
$this->id = $ilDB->nextId('booking_schedule');
$ilDB->manipulate('INSERT INTO booking_schedule'.
' (booking_schedule_id,title,pool_id,raster,rent_min,rent_max,auto_break,'.
'deadline)'.
' VALUES ('.$ilDB->quote($this->id, 'integer').','.$ilDB->quote($this->getTitle(), 'text').
','.$ilDB->quote($this->getPoolId(), 'integer').','.$ilDB->quote($this->getRaster(), 'integer').
','.$ilDB->quote($this->getMinRental(), 'integer').','.$ilDB->quote($this->getMaxRental(), 'integer').
','.$ilDB->quote($this->getAutoBreak(), 'integer').','.$ilDB->quote($this->getDeadline(), 'integer').')');
$this->saveDefinition();
return $this->id;
}

+ Here is the call graph for this function:

ilBookingSchedule::saveDefinition ( )
protected

Save current definition.

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

References $definition, and getDefinition().

Referenced by save(), and update().

{
global $ilDB;
if(!$this->id)
{
return false;
}
$ilDB->manipulate('DELETE FROM booking_schedule_slot'.
' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
{
foreach($definition as $day_id => $slots)
{
foreach($slots as $slot_id => $times)
{
$fields = array(
"booking_schedule_id" => array('integer', $this->id),
"day_id" => array('text', $day_id),
"slot_id" => array('integer', $slot_id),
"times" => array('text', $times)
);
$ilDB->insert('booking_schedule_slot', $fields);
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingSchedule::setAutoBreak (   $a_break)

Set break time.

Parameters
int$a_break

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

Referenced by read().

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

+ Here is the caller graph for this function:

ilBookingSchedule::setDeadline (   $a_deadline)

Set deadline.

Parameters
int$a_deadline

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

Referenced by read().

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

+ Here is the caller graph for this function:

ilBookingSchedule::setDefinition (   $a_definition)

Set definition.

Parameters
array$a_definition

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

Referenced by read(), and setDefinitionBySlots().

{
$this->definition = $a_definition;
}

+ Here is the caller graph for this function:

ilBookingSchedule::setDefinitionBySlots ( array  $a_def)

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

References setDefinition().

{
$slots = array();
foreach($a_def as $time => $days)
{
foreach($days as $day)
{
$slots[$day][] = $time;
}
}
$this->setDefinition($slots);
}

+ Here is the call graph for this function:

ilBookingSchedule::setMaxRental (   $a_max)

Set maximum rental time.

Parameters
int$a_max

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

Referenced by read().

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

+ Here is the caller graph for this function:

ilBookingSchedule::setMinRental (   $a_min)

Set minimum rental time.

Parameters
int$a_min

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

Referenced by read().

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

+ Here is the caller graph for this function:

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.

{
$this->pool_id = (int)$a_pool_id;
}
ilBookingSchedule::setRaster (   $a_raster)

Set booking raster (in minutes)

Parameters
int$a_raster

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

Referenced by read().

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

+ Here is the caller graph for this function:

ilBookingSchedule::setTitle (   $a_title)

Set object title.

Parameters
string$a_title

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

Referenced by read().

{
$this->title = $a_title;
}

+ Here is the caller graph for this function:

ilBookingSchedule::update ( )

Update entry in db.

Returns
bool

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

References saveDefinition().

{
global $ilDB;
if(!$this->id)
{
return false;
}
$ilDB->manipulate('UPDATE booking_schedule'.
' SET title = '.$ilDB->quote($this->getTitle(), 'text').
', pool_id = '.$ilDB->quote($this->getPoolId(), 'integer').
', raster = '.$ilDB->quote($this->getRaster(), 'integer').
', rent_min = '.$ilDB->quote($this->getMinRental(), 'integer').
', rent_max = '.$ilDB->quote($this->getMaxRental(), 'integer').
', auto_break = '.$ilDB->quote($this->getAutoBreak(), 'integer').
', deadline = '.$ilDB->quote($this->getDeadline(), 'integer').
' WHERE booking_schedule_id = '.$ilDB->quote($this->id, 'integer'));
$this->saveDefinition();
}

+ Here is the call graph for this function:

Field Documentation

ilBookingSchedule::$auto_break
protected

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

Referenced by getAutoBreak().

ilBookingSchedule::$deadline
protected

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

Referenced by getDeadline().

ilBookingSchedule::$definition
protected

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

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

ilBookingSchedule::$id
protected

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

Referenced by save().

ilBookingSchedule::$pool_id
protected

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

Referenced by getPoolId().

ilBookingSchedule::$raster
protected

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

Referenced by getRaster().

ilBookingSchedule::$rent_max
protected

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

Referenced by getMaxRental().

ilBookingSchedule::$rent_min
protected

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

Referenced by getMinRental().

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: