protected function createAppointment()
 {
     global $ilTabs;
     $form = $this->initAppointmentCreationForm();
     $ilTabs->activateTab('content');
     if (!$form->checkInput()) {
         $form->setValuesByPost();
         ilUtil::sendFailure($this->lng->txt('err_check_input'));
         $GLOBALS['tpl']->setContent($form->getHTML());
         return false;
     }
     // Save and create appointment
     $settings = ilViteroSettings::getInstance();
     $room = new ilViteroRoom();
     $room->setRoomSize($form->getInput('room_size'));
     if ($settings->isCafeEnabled() and $settings->isStandardRoomEnabled()) {
         if ($form->getInput('atype') == ilViteroRoom::TYPE_CAFE) {
             $room = $this->loadCafeSettings($form, $room);
         } else {
             $room = $this->loadStandardRoomSettings($form, $room);
         }
         $room->isCafe($form->getInput('atype') == ilViteroRoom::TYPE_CAFE);
     } elseif ($settings->isCafeEnabled()) {
         $this->loadCafeSettings($form, $room);
     } else {
         $this->loadStandardRoomSettings($form, $room);
     }
     try {
         $this->object->initAppointment($room);
         ilUtil::sendSuccess(ilViteroPlugin::getInstance()->txt('created_vitero'), true);
         $this->ctrl->redirect($this, 'showContent');
         return true;
     } catch (ilViteroConnectorException $e) {
         ilUtil::sendFailure($e->getViteroMessage(), true);
         $form->setValuesByPost();
         $GLOBALS['tpl']->setContent($form->getHTML());
     }
 }
 /**
  * Copy bookings from one group to another
  * @param <type> $a_old_group
  * @param <type> $a_new_group
  * @throws ilViteroConnectorException
  */
 public function copyBookings($a_old_group, $a_new_group)
 {
     // Read all bookings of old group
     $now = new ilDateTime(time(), IL_CAL_UNIX);
     $later = clone $now;
     $later->increment(IL_CAL_YEAR, 5);
     try {
         $bookings = $this->getByGroupAndDate($a_old_group, $now, $later);
     } catch (ilViteroConnectorException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Copying vitero group failed with message ' . $e);
         return false;
     }
     foreach ((array) $bookings->booking as $booking) {
         $room = new ilViteroRoom();
         $room->setBufferBefore($booking->startbuffer);
         $room->setBufferAfter($booking->endbuffer);
         $room->setRoomSize($booking->roomsize);
         $room->enableCafe($booking->cafe ? true : false);
         $room->setStart(ilViteroUtils::parseSoapDate($booking->start));
         $room->setEnd(ilViteroUtils::parseSoapDate($booking->end));
         $room->setRepetition($booking->repetitionpattern);
         $rep_end = ilViteroUtils::parseSoapDate($booking->repetitionenddate);
         if ($rep_end instanceof ilDateTime) {
             $room->setRepetitionEndDate($rep_end);
         }
         try {
             $this->create($room, $a_new_group);
         } catch (ilViteroConnectorException $e) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Copying vitero group failed with message ' . $e);
         }
     }
 }