4 require_once
"./classes/class.ilObjectGUI.php";
21 function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output =
true)
24 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
25 $this->lng->loadLanguageModule(
"book");
33 global
$tpl, $ilTabs, $ilNavigationHistory;
35 $next_class = $this->ctrl->getNextClass($this);
36 $cmd = $this->ctrl->getCmd();
38 if(!$next_class &&
$cmd ==
'render')
40 $this->ctrl->setCmdClass(
'ilBookingTypeGUI');
41 $next_class = $this->ctrl->getNextClass($this);
44 if(substr(
$cmd, 0, 4) ==
'book')
49 $ilNavigationHistory->addItem($this->ref_id,
50 "./goto.php?target=book_".$this->ref_id,
"book");
56 case 'ilpermissiongui':
57 $this->tabs_gui->setTabActive(
'perm_settings');
58 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
60 $ret =& $this->ctrl->forwardCommand($perm_gui);
63 case 'ilbookingtypegui':
64 $this->tabs_gui->setTabActive(
'render');
65 include_once(
"Modules/BookingManager/classes/class.ilBookingTypeGUI.php");
67 $ret =& $this->ctrl->forwardCommand($type_gui);
70 case 'ilbookingobjectgui':
71 $this->tabs_gui->setTabActive(
'render');
72 include_once(
"Modules/BookingManager/classes/class.ilBookingObjectGUI.php");
74 $ret =& $this->ctrl->forwardCommand($object_gui);
77 case 'ilbookingschedulegui':
78 $this->tabs_gui->setTabActive(
'schedules');
79 include_once(
"Modules/BookingManager/classes/class.ilBookingScheduleGUI.php");
81 $ret =& $this->ctrl->forwardCommand($schedule_gui);
84 case 'ilpublicuserprofilegui':
85 $this->tabs_gui->setTabActive(
'schedules');
86 include_once(
"Services/User/classes/class.ilPublicUserProfileGUI.php");
88 $ret =& $this->ctrl->forwardCommand($profile);
91 case 'ilinfoscreengui':
96 $cmd = $this->ctrl->getCmd();
112 $tpl->setContent($form->getHTML());
122 $this->tabs_gui->setTabActive(
'edit');
125 $tpl->setContent($form->getHTML());
134 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
139 $title->setRequired(
true);
141 $title->setMaxLength(120);
142 $form_gui->addItem(
$title);
147 $form_gui->addItem(
$desc);
149 if ($a_mode ==
"edit")
152 $form_gui->addItem($online);
155 $public->
setInfo($this->lng->txt(
"book_public_log_info"));
156 $form_gui->addItem($public);
161 $slots->setMinValue(1);
162 $slots->setMaxValue(24);
163 $slots->setInfo($this->lng->txt(
"book_slots_no_info"));
164 $form_gui->addItem($slots);
166 $form_gui->setTitle($this->lng->txt(
"settings"));
167 $title->setValue($this->object->getTitle());
168 $desc->setValue($this->object->getDescription());
169 $online->setChecked(!$this->object->isOffline());
170 $public->setChecked($this->object->hasPublicLog());
171 $slots->setValue($this->object->getNumberOfSlots());
172 $form_gui->addCommandButton(
"update", $this->lng->txt(
"save"));
173 $form_gui->addCommandButton(
"render", $this->lng->txt(
"cancel"));
177 $form_gui->setTitle($this->lng->txt(
"book_create_title"));
178 $form_gui->addCommandButton(
"save", $this->lng->txt(
"save"));
179 $form_gui->addCommandButton(
"cancel", $this->lng->txt(
"cancel"));
181 $form_gui->setFormAction($this->ctrl->getFormAction($this));
194 if($form->checkInput())
196 $_POST[
"new_type"] =
"book";
197 $_POST[
"Fobject"][
"title"] = $form->getInput(
"standard_title");
198 $_POST[
"Fobject"][
"desc"] = $form->getInput(
"description");
203 $newObj->setOffline(
true);
204 $newObj->setNumberOfSlots(4);
212 require_once(
'Services/Tracking/classes/class.ilChangeEvent.php');
219 $this->ctrl->setParameter($this,
"ref_id", $newObj->getRefId());
220 $this->ctrl->redirect($this,
"edit");
224 $form->setValuesByPost();
225 $tpl->setContent($form->getHTML());
237 if($form->checkInput())
239 $_POST[
"Fobject"][
"title"] = $form->getInput(
"standard_title");
240 $_POST[
"Fobject"][
"desc"] = $form->getInput(
"description");
242 $this->
object->setOffline(!$form->getInput(
'online'));
243 $this->
object->setPublicLog($form->getInput(
'public'));
244 $this->
object->setNumberOfSlots($form->getInput(
'slots'));
248 $ilCtrl->redirect($this,
"render");
252 $this->tabs_gui->setTabActive(
'edit');
253 $form->setValuesByPost();
254 $tpl->setContent($form->getHTML());
270 if (in_array($this->ctrl->getCmd(), array(
"create",
"save")) && !$this->ctrl->getNextClass())
275 $this->tabs_gui->addTab(
"render",
276 $this->lng->txt(
"book_booking_types"),
277 $this->ctrl->getLinkTarget($this,
"render"));
279 $this->tabs_gui->addTab(
"info",
280 $this->lng->txt(
"info_short"),
281 $this->ctrl->getLinkTarget($this,
"infoscreen"));
283 if ($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()) ||
284 $this->object->hasPublicLog())
286 $this->tabs_gui->addTab(
"log",
287 $this->lng->txt(
"book_log"),
288 $this->ctrl->getLinkTarget($this,
"log"));
291 if ($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()))
293 $this->tabs_gui->addTab(
"schedules",
294 $this->lng->txt(
"book_schedules"),
295 $this->ctrl->getLinkTargetByClass(
"ilbookingschedulegui",
"render"));
297 $this->tabs_gui->addTab(
"edit",
298 $this->lng->txt(
"settings"),
299 $this->ctrl->getLinkTarget($this,
"edit"));
302 if($ilAccess->checkAccess(
'edit_permission',
'', $this->object->getRefId()))
304 $this->tabs_gui->addTab(
"perm_settings",
305 $this->lng->txt(
"perm_settings"),
306 $this->ctrl->getLinkTargetByClass(
"ilpermissiongui",
"perm"));
315 $this->tabs_gui->clearTargets();
316 $this->tabs_gui->setBackTarget($this->lng->txt(
'book_back_to_list'), $this->ctrl->getLinkTarget($this,
'render'));
318 if(isset(
$_GET[
'object_id']))
320 $this->ctrl->setParameter($this,
'object_id', (
int)
$_GET[
'object_id']);
325 $this->ctrl->setParameter($this,
'type_id', (
int)
$_GET[
'type_id']);
338 $this->lng->loadLanguageModule(
"dateplaner");
340 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
341 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
345 $tpl->setContent($this->
renderList($schedule, array($a_object_id), $obj->getTitle()));
356 $this->lng->loadLanguageModule(
"dateplaner");
358 include_once
'Modules/BookingManager/classes/class.ilBookingType.php';
359 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
360 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
363 $object_ids = array();
366 $object_ids[] = $item[
'booking_object_id'];
369 $tpl->setContent($this->
renderList($schedule, $object_ids,
$type->getTitle()));
379 $mytpl =
new ilTemplate(
'tpl.booking_reservation_fix.html',
true,
true,
'Modules/BookingManager');
381 $mytpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this));
382 $mytpl->setVariable(
'TXT_TITLE', $this->lng->txt(
'book_reservation_title'));
383 $mytpl->setVariable(
'TXT_INFO', $this->lng->txt(
'book_reservation_fix_info'));
384 $mytpl->setVariable(
'TXT_OBJECT',
$title);
385 $mytpl->setVariable(
'TXT_CMD_BOOK', $this->lng->txt(
'book_confirm_booking'));
386 $mytpl->setVariable(
'TXT_CMD_CANCEL', $this->lng->txt(
'cancel'));
388 include_once
'Services/Calendar/classes/class.ilCalendarUserSettings.php';
392 $morning_aggr = $user_settings->getDayStart();
393 $evening_aggr = $user_settings->getDayEnd();
395 for($i = $morning_aggr;$i <= $evening_aggr;$i++)
397 switch($user_settings->getTimeFormat())
400 if ($morning_aggr > 0 && $i == $morning_aggr)
402 $hours[$i] = sprintf(
'%02d:00',0).
"-";
404 $hours[$i].= sprintf(
'%02d:00',$i);
405 if ($evening_aggr < 23 && $i == $evening_aggr)
407 $hours[$i].=
"-".sprintf(
'%02d:00',23);
412 if ($morning_aggr > 0 && $i == $morning_aggr)
414 $hours[$i] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
416 $hours[$i].= date(
'h a',mktime($i,0,0,1,1,2000));
417 if ($evening_aggr < 23 && $i == $evening_aggr)
419 $hours[$i].=
"-".date(
'h a',mktime(23,0,0,1,1,2000));
425 if(isset(
$_GET[
'seed']))
427 $find_first_open =
false;
432 $find_first_open =
true;
436 include_once
'Services/Calendar/classes/class.ilCalendarUtil.php';
437 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
438 $week_start = $user_settings->getWeekStart();
440 if(!$find_first_open)
448 $has_open_slot = $this->
buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
454 $limit = clone($seed);
458 while(!$has_open_slot && $seed->get(
IL_CAL_UNIX) < $limit)
463 $has_open_slot = $this->
buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
468 include_once
'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php';
470 $mytpl->setVariable(
'NAVIGATION', $navigation->getHTML());
476 $mytpl->setCurrentBlock(
'weekdays');
479 $mytpl->parseCurrentBlock();
482 include_once
'Services/Calendar/classes/class.ilCalendarAppointmentColors.php';
483 include_once
'Services/Calendar/classes/class.ilCalendarUtil.php';
486 for($loop = 0; $loop < 7; $loop++)
490 $color[$loop+1] =
'border-bottom: 1px solid '.$col.
'; background-color: '.$col.
'; color: '.$fnt;
494 foreach($dates as $hour => $days)
497 $caption = array_shift($caption);
499 for($loop = 1; $loop < 8; $loop++)
501 if(!isset($days[$loop]))
503 $mytpl->setCurrentBlock(
'dates');
504 $mytpl->setVariable(
'DUMMY',
' ');
505 $mytpl->parseCurrentBlock();
509 if(isset($days[$loop][
'captions']))
511 foreach($days[$loop][
'captions'] as $slot_id => $slot_caption)
513 $mytpl->setCurrentBlock(
'choice');
514 $mytpl->setVariable(
'TXT_DATE', $slot_caption);
515 $mytpl->setVariable(
'VALUE_DATE', $slot_id);
516 $mytpl->setVariable(
'DATE_COLOR', $color[$loop]);
517 $mytpl->parseCurrentBlock();
520 $mytpl->setCurrentBlock(
'dates');
521 $mytpl->setVariable(
'DUMMY',
'');
522 $mytpl->parseCurrentBlock();
524 else if(isset($days[$loop][
'in_slot']))
526 $mytpl->setCurrentBlock(
'dates');
527 $mytpl->setVariable(
'DATE_COLOR', $color[$loop]);
528 $mytpl->parseCurrentBlock();
532 $mytpl->setCurrentBlock(
'dates');
533 $mytpl->setVariable(
'DUMMY',
' ');
534 $mytpl->parseCurrentBlock();
539 $mytpl->setCurrentBlock(
'slots');
540 $mytpl->setVariable(
'TXT_HOUR', $caption);
543 $mytpl->setVariable(
'CSS_ROW',
'tblrow1');
547 $mytpl->setVariable(
'CSS_ROW',
'tblrow2');
549 $mytpl->parseCurrentBlock();
560 return $mytpl->get();
563 protected function buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates)
565 $map = array(
'mo',
'tu',
'we',
'th',
'fr',
'sa',
'su');
566 $definition = $schedule->getDefinition();
568 $has_open_slot =
false;
574 if(isset($definition[$map[$date_info[
'isoday']-1]]))
577 foreach($definition[$map[$date_info[
'isoday']-1]] as $slot)
579 $slot = explode(
'-', $slot);
580 $slots[] = array(
'from'=>str_replace(
':',
'', $slot[0]),
581 'to'=>str_replace(
':',
'', $slot[1]));
585 $last = array_pop(array_keys($hours));
586 $slot_captions = array();
587 foreach($hours as $hour => $period)
589 $dates[$hour][0] = $period;
591 $column = $date_info[
'isoday'];
607 foreach($slots as $slot)
609 $slot_from = mktime(substr($slot[
'from'], 0, 2), substr($slot[
'from'], 2, 2), 0, $date_info[
"mon"], $date_info[
"mday"], $date_info[
"year"]);
610 $slot_to = mktime(substr($slot[
'to'], 0, 2), substr($slot[
'to'], 2, 2), 0, $date_info[
"mon"], $date_info[
"mday"], $date_info[
"year"]);
619 if((
int)$slot[
'from'] < (int)$hour.
"59" && (
int)$slot[
'to'] > (int)$hour.
"00")
622 $from = array_pop(explode(
' ', $from));
624 $to = array_pop(explode(
' ', $to));
627 $id = $slot_from.
'_'.$slot_to;
628 if(!in_array($id, $slot_captions))
630 $dates[$hour][$column][
'captions'][$id] = $from.
'-'.$to;
631 $slot_captions[] = $id;
640 $has_open_slot =
true;
641 $dates[$hour][$column][
'in_slot'] =
$in;
647 return $has_open_slot;
657 if(!isset(
$_POST[
'date']))
663 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
664 $fromto = explode(
'_',
$_POST[
'date']);
666 if(isset(
$_GET[
'object_id']))
668 $object_id = (int)
$_GET[
'object_id'];
673 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
677 $ids[] = $item[
'booking_object_id'];
685 $reservation->setObjectId($object_id);
686 $reservation->setUserId($ilUser->getID());
687 $reservation->setFrom($fromto[0]);
688 $reservation->setTo($fromto[1]);
689 $reservation->save();
691 $this->lng->loadLanguageModule(
'dateplaner');
692 include_once
'Services/Calendar/classes/class.ilCalendarUtil.php';
693 include_once
'Services/Calendar/classes/class.ilCalendarCategory.php';
696 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
699 include_once
'Services/Calendar/classes/class.ilCalendarEntry.php';
703 $entry->setTitle($this->lng->txt(
'book_cal_entry').
' '.
$object->getTitle());
704 $entry->setContextId($reservation->getId());
707 include_once
'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
712 $this->ctrl->redirect($this,
'render');
717 $this->ctrl->redirect($this,
'book');
728 $this->tabs_gui->setTabActive(
'log');
730 include_once
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
732 $tpl->setContent($table->getHTML());
742 $this->tabs_gui->setTabActive(
'log');
744 if(!
$_POST[
'reservation_id'])
750 if ($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()))
752 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
757 return $this->ctrl->redirect($this,
'log');
765 include_once
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
767 $table->resetOffset();
768 $table->writeFilterToSession();
777 include_once
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
779 $table->resetOffset();
780 $table->resetFilter();
788 if ($ilAccess->checkAccess(
"read",
"", $a_target))
790 $_GET[
"cmd"] =
"render";
791 $_GET[
"ref_id"] = $a_target;
792 include(
"repository.php");
795 else if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
797 $_GET[
"cmd"] =
"frameset";
798 $_GET[
"target"] =
"";
799 $_GET[
"ref_id"] = ROOT_FOLDER_ID;
802 include(
"repository.php");
806 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->FATAL);
816 $this->ctrl->setCmd(
"showSummary");
817 $this->ctrl->setCmdClass(
"ilinfoscreengui");
825 $this->tabs_gui->setTabActive(
'info');
827 if (!$ilAccess->checkAccess(
"visible",
"", $this->ref_id))
829 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
832 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
835 $info->enablePrivateNotes();
837 if ($ilAccess->checkAccess(
"read",
"",
$_GET[
"ref_id"]))
843 $info->enableNewsEditing(
false);
844 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
"ref_id"]))
847 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
849 if ($enable_internal_rss)
851 $info->setBlockProperty(
"news",
"settings",
true);
852 $info->setBlockProperty(
"news",
"public_notifications_option",
true);
857 if ($ilCtrl->getNextClass() ==
"ilinfoscreengui")
859 $ilCtrl->forwardCommand($info);
863 return $ilCtrl->getHTML($info);
869 global $ilAccess, $ilUser;
871 $this->tabs_gui->setTabActive(
'log');
873 $id = (int)
$_GET[
'reservation_id'];
874 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
877 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id) && $obj->getUserId() != $ilUser->getId())
880 $this->ctrl->redirect($this,
'log');
887 include_once
'Services/Calendar/classes/class.ilCalendarCategory.php';
888 include_once
'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
892 include_once
'Services/Calendar/classes/class.ilCalendarEntry.php';
905 $this->tabs_gui->setTabActive(
'log');
907 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id))
910 $this->ctrl->redirect($this,
'log');
913 $id = (int)
$_GET[
'reservation_id'];
914 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
916 $obj->setStatus(NULL);
927 $this->tabs_gui->setTabActive(
'log');
929 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id))
932 $this->ctrl->redirect($this,
'log');
935 $id = (int)
$_GET[
'reservation_id'];
936 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
949 $this->tabs_gui->setTabActive(
'log');
951 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id))
954 $this->ctrl->redirect($this,
'log');
957 $id = (int)
$_GET[
'reservation_id'];
958 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
960 $obj->setStatus(NULL);
971 $this->tabs_gui->clearTargets();
972 $this->tabs_gui->setBackTarget($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this,
'log'));
974 $user_id = (int)
$_GET[
'user_id'];
976 include_once
'Services/User/classes/class.ilPublicUserProfileGUI.php';
978 $tpl->setContent($profile->getHTML());