26 protected \ILIAS\DI\UIServices
$ui;
27 protected \ILIAS\BookingManager\InternalService
$service;
48 int $context_obj_id = 0
52 $this->tpl = $DIC->ui()->mainTemplate();
54 $this->
ctrl = $DIC->ctrl();
56 $this->
lng = $DIC->language();
57 $this->
access = $DIC->access();
58 $this->tabs_gui = $DIC->tabs();
60 $this->
user = $DIC->user();
61 $this->book_request = $DIC->bookingManager()
65 $this->service = $DIC->bookingManager()->internal();
66 $this->
ui = $DIC->ui();
67 $this->
toolbar = $DIC->toolbar();
69 $this->book_obj_id = $this->book_request->getObjectId();
74 $this->booked_user = $this->book_request->getBookedUser();
75 if ($this->booked_user === 0) {
76 $this->booked_user = $DIC->user()->getId();
79 $this->reservation_id = $this->book_request->getReservationId();
81 $this->
ctrl->saveParameter($this, [
"object_id",
"bkusr"]);
84 throw new ilException(
"Booking Object ID does not match Booking Pool.");
87 $this->raw_post_data = $DIC->http()->request()->getParsedBody();
95 $mrsv = $this->book_request->getReservationIds();
96 if (count($mrsv) > 0) {
99 if ($this->reservation_id > 0) {
100 return array($this->reservation_id);
110 $cmd = $ctrl->
getCmd(
"log");
112 switch ($next_class) {
114 if (in_array($cmd, array(
"log",
"logDetails",
"changeStatusObject",
"rsvConfirmCancelUser",
"rsvCancelUser",
115 "applyLogFilter",
"resetLogFilter",
"rsvConfirmCancel",
"rsvCancel",
"back",
"rsvConfirmDelete",
"rsvDelete",
"confirmResetRun",
"resetRun"))) {
123 $this->
help->setHelpId($a_id);
129 public function log(): void
141 ?
string $reservation_id = null
146 if ($this->book_obj_id > 0) {
150 if ($this->book_request->getUserId() > 0) {
151 $filter[
"user_id"] = $this->book_request->getUserId();
153 $context_filter = ($this->context_obj_id > 0)
154 ? [$this->context_obj_id]
161 $this->pool->getId(),
174 $this->tabs_gui->clearTargets();
175 $this->tabs_gui->setBackTarget(
176 $this->
lng->txt(
"back"),
177 $this->
ctrl->getLinkTarget($this,
"log")
189 $rsv_ids = $this->book_request->getReservationIds();
190 if (count($rsv_ids) === 0) {
191 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
198 $this->book_request->getStatus()
202 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
203 $this->
ctrl->redirect($this,
'log');
209 $table->resetOffset();
210 $table->writeFilterToSession();
217 $table->resetOffset();
218 $table->resetFilter();
224 return $this->
access->checkAccess($a_perm,
"", $this->ref_id);
253 $conf->setFormAction($ilCtrl->getFormAction($this));
254 $conf->setHeaderText($lng->
txt(
'book_confirm_cancel'));
257 $conf->addItem(
'object_id',
$id,
$type->getTitle());
258 $conf->setConfirm($lng->
txt(
'book_set_cancel'),
'rsvCancelUser');
259 $conf->setCancel($lng->
txt(
'cancel'),
'back');
274 if (!
$id || !$user_id) {
281 if ($obj->getUserId() !== $user_id) {
282 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'permission_denied'),
true);
289 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
'settings_saved'),
true);
296 protected function back(): void
298 $this->
ctrl->redirect($this,
"log");
312 if (count($ids) === 0) {
316 foreach ($ids as $idx =>
$id) {
317 if (!is_numeric(
$id)) {
318 [$obj_id, $user_id, $from, $to] = explode(
"_",
$id);
320 $valid_ids = array();
322 $valid_ids[$item[
"booking_object_id"]] = $item[
"title"];
324 if (array_key_exists($obj_id, $valid_ids) && $from > time() && ($this->
checkPermissionBool(
"write") || (
int) $user_id ===
$ilUser->getId())) {
326 if (!count($rsv_ids)) {
329 if (count($rsv_ids) > 1) {
330 $max[
$id] = count($rsv_ids);
331 $ids[$idx] = $rsv_ids;
334 $ids[$idx] = array_shift($rsv_ids);
342 if (!is_array($ids) || !count($ids)) {
343 $this->
ctrl->redirect($this,
'log');
347 if (count($max) && max($max) > 1) {
352 $this->tabs_gui->clearTargets();
353 $this->tabs_gui->setBackTarget(
355 $ilCtrl->getLinkTargetByClass(
"ilBookingReservationsGUI",
"")
361 $conf->setFormAction($ilCtrl->getFormAction($this,
'rsvCancel'));
362 $conf->setHeaderText($lng->
txt(
'book_confirm_cancel'));
363 $conf->setConfirm($lng->
txt(
'book_set_cancel'),
'rsvCancel');
364 $conf->setCancel($lng->
txt(
'cancel'),
'back');
366 foreach ($ids as
$id) {
378 $conf->addItem(
'rsv_id[]', $id, $details);
395 $this->tabs_gui->clearTargets();
396 $this->tabs_gui->setBackTarget(
398 $ilCtrl->getLinkTarget($this,
"log")
404 $this->tpl->setOnScreenMessage(
'question', $lng->
txt(
"book_confirm_cancel"));
418 $form->setFormAction($this->
ctrl->getFormAction($this,
"rsvCancel"));
419 $form->setTitle($this->
lng->txt(
"book_confirm_cancel_aggregation"));
423 foreach ($a_ids as $idx => $ids) {
425 if (is_array($ids)) {
426 $first = array_shift($first);
438 if (is_array($ids)) {
439 $caption .=
" (" . count($ids) .
")";
443 $item->setRequired(
true);
444 $item->setMinValue(0);
446 $form->addItem($item);
448 if (is_array($ids)) {
449 $item->setMaxValue(count($ids));
451 foreach ($ids as
$id) {
453 $hidden->setValue($id);
454 $form->addItem($hidden);
457 $item->setMaxValue(1);
460 $hidden->setValue($ids);
461 $form->addItem($hidden);
464 if ($this->book_request->getCancelNr($idx)) {
465 $item->setValue($this->book_request->getCancelNr($idx));
469 $form->addCommandButton(
"rsvCancel", $this->
lng->txt(
"confirm"));
470 $form->addCommandButton(
"log", $this->
lng->txt(
"cancel"));
486 $ids = $this->book_request->getReservationIds();
488 $rsv_aggr = $this->raw_post_data[
"rsv_aggr"] ?? null;
490 if (!is_null($rsv_aggr)) {
492 if (!$form->checkInput()) {
493 $this->tabs_gui->clearTargets();
494 $this->tabs_gui->setBackTarget(
496 $ilCtrl->getLinkTarget($this,
"log")
504 foreach ($rsv_aggr as $idx => $aggr_ids) {
505 $max = $this->book_request->getCancelNr($idx);
507 if (!is_array($aggr_ids)) {
510 $aggr_ids = array_slice($aggr_ids, 0, $max);
511 $ids = array_merge($ids, $aggr_ids);
519 foreach ($ids as
$id) {
525 if (!$cancel_allowed_per_read && !$cancel_allowed_per_write) {
526 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
527 $this->
ctrl->redirect($this,
'log');
535 $cal_entry_id =
$res->getCalendarEntry();
544 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'));
552 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
553 $this->
ctrl->redirect($this,
'log');
557 if (count($ids) === 0) {
561 $this->tabs_gui->clearTargets();
562 $this->tabs_gui->setBackTarget(
563 $this->
lng->txt(
"back"),
564 $this->
ctrl->getLinkTarget($this,
"log")
568 $conf->setFormAction($this->
ctrl->getFormAction($this,
'rsvDelete'));
569 $conf->setHeaderText($this->
lng->txt(
'book_confirm_delete'));
570 $conf->setConfirm($this->
lng->txt(
'book_set_delete'),
'rsvDelete');
571 $conf->setCancel($this->
lng->txt(
'cancel'),
'log');
574 foreach ($ids as $idx =>
$id) {
575 [$obj_id, $user_id, $from, $to] = explode(
"_",
$id);
577 $rsv_id = $rsv_ids[0];
582 $details = sprintf($this->
lng->txt(
'X_reservations_of'), count($rsv_ids)) .
' ' . $obj->getTitle();
587 $conf->addItem(
'mrsv[]',
$id, $details);
590 foreach ($ids as $idx => $rsv_id) {
593 $details = sprintf($this->
lng->txt(
'X_reservations_of'), 1) .
' ' . $obj->getTitle();
594 $conf->addItem(
'mrsv[]', $rsv_id, $details);
597 $this->tpl->setContent($conf->getHTML());
603 $get = $DIC->http()->request()->getParsedBody()[
'mrsv'];
605 foreach ($get as
$id) {
607 list($obj_id, $user_id, $from, $to) = explode(
"_", $id);
613 foreach ($rsv_ids as $rsv_id) {
617 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
618 $this->
ctrl->redirect($this,
'log');
621 $cal_entry_id =
$res->getCalendarEntry();
631 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'reservation_deleted'),
true);
632 $this->
ctrl->redirect($this,
'log');
641 $pref_manager = $this->service->domain()->preferences($this->pool);
642 if ($pref_manager->hasRun()) {
643 $this->
toolbar->addComponent($this->
ui->factory()->button()->standard(
644 $this->
lng->txt(
"book_rerun_assignments"),
645 $this->
ctrl->getLinkTarget($this,
"confirmResetRun")
656 $this->tabs_gui->activateTab(
"log");
657 $mess = $this->
ui->factory()->messageBox()->confirmation($this->
lng->txt(
"book_rerun_confirmation"))->withButtons(
659 $this->
ui->factory()->button()->standard(
660 $this->
lng->txt(
"book_rerun_assignments"),
661 $this->
ctrl->getLinkTarget($this,
"resetRun")
663 $this->
ui->factory()->button()->standard(
664 $this->
lng->txt(
"cancel"),
665 $this->
ctrl->getLinkTarget($this,
"log")
669 $this->tpl->setContent(
670 $this->
ui->renderer()->render($mess)
680 && $this->
access->checkAccess(
"write",
"", $this->pool->getRefId())) {
681 $pref_manager = $this->service->domain()->preferences($this->pool);
682 $repo = $this->service->repo()->preferences();
683 $pref_manager->resetRun();
684 $pref_manager->storeBookings(
685 $repo->getPreferences($this->pool->getId())
688 $this->
ctrl->redirect($this,
"log");
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...
static changeStatus(array $a_ids, int $a_status)
Batch update reservation status.
rsvCancelUser()
(C1.a) Confirmed (C1)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getCmd(string $fallback_command=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS BookingManager InternalService $service
static getObjectReservationForUser(int $a_object_id, int $a_user_id)
back()
Back to reservation list.
rsvConfirmCancel()
(C2) Confirmation screen for canceling booking from reservations screen (with and without schedule) ...
ilBookingHelpAdapter $help
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getReservationsTable(?string $reservation_id=null)
Get reservationsTable.
getLogReservationIds()
Reservations IDs as currently provided from.
showRerunPreferenceAssignment()
getNextClass($a_gui_class=null)
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
rsvConfirmCancelUser()
(C1) Confirmation screen for canceling booking without schedule from booking objects screen or from p...
static getCancelDetails(int $a_obj_id, int $a_user_id, int $a_from, int $a_to)
Get reservation ids from aggregated id for cancellation.
__construct(ilObjBookingPool $pool, ilBookingHelpAdapter $help, int $context_obj_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
changeStatusObject()
Change status of given reservations.
ILIAS BookingManager StandardGUIRequest $book_request
rsvConfirmCancelAggregationForm(array $a_ids)
Form being used in (C2.a)
static lookupPoolId(int $object_id)
const TYPE_NO_SCHEDULE_PREFERENCES
static setUseRelativeDates(bool $a_status)
set use relative dates
static getList(int $a_pool_id, string $a_title=null)
Get list of booking objects.
checkPermissionBool(string $a_perm)
rsvCancel()
(C2.b) Cancel reservations (coming from C2 or C2.a)
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...
rsvConfirmCancelAggregation(array $a_ids=null)
(C2.a) Cancel aggregated booking from reservations screen (with and without schedule) called in (C2) ...