/**
  * getHTML
  *
  * @access public
  * 
  */
 public function getHTML()
 {
     global $lng;
     $this->tpl = new ilTemplate('tpl.navigation_header.html', true, true, 'Services/Calendar');
     $this->incrementDate(-2);
     $num = 0;
     do {
         switch ($this->increment) {
             case ilDateTime::DAY:
                 $this->tpl->setVariable('NAV_NAME_' . ++$num, ilCalendarUtil::_numericDayToString($this->seed->get(IL_CAL_FKT_DATE, 'w')));
                 break;
             case ilDateTime::WEEK:
                 $this->tpl->setVariable('NAV_NAME_' . ++$num, $this->lng->txt('week') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'W'));
                 break;
             case ilDateTime::MONTH:
                 if ($num == 2) {
                     $this->tpl->setVariable('NAV_NAME_' . ++$num, $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y'));
                 } else {
                     $this->tpl->setVariable('NAV_NAME_' . ++$num, $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long'));
                 }
                 break;
         }
         $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', $this->seed->get(IL_CAL_DATE));
         $this->tpl->setVariable('NAV_LINK_' . $num, $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd));
         // $this->ctrl->clearParametersByClass(get_class($this->cmdClass));
         $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', '');
         $this->incrementDate(1);
     } while ($num < 6);
     // header
     switch ($this->increment) {
         case ilDateTime::DAY:
             $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_day_selection"));
             $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_day_overview"));
             break;
         case ilDateTime::WEEK:
             $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_week_selection"));
             $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_week_overview"));
             break;
         case ilDateTime::MONTH:
             $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_month_selection"));
             $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_month_overview"));
             break;
     }
     $this->tpl->setVariable('TXT_SELECTED', $lng->txt("stat_selected"));
     return $this->tpl->get();
 }
Ejemplo n.º 2
0
 /**
  * Add mini version of monthly overview
  * (Maybe extracted to another class, if used in pd calendar tab
  */
 function addMiniMonth($a_tpl)
 {
     global $ilCtrl, $lng, $ilUser;
     // weekdays
     include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
     $a_tpl->setCurrentBlock('month_header_col');
     $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
     $a_tpl->parseCurrentBlock();
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $a_tpl->setCurrentBlock('month_header_col');
         $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
         $a_tpl->parseCurrentBlock();
     }
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
     } else {
         $user_id = $ilUser->getId();
         $disable_empty = false;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $counter = 0;
     foreach (ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE, 'm'), $this->seed->get(IL_CAL_FKT_DATE, 'Y'), $this->user_settings->getWeekStart())->get() as $date) {
         $counter++;
         $events = $this->scheduler->getByDay($date, $ilUser->getTimeZone());
         $has_events = (bool) count($events);
         if ($has_events || !$disable_empty) {
             $a_tpl->setCurrentBlock('month_col_link');
         } else {
             $a_tpl->setCurrentBlock('month_col_no_link');
         }
         if ($disable_empty) {
             if (!$has_events) {
                 $a_tpl->setVariable('DAY_CLASS', 'calminiinactive');
             } else {
                 $week_has_events = true;
                 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
                 foreach ($events as $event) {
                     $booking = new ilBookingEntry($event['event']->getContextId());
                     if ($booking->hasBooked($event['event']->getEntryId())) {
                         $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
                         break;
                     }
                 }
             }
         } elseif ($has_events) {
             $week_has_events = true;
             $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
         }
         $day = $date->get(IL_CAL_FKT_DATE, 'j');
         $month = $date->get(IL_CAL_FKT_DATE, 'n');
         $month_day = $day;
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $ilCtrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
         $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui', ''));
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $a_tpl->setVariable('MONTH_DAY', $month_day);
         $a_tpl->parseCurrentBlock();
         $a_tpl->setCurrentBlock('month_col');
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         if (ilCalendarUtil::_isToday($date)) {
             $a_tpl->setVariable('TD_CLASS', 'calminitoday');
         } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calministd');
         } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calminiprev');
         } else {
             $a_tpl->setVariable('TD_CLASS', 'calmininext');
         }
         $a_tpl->parseCurrentBlock();
         if ($counter and !($counter % 7)) {
             if (!$disable_empty || $week_has_events) {
                 $a_tpl->setCurrentBlock('month_row_link');
                 $ilCtrl->clearParametersByClass('ilcalendarweekgui');
                 $ilCtrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
                 $a_tpl->setVariable('OPEN_WEEK_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarweekgui', ''));
                 $ilCtrl->clearParametersByClass('ilcalendarweekgui');
             } else {
                 $a_tpl->setCurrentBlock('month_row_no_link');
                 $a_tpl->setVariable('WEEK_CLASS', 'calminiinactive');
             }
             $a_tpl->setVariable('WEEK', $date->get(IL_CAL_FKT_DATE, 'W'));
             $a_tpl->parseCurrentBlock();
             $a_tpl->setCurrentBlock('month_row');
             $a_tpl->setVariable('TD_CLASS', 'calminiweek');
             $a_tpl->parseCurrentBlock();
             $week_has_events = false;
         }
     }
     $a_tpl->setCurrentBlock('mini_month');
     $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
     $a_tpl->setVariable('TXT_MONTH', $lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y'));
     $myseed = clone $this->seed;
     $ilCtrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('OPEN_MONTH_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
     $myseed->increment(ilDateTime::MONTH, -1);
     $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('BL_TYPE', $this->getBlockType());
     $a_tpl->setVariable('BL_ID', $this->getBlockId());
     $a_tpl->setVariable('PREV_MONTH', $ilCtrl->getLinkTarget($this, "setSeed"));
     $a_tpl->setVariable('PREV_MONTH_ASYNC', $ilCtrl->getLinkTarget($this, "setSeed", "", true));
     $myseed->increment(ilDateTime::MONTH, 2);
     $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('NEXT_MONTH', $ilCtrl->getLinkTarget($this, "setSeed"));
     $a_tpl->setVariable('NEXT_MONTH_ASYNC', $ilCtrl->getLinkTarget($this, "setSeed", "", true));
     $ilCtrl->setParameter($this, 'seed', "");
     $a_tpl->parseCurrentBlock();
 }
Ejemplo n.º 3
0
 /**
  * fill data section
  *
  * @access protected
  * 
  */
 protected function show()
 {
     global $lng, $ilUser;
     // config
     $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.day_view.html', true, true, 'Services/Calendar');
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $no_add = true;
     } elseif ($ilUser->getId() == ANONYMOUS_USER_ID) {
         $user_id = $ilUser->getId();
         $no_add = true;
     } else {
         $user_id = $ilUser->getId();
         $no_add = false;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_DAY, $user_id);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $daily_apps = $this->scheduler->getByDay($this->seed, $this->timezone);
     $hours = $this->parseInfoIntoRaster($daily_apps, $morning_aggr, $evening_aggr, $raster);
     $colspan = $this->calculateColspan($hours);
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::DAY);
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
     // add milestone link
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     if (!$no_add) {
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE));
         $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
         if ($settings->getEnableGroupMilestones()) {
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE));
             $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone');
             $this->tpl->setCurrentBlock("new_ms");
             $this->tpl->setVariable('DD_ID', $this->seed->get(IL_CAL_UNIX));
             $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD));
             $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url);
             $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app'));
             $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url);
             $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms'));
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("new_app1");
             $this->tpl->setVariable('H_NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
             $this->tpl->setVariable('NEW_APP_LINK', $new_app_url);
             $this->tpl->parseCurrentBlock();
         }
         $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     }
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     $this->tpl->setVariable('HEADER_DATE', $this->seed_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($this->seed_info['mon'], false));
     $this->tpl->setVariable('HEADER_DAY', ilCalendarUtil::_numericDayToString($this->seed_info['wday'], true));
     $this->tpl->setVariable('HCOLSPAN', $colspan - 1);
     $this->tpl->setVariable('TXT_TIME', $lng->txt("time"));
     // show fullday events
     foreach ($daily_apps as $event) {
         if ($event['fullday']) {
             $this->showFulldayAppointment($event);
         }
     }
     $this->tpl->setCurrentBlock('fullday_apps');
     $this->tpl->setVariable('TXT_F_DAY', $lng->txt("cal_all_day"));
     $this->tpl->setVariable('COLSPAN', $colspan - 1);
     $this->tpl->parseCurrentBlock();
     // parse the hour rows
     foreach ($hours as $numeric => $hour) {
         if (!($numeric % 60) || $numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) {
             if (!$no_add) {
                 $this->tpl->setCurrentBlock("new_app2");
                 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'hour', floor($numeric / 60));
                 $this->tpl->setVariable('NEW_APP_HOUR_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add'));
                 $this->tpl->setVariable('NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 $this->tpl->parseCurrentBlock();
             }
             // aggregation rows
             if ($numeric == $morning_aggr && $morning_aggr || $numeric == $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);
         }
         if ($ilUser->prefs["screen_reader_optimization"]) {
             $this->tpl->touchBlock('scrd_app_cell');
         }
         for ($i = $colspan - 1; $i > $hour['apps_num']; $i--) {
             $this->tpl->setCurrentBlock('empty_cell');
             $this->tpl->setVariable('EMPTY_WIDTH', 100 / (int) ($colspan - 1) . '%');
             // last "slot" of hour needs border
             if ($numeric % 60 == 60 - $raster || $numeric == $morning_aggr && $morning_aggr || $numeric == $evening_aggr && $evening_aggr) {
                 $this->tpl->setVariable('EMPTY_STYLE', ' calempty_border');
             }
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->touchBlock('time_row');
     }
 }
 /**
  * Add mini version of monthly overview
  * (Maybe extracted to another class, if used in pd calendar tab
  */
 function addMiniMonth($a_tpl)
 {
     global $ilCtrl, $lng, $ilUser;
     // weekdays
     include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
     $a_tpl->setCurrentBlock('month_header_col');
     $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
     $a_tpl->parseCurrentBlock();
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $a_tpl->setCurrentBlock('month_header_col');
         $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
         $a_tpl->parseCurrentBlock();
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH);
     $this->scheduler->calculate();
     $counter = 0;
     foreach (ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE, 'm'), $this->seed->get(IL_CAL_FKT_DATE, 'Y'), $this->user_settings->getWeekStart())->get() as $date) {
         $counter++;
         //$this->showEvents($date);
         $a_tpl->setCurrentBlock('month_col');
         if (count($this->scheduler->getByDay($date, $ilUser->getTimeZone()))) {
             $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
             #$a_tpl->setVariable('TD_CLASS','calminiapp');
         }
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         if (ilCalendarUtil::_isToday($date)) {
             $a_tpl->setVariable('TD_CLASS', 'calminitoday');
         } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calministd');
         } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calminiprev');
         } else {
             $a_tpl->setVariable('TD_CLASS', 'calmininext');
         }
         $day = $date->get(IL_CAL_FKT_DATE, 'j');
         $month = $date->get(IL_CAL_FKT_DATE, 'n');
         $month_day = $day;
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $ilCtrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
         $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui', ''));
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $a_tpl->setVariable('MONTH_DAY', $month_day);
         //$this->tpl->setVariable('NEW_SRC',ilUtil::getImagePath('new.png','calendar'));
         //$this->tpl->setVariable('NEW_ALT',$this->lng->txt('cal_new_app'));
         //$this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$date->get(IL_CAL_DATE));
         //$this->tpl->setVariable('ADD_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','add'));
         //$this->tpl->setVariable('OPEN_SRC',ilUtil::getImagePath('open.png','calendar'));
         $a_tpl->parseCurrentBlock();
         if ($counter and !($counter % 7)) {
             $a_tpl->setCurrentBlock('month_row');
             $ilCtrl->clearParametersByClass('ilcalendarweekgui');
             $ilCtrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
             $a_tpl->setVariable('OPEN_WEEK_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarweekgui', ''));
             $ilCtrl->clearParametersByClass('ilcalendarweekgui');
             $a_tpl->setVariable('TD_CLASS', 'calminiweek');
             $a_tpl->setVariable('WEEK', $date->get(IL_CAL_FKT_DATE, 'W'));
             $a_tpl->parseCurrentBlock();
         }
     }
     $a_tpl->setCurrentBlock('mini_month');
     $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
     $a_tpl->setVariable('TXT_MONTH', $lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y'));
     $myseed = clone $this->seed;
     $ilCtrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('OPEN_MONTH_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
     $myseed->increment(ilDateTime::MONTH, -1);
     $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
     //$a_tpl->setVariable('BL_TYPE', $this->getBlockType());
     //$a_tpl->setVariable('BL_ID', $this->getBlockId());
     $a_tpl->setVariable('PREV_MONTH', $ilCtrl->getLinkTarget($this->getParentObject(), ""));
     $myseed->increment(ilDateTime::MONTH, 2);
     $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('NEXT_MONTH', $ilCtrl->getLinkTarget($this->getParentObject(), ""));
     $ilCtrl->setParameter($this->getParentObject(), 'seed', "");
     $a_tpl->parseCurrentBlock();
 }
Ejemplo n.º 5
0
 /**
  * fill data section
  *
  * @access public
  * 
  */
 public function show()
 {
     global $ilUser, $lng;
     // config
     $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.week_view.html', true, true, 'Services/Calendar');
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     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;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_WEEK, $user_id, $disable_empty);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $counter = 0;
     $hours = null;
     $all_fullday = array();
     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);
         $all_fullday[] = $daily_apps;
         $counter++;
     }
     $colspans = $this->calculateColspans($hours);
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     // 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));
         if (!$no_add) {
             $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
             if ($settings->getEnableGroupMilestones()) {
                 $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone');
                 $this->tpl->setCurrentBlock("new_ms");
                 $this->tpl->setVariable('DD_ID', $date->get(IL_CAL_UNIX));
                 $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD));
                 $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url);
                 $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url);
                 $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms'));
                 $this->tpl->parseCurrentBlock();
             } else {
                 $this->tpl->setCurrentBlock("new_app");
                 $this->tpl->setVariable('NEW_APP_LINK', $new_app_url);
                 $this->tpl->setVariable('NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 // $this->tpl->setVariable('NEW_APP_ALT',$this->lng->txt('cal_new_app'));
                 $this->tpl->parseCurrentBlock();
             }
             $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         }
         $dayname = ilCalendarUtil::_numericDayToString($date->get(IL_CAL_FKT_DATE, 'w'), true);
         $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++;
     }
     // show fullday events
     $counter = 0;
     foreach ($all_fullday as $daily_apps) {
         foreach ($daily_apps as $event) {
             if ($event['fullday']) {
                 $this->showFulldayAppointment($event);
             }
         }
         $this->tpl->setCurrentBlock('f_day_row');
         $this->tpl->setVariable('COLSPAN', max($colspans[$counter], 1));
         $this->tpl->parseCurrentBlock();
         $counter++;
     }
     $this->tpl->setCurrentBlock('fullday_apps');
     $this->tpl->setVariable('TXT_F_DAY', $lng->txt("cal_all_day"));
     $this->tpl->parseCurrentBlock();
     $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;
                     // 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
             if (!$hour['apps_num'] && !$ilUser->prefs["screen_reader_optimization"] && !$no_add) {
                 $this->tpl->setCurrentBlock('new_app_link');
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $this->weekdays[$num_day]->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'hour', floor($num_hour / 60));
                 $this->tpl->setVariable('DAY_NEW_APP_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add'));
                 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
                 $this->tpl->setVariable('DAY_NEW_APP_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 $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", $lng->txt("time"));
 }
 protected function exportCSV(array $a_data, $a_scale)
 {
     global $lng, $ilClientIniFile, $ilUser;
     ilDatePresentation::setUseRelativeDates(false);
     include_once './Services/Link/classes/class.ilLink.php';
     include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
     $csv = new ilCSVWriter();
     $csv->setSeparator(";");
     $now = time();
     // meta
     $meta = array($lng->txt("trac_name_of_installation") => $ilClientIniFile->readVariable('client', 'name'), $lng->txt("trac_report_date") => ilDatePresentation::formatDate(new ilDateTime($now, IL_CAL_UNIX), IL_CAL_DATETIME), $lng->txt("trac_report_owner") => $ilUser->getFullName());
     foreach ($a_data as $idx => $item) {
         switch ($idx) {
             case "title":
                 $meta[$lng->txt("title")] = $item;
                 break;
             case "active":
                 // nothing to do
                 break;
             case "closed_details":
                 foreach ($item as $detail) {
                     $meta[$a_data["closed"][0] . " - " . $detail[0]] = $detail[1];
                 }
                 break;
             default:
                 $meta[$item[0]] = $item[1];
                 break;
         }
     }
     foreach ($meta as $caption => $value) {
         $csv->addColumn(strip_tags($caption));
         $csv->addColumn(strip_tags($value));
         $csv->addRow();
     }
     $csv->addRow();
     // aggregate data
     $aggr_data = $this->adaptDataToScale($a_scale, $a_data["active"], 700);
     unset($a_data);
     // header
     $first = $aggr_data;
     $first = array_keys(array_shift($first));
     foreach ($first as $column) {
         // split weekday and time slot again
         if ($a_scale == self::SCALE_PERIODIC_WEEK && $column == "slot_begin") {
             $csv->addColumn("weekday");
             $csv->addColumn("time");
         } else {
             $csv->addColumn(strip_tags($column));
         }
     }
     $csv->addRow();
     // data
     foreach ($aggr_data as $row) {
         foreach ($row as $column => $value) {
             if (is_array($value)) {
                 $value = implode(', ', $value);
             }
             switch ($column) {
                 case "slot_begin":
                     // split weekday and time slot again
                     if ($a_scale == self::SCALE_PERIODIC_WEEK) {
                         $csv->addColumn(ilCalendarUtil::_numericDayToString(substr($value, 0, 1)));
                         $value = substr($value, 1, 2) . ":" . substr($value, 3, 2);
                         break;
                     }
                     // fallthrough
                 // fallthrough
                 case "slot_end":
                     $value = date("d.m.Y H:i", $value);
                     break;
             }
             $csv->addColumn(strip_tags($value));
         }
         $csv->addRow();
     }
     // send
     $filename .= "session_statistics_" . date("Ymd", $now) . ".csv";
     header("Content-type: text/comma-separated-values");
     header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
     header("Pragma: public");
     echo $csv->getCSVString();
     exit;
 }
 protected function renderSlots(ilBookingSchedule $schedule, array $object_ids, $title)
 {
     global $ilUser;
     // fix
     if (!$schedule->getRaster()) {
         $mytpl = new ilTemplate('tpl.booking_reservation_fix.html', true, true, 'Modules/BookingManager');
         $mytpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this));
         $mytpl->setVariable('TXT_TITLE', $this->lng->txt('book_reservation_title'));
         $mytpl->setVariable('TXT_INFO', $this->lng->txt('book_reservation_fix_info'));
         $mytpl->setVariable('TXT_OBJECT', $title);
         $mytpl->setVariable('TXT_CMD_BOOK', $this->lng->txt('book_confirm_booking'));
         $mytpl->setVariable('TXT_CMD_CANCEL', $this->lng->txt('cancel'));
         include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php';
         $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
         $morning_aggr = $user_settings->getDayStart();
         $evening_aggr = $user_settings->getDayEnd();
         $hours = array();
         for ($i = $morning_aggr; $i <= $evening_aggr; $i++) {
             switch ($user_settings->getTimeFormat()) {
                 case ilCalendarSettings::TIME_FORMAT_24:
                     if ($morning_aggr > 0 && $i == $morning_aggr) {
                         $hours[$i] = sprintf('%02d:00', 0) . "-";
                     }
                     $hours[$i] .= sprintf('%02d:00', $i);
                     if ($evening_aggr < 23 && $i == $evening_aggr) {
                         $hours[$i] .= "-" . sprintf('%02d:00', 23);
                     }
                     break;
                 case ilCalendarSettings::TIME_FORMAT_12:
                     if ($morning_aggr > 0 && $i == $morning_aggr) {
                         $hours[$i] = date('h a', mktime(0, 0, 0, 1, 1, 2000)) . "-";
                     }
                     $hours[$i] .= date('h a', mktime($i, 0, 0, 1, 1, 2000));
                     if ($evening_aggr < 23 && $i == $evening_aggr) {
                         $hours[$i] .= "-" . date('h a', mktime(23, 0, 0, 1, 1, 2000));
                     }
                     break;
             }
         }
         if (isset($_GET['seed'])) {
             $find_first_open = false;
             $seed = new ilDate($_GET['seed'], IL_CAL_DATE);
         } else {
             $find_first_open = true;
             $seed = new ilDate(time(), IL_CAL_UNIX);
         }
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
         $week_start = $user_settings->getWeekStart();
         if (!$find_first_open) {
             $dates = array();
             $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
         } else {
             $dates = array();
             $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
             // find first open slot
             if (!$has_open_slot) {
                 // 1 year is limit for search
                 $limit = clone $seed;
                 $limit->increment(ilDate::YEAR, 1);
                 $limit = $limit->get(IL_CAL_UNIX);
                 while (!$has_open_slot && $seed->get(IL_CAL_UNIX) < $limit) {
                     $seed->increment(ilDate::WEEK, 1);
                     $dates = array();
                     $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
                 }
             }
         }
         include_once 'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php';
         $navigation = new ilCalendarHeaderNavigationGUI($this, $seed, ilDateTime::WEEK, 'book');
         $mytpl->setVariable('NAVIGATION', $navigation->getHTML());
         foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) {
             $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
             $mytpl->setCurrentBlock('weekdays');
             $mytpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($date_info['wday']));
             $mytpl->setVariable('TXT_DATE', $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon']));
             $mytpl->parseCurrentBlock();
         }
         include_once 'Services/Calendar/classes/class.ilCalendarAppointmentColors.php';
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         $color = array();
         $all = ilCalendarAppointmentColors::_getColorsByType('crs');
         for ($loop = 0; $loop < 7; $loop++) {
             $col = $all[$loop];
             $fnt = ilCalendarUtil::calculateFontColor($col);
             $color[$loop + 1] = 'border-bottom: 1px solid ' . $col . '; background-color: ' . $col . '; color: ' . $fnt;
         }
         $counter = 0;
         foreach ($dates as $hour => $days) {
             $caption = $days;
             $caption = array_shift($caption);
             for ($loop = 1; $loop < 8; $loop++) {
                 if (!isset($days[$loop])) {
                     $mytpl->setCurrentBlock('dates');
                     $mytpl->setVariable('DUMMY', '&nbsp;');
                     $mytpl->parseCurrentBlock();
                 } else {
                     if (isset($days[$loop]['captions'])) {
                         foreach ($days[$loop]['captions'] as $slot_id => $slot_caption) {
                             $mytpl->setCurrentBlock('choice');
                             $mytpl->setVariable('TXT_DATE', $slot_caption);
                             $mytpl->setVariable('VALUE_DATE', $slot_id);
                             $mytpl->setVariable('DATE_COLOR', $color[$loop]);
                             $mytpl->parseCurrentBlock();
                         }
                         $mytpl->setCurrentBlock('dates');
                         $mytpl->setVariable('DUMMY', '');
                         $mytpl->parseCurrentBlock();
                     } else {
                         if (isset($days[$loop]['in_slot'])) {
                             $mytpl->setCurrentBlock('dates');
                             $mytpl->setVariable('DATE_COLOR', $color[$loop]);
                             $mytpl->parseCurrentBlock();
                         } else {
                             $mytpl->setCurrentBlock('dates');
                             $mytpl->setVariable('DUMMY', '&nbsp;');
                             $mytpl->parseCurrentBlock();
                         }
                     }
                 }
             }
             $mytpl->setCurrentBlock('slots');
             $mytpl->setVariable('TXT_HOUR', $caption);
             if ($counter % 2) {
                 $mytpl->setVariable('CSS_ROW', 'tblrow1');
             } else {
                 $mytpl->setVariable('CSS_ROW', 'tblrow2');
             }
             $mytpl->parseCurrentBlock();
             $counter++;
         }
     } else {
         // :TODO: inactive for now
     }
     return $mytpl->get();
 }
 /**
  * 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();
     }
 }
Ejemplo n.º 9
0
 /**
  * fill data section
  *
  * @access public
  * 
  */
 public function show()
 {
     global $tpl, $ilUser;
     $this->tpl = new ilTemplate('tpl.month_view.html', true, true, 'Services/Calendar');
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::MONTH);
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $this->tpl->setCurrentBlock('month_header_col');
         $this->tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, true));
         $this->tpl->parseCurrentBlock();
     }
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
         $no_add = true;
     } else {
         if ($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;
         }
     }
     $is_portfolio_embedded = false;
     if (ilCalendarCategories::_getInstance()->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) {
         $no_add = true;
         $is_portfolio_embedded = true;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
     $this->scheduler->addSubitemCalendars(true);
     if (sizeof($this->schedule_filters)) {
         foreach ($this->schedule_filters as $filter) {
             $this->scheduler->addFilter($filter);
         }
     }
     $this->scheduler->calculate();
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     $counter = 0;
     foreach (ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE, 'm'), $this->seed->get(IL_CAL_FKT_DATE, 'Y'), $this->user_settings->getWeekStart())->get() as $date) {
         $counter++;
         $has_events = (bool) $this->showEvents($date);
         if (!$no_add) {
             include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
             $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
             $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
             if ($settings->getEnableGroupMilestones()) {
                 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
                 $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone');
                 $this->tpl->setCurrentBlock("new_ms");
                 $this->tpl->setVariable('DD_ID', $date->get(IL_CAL_UNIX));
                 $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD));
                 $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url);
                 $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url);
                 $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms'));
                 $this->tpl->parseCurrentBlock();
             } else {
                 $this->tpl->setCurrentBlock("new_app");
                 $this->tpl->setVariable('ADD_LINK', $new_app_url);
                 $this->tpl->setVariable('NEW_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 $this->tpl->parseCurrentBlock();
             }
         }
         $day = $date->get(IL_CAL_FKT_DATE, 'j');
         $month = $date->get(IL_CAL_FKT_DATE, 'n');
         if ($day == 1) {
             $month_day = '1 ' . ilCalendarUtil::_numericMonthToString($month, false);
         } else {
             $month_day = $day;
         }
         if (!$is_portfolio_embedded && (!$disable_empty || $has_events)) {
             $this->tpl->setCurrentBlock('month_day_link');
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
             $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
             $this->tpl->setVariable('OPEN_DAY_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''));
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
         } else {
             $this->tpl->setCurrentBlock('month_day_no_link');
         }
         $this->tpl->setVariable('MONTH_DAY', $month_day);
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock('month_col');
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         if (ilCalendarUtil::_isToday($date)) {
             $this->tpl->setVariable('TD_CLASS', 'caltoday');
         } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
             $this->tpl->setVariable('TD_CLASS', 'calstd');
         } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
             $this->tpl->setVariable('TD_CLASS', 'calprev');
         } else {
             $this->tpl->setVariable('TD_CLASS', 'calnext');
         }
         $this->tpl->parseCurrentBlock();
         if ($counter and !($counter % 7)) {
             $this->tpl->setCurrentBlock('month_row');
             $this->tpl->parseCurrentBlock();
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * 
  *
  * @access protected
  * @param
  * @return
  */
 protected function buildYearlyByDaySelection($tpl)
 {
     $tpl->setVariable('TXT_ON_THE', $this->lng->txt('cal_on_the'));
     $chosen_num_day = 1;
     $chosen_day = 'MO';
     $chosen = false;
     foreach ($this->recurrence->getBYDAYList() as $byday) {
         if (preg_match('/^(-?\\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
             $chosen = true;
             $chosen_num_day = $parsed[1];
             $chosen_day = $parsed[2];
         }
     }
     $num_options = array(1 => $this->lng->txt('cal_first'), 2 => $this->lng->txt('cal_second'), 3 => $this->lng->txt('cal_third'), 4 => $this->lng->txt('cal_fourth'), 5 => $this->lng->txt('cal_fifth'), -1 => $this->lng->txt('cal_last'));
     $tpl->setVariable('SELECT_BYDAY_NUM_YEARLY', ilUtil::formSelect($chosen_num_day, 'yearly_byday_num', $num_options, false, true, '', '', array('onchange' => "ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
     $days = array(0 => 'SU', 1 => 'MO', 2 => 'TU', 3 => 'WE', 4 => 'TH', 5 => 'FR', 6 => 'SA', 7 => 'SU');
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $days_select[$days[$i]] = ilCalendarUtil::_numericDayToString($i);
     }
     $tpl->setVariable('SELECT_BYDAY_DAY_YEARLY', ilUtil::formSelect($chosen_day, 'yearly_byday', $days_select, false, true, '', '', array('onchange' => "ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
     $chosen = false;
     $chosen_month = 1;
     foreach ($this->recurrence->getBYMONTHList() as $month) {
         if ($this->recurrence->getBYMONTHDAYList()) {
             $chosen_month = $month;
             $chosen = true;
             break;
         }
     }
     $options = array();
     for ($m = 1; $m < 13; $m++) {
         $options[$m] = ilCalendarUtil::_numericMonthToString($m);
     }
     $tpl->setVariable('SELECT_BYMONTH_BYDAY', ilUtil::formSelect($chosen_month, 'yearly_bymonth_byday', $options, false, true, '', '', array('onchange' => "ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
 }
 protected function fillRowCSV($a_csv, $a_set)
 {
     $a_csv->addColumn($a_set["title"]);
     if ($this->has_schedule) {
         $a_csv->addColumn(ilDatePresentation::formatDate(new ilDate($a_set["date"], IL_CAL_DATE)));
         $a_csv->addColumn(ilCalendarUtil::_numericDayToString($a_set["weekday"], false));
         $a_csv->addColumn($a_set["slot"]);
         $a_csv->addColumn($a_set["counter"]);
     } else {
         $status = "";
         if (in_array($a_set['status'], array(ilBookingReservation::STATUS_CANCELLED, ilBookingReservation::STATUS_IN_USE))) {
             $status = $this->lng->txt('book_reservation_status_' . $a_set['status']);
         }
         $a_csv->addColumn($status);
     }
     $a_csv->addColumn($a_set['user_name']);
     $a_csv->addRow();
 }