/**
  * Update multiple sequence items
  * @return
  */
 protected function updateMulti()
 {
     global $ilObjDataCache;
     $this->initFormSequence(self::MODE_MULTI);
     if ($this->form->checkInput()) {
         $this->form->setValuesByPost();
         $apps = explode(';', $_POST['apps']);
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
         // do collision-check if max bookings were reduced
         // no collision check
         $first = $apps;
         $first = array_shift($first);
         $entry = ilBookingEntry::getInstanceByCalendarEntryId($first);
         #if($this->form->getInput('bo') < $entry->getNumberOfBookings())
         #{
         #   $this->edit();
         #   return;
         #}
         // create new context
         $booking = new ilBookingEntry();
         $booking->setObjId($this->getUserId());
         $booking->setNumberOfBookings($this->form->getInput('bo'));
         $deadline = $this->form->getInput('dead');
         $deadline = $deadline['dd'] * 24 + $deadline['hh'];
         $booking->setDeadlineHours($deadline);
         $tgt = explode(',', $this->form->getInput('tgt'));
         $obj_ids = array();
         foreach ((array) $tgt as $ref_id) {
             if (!trim($ref_id)) {
                 continue;
             }
             $obj_id = $ilObjDataCache->lookupObjId($ref_id);
             $type = ilObject::_lookupType($obj_id);
             $valid_types = array('crs', 'grp');
             if (!$obj_id or !in_array($type, $valid_types)) {
                 ilUtil::sendFailure($this->lng->txt('cal_ch_unknown_repository_object'));
                 $this->edit();
                 return;
             }
             $obj_ids[] = $obj_id;
         }
         $booking->setTargetObjIds($obj_ids);
         include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php';
         if (ilConsultationHourGroups::getCountGroupsOfUser($this->getUserId())) {
             $booking->setBookingGroup($this->form->getInput('grp'));
         }
         $booking->save();
         // update entries
         $title = $this->form->getInput('ti');
         $location = $this->form->getInput('lo');
         $description = $this->form->getInput('de');
         foreach ($apps as $item_id) {
             $entry = new ilCalendarEntry($item_id);
             $entry->setContextId($booking->getId());
             $entry->setTitle($title);
             $entry->setLocation($location);
             $entry->setDescription($description);
             $entry->update();
         }
         ilBookingEntry::removeObsoleteEntries();
         ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
         $this->ctrl->redirect($this, 'appointmentList');
     }
     $this->tpl->setContent($this->form->getHTML());
 }
 /**
  * Update multiple sequence items
  * @return
  */
 protected function updateMulti()
 {
     global $ilObjDataCache;
     $this->initFormSequence(self::MODE_MULTI);
     if ($this->form->checkInput()) {
         $this->form->setValuesByPost();
         $apps = explode(';', $_POST['apps']);
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
         // do collision-check if max bookings were reduced
         $first = $apps;
         $first = array_shift($first);
         $entry = ilBookingEntry::getInstanceByCalendarEntryId($first);
         if ($this->form->getInput('bo') < $entry->getNumberOfBookings()) {
             $this->edit();
             return;
         }
         // create new context
         $booking = new ilBookingEntry();
         $booking->setObjId($this->getUserId());
         $booking->setNumberOfBookings($this->form->getInput('bo'));
         $deadline = $this->form->getInput('dead');
         $deadline = $deadline['dd'] * 24 + $deadline['hh'];
         $booking->setDeadlineHours($deadline);
         $tgt = $this->form->getInput('tgt');
         if ($tgt) {
             // if value was not changed, we already have an object id
             if ($tgt != $entry->getTargetObjId()) {
                 $obj_id = $ilObjDataCache->lookupObjId($tgt);
                 if (!$obj_id) {
                     ilUtil::sendFailure($this->lng->txt('cal_ch_unknown_repository_object'), true);
                     $this->edit();
                     return;
                 }
                 $booking->setTargetObjId($obj_id);
             } else {
                 $booking->setTargetObjId($tgt);
             }
         }
         $booking->save();
         // update entries
         $title = $this->form->getInput('ti');
         $location = $this->form->getInput('lo');
         $description = $this->form->getInput('de');
         foreach ($apps as $item_id) {
             $entry = new ilCalendarEntry($item_id);
             $entry->setContextId($booking->getId());
             $entry->setTitle($title);
             $entry->setLocation($location);
             $entry->setDescription($description);
             $entry->update();
         }
         ilBookingEntry::removeObsoleteEntries();
         ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
         $this->ctrl->redirect($this, 'appointmentList');
     }
     $this->tpl->setContent($this->form->getHTML());
 }