/**
  * Fills the table with data for whole week.
  */
 public function show($export = false)
 {
     if ($export && isset($_SESSION['weeklySeed'])) {
         $this->seed = $_SESSION['weeklySeed'];
     } else {
         $_SESSION['weeklySeed'] = $this->seed;
     }
     if (!$this->permission->checkPrivilege(PRIVC::SEE_BOOKINGS_OF_ROOMS)) {
         ilUtil::sendFailure($this->lng->txt("rep_robj_xrs_no_permission_for_action"));
         $this->ctrl->redirectByClass('ilinfoscreengui', 'showSummary', 'showSummary');
         return false;
     }
     global $ilUser;
     $this->setSubTabs('weekview');
     //intervalsize
     $raster = 15;
     if ($this->user_settings->getDayStart()) {
         // push starting point to last "slot" of hour BEFORE morning aggregation
         $morning_aggr = ($this->user_settings->getDayStart() - 1) * 60 + (60 - $raster);
     } else {
         $morning_aggr = 0;
     }
     $evening_aggr = $this->user_settings->getDayEnd() * 60;
     $this->tpl = new ilTemplate('tpl.room_week_view.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/RoomSharing');
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::WEEK);
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
         $no_add = true;
     } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) {
         $user_id = $ilUser->getId();
         $disable_empty = false;
         $no_add = true;
     } else {
         $user_id = $ilUser->getId();
         $disable_empty = false;
         $no_add = false;
     }
     $room = new ilRoomSharingRoom($this->pool_id, $this->room_id);
     $this->tpl->setVariable('ROOM', $this->lng->txt('rep_robj_xrs_room_occupation_title') . " " . $room->getName());
     $this->scheduler = new ilRoomSharingCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_WEEK, $user_id, $room);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $counter = 0;
     $hours = NULL;
     foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) {
         $daily_apps = $this->scheduler->getByDay($date, $this->timezone);
         $hours = $this->parseHourInfo($daily_apps, $date, $counter, $hours, $morning_aggr, $evening_aggr, $raster);
         $this->weekdays[] = $date;
         $num_apps[$date->get(IL_CAL_DATE)] = count($daily_apps);
         $counter++;
     }
     $colspans = $this->calculateColspans($hours);
     $settings = ilCalendarSettings::_getInstance();
     $exportLink = $this->ctrl->getLinkTargetByClass("ilroomsharingcalendarweekgui", "export");
     $this->tpl->setCurrentBlock("export_block");
     $this->tpl->setVariable('EXPORT_LINK', $exportLink);
     $this->tpl->parseCurrentBlock();
     // Table header
     $counter = 0;
     foreach (ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get() as $date) {
         $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $date->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
         $dayname = ilCalendarUtil::_numericDayToString($date->get(IL_CAL_FKT_DATE, 'w'), true);
         $this->days[$counter] = $date;
         $daydate = $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'], false);
         if (!$disable_empty || $num_apps[$date->get(IL_CAL_DATE)] > 0) {
             $link = $this->ctrl->getLinkTargetByClass('ilcalendardaygui', '');
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
             $this->tpl->setCurrentBlock("day_view1_link");
             $this->tpl->setVariable('HEADER_DATE', $daydate);
             $this->tpl->setVariable('DAY_VIEW_LINK', $link);
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("day_view2_link");
             $this->tpl->setVariable('DAYNAME', $dayname);
             $this->tpl->setVariable('DAY_VIEW_LINK', $link);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("day_view1_no_link");
             $this->tpl->setVariable('HEADER_DATE', $daydate);
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("day_view2_no_link");
             $this->tpl->setVariable('DAYNAME', $dayname);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('day_header_row');
         $this->tpl->setVariable('DAY_COLSPAN', max($colspans[$counter], 1));
         $this->tpl->parseCurrentBlock();
         $counter++;
     }
     $new_link_counter = 0;
     foreach ($hours as $num_hour => $hours_per_day) {
         $first = true;
         foreach ($hours_per_day as $num_day => $hour) {
             if ($first) {
                 if (!($num_hour % 60) || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                     $first = false;
                     $this->timeIntervals[] = $hours_per_day[2];
                     // aggregation rows
                     if ($num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                         $this->tpl->setVariable('TIME_ROWSPAN', 1);
                     } else {
                         $this->tpl->setVariable('TIME_ROWSPAN', 60 / $raster);
                     }
                     $this->tpl->setCurrentBlock('time_txt');
                     $this->tpl->setVariable('TIME', $hour['txt']);
                     $this->tpl->parseCurrentBlock();
                 }
             }
             foreach ($hour['apps_start'] as $app) {
                 $this->showAppointment($app);
             }
             // screen reader: appointments are divs, now output cell
             if ($ilUser->prefs["screen_reader_optimization"]) {
                 $this->tpl->setCurrentBlock('scrd_day_cell');
                 $this->tpl->setVariable('TD_CLASS', 'calstd');
                 $this->tpl->parseCurrentBlock();
             }
             #echo "NUMDAY: ".$num_day;
             #echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
             $num_apps = $hour['apps_num'];
             $colspan = max($colspans[$num_day], 1);
             // Show new apointment link
             $userCanAddBooking = $this->permission->checkPrivilege(PRIVC::ADD_OWN_BOOKINGS);
             $calStuffAllowed = !$hour['apps_num'] && !$ilUser->prefs["screen_reader_optimization"] && !$no_add;
             if ($userCanAddBooking && $calStuffAllowed) {
                 $this->tpl->setCurrentBlock('new_app_link');
                 $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->lng->txt('rep_robj_xrs_room_book'));
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'room', $room->getName());
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'room_id', $room->getId());
                 $_SESSION['last_cmd'] = 'showroom';
                 $date = $this->weekdays[$num_day]->get(IL_CAL_DATE);
                 //convert time into suitable format (HH:ii:ss)
                 $hr = floor($num_hour / 60);
                 $hr = $hr < 10 ? "0" . $hr : $hr;
                 $hr_end = floor(($num_hour + 60) / 60);
                 $hr_end = $hr_end < 10 ? "0" . $hr_end : $hr_end;
                 $min = floor($num_hour % 60);
                 $min = $min < 10 ? "0" . $min : $min;
                 $min_end = floor(($num_hour + 60) % 60);
                 $min_end = $min_end < 10 ? "0" . $min_end : $min_end;
                 $time_from = $hr . ":" . $min . ":00";
                 $time_to = $hr_end . ":" . $min_end . ":00";
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'date', $date);
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'time_from', $time_from);
                 $this->ctrl->setParameterByClass('ilobjroomsharinggui', 'time_to', $time_to);
                 $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->ctrl->getLinkTargetByClass('ilobjroomsharinggui', 'book'));
                 // free the parameters
                 $this->ctrl->clearParametersByClass('ilobjroomsharinggui');
                 $this->tpl->setVariable('DAY_NEW_APP_SRC', ilUtil::getImagePath('date_add.png'));
                 $this->tpl->setVariable('DAY_NEW_APP_ALT', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('DAY_NEW_ID', ++$new_link_counter);
                 $this->tpl->parseCurrentBlock();
             }
             for ($i = $colspan; $i > $hour['apps_num']; $i--) {
                 if ($ilUser->prefs["screen_reader_optimization"]) {
                     continue;
                 }
                 $this->tpl->setCurrentBlock('day_cell');
                 // last "slot" of hour needs border
                 $empty_border = '';
                 if ($num_hour % 60 == 60 - $raster || $num_hour == $morning_aggr && $morning_aggr || $num_hour == $evening_aggr && $evening_aggr) {
                     $empty_border = ' calempty_border';
                 }
                 if ($i == $hour['apps_num'] + 1) {
                     $this->tpl->setVariable('TD_CLASS', 'calempty calrightborder' . $empty_border);
                     #$this->tpl->setVariable('TD_STYLE',$add_style);
                 } else {
                     $this->tpl->setVariable('TD_CLASS', 'calempty' . $empty_border);
                     #$this->tpl->setVariable('TD_STYLE',$add_style);
                 }
                 if (!$hour['apps_num']) {
                     $this->tpl->setVariable('DAY_ID', $new_link_counter);
                 }
                 $this->tpl->setVariable('TD_ROWSPAN', 1);
                 $this->tpl->parseCurrentBlock();
             }
         }
         $this->tpl->touchBlock('time_row');
     }
     $this->tpl->setVariable("TXT_TIME", $this->lng->txt("time"));
     if ($export) {
         $this->export();
     }
 }
 /**
  * @covers ilRoomSharingRoom::setFileId
  */
 public function testSetFileId()
 {
     self::$room->setId(33);
     $this->assertEquals(33, self::$room->getId());
 }