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'));
243 $row =
$ilDB->fetchAssoc($set);
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'));
260 while ($row =
$ilDB->fetchAssoc($set)) {
261 $definition[$row[
"day_id"]][$row[
"slot_id"]] = $row[
"times"];
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') .
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);
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);
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');
418 while ($row =
$ilDB->fetchAssoc($set)) {
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;
An exception for terminatinating execution or to throw for unit testing.
schedule for booking ressource
getAutoBreak()
Get break time.
setTitle($a_title)
Set object title.
getRaster()
Get booking raster.
setDefinitionBySlots(array $a_def)
setDeadline($a_deadline)
Set deadline.
static hasExistingSchedules($a_pool_id)
Check if given pool has any defined schedules.
setPoolId($a_pool_id)
Set booking pool id (aka parent obj ref id)
saveDefinition()
Save current definition.
getDeadline()
Get deadline.
getMaxRental()
Get maximum rental time.
getAvailabilityTo()
Get availability end.
save()
Create new entry in db.
setRaster($a_raster)
Set booking raster (in minutes)
getAvailabilityFrom()
Get availability start.
update()
Update entry in db.
setDefinition($a_definition)
Set definition.
getMinRental()
Get minimum rental time.
getDefinition()
Get definition.
getDefinitionBySlots()
Return definition grouped by slots (not days)
setAutoBreak($a_break)
Set break time.
setMaxRental($a_max)
Set maximum rental time.
__construct($a_id=null)
Constructor.
static getList($a_pool_id)
Get list of booking objects for given pool.
setMinRental($a_min)
Set minimum rental time.
setAvailabilityFrom(ilDateTime $a_date=null)
Set availability start.
read()
Get dataset from db.
setAvailabilityTo(ilDateTime $a_date=null)
Set availability end.
getTitle()
Get object title.
getPoolId()
Get booking pool id.
@classDescription Date and time handling
foreach($_POST as $key=> $value) $res