4 require_once
"./classes/class.ilObjectGUI.php";
23 function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output =
true)
26 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
27 $this->lng->loadLanguageModule(
"book");
35 global
$tpl, $ilTabs, $ilNavigationHistory;
37 $next_class = $this->ctrl->getNextClass($this);
38 $cmd = $this->ctrl->getCmd();
40 if(!$next_class &&
$cmd ==
'render')
42 $this->ctrl->setCmdClass(
'ilBookingTypeGUI');
43 $next_class = $this->ctrl->getNextClass($this);
46 if(substr(
$cmd, 0, 4) ==
'book')
51 $ilNavigationHistory->addItem($this->ref_id,
52 "./goto.php?target=book_".$this->ref_id,
"book");
58 case 'ilpermissiongui':
59 $this->tabs_gui->setTabActive(
'perm_settings');
60 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
62 $ret =& $this->ctrl->forwardCommand($perm_gui);
65 case 'ilbookingtypegui':
66 $this->tabs_gui->setTabActive(
'render');
67 include_once(
"Modules/BookingManager/classes/class.ilBookingTypeGUI.php");
69 $ret =& $this->ctrl->forwardCommand($type_gui);
72 case 'ilbookingobjectgui':
73 $this->tabs_gui->setTabActive(
'render');
74 include_once(
"Modules/BookingManager/classes/class.ilBookingObjectGUI.php");
76 $ret =& $this->ctrl->forwardCommand($object_gui);
79 case 'ilbookingschedulegui':
80 $this->tabs_gui->setTabActive(
'schedules');
81 include_once(
"Modules/BookingManager/classes/class.ilBookingScheduleGUI.php");
83 $ret =& $this->ctrl->forwardCommand($schedule_gui);
86 case 'ilpublicuserprofilegui':
87 $ilTabs->clearTargets();
88 include_once(
"Services/User/classes/class.ilPublicUserProfileGUI.php");
90 $profile->setBackUrl($this->ctrl->getLinkTarget($this,
'log'));
91 $ret = $this->ctrl->forwardCommand($profile);
92 $tpl->setContent(
$ret);
95 case 'ilinfoscreengui':
99 case "ilcommonactiondispatchergui":
100 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
102 $this->ctrl->forwardCommand($gui);
106 $cmd = $this->ctrl->getCmd();
118 return array(self::CFORM_NEW => $this->
initCreateForm($a_new_type));
123 $a_new_object->setOffline(
true);
124 $a_new_object->setNumberOfSlots(4);
129 $this->ctrl->setParameter($this,
"ref_id", $a_new_object->
getRefId());
130 $this->ctrl->redirect($this,
"edit");
136 include_once
"Modules/BookingManager/classes/class.ilBookingSchedule.php";
151 $public->
setInfo($this->lng->txt(
"book_public_log_info"));
157 $slots->setMinValue(1);
158 $slots->setMaxValue(24);
159 $slots->setInfo($this->lng->txt(
"book_slots_no_info"));
165 $a_values[
"online"] = !$this->
object->isOffline();
166 $a_values[
"public"] = $this->
object->hasPublicLog();
167 $a_values[
"slots"] = $this->
object->getNumberOfSlots();
172 $this->
object->setOffline(!$a_form->
getInput(
'online'));
173 $this->
object->setPublicLog($a_form->
getInput(
'public'));
174 $this->
object->setNumberOfSlots($a_form->
getInput(
'slots'));
184 if (in_array($this->ctrl->getCmd(), array(
"create",
"save")) && !$this->ctrl->getNextClass())
189 $this->tabs_gui->addTab(
"render",
190 $this->lng->txt(
"book_booking_types"),
191 $this->ctrl->getLinkTarget($this,
"render"));
193 $this->tabs_gui->addTab(
"info",
194 $this->lng->txt(
"info_short"),
195 $this->ctrl->getLinkTarget($this,
"infoscreen"));
197 if ($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()) ||
198 $this->object->hasPublicLog())
200 $this->tabs_gui->addTab(
"log",
201 $this->lng->txt(
"book_log"),
202 $this->ctrl->getLinkTarget($this,
"log"));
205 if ($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()))
207 $this->tabs_gui->addTab(
"schedules",
208 $this->lng->txt(
"book_schedules"),
209 $this->ctrl->getLinkTargetByClass(
"ilbookingschedulegui",
"render"));
211 $this->tabs_gui->addTab(
"settings",
212 $this->lng->txt(
"settings"),
213 $this->ctrl->getLinkTarget($this,
"edit"));
216 if($ilAccess->checkAccess(
'edit_permission',
'', $this->object->getRefId()))
218 $this->tabs_gui->addTab(
"perm_settings",
219 $this->lng->txt(
"perm_settings"),
220 $this->ctrl->getLinkTargetByClass(
"ilpermissiongui",
"perm"));
229 $this->tabs_gui->clearTargets();
230 $this->tabs_gui->setBackTarget($this->lng->txt(
'book_back_to_list'), $this->ctrl->getLinkTarget($this,
'render'));
232 if(isset(
$_GET[
'object_id']))
234 $this->ctrl->setParameter($this,
'object_id', (
int)
$_GET[
'object_id']);
239 $this->ctrl->setParameter($this,
'type_id', (
int)
$_GET[
'type_id']);
252 $this->lng->loadLanguageModule(
"dateplaner");
254 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
255 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
259 $tpl->setContent($this->
renderList($schedule, array($a_object_id), $obj->getTitle()));
270 $this->lng->loadLanguageModule(
"dateplaner");
272 include_once
'Modules/BookingManager/classes/class.ilBookingType.php';
273 include_once
'Modules/BookingManager/classes/class.ilBookingSchedule.php';
274 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
277 $object_ids = array();
280 $object_ids[] = $item[
'booking_object_id'];
293 $mytpl =
new ilTemplate(
'tpl.booking_reservation_fix.html',
true,
true,
'Modules/BookingManager');
295 $mytpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this));
296 $mytpl->setVariable(
'TXT_TITLE', $this->lng->txt(
'book_reservation_title'));
297 $mytpl->setVariable(
'TXT_INFO', $this->lng->txt(
'book_reservation_fix_info'));
298 $mytpl->setVariable(
'TXT_OBJECT',
$title);
299 $mytpl->setVariable(
'TXT_CMD_BOOK', $this->lng->txt(
'book_confirm_booking'));
300 $mytpl->setVariable(
'TXT_CMD_CANCEL', $this->lng->txt(
'cancel'));
302 include_once
'Services/Calendar/classes/class.ilCalendarUserSettings.php';
306 $morning_aggr = $user_settings->getDayStart();
307 $evening_aggr = $user_settings->getDayEnd();
309 for($i = $morning_aggr;$i <= $evening_aggr;$i++)
311 switch($user_settings->getTimeFormat())
314 if ($morning_aggr > 0 && $i == $morning_aggr)
316 $hours[$i] = sprintf(
'%02d:00',0).
"-";
318 $hours[$i].= sprintf(
'%02d:00',$i);
319 if ($evening_aggr < 23 && $i == $evening_aggr)
321 $hours[$i].=
"-".sprintf(
'%02d:00',23);
326 if ($morning_aggr > 0 && $i == $morning_aggr)
328 $hours[$i] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
330 $hours[$i].= date(
'h a',mktime($i,0,0,1,1,2000));
331 if ($evening_aggr < 23 && $i == $evening_aggr)
333 $hours[$i].=
"-".date(
'h a',mktime(23,0,0,1,1,2000));
339 if(isset(
$_GET[
'seed']))
341 $find_first_open =
false;
346 $find_first_open =
true;
350 include_once
'Services/Calendar/classes/class.ilCalendarUtil.php';
351 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
352 $week_start = $user_settings->getWeekStart();
354 if(!$find_first_open)
362 $has_open_slot = $this->
buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
368 $limit = clone($seed);
372 while(!$has_open_slot && $seed->get(
IL_CAL_UNIX) < $limit)
377 $has_open_slot = $this->
buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
382 include_once
'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php';
384 $mytpl->setVariable(
'NAVIGATION', $navigation->getHTML());
390 $mytpl->setCurrentBlock(
'weekdays');
393 $mytpl->parseCurrentBlock();
396 include_once
'Services/Calendar/classes/class.ilCalendarAppointmentColors.php';
397 include_once
'Services/Calendar/classes/class.ilCalendarUtil.php';
400 for($loop = 0; $loop < 7; $loop++)
404 $color[$loop+1] =
'border-bottom: 1px solid '.$col.
'; background-color: '.$col.
'; color: '.$fnt;
408 foreach($dates as $hour => $days)
411 $caption = array_shift($caption);
413 for($loop = 1; $loop < 8; $loop++)
415 if(!isset($days[$loop]))
417 $mytpl->setCurrentBlock(
'dates');
418 $mytpl->setVariable(
'DUMMY',
' ');
419 $mytpl->parseCurrentBlock();
423 if(isset($days[$loop][
'captions']))
425 foreach($days[$loop][
'captions'] as $slot_id => $slot_caption)
427 $mytpl->setCurrentBlock(
'choice');
428 $mytpl->setVariable(
'TXT_DATE', $slot_caption);
429 $mytpl->setVariable(
'VALUE_DATE', $slot_id);
430 $mytpl->setVariable(
'DATE_COLOR', $color[$loop]);
431 $mytpl->parseCurrentBlock();
434 $mytpl->setCurrentBlock(
'dates');
435 $mytpl->setVariable(
'DUMMY',
'');
436 $mytpl->parseCurrentBlock();
438 else if(isset($days[$loop][
'in_slot']))
440 $mytpl->setCurrentBlock(
'dates');
441 $mytpl->setVariable(
'DATE_COLOR', $color[$loop]);
442 $mytpl->parseCurrentBlock();
446 $mytpl->setCurrentBlock(
'dates');
447 $mytpl->setVariable(
'DUMMY',
' ');
448 $mytpl->parseCurrentBlock();
453 $mytpl->setCurrentBlock(
'slots');
454 $mytpl->setVariable(
'TXT_HOUR', $caption);
457 $mytpl->setVariable(
'CSS_ROW',
'tblrow1');
461 $mytpl->setVariable(
'CSS_ROW',
'tblrow2');
463 $mytpl->parseCurrentBlock();
474 return $mytpl->get();
477 protected function buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates)
479 $map = array(
'mo',
'tu',
'we',
'th',
'fr',
'sa',
'su');
480 $definition = $schedule->getDefinition();
482 $has_open_slot =
false;
488 if(isset($definition[$map[$date_info[
'isoday']-1]]))
491 foreach($definition[$map[$date_info[
'isoday']-1]] as $slot)
493 $slot = explode(
'-', $slot);
494 $slots[] = array(
'from'=>str_replace(
':',
'', $slot[0]),
495 'to'=>str_replace(
':',
'', $slot[1]));
499 $last = array_pop(array_keys($hours));
500 $slot_captions = array();
501 foreach($hours as $hour => $period)
503 $dates[$hour][0] = $period;
505 $period = explode(
"-", $period);
506 if(
sizeof($period) == 1)
508 $period_from = (int)substr($period[0], 0, 2).
"00";
509 $period_to = (int)substr($period[0], 0, 2).
"59";
513 $period_from = (int)substr($period[0], 0, 2).
"00";
514 $period_to = (int)substr($period[1], 0, 2).
"59";
517 $column = $date_info[
'isoday'];
533 foreach($slots as $slot)
535 $slot_from = mktime(substr($slot[
'from'], 0, 2), substr($slot[
'from'], 2, 2), 0, $date_info[
"mon"], $date_info[
"mday"], $date_info[
"year"]);
536 $slot_to = mktime(substr($slot[
'to'], 0, 2), substr($slot[
'to'], 2, 2), 0, $date_info[
"mon"], $date_info[
"mday"], $date_info[
"year"]);
545 if((
int)$slot[
'from'] <= $period_to && (int)$slot[
'to'] >= $period_from)
548 $from = array_pop(explode(
' ', $from));
550 $to = array_pop(explode(
' ', $to));
553 $id = $slot_from.
'_'.$slot_to;
554 if(!in_array($id, $slot_captions))
556 $dates[$hour][$column][
'captions'][$id] = $from.
'-'.$to;
557 $slot_captions[] = $id;
566 $has_open_slot =
true;
567 $dates[$hour][$column][
'in_slot'] =
$in;
573 return $has_open_slot;
583 if(!isset(
$_POST[
'date']))
591 if(isset(
$_GET[
'object_id']))
593 foreach(
$_POST[
'date'] as $date)
595 $fromto = explode(
'_', $date);
598 $object_id = (int)
$_GET[
'object_id'];
609 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
610 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
611 $all_object_ids = array();
614 $all_object_ids[] = $item[
'booking_object_id'];
617 $possible_objects = $counter = array();
619 foreach(
$_POST[
'date'] as $date)
621 $fromto = explode(
'_', $date);
624 foreach($possible_objects[$date] as
$obj_id)
634 $counter = array_keys($counter);
637 foreach($possible_objects as $date => $available_ids)
639 $fromto = explode(
'_', $date);
643 foreach($counter as $best_object_id)
645 if(in_array($best_object_id, $available_ids))
647 $object_id = $best_object_id;
660 $this->ctrl->redirect($this,
'render');
665 $this->ctrl->redirect($this,
'book');
680 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
682 $reservation->setObjectId($a_object_id);
683 $reservation->setUserId($ilUser->getID());
684 $reservation->setFrom($a_from);
685 $reservation->setTo($a_to);
686 $reservation->save();
688 $this->lng->loadLanguageModule(
'dateplaner');
689 include_once
'Services/Calendar/classes/class.ilCalendarUtil.php';
690 include_once
'Services/Calendar/classes/class.ilCalendarCategory.php';
693 include_once
'Modules/BookingManager/classes/class.ilBookingObject.php';
696 include_once
'Services/Calendar/classes/class.ilCalendarEntry.php';
700 $entry->setTitle($this->lng->txt(
'book_cal_entry').
' '.
$object->getTitle());
701 $entry->setContextId($reservation->getId());
704 include_once
'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
716 $this->tabs_gui->setTabActive(
'log');
718 include_once
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
720 $tpl->setContent($table->getHTML());
730 $this->tabs_gui->setTabActive(
'log');
732 if(!
$_POST[
'reservation_id'])
738 if ($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()))
740 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
745 return $this->ctrl->redirect($this,
'log');
753 include_once
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
755 $table->resetOffset();
756 $table->writeFilterToSession();
765 include_once
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
767 $table->resetOffset();
768 $table->resetFilter();
776 if ($ilAccess->checkAccess(
"read",
"", $a_target))
778 $_GET[
"cmd"] =
"render";
779 $_GET[
"ref_id"] = $a_target;
780 include(
"repository.php");
783 else if ($ilAccess->checkAccess(
"read",
"", ROOT_FOLDER_ID))
785 $_GET[
"cmd"] =
"frameset";
786 $_GET[
"target"] =
"";
787 $_GET[
"ref_id"] = ROOT_FOLDER_ID;
790 include(
"repository.php");
794 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->FATAL);
804 $this->ctrl->setCmd(
"showSummary");
805 $this->ctrl->setCmdClass(
"ilinfoscreengui");
813 $this->tabs_gui->setTabActive(
'info');
815 if (!$ilAccess->checkAccess(
"visible",
"", $this->ref_id))
817 $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
820 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
823 $info->enablePrivateNotes();
825 if ($ilAccess->checkAccess(
"read",
"",
$_GET[
"ref_id"]))
831 $info->enableNewsEditing(
false);
832 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
"ref_id"]))
835 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
837 if ($enable_internal_rss)
839 $info->setBlockProperty(
"news",
"settings",
true);
840 $info->setBlockProperty(
"news",
"public_notifications_option",
true);
845 if ($ilCtrl->getNextClass() ==
"ilinfoscreengui")
847 $ilCtrl->forwardCommand($info);
851 return $ilCtrl->getHTML($info);
857 global $ilAccess, $ilUser;
859 $this->tabs_gui->setTabActive(
'log');
861 $id = (int)
$_GET[
'reservation_id'];
862 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
865 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id) && $obj->getUserId() != $ilUser->getId())
868 $this->ctrl->redirect($this,
'log');
875 $cal_entry_id = $obj->getCalendarEntry();
878 include_once
'Services/Calendar/classes/class.ilCalendarEntry.php';
891 $this->tabs_gui->setTabActive(
'log');
893 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id))
896 $this->ctrl->redirect($this,
'log');
899 $id = (int)
$_GET[
'reservation_id'];
900 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
902 $obj->setStatus(NULL);
913 $this->tabs_gui->setTabActive(
'log');
915 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id))
918 $this->ctrl->redirect($this,
'log');
921 $id = (int)
$_GET[
'reservation_id'];
922 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
935 $this->tabs_gui->setTabActive(
'log');
937 if (!$ilAccess->checkAccess(
"write",
"", $this->ref_id))
940 $this->ctrl->redirect($this,
'log');
943 $id = (int)
$_GET[
'reservation_id'];
944 include_once
'Modules/BookingManager/classes/class.ilBookingReservation.php';
946 $obj->setStatus(NULL);
957 $this->tabs_gui->clearTargets();
959 $user_id = (int)
$_GET[
'user_id'];
961 include_once
'Services/User/classes/class.ilPublicUserProfileGUI.php';
963 $profile->setBackUrl($this->ctrl->getLinkTarget($this,
'log'));
964 $tpl->setContent($ilCtrl->getHTML($profile));
971 if (is_object($this->
object))
973 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
"infoScreen"),
"",
$_GET[
"ref_id"]);