ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBookingSchedule Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilBookingSchedule:

Public Member Functions

 __construct (?int $a_id=null)
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPoolId (int $a_pool_id)
 
 getPoolId ()
 
 setRaster (int $a_raster)
 Set booking raster (in minutes) More...
 
 getRaster ()
 
 setMinRental (int $a_min)
 Set minimum rental time. More...
 
 getMinRental ()
 
 setMaxRental (int $a_max)
 Set maximum rental time. More...
 
 getMaxRental ()
 
 setAutoBreak (int $a_break)
 
 getAutoBreak ()
 
 setDeadline (int $a_deadline)
 Set deadline. More...
 
 getDeadline ()
 
 setDefinition (array $a_definition)
 Set definition. More...
 
 getDefinition ()
 
 setAvailabilityFrom (?ilDateTime $a_date=null)
 
 getAvailabilityFrom ()
 
 setAvailabilityTo (?ilDateTime $a_date=null)
 
 getAvailabilityTo ()
 
 save ()
 
 update ()
 
 doClone (int $a_pool_id)
 
 delete ()
 
 getDefinitionBySlots ()
 Return definition grouped by slots (not days) More...
 
 setDefinitionBySlots (array $a_def)
 

Static Public Member Functions

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

Protected Member Functions

 read ()
 
 saveDefinition ()
 Save current definition (slots) More...
 

Protected Attributes

ilDBInterface $db
 
int $id = 0
 
string $title = ""
 
int $pool_id = 0
 
int $raster = 0
 
int $rent_min = 0
 
int $rent_max = 0
 
int $auto_break = 0
 
int $deadline = 0
 
array $definition
 
ilDateTime $av_from = null
 
ilDateTime $av_to = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

ilBookingSchedule::__construct ( ?int  $a_id = null)

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

40 {
41 global $DIC;
42
43 $this->db = $DIC->database();
44 $this->id = (int) $a_id;
45 $this->read();
46 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\int(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingSchedule::delete ( )

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

357 : int
358 {
360
361 if ($this->id) {
362 return $ilDB->manipulate('DELETE FROM booking_schedule' .
363 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
364 }
365 return 0;
366 }

References $ilDB.

◆ doClone()

ilBookingSchedule::doClone ( int  $a_pool_id)

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

267 : int
268 {
269 $new_obj = new self();
270 $new_obj->setPoolId($a_pool_id);
271 $new_obj->setTitle($this->getTitle());
272 $new_obj->setRaster($this->getRaster());
273 $new_obj->setMinRental($this->getMinRental());
274 $new_obj->setMaxRental($this->getMaxRental());
275 $new_obj->setAutoBreak($this->getAutoBreak());
276 $new_obj->setDeadline($this->getDeadline());
277 $new_obj->setDefinition($this->getDefinition());
278 $new_obj->setAvailabilityFrom($this->getAvailabilityFrom());
279 $new_obj->setAvailabilityTo($this->getAvailabilityTo());
280 return $new_obj->save();
281 }

References ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

◆ getAutoBreak()

ilBookingSchedule::getAutoBreak ( )

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

118 : int
119 {
120 return $this->auto_break;
121 }

◆ getAvailabilityFrom()

ilBookingSchedule::getAvailabilityFrom ( )

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

156 : ?ilDateTime
157 {
158 return $this->av_from;
159 }
@classDescription Date and time handling

◆ getAvailabilityTo()

ilBookingSchedule::getAvailabilityTo ( )

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

167 : ?ilDateTime
168 {
169 return $this->av_to;
170 }

◆ getDeadline()

ilBookingSchedule::getDeadline ( )

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

131 : int
132 {
133 return $this->deadline;
134 }

◆ getDefinition()

ilBookingSchedule::getDefinition ( )

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

145 : array
146 {
147 return $this->definition;
148 }

◆ getDefinitionBySlots()

ilBookingSchedule::getDefinitionBySlots ( )

Return definition grouped by slots (not days)

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

371 : array
372 {
373 $def = $this->getDefinition();
374 $slots = array();
375 foreach ($def as $day => $times) {
376 foreach ($times as $time) {
377 $slots[$time][] = $day;
378 }
379 }
380 foreach ($slots as $time => $days) {
381 $slots[$time] = array_unique($days);
382 }
383 ksort($slots);
384 return $slots;
385 }

◆ getList()

static ilBookingSchedule::getList ( int  $a_pool_id)
static

Get list of booking objects for given pool.

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

332 : array
333 {
334 global $DIC;
335
336 $ilDB = $DIC->database();
337
338 $set = $ilDB->query('SELECT s.booking_schedule_id,s.title,' .
339 'MAX(o.schedule_id) AS object_has_schedule' .
340 ' FROM booking_schedule s' .
341 ' LEFT JOIN booking_object o ON (s.booking_schedule_id = o.schedule_id)' .
342 ' WHERE s.pool_id = ' . $ilDB->quote($a_pool_id, 'integer') .
343 ' GROUP BY s.booking_schedule_id,s.title' .
344 ' ORDER BY s.title');
345 $res = array();
346 while ($row = $ilDB->fetchAssoc($set)) {
347 if (!$row['object_has_schedule']) {
348 $row['is_used'] = false;
349 } else {
350 $row['is_used'] = true;
351 }
352 $res[] = $row;
353 }
354 return $res;
355 }
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, and $res.

◆ getMaxRental()

ilBookingSchedule::getMaxRental ( )

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

107 : int
108 {
109 return $this->rent_max;
110 }

◆ getMinRental()

ilBookingSchedule::getMinRental ( )

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

93 : int
94 {
95 return $this->rent_min;
96 }

◆ getPoolId()

ilBookingSchedule::getPoolId ( )

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

65 : int
66 {
67 return $this->pool_id;
68 }

◆ getRaster()

ilBookingSchedule::getRaster ( )

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

79 : int
80 {
81 return $this->raster;
82 }

◆ getTitle()

ilBookingSchedule::getTitle ( )

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

54 : string
55 {
56 return $this->title;
57 }

◆ hasExistingSchedules()

static ilBookingSchedule::hasExistingSchedules ( int  $a_pool_id)
static

Check if given pool has any defined schedules.

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

317 : bool
318 {
319 global $DIC;
320
321 $ilDB = $DIC->database();
322
323 $set = $ilDB->query("SELECT booking_schedule_id" .
324 " FROM booking_schedule" .
325 " WHERE pool_id = " . $ilDB->quote($a_pool_id, 'integer'));
326 return (bool) $ilDB->numRows($set);
327 }

References $DIC, and $ilDB.

◆ read()

ilBookingSchedule::read ( )
protected

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

172 : void
173 {
175
176 if ($this->id) {
177 $set = $ilDB->query('SELECT title,raster,rent_min,rent_max,auto_break,' .
178 'deadline,av_from,av_to' .
179 ' FROM booking_schedule' .
180 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
181 $row = $ilDB->fetchAssoc($set);
182 $this->setTitle($row['title'] ?? "");
183 $this->setDeadline($row['deadline'] ?? 0);
184 $this->setAvailabilityFrom($row['av_from'] ? new ilDateTime($row['av_from'], IL_CAL_UNIX) : null);
185 $this->setAvailabilityTo($row['av_to'] ? new ilDateTime($row['av_to'], IL_CAL_UNIX) : null);
186 if ($row['raster']) {
187 $this->setRaster($row['raster']);
188 $this->setMinRental($row['rent_min']);
189 $this->setMaxRental($row['rent_max']);
190 $this->setAutoBreak($row['auto_break']);
191 }
192
193 // load definition
194 $definition = array();
195 $set = $ilDB->query('SELECT day_id,slot_id,times' .
196 ' FROM booking_schedule_slot' .
197 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
198 while ($row = $ilDB->fetchAssoc($set)) {
199 $definition[$row["day_id"]][$row["slot_id"]] = $row["times"];
200 }
202 }
203 }
const IL_CAL_UNIX
setAvailabilityFrom(?ilDateTime $a_date=null)
setRaster(int $a_raster)
Set booking raster (in minutes)
setMinRental(int $a_min)
Set minimum rental time.
setMaxRental(int $a_max)
Set maximum rental time.
setDeadline(int $a_deadline)
Set deadline.
setAvailabilityTo(?ilDateTime $a_date=null)
setDefinition(array $a_definition)
Set definition.

References $ilDB, and IL_CAL_UNIX.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ save()

ilBookingSchedule::save ( )

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

205 : ?int
206 {
208
209 if ($this->id) {
210 return null;
211 }
212
213 $this->id = $ilDB->nextId('booking_schedule');
214
215 $av_from = ($this->getAvailabilityFrom() && !$this->getAvailabilityFrom()->isNull())
216 ? $this->getAvailabilityFrom()->get(IL_CAL_UNIX)
217 : null;
218 $av_to = ($this->getAvailabilityTo() && !$this->getAvailabilityTo()->isNull())
219 ? $this->getAvailabilityTo()->get(IL_CAL_UNIX)
220 : null;
221
222 $ilDB->manipulate('INSERT INTO booking_schedule' .
223 ' (booking_schedule_id,title,pool_id,raster,rent_min,rent_max,auto_break,' .
224 'deadline,av_from,av_to)' .
225 ' VALUES (' . $ilDB->quote($this->id, 'integer') . ',' . $ilDB->quote($this->getTitle(), 'text') .
226 ',' . $ilDB->quote($this->getPoolId(), 'integer') . ',' . $ilDB->quote($this->getRaster(), 'integer') .
227 ',' . $ilDB->quote($this->getMinRental(), 'integer') . ',' . $ilDB->quote($this->getMaxRental(), 'integer') .
228 ',' . $ilDB->quote($this->getAutoBreak(), 'integer') . ',' . $ilDB->quote($this->getDeadline(), 'integer') .
229 ',' . $ilDB->quote($av_from, 'integer') . ',' . $ilDB->quote($av_to, 'integer') . ')');
230
231 $this->saveDefinition();
232
233 return $this->id;
234 }
saveDefinition()
Save current definition (slots)

References $id, $ilDB, ilDateTime\get(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ saveDefinition()

ilBookingSchedule::saveDefinition ( )
protected

Save current definition (slots)

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

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

References $ilDB.

◆ setAutoBreak()

ilBookingSchedule::setAutoBreak ( int  $a_break)

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

113 : void
114 {
115 $this->auto_break = $a_break;
116 }

◆ setAvailabilityFrom()

ilBookingSchedule::setAvailabilityFrom ( ?ilDateTime  $a_date = null)

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

152 : void {
153 $this->av_from = $a_date;
154 }

Referenced by ilBookingScheduleGUI\formToObject().

+ Here is the caller graph for this function:

◆ setAvailabilityTo()

ilBookingSchedule::setAvailabilityTo ( ?ilDateTime  $a_date = null)

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

163 : void {
164 $this->av_to = $a_date;
165 }

◆ setDeadline()

ilBookingSchedule::setDeadline ( int  $a_deadline)

Set deadline.

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

126 : void
127 {
128 $this->deadline = $a_deadline;
129 }

◆ setDefinition()

ilBookingSchedule::setDefinition ( array  $a_definition)

Set definition.

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

141 : void {
142 $this->definition = $a_definition;
143 }

◆ setDefinitionBySlots()

ilBookingSchedule::setDefinitionBySlots ( array  $a_def)

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

387 : void
388 {
389 $slots = array();
390 foreach ($a_def as $time => $days) {
391 foreach ($days as $day) {
392 $slots[$day][] = $time;
393 }
394 }
395 $this->setDefinition($slots);
396 }

◆ setMaxRental()

ilBookingSchedule::setMaxRental ( int  $a_max)

Set maximum rental time.

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

103 : void {
104 $this->rent_max = $a_max;
105 }

◆ setMinRental()

ilBookingSchedule::setMinRental ( int  $a_min)

Set minimum rental time.

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

89 : void {
90 $this->rent_min = $a_min;
91 }

◆ setPoolId()

ilBookingSchedule::setPoolId ( int  $a_pool_id)

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

61 : void {
62 $this->pool_id = $a_pool_id;
63 }

◆ setRaster()

ilBookingSchedule::setRaster ( int  $a_raster)

Set booking raster (in minutes)

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

75 : void {
76 $this->raster = $a_raster;
77 }

◆ setTitle()

ilBookingSchedule::setTitle ( string  $a_title)

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

50 : void {
51 $this->title = $a_title;
52 }

◆ update()

ilBookingSchedule::update ( )

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

236 : bool
237 {
239
240 if (!$this->id) {
241 return false;
242 }
243
244 $av_from = ($this->getAvailabilityFrom() && !$this->getAvailabilityFrom()->isNull())
245 ? $this->getAvailabilityFrom()->get(IL_CAL_UNIX)
246 : null;
247 $av_to = ($this->getAvailabilityTo() && !$this->getAvailabilityTo()->isNull())
248 ? $this->getAvailabilityTo()->get(IL_CAL_UNIX)
249 : null;
250
251 $ilDB->manipulate('UPDATE booking_schedule' .
252 ' SET title = ' . $ilDB->quote($this->getTitle(), 'text') .
253 ', pool_id = ' . $ilDB->quote($this->getPoolId(), 'integer') .
254 ', raster = ' . $ilDB->quote($this->getRaster(), 'integer') .
255 ', rent_min = ' . $ilDB->quote($this->getMinRental(), 'integer') .
256 ', rent_max = ' . $ilDB->quote($this->getMaxRental(), 'integer') .
257 ', auto_break = ' . $ilDB->quote($this->getAutoBreak(), 'integer') .
258 ', deadline = ' . $ilDB->quote($this->getDeadline(), 'integer') .
259 ', av_from = ' . $ilDB->quote($av_from, 'integer') .
260 ', av_to = ' . $ilDB->quote($av_to, 'integer') .
261 ' WHERE booking_schedule_id = ' . $ilDB->quote($this->id, 'integer'));
262
263 $this->saveDefinition();
264 return true;
265 }

References $ilDB, ilDateTime\get(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

Field Documentation

◆ $auto_break

int ilBookingSchedule::$auto_break = 0
protected

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

◆ $av_from

ilDateTime ilBookingSchedule::$av_from = null
protected

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

◆ $av_to

ilDateTime ilBookingSchedule::$av_to = null
protected

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

◆ $db

ilDBInterface ilBookingSchedule::$db
protected

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

◆ $deadline

int ilBookingSchedule::$deadline = 0
protected

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

◆ $definition

array ilBookingSchedule::$definition
protected

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

◆ $id

int ilBookingSchedule::$id = 0
protected

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

◆ $pool_id

int ilBookingSchedule::$pool_id = 0
protected

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

◆ $raster

int ilBookingSchedule::$raster = 0
protected

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

◆ $rent_max

int ilBookingSchedule::$rent_max = 0
protected

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

◆ $rent_min

int ilBookingSchedule::$rent_min = 0
protected

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

◆ $title

string ilBookingSchedule::$title = ""
protected

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


The documentation for this class was generated from the following file: