19declare(strict_types=1);
35 protected \ilObjBookingPool
$pool;
36 protected \ilBookingHelpAdapter
$help;
40 protected \ilLanguage
$lng;
41 protected \ilGlobalTemplateInterface
$tpl;
49 $this->gui = $gui_service;
50 $this->domain = $domain_service;
51 $this->log = $domain_service->
log();
55 $this->
ctrl = $this->gui->ctrl();
56 $this->request = $this->gui->standardRequest();
58 $this->
lng = $domain_service->lng();
59 $this->tpl = $this->gui->mainTemplate();
63 public function back(): void
65 $this->log->debug(
"back");
66 $retCmd = $this->request->getReturnCmd();
67 $this->log->debug(
"returnCmd is " . $retCmd);
69 $class = get_class($this->parent_gui);
70 if ($retCmd ===
'week' && $class === ilBookingProcessWithScheduleGUI::class) {
71 if ($this->request->getOriginCmd() ===
'book') {
72 $this->domain->objectSelection($this->pool->getId())->setSelectedObjects([$this->request->getObjectId()]);
74 $this->
ctrl->setParameterByClass($class,
'seed', $this->request->getSeed());
75 $this->
ctrl->redirectByClass($class, $retCmd);
79 if ($retCmd ===
'render') {
85 $this->
ctrl->redirectByClass(get_class($this->parent_gui), $retCmd);
89 $this->
ctrl->returnToParent($this->parent_gui);
95 $this->
help->setHelpId($a_id);
101 $tabs = $this->gui->tabs();
102 $ctrl = $this->gui->ctrl();
103 $lng = $this->domain->lng();
104 $main_tpl = $this->gui->mainTemplate();
106 $tabs->clearTargets();
109 $table = new \ilBookingAssignParticipantsTableGUI($this->parent_gui,
'assignParticipants', $this->pool->getRefId(), $this->pool->getId(), $book_obj_id);
110 $main_tpl->setContent($table->getHTML());
137 string $post_info_cmd,
138 ?array $a_rsv_ids =
null,
141 $this->log->debug(
'handleBookingSuccess');
142 $this->tpl->setOnScreenMessage(
144 $message ?: $this->
lng->txt(
'book_reservation_confirmed'),
155 $obj = new \ilBookingObject($a_obj_id);
156 if (trim($obj->getPostText()) ===
'' && $this->objects_manager->getBookingInfoFilename($a_obj_id) ===
'') {
161 if ($a_rsv_ids !== []) {
162 $this->
ctrl->setParameter($this->parent_gui,
'rsv_ids', implode(
';', $a_rsv_ids));
164 $this->
ctrl->redirect($this->parent_gui, $post_info_cmd);
169 if (!$this->
ctrl->isAsynch()) {
174 "<script>window.location.href = '{$this->ctrl->getLinkTarget($this->parent_gui, $this->request->getReturnCmd())}';</script>"
180 $this->
ctrl->saveParameterByClass(\ilObjBookingPoolGUI::class,
'ref_id');
181 $this->
ctrl->redirectByClass(\ilObjBookingPoolGUI::class,
'render');
190 string $file_deliver_cmd
192 $this->log->debug(
'displayPostInfo');
193 $booking_ids = $this->request->getReservationIdsFromString();
195 $objects_with_periods = $this->resolveObjectsWithPeriodsForPostInfo(
201 if ($objects_with_periods === []) {
202 $this->
ctrl->redirect($this->parent_gui,
'back');
206 $booking_objects = [];
207 $booking_info_filenames = [];
209 $objects_with_info = [];
210 foreach ($objects_with_periods as $object_id => $periods) {
211 $booking_objects[$object_id] = new \ilBookingObject($object_id);
212 $booking_info_filenames[$object_id] = trim($this->objects_manager->getBookingInfoFilename($object_id));
215 trim($booking_objects[$object_id]->getPostText()) ===
''
216 && $booking_info_filenames[$object_id] ===
''
221 $objects_with_info[$object_id] = $periods;
224 if ($objects_with_info === []) {
225 $this->
ctrl->redirect($this->parent_gui,
'back');
229 $template = new \ilTemplate(
230 'tpl.booking_reservation_post.html',
233 'components/ILIAS/BookingManager/BookingProcess'
235 $multiple_objects = count($objects_with_info) > 1;
236 $submit_url = $this->
ctrl->getLinkTarget($this->parent_gui,
'back');
238 foreach ($objects_with_info as $object_id => $periods) {
239 $booking_object = $booking_objects[$object_id];
240 $post_text = trim($booking_object->getPostText());
242 $template->setCurrentBlock(
'info_block');
243 $title = $multiple_objects
244 ? sprintf($this->
lng->txt(
'book_post_booking_information_for'), $booking_object->getTitle())
245 : $this->
lng->txt(
'book_post_booking_information');
246 $template->setVariable(
'TITLE', $title);
248 if ($post_text !==
'') {
249 $post_text = str_replace(
250 [
'[OBJECT]',
'[PERIOD]'],
251 [$booking_object->getTitle(), implode(
'<br />', $periods)],
254 $template->setVariable(
'POST_TEXT', nl2br($post_text));
257 if ($booking_info_filenames[$object_id] ===
'') {
258 $template->parseCurrentBlock();
262 $this->
ctrl->setParameter($this->parent_gui,
'object_id', $object_id);
263 $url = $this->
ctrl->getLinkTarget($this->parent_gui, $file_deliver_cmd);
264 $this->
ctrl->clearParameterByClass($this->parent_gui::class,
'object_id');
266 $template->setCurrentBlock(
'download');
267 $template->setVariable(
'DOWNLOAD', $this->
lng->txt(
'download'));
268 $template->setVariable(
'URL_FILE', $url);
269 $template->setVariable(
'TXT_FILE', $booking_info_filenames[$object_id]);
270 $template->parseCurrentBlock();
271 $template->setCurrentBlock(
'info_block');
273 $template->parseCurrentBlock();
276 $template->setCurrentBlock(
'submit');
277 $template->setVariable(
'TXT_SUBMIT', $this->
lng->txt(
'ok'));
278 $template->setVariable(
'URL_SUBMIT', $submit_url);
279 $template->parseCurrentBlock();
281 $this->tpl->setContent($template->get());
292 if ($booking_ids !== []) {
293 return $this->resolvePeriodsFromReservationIds($booking_ids);
296 if ($book_obj_id <= 0) {
301 if ($this->request->getReservationId() !==
'') {
302 $reservation_id_parts = explode(
'_', $this->request->getReservationId());
304 $from = (
int) ($reservation_id_parts[2] ?? 0);
306 if ($from > time()) {
307 $to = (
int) ($reservation_id_parts[3] ?? 0);
308 $period_slots[
"$from-$to"] = 1;
314 foreach ($book_ids as $book_id) {
315 if (!in_array($book_id, $booking_ids,
true) && $booking_ids !== []) {
319 $reservation = new \ilBookingReservation($book_id);
320 $from = $reservation->getFrom();
321 $to = $reservation->getTo();
322 if ($from > time()) {
324 $period_slots[$key] = ($period_slots[$key] ?? 0) + 1;
328 return $period_slots === []
330 : [$book_obj_id => $this->formatPeriodSlots($period_slots)];
339 $period_slots_by_object = [];
341 foreach ($booking_ids as $booking_id) {
342 $booking_id = (
int) $booking_id;
343 if ($booking_id <= 0) {
347 $reservation = new \ilBookingReservation($booking_id);
348 $object_id = $reservation->getObjectId();
349 $key =
"{$reservation->getFrom()}-{$reservation->getTo()}";
350 $period_slots_by_object[$object_id][$key] = ($period_slots_by_object[$object_id][$key] ?? 0) + 1;
353 $objects_with_periods = [];
354 foreach ($period_slots_by_object as $object_id => $period_slots) {
355 $objects_with_periods[$object_id] = $this->formatPeriodSlots($period_slots);
358 ksort($objects_with_periods);
360 return $objects_with_periods;
373 ksort($period_slots);
374 foreach ($period_slots as $time => $counter) {
375 $time_parts = explode(
'-', $time);
382 $formatted .=
" ($counter)";
385 $period[] = $formatted;
400 $this->log->debug(
"deliverPostFile");
407 $book_id = current($book_ids);
408 $obj = new \ilBookingReservation($book_id);
409 if ($obj->getUserId() !==
$user_id) {
413 $this->domain->objects($this->pool->getId())->deliverBookingInfo(
$id);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
formatPeriodSlots(array $period_slots)
ilGlobalTemplateInterface $tpl
__construct(InternalDomainService $domain_service, InternalGUIService $gui_service, \ilObjBookingPool $pool, object $parent_gui)
assignParticipants(int $book_obj_id)
ObjectsManager $objects_manager
redirectToBookingInformationIfAvailable(int $a_obj_id, string $post_info_cmd, ?array $a_rsv_ids=null)
resolveObjectsWithPeriodsForPostInfo(int $book_obj_id, int $user_id, array $booking_ids)
StandardGUIRequest $request
resolvePeriodsFromReservationIds(array $booking_ids)
displayPostInfo(int $book_obj_id, int $user_id, string $file_deliver_cmd)
Display post booking informations.
InternalDomainService $domain
ilBookingHelpAdapter $help
redirectToReturnCmdIfAsynchronous()
deliverPostFile(int $book_obj_id, int $user_id)
Deliver post booking file.
handleBookingSuccess(int $a_obj_id, string $post_info_cmd, ?array $a_rsv_ids=null, ?string $message=null)
Author: Alexander Killing killing@leifos.de
bookingHelp(\ilObjBookingPool $pool)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getObjectReservationForUser(int $a_object_id, int $a_user_id)
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static useRelativeDates()
static setUseRelativeDates(bool $a_status)
set use relative dates
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
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
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...
if(!file_exists('../ilias.ini.php'))