/**
  * get singleton instance
  *
  * @access public
  * @param
  * @return
  * @static
  */
 public static function _getInstance(ilDate $seed)
 {
     if (isset(self::$instance) and self::$instance) {
         return self::$instance;
     }
     return self::$instance = new ilCalendarAppointmentPanelGUI($seed);
 }
 /**
  * show appointment
  *
  * @access protected
  * @param array appointment
  */
 protected function showAppointment($a_app)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('panel_code');
     $this->tpl->setVariable('NUM', $this->num_appointments);
     $this->tpl->parseCurrentBlock();
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         $this->tpl->setCurrentBlock('app');
     } else {
         $this->tpl->setCurrentBlock('scrd_app');
     }
     include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
     $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
     $this->tpl->setVariable('PANEL_NUM', $this->num_appointments);
     $this->tpl->setVariable('APP_ROWSPAN', $a_app['rowspan']);
     $this->tpl->setVariable('APP_TITLE', $a_app['event']->getPresentationTitle(false));
     switch ($this->user_settings->getTimeFormat()) {
         case ilCalendarSettings::TIME_FORMAT_24:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
             break;
         case ilCalendarSettings::TIME_FORMAT_12:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
             break;
     }
     // add end time for screen readers
     if ($ilUser->prefs["screen_reader_optimization"]) {
         switch ($this->user_settings->getTimeFormat()) {
             case ilCalendarSettings::TIME_FORMAT_24:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                 break;
             case ilCalendarSettings::TIME_FORMAT_12:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                 break;
         }
     }
     $title .= ' ' . $a_app['event']->getPresentationTitle(false);
     $this->tpl->setVariable('APP_TITLE', $title);
     $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_BGCOLOR', $color);
     $this->tpl->setVariable('APP_COLOR', ilCalendarUtil::calculateFontColor($color));
     $this->tpl->setVariable('APP_ADD_STYLES', $a_app['event']->getPresentationStyle());
     $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
     $this->tpl->parseCurrentBlock();
     $this->num_appointments++;
 }
 /**
  * show appointment
  *
  * @access protected
  * @param array appointment
  */
 protected function showAppointment($a_app)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('panel_code');
     $this->tpl->setVariable('NUM', $this->num_appointments);
     $this->tpl->parseCurrentBlock();
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         $this->tpl->setCurrentBLock('not_empty');
     } else {
         $this->tpl->setCurrentBLock('scrd_not_empty');
     }
     include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
     $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
     $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
     $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
     $style = 'background-color: ' . $color . ';';
     $style .= 'color:' . ilCalendarUtil::calculateFontColor($color);
     $td_style = $style;
     if ($a_app['event']->isFullDay()) {
         $title = $a_app['event']->getPresentationTitle();
     } else {
         switch ($this->user_settings->getTimeFormat()) {
             case ilCalendarSettings::TIME_FORMAT_24:
                 $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                 break;
             case ilCalendarSettings::TIME_FORMAT_12:
                 $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                 break;
         }
         // add end time for screen readers
         if ($ilUser->prefs["screen_reader_optimization"]) {
             switch ($this->user_settings->getTimeFormat()) {
                 case ilCalendarSettings::TIME_FORMAT_24:
                     $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                     break;
                 case ilCalendarSettings::TIME_FORMAT_12:
                     $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                     break;
             }
         }
         $title .= ' ' . $a_app['event']->getPresentationTitle();
         $td_style .= $a_app['event']->getPresentationStyle();
     }
     $this->tpl->setVariable('APP_TITLE', $title);
     $this->tpl->setVariable('LINK_NUM', $this->num_appointments);
     $this->tpl->setVariable('LINK_STYLE', $style);
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         // provide table cell attributes
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock('day_cell');
         $this->tpl->setVariable('DAY_CELL_NUM', $this->num_appointments);
         $this->tpl->setVariable('TD_ROWSPAN', $a_app['rowspan']);
         $this->tpl->setVariable('TD_STYLE', $td_style);
         $this->tpl->setVariable('TD_CLASS', 'calevent');
         $this->tpl->parseCurrentBlock();
     } else {
         // screen reader: work on div attributes
         $this->tpl->setVariable('DIV_STYLE', $style);
         $this->tpl->parseCurrentBlock();
     }
     $this->num_appointments++;
 }
 /**
  * 
  * Show events
  *
  * @access protected
  */
 protected function showEvents(ilDate $date)
 {
     global $tree, $ilUser;
     $count = 0;
     foreach ($this->scheduler->getByDay($date, $this->timezone) as $item) {
         $this->tpl->setCurrentBlock('panel_code');
         $this->tpl->setVariable('NUM', $this->num_appointments);
         $this->tpl->parseCurrentBlock();
         // milestone icon
         if ($item['event']->isMilestone()) {
             $this->tpl->setCurrentBlock('fullday_ms_icon');
             $this->tpl->setVariable('ALT_FD_MS', $this->lng->txt("cal_milestone"));
             $this->tpl->setVariable('SRC_FD_MS', ilUtil::getImagePath("icon_ms.svg"));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('il_event');
         include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
         $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($item));
         $this->tpl->setVariable('PANEL_NUM', $this->num_appointments);
         $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $item['event']->getEntryId());
         $this->tpl->setVariable('EVENT_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
         $this->tpl->setVariable('EVENT_NUM', $item['event']->getEntryId());
         $compl = $item['event']->isMilestone() && $item['event']->getCompletion() > 0 ? " (" . $item['event']->getCompletion() . "%)" : "";
         if ($item['event']->isFullDay()) {
             $title = $item['event']->getPresentationTitle() . $compl;
         } else {
             switch ($this->user_settings->getTimeFormat()) {
                 case ilCalendarSettings::TIME_FORMAT_24:
                     $title = $item['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                     break;
                 case ilCalendarSettings::TIME_FORMAT_12:
                     $title = $item['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                     break;
             }
             $title .= ' ' . $item['event']->getPresentationTitle();
         }
         $this->tpl->setVariable('EVENT_TITLE', $title);
         $color = $this->app_colors->getColorByAppointment($item['event']->getEntryId());
         $this->tpl->setVariable('EVENT_BGCOLOR', $color);
         $this->tpl->setVariable('EVENT_ADD_STYLES', $item['event']->getPresentationStyle());
         $this->tpl->setVariable('EVENT_FONTCOLOR', ilCalendarUtil::calculateFontColor($color));
         $this->tpl->parseCurrentBlock();
         $this->num_appointments++;
         $count++;
     }
     return $count;
 }
 /**
  * show appointment
  *
  * @access protected
  * @param array appointment
  */
 protected function showAppointment($a_app)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('panel_code');
     $this->tpl->setVariable('NUM', $this->num_appointments);
     $this->tpl->parseCurrentBlock();
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         $this->tpl->setCurrentBlock('app');
     } else {
         $this->tpl->setCurrentBlock('scrd_app');
     }
     include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
     $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
     $this->tpl->setVariable('PANEL_NUM', $this->num_appointments);
     $this->tpl->setVariable('APP_ROWSPAN', $a_app['rowspan']);
     $this->tpl->setVariable('APP_TITLE', $a_app['event']->getPresentationTitle(false));
     switch ($this->user_settings->getTimeFormat()) {
         case ilCalendarSettings::TIME_FORMAT_24:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
             break;
         case ilCalendarSettings::TIME_FORMAT_12:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
             break;
     }
     // add end time for screen readers
     if ($ilUser->prefs["screen_reader_optimization"]) {
         switch ($this->user_settings->getTimeFormat()) {
             case ilCalendarSettings::TIME_FORMAT_24:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                 break;
             case ilCalendarSettings::TIME_FORMAT_12:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                 break;
         }
     }
     // booking
     if ($a_app['category_type'] == ilCalendarCategory::TYPE_CH) {
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         $entry = new ilBookingEntry($a_app['event']->getContextId());
         if ($entry) {
             $title .= ' ' . $a_app['event']->getTitle();
             if ($entry->isOwner()) {
                 $max = (int) $entry->getNumberOfBookings();
                 $current = (int) $entry->getCurrentNumberOfBookings($a_app['event']->getEntryId());
                 if ($max > 1) {
                     $title .= ' (' . $current . '/' . $max . ')';
                 } else {
                     if ($current == $max) {
                         $title .= ' (' . $this->lng->txt('cal_booked_out') . ')';
                     } else {
                         $title .= ' (' . $this->lng->txt('cal_book_free') . ')';
                     }
                 }
             } else {
                 if ($entry->hasBooked($a_app['event']->getEntryId())) {
                     $title .= ' (' . $this->lng->txt('cal_date_booked') . ')';
                 }
             }
         }
     } else {
         $title .= ' ' . $a_app['event']->getPresentationTitle(false);
     }
     $this->tpl->setVariable('APP_TITLE', $title);
     $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_BGCOLOR', $color);
     $this->tpl->setVariable('APP_COLOR', ilCalendarUtil::calculateFontColor($color));
     $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
     $this->tpl->parseCurrentBlock();
     $this->num_appointments++;
 }