42 $this->db = $DIC->database();
43 $this->
id = (int) $a_id;
53 $this->title = $a_title;
71 $this->pool_id = (int) $a_pool_id;
89 $this->raster = (int) $a_raster;
107 $this->rent_min = (int) $a_min;
125 $this->rent_max = (int) $a_max;
143 $this->auto_break = (int) $a_break;
161 $this->deadline = (int) $a_deadline;
179 $this->definition = $a_definition;
198 $this->av_from = $a_date;
218 $this->av_to = $a_date;
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'));
248 if (
$row[
'raster']) {
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'));
279 $this->
id =
$ilDB->nextId(
'booking_schedule');
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') .
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') .
331 ' WHERE booking_schedule_id = ' .
$ilDB->quote($this->
id,
'integer'));
338 $new_obj =
new self();
339 $new_obj->setPoolId($a_pool_id);
340 $new_obj->setTitle($this->
getTitle());
349 return $new_obj->save();
363 $ilDB->manipulate(
'DELETE FROM booking_schedule_slot' .
364 ' WHERE booking_schedule_id = ' .
$ilDB->quote($this->id,
'integer'));
369 foreach ($slots as $slot_id => $times) {
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)
376 $ilDB->insert(
'booking_schedule_slot', $fields);
391 $ilDB = $DIC->database();
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 $ilDB = $DIC->database();
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');
419 if (!
$row[
'object_has_schedule']) {
420 $row[
'is_used'] =
false;
422 $row[
'is_used'] =
true;
433 public function delete()
438 return $ilDB->manipulate(
'DELETE FROM booking_schedule' .
439 ' WHERE booking_schedule_id = ' .
$ilDB->quote($this->id,
'integer'));
452 foreach (
$def as $day => $times) {
453 foreach ($times as
$time) {
454 $slots[
$time][] = $day;
457 foreach ($slots as
$time => $days) {
458 $slots[
$time] = array_unique($days);
467 foreach ($a_def as
$time => $days) {
468 foreach ($days as $day) {
469 $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.
foreach($_POST as $key=> $value) $res
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.