/**
  * Edit multiple sequence items
  */
 public function edit()
 {
     global $ilTabs;
     if (!isset($_REQUEST['apps'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         return $this->appointmentList();
     }
     $this->initFormSequence(self::MODE_MULTI);
     if ($_REQUEST['apps'] && !is_array($_REQUEST['apps'])) {
         $_REQUEST['apps'] = explode(';', $_REQUEST['apps']);
     }
     $hidden = new ilHiddenInputGUI('apps');
     $hidden->setValue(implode(';', $_REQUEST['apps']));
     $this->form->addItem($hidden);
     include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
     $first = $_REQUEST['apps'];
     $first = array_shift($_REQUEST['apps']);
     $entry = new ilCalendarEntry($first);
     $this->form->getItemByPostVar('ti')->setValue($entry->getTitle());
     $this->form->getItemByPostVar('lo')->setValue($entry->getLocation());
     $this->form->getItemByPostVar('de')->setValue($entry->getDescription());
     include_once 'Services/Booking/classes/class.ilBookingEntry.php';
     $booking = new ilBookingEntry($entry->getContextId());
     $this->form->getItemByPostVar('bo')->setValue($booking->getNumberOfBookings());
     $ref_ids = array();
     foreach ($booking->getTargetObjIds() as $obj_id) {
         $refs = ilObject::_getAllReferences($obj_id);
         $ref_ids[] = end($refs);
     }
     $this->form->getItemByPostVar('tgt')->setValue(implode(',', $ref_ids));
     $deadline = $booking->getDeadlineHours();
     $this->form->getItemByPostVar('dead')->setDays(floor($deadline / 24));
     $this->form->getItemByPostVar('dead')->setHours($deadline % 24);
     if ($booking->getBookingGroup()) {
         $this->form->getItemByPostVar('grp')->setValue($booking->getBookingGroup());
     }
     $this->tpl->setContent($this->form->getHTML());
 }
 /**
  * set appointments
  *
  * @access public
  * @return
  */
 public function setAppointments($a_apps)
 {
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     $cat = new ilCalendarCategory($this->cat_id);
     foreach ($a_apps as $cal_entry_id) {
         $entry = new ilCalendarEntry($cal_entry_id);
         $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
         // booking
         if ($cat->getType() == ilCalendarCategory::TYPE_CH) {
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $book = new ilBookingEntry($entry->getContextId());
             if ($book) {
                 $title = $entry->getTitle();
                 if ($book->isOwner()) {
                     $max = (int) $book->getNumberOfBookings();
                     $current = (int) $book->getCurrentNumberOfBookings($entry->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 ($book->hasBooked($entry->getEntryId())) {
                         $title .= ' (' . $this->lng->txt('cal_date_booked') . ')';
                     }
                 }
             }
         } else {
             $title = $entry->getPresentationTitle();
         }
         $tmp_arr['id'] = $entry->getEntryId();
         $tmp_arr['title'] = $title;
         $tmp_arr['description'] = $entry->getDescription();
         $tmp_arr['fullday'] = $entry->isFullday();
         $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
         $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
         $tmp_arr['dt_sort'] = $entry->getStart()->get(IL_CAL_UNIX);
         $tmp_arr['dt'] = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
         #$tmp_arr['duration'] = ($dur = $tmp_arr['end'] - $tmp_arr['begin']) ? $dur : 60 * 60 * 24;
         $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
         if ($tmp_arr['fullday']) {
             $tmp_arr['duration'] += 60 * 60 * 24;
         }
         if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) {
             $tmp_arr['duration'] = '';
         }
         $tmp_arr['frequence'] = $rec->getFrequenceType();
         $tmp_arr['deletable'] = (!$entry->isAutoGenerated() and $this->is_editable);
         $appointments[] = $tmp_arr;
     }
     $this->setData($appointments ? $appointments : array());
 }