25 protected \ILIAS\BookingManager\Access\AccessManager
$access;
29 protected \ILIAS\BookingManager\Reservations\ReservationManager
$reservation;
30 protected \ILIAS\BookingManager\BookingProcess\ProcessUtilGUI
$util_gui;
31 protected \ILIAS\BookingManager\InternalRepoService
$repo;
32 protected \ILIAS\BookingManager\BookingProcess\BookingProcessManager
$process;
33 protected \ILIAS\HTTP\Services
$http;
34 protected \ILIAS\BookingManager\InternalGUIService
$gui;
61 $this->
ctrl = $DIC->ctrl();
62 $this->tpl =
$DIC[
"tpl"];
63 $this->
lng = $DIC->language();
64 $this->tabs_gui =
$DIC->tabs();
65 $this->
user = $DIC->user();
66 $this->
http = $DIC->http();
75 $internal_service =
$DIC->bookingManager()->internal();
76 $this->gui = $internal_service->gui();
77 $domain = $internal_service->domain();
78 $this->book_request = $this->gui->standardRequest();
79 $this->
help = $this->gui->bookingHelp(
$pool);
80 $this->log = $domain->log();
82 $this->repo = $internal_service->repo();
84 $this->object_manager = $domain->objects(
$pool->
getId());
85 $this->object_selection = $domain->objectSelection(
$pool->
getId());
87 $this->rsv_ids = $this->book_request->getReservationIdsFromString();
89 $this->raw_post_data =
$DIC->http()->request()->getParsedBody();
91 $this->user_id_assigner = $this->
user->getId();
92 if ($this->book_request->getBookedUser() > 0) {
93 $this->user_id_to_book = $this->book_request->getBookedUser();
97 $this->
ctrl->saveParameter($this, [
"bkusr",
"returnCmd"]);
98 $this->
ctrl->setParameter($this,
"seed", $this->seed);
100 $this->process =
$DIC->bookingManager()->internal()->domain()->process();
101 $this->reservation =
$DIC->bookingManager()->internal()->domain()->reservations();
102 $this->util_gui =
$DIC->bookingManager()->internal()->gui()->process()->ProcessUtilGUI(
106 $this->
access = $DIC->bookingManager()->internal()->domain()->access();
115 switch ($next_class) {
117 if (in_array($cmd, array(
"book",
"back",
"week",
118 "assignParticipants",
119 "bookMultipleParticipants",
120 "saveMultipleBookings",
125 "bookAvailableItems",
128 "redirectToParticipantsList"
137 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_permission"),
true);
151 $this->log->debug(
"Step 0, week");
156 $this->util_gui->setHelpId(
"week");
157 $this->
ctrl->setParameter($this,
'returnCmd',
"week");
159 if ($this->user_id_to_book !== $this->user_id_assigner) {
160 $this->
ctrl->setParameter($this,
'bkusr', $this->user_id_to_book);
164 $week_gui = new \ILIAS\BookingManager\BookingProcess\WeekGUI(
167 $this->object_selection->getSelectedObjects(),
168 $this->pool->getId(),
170 $user_settings->getWeekStart()
174 $book_week = $this->
lng->txt(
'book_week');
175 $mode_control = $this->gui->ui()->factory()->viewControl()->mode(
177 $this->
lng->txt(
'book_table') => $this->ctrl->getLinkTargetByClass(ilObjBookingPoolGUI::class,
'render'),
178 $book_week => $this->ctrl->getLinkTarget($this,
'week')
180 $this->lng->txt(
'book_view')
181 )->withActive($book_week);
182 $this->gui->toolbar()->addComponent($mode_control);
184 $list_gui = new \ILIAS\BookingManager\BookingProcess\ObjectSelectionListGUI(
185 $this->pool->getId(),
186 $this->ctrl->getFormAction($this,
"selectObjects")
193 $this->log->debug(
"selectObjects");
194 $obj_ids = $this->book_request->getObjectIds();
195 $this->object_selection->setSelectedObjects($obj_ids);
196 $this->
ctrl->redirect($this,
"week");
212 $this->log->debug(
"Step 1, book");
215 $this->tabs_gui->clearTargets();
216 $this->tabs_gui->setBackTarget($this->
lng->txt(
'book_back_to_list'), $this->ctrl->getLinkTarget($this,
'back'));
218 $this->util_gui->setHelpId(
"book");
222 $this->
lng->loadLanguageModule(
"dateplaner");
223 $this->
ctrl->setParameter($this,
'object_id', $obj->getId());
224 $this->
ctrl->setParameter($this,
'returnCmd',
'week');
226 if ($this->user_id_to_book !== $this->user_id_assigner) {
227 $this->
ctrl->setParameter($this,
'bkusr', $this->user_id_to_book);
230 if (!$this->
access->canManageReservationForUser($this->book_request->getRefId(), $this->user_id_to_book)) {
236 $week_gui = new \ILIAS\BookingManager\BookingProcess\WeekGUI(
240 $this->pool->getId(),
242 $user_settings->getWeekStart()
250 $this->util_gui->assignParticipants($this->book_obj_id);
255 $this->log->debug(
"showNumberForm");
257 $from = $this->book_request->getSlotFrom();
258 $to = $this->book_request->getSlotTo() - 1;
259 $this->tabs_gui->clearTargets();
260 $this->tabs_gui->setBackTarget(
261 $this->
lng->txt(
'book_back_to_list'),
262 $this->ctrl->getLinkTarget($this,
'back')
283 ): \
ILIAS\Repository\Form\FormAdapterGUI {
284 $counter = $this->reservation->getAvailableNr($this->book_request->
getObjectId(), $from, $to);
289 $this->
ctrl->setParameter($this,
"slot", $from .
"_" . $to);
290 $form = $this->gui->form([self::class],
"processNumberForm")
294 $this->
lng->txt(
"book_confirm_booking_schedule_number_of_objects"),
295 $this->lng->txt(
"book_confirm_booking_schedule_number_of_objects_info")
297 ->number(
"nr", $period,
"", 1, 1, $counter)
298 ->radio(
"recurrence", $this->
lng->txt(
"book_recurrence"),
"",
"0")
299 ->radioOption(
"0", $this->
lng->txt(
"book_no_recurrence"))
300 ->radioOption(
"1", $this->
lng->txt(
"book_book_recurrence"))
301 ->hidden(
"origin_cmd", $this->book_request->getOriginCmd());
302 if ($this->pool->usesMessages()) {
303 $form = $form->textarea(
305 $this->
lng->txt(
"book_message"),
306 $this->lng->txt(
"book_message_info")
314 $this->log->debug(
"processNumberForm");
316 if ($this->book_request->getBookedUser() > 0) {
317 $this->user_id_to_book = $this->book_request->getBookedUser();
319 $slot = $this->book_request->getSlot();
320 $from = $this->book_request->getSlotFrom();
321 $to = $this->book_request->getSlotTo();
322 $obj_id = $this->book_request->getObjectId();
324 if ($this->user_id_assigner !== $this->user_id_to_book) {
325 $this->
ctrl->setParameterByClass(self::class,
"bkusr", $this->user_id_to_book);
327 $this->
ctrl->setParameterByClass(self::class,
"slot", $slot);
330 $form = $this->getNumberForm($from, $to);
331 if (!$form->isValid()) {
332 $this->gui->modal($this->getBookgingObjectTitle())
337 $origin_cmd = $form->getData(
"origin_cmd");
338 if (is_string($origin_cmd) && $origin_cmd !==
"") {
339 $this->origin_cmd = $origin_cmd;
342 $message = $this->pool->usesMessages()
343 ? $form->getData(
"message")
347 $recurrence = $form->getData(
"recurrence");
348 if ($recurrence ===
"1") {
349 if ($this->pool->usesMessages()) {
350 $this->
ctrl->setParameterByClass(
356 $this->
ctrl->setParameterByClass(self::class,
"object_id", $this->book_request->getObjectId());
357 $this->
ctrl->setParameterByClass(self::class,
"nr", (
int) $form->getData(
"nr"));
358 $form = $this->getRecurrenceForm();
359 $this->gui->modal($this->getBookgingObjectTitle())
363 $this->checkAvailability(
365 $form->getData(
"nr"),
373 $this->
lng->loadLanguageModule(
"dateplaner");
375 $form = $this->gui->form([self::class],
"checkAvailability")
378 $this->
lng->txt(
"book_confirm_booking_schedule_number_of_objects"),
379 $this->lng->txt(
"book_confirm_booking_schedule_number_of_objects_info")
381 ->switch(
"recurrence", $this->
lng->txt(
"cal_recurrences"),
"",
"1")
382 ->group(
"1", $this->
lng->txt(
"cal_weekly"))
383 ->date(
"until1", $this->
lng->txt(
"cal_repeat_until"),
"", $today)
384 ->group(
"2", $this->
lng->txt(
"r_14"))
385 ->date(
"until2", $this->
lng->txt(
"cal_repeat_until"),
"", $today)
386 ->group(
"4", $this->
lng->txt(
"r_4_weeks"))
387 ->date(
"until4", $this->
lng->txt(
"cal_repeat_until"),
"", $today)
393 bool $incl_recurrence =
true,
397 $this->log->debug(
"checkAvailability");
398 $obj_id = $this->book_request->getObjectId();
399 $from = $this->book_request->getSlotFrom();
400 $to = $this->book_request->getSlotTo();
402 $nr = $this->book_request->getNr();
404 if (
$message ===
"" && $this->pool->usesMessages()) {
405 $message = $this->book_request->getMessage();
409 if ($incl_recurrence) {
410 $form = $this->getRecurrenceForm();
412 if (!$form->isValid()) {
413 $this->gui->modal($this->getBookgingObjectTitle())
418 $recurrence = (
int) $form->getData(
"recurrence");
419 $until = $form->getData(
"until" . $recurrence);
423 $this->
ctrl->saveParameter($this, [
"object_id",
"slot",
"nr"]);
424 if ($this->pool->usesMessages()) {
425 $this->
ctrl->setParameter(
431 $this->
ctrl->setParameter($this,
"recurrence", $recurrence);
432 $this->
ctrl->setParameter($this,
"until", $until_ts);
433 $book_available_target = $this->getBookAvailableTarget(
435 $this->book_request->getSlot(),
441 if ($incl_recurrence) {
443 $missing = $this->process->getRecurrenceMissingAvailability(
453 if (count($missing) > 0) {
454 $html = $this->getMissingAvailabilityMessage($missing);
455 $this->gui->modal($this->getBookgingObjectTitle())
458 $this->
lng->txt(
"book_book_available"),
459 $book_available_target,
465 $this->gui->send(
"<script>window.location.href = '" . $book_available_target .
"';</script>");
470 $f = $this->gui->ui()->factory();
471 $box =
$f->messageBox()->failure($this->
lng->txt(
"book_missing_availability"));
472 $items = array_map(
function ($i) {
475 return $from .
" - " . $to .
" : " . str_replace(
"$1", $i[
"missing"], $this->
lng->txt(
"book_missing_items"));
478 $list =
$f->listing()->unordered($items);
479 return $this->gui->ui()->renderer()->render([$box, $list]);
484 if (!$this->
access->canManageReservationForUser($this->pool->getRefId(), $this->user_id_to_book)) {
485 $this->showNoPermission();
488 $this->log->debug(
"bookAvailableItems");
489 $obj_id = $this->book_request->getObjectId();
490 $from = $this->book_request->getSlotFrom();
491 $to = $this->book_request->getSlotTo();
492 $nr = $this->book_request->getNr();
493 $message = $this->pool->usesMessages()
494 ? $this->book_request->getMessage()
496 if (is_null($recurrence)) {
497 $recurrence = (
int) $this->book_request->getRecurrence();
499 if (is_null($until)) {
500 if ($this->book_request->getUntil() > 0) {
505 $booked = $this->process->bookAvailableObjects(
507 $this->user_id_to_book,
508 $this->user_id_assigner,
509 $this->context_obj_id,
517 if ($booked !== []) {
518 $this->util_gui->handleBookingSuccess($obj_id,
'displayPostInfo', $booked);
522 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'book_reservation_failed'),
true);
523 $this->util_gui->back();
533 $this->
ctrl->setParameter($this,
"obj_id", $obj_id);
534 $this->
ctrl->setParameter($this,
"slot", $slot);
535 $this->
ctrl->setParameter($this,
"recurrence", $recurrence);
536 $this->
ctrl->setParameter($this,
"nr", $nr);
537 $this->
ctrl->setParameter($this,
"until", $until);
538 if (is_string($this->origin_cmd) && $this->origin_cmd !==
"") {
539 $this->
ctrl->setParameter($this,
"origin_cmd", $this->origin_cmd);
541 return $this->
ctrl->getLinkTarget($this,
"bookAvailableItems");
546 $this->util_gui->displayPostInfo(
548 $this->user_id_assigner,
555 $this->util_gui->deliverPostFile(
557 $this->user_id_assigner
563 $this->util_gui->back();
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS BookingManager StandardGUIRequest $book_request
ilBookingHelpAdapter $help
ILIAS BookingManager Access AccessManager $access
week()
First step in booking process.
ILIAS HTTP Services $http
ILIAS BookingManager InternalGUIService $gui
bookAvailableItems(?int $recurrence=null, ?ilDateTime $until=null)
ILIAS BookingManager BookingProcess BookingProcessManager $process
__construct(ilObjBookingPool $pool, int $booking_object_id, string $seed="", int $context_obj_id=0)
checkAvailability(bool $incl_recurrence=true, int $nr=0, string $message="")
getNumberForm(int $from, int $to)
getMissingAvailabilityMessage(array $missing)
ILIAS BookingManager InternalRepoService $repo
ILIAS BookingManager Objects ObjectsManager $object_manager
book()
Triggered from object list week view for booking a single object / confirmation for.
ILIAS BookingManager BookingProcess ObjectSelectionManager $object_selection
ilGlobalTemplateInterface $tpl
ILIAS BookingManager BookingProcess ProcessUtilGUI $util_gui
ILIAS BookingManager Reservations ReservationManager $reservation
getBookAvailableTarget(int $obj_id, string $slot, int $recurrence, int $nr, int $until)
static _getInstanceByUserId(int $a_user_id)
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
@classDescription Date and time handling
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRightContent(string $a_html)
Sets content of right column.
setContent(string $a_html)
Sets content for standard template.
static http()
Fetches the global http state from ILIAS.
getObjectId()
Get the object ID of the object that contains the questions.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.