Exemplo n.º 1
0
 protected function updateBooking()
 {
     global $ilTabs;
     $ilTabs->activateTab('content');
     $this->ctrl->setParameter($this, 'bookid', (int) $_REQUEST['bookid']);
     try {
         $booking_service = new ilViteroBookingSoapConnector();
         $booking = $booking_service->getBookingById((int) $_REQUEST['bookid']);
     } catch (ilViteroConnectorException $e) {
         ilUtil::sendFailure($e->getMessage(), true);
         $this->ctrl->redirect($this, 'showContent');
     }
     $form = $this->initUpdateBookingForm($booking);
     if (!$form->checkInput()) {
         $form->setValuesByPost();
         ilUtil::sendFailure($this->lng->txt('err_check_input'));
         $GLOBALS['tpl']->setContent($form->getHTML());
         return false;
     }
     $room = new ilViteroRoom();
     $room->setBookingId($booking->booking->bookingid);
     $room->setBufferBefore((int) $_POST['buffer_before']);
     $room->setBufferAfter((int) $_POST['buffer_after']);
     // Set end date for cafe room
     if ($booking->booking->cafe) {
         $start = $form->getItemByPostVar('cstart')->getDate();
         $end = clone $start;
         $end->increment(IL_CAL_DAY, 1);
         $room->setStart($start);
         $room->setEnd($end);
     } else {
         $start = $form->getItemByPostVar('roomduration')->getStart();
         $end = $form->getItemByPostVar('roomduration')->getEnd();
         $room->setStart($start);
         $room->setEnd($end);
     }
     try {
         $con = new ilViteroBookingSoapConnector();
         $con->updateBooking($room, $this->object->getVGroupId());
         ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'), 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);
         }
     }
 }