/**
  * 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();
 }
 /**
  * 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();
 }
 /**
  * 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();
         }
     }
 }