35 $this->
id = (int)$a_id;
45 $this->title = $a_title;
63 $this->pool_id = (int)$a_pool_id;
81 $this->raster = (int)$a_raster;
99 $this->rent_min = (int)$a_min;
117 $this->rent_max = (int)$a_max;
135 $this->auto_break = (int)$a_break;
153 $this->deadline = (int)$a_deadline;
171 $this->definition = $a_definition;
190 $this->av_from = $a_date;
210 $this->av_to = $a_date;
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);
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))
275 $this->
id = $ilDB->nextId(
'booking_schedule');
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').
291 ','.$ilDB->quote(
$av_from,
'integer').
','.$ilDB->quote(
$av_to,
'integer').
')');
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'));
335 $new_obj =
new self();
336 $new_obj->setPoolId($a_pool_id);
337 $new_obj->setTitle($this->
getTitle());
346 return $new_obj->save();
361 $ilDB->manipulate(
'DELETE FROM booking_schedule_slot'.
362 ' WHERE booking_schedule_id = '.$ilDB->quote($this->id,
'integer'));
369 foreach($slots as $slot_id => $times)
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)
377 $ilDB->insert(
'booking_schedule_slot', $fields);
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);
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');
416 while(
$row = $ilDB->fetchAssoc($set))
418 if(!
$row[
'object_has_schedule'])
420 $row[
'is_used'] =
false;
424 $row[
'is_used'] =
true;
441 return $ilDB->manipulate(
'DELETE FROM booking_schedule'.
442 ' WHERE booking_schedule_id = '.$ilDB->quote($this->id,
'integer'));
455 foreach($def as $day => $times)
457 foreach($times as $time)
459 $slots[$time][] = $day;
462 foreach($slots as $time => $days)
464 $slots[$time] = array_unique($days);
473 foreach($a_def as $time => $days)
475 foreach($days as $day)
477 $slots[$day][] = $time;
getAutoBreak()
Get break time.
setRaster($a_raster)
Set booking raster (in minutes)
setDefinition($a_definition)
Set definition.
getDefinitionBySlots()
Return definition grouped by slots (not days)
static hasExistingSchedules($a_pool_id)
Check if given pool has any defined schedules.
setAvailabilityFrom(ilDateTime $a_date=null)
Set availability start.
setMinRental($a_min)
Set minimum rental time.
getAvailabilityFrom()
Get availability start.
schedule for booking ressource
getRaster()
Get booking raster.
getAvailabilityTo()
Get availability end.
update()
Update entry in db.
__construct($a_id=NULL)
Constructor.
getMinRental()
Get minimum rental time.
setAutoBreak($a_break)
Set break time.
getDeadline()
Get deadline.
setMaxRental($a_max)
Set maximum rental time.
setDeadline($a_deadline)
Set deadline.
setDefinitionBySlots(array $a_def)
getPoolId()
Get booking pool id.
getDefinition()
Get definition.
Create styles array
The data for the language used.
saveDefinition()
Save current definition.
getTitle()
Get object title.
setPoolId($a_pool_id)
Set booking pool id (aka parent obj ref id)
setTitle($a_title)
Set object title.
setAvailabilityTo(ilDateTime $a_date=null)
Set availability end.
static getList($a_pool_id)
Get list of booking objects for given pool.
save()
Create new entry in db.
getMaxRental()
Get maximum rental time.
read()
Get dataset from db.