/** * Method to add a new booking into the database * * @param type $a_booking_values Array with the values of the booking * @param type $a_booking_attr_values Array with the values of the booking-attributes * @param type $a_booking_participants Array with the values of the participants * @param type $a_recurrence_entries Array with recurrence information * @param boolean $sendmessage Send message * * @throws ilRoomSharingBookException * @return array Booking-IDs which are canceled */ public function addBooking($a_booking_values, $a_booking_attr_values, $a_booking_participants, $a_recurrence_entries, $sendmessage = true) { if ($this->permission->checkPrivilege(PRIVC::ADD_OWN_BOOKINGS)) { $this->date_from = $a_booking_values['from']['date'] . " " . $a_booking_values['from']['time']; $this->date_to = $a_booking_values['to']['date'] . " " . $a_booking_values['to']['time']; $this->room_id = $a_booking_values['room']; $this->participants = $a_booking_participants; $this->recurrence = $a_recurrence_entries; $datetimes = $this->generateDatetimesForBooking(); $this->validateBookingInput($datetimes['from'], $datetimes['to']); $a_booking_values['from'] = $datetimes['from']; $a_booking_values['to'] = $datetimes['to']; $booking_ids_of_bookings_to_be_canceled = $this->ilRoomsharingDatabase->getBookingIdsForRoomInDateimeRanges($this->room_id, $a_booking_values['from'], $a_booking_values['to']); if (ilRoomSharingNumericUtils::isPositiveNumber(count($booking_ids_of_bookings_to_be_canceled))) { $bookings = new ilRoomSharingBookings($this->pool_id); try { $bookings->removeMultipleBookings($booking_ids_of_bookings_to_be_canceled, true); } catch (ilRoomSharingBookingsException $ex) { throw new ilRoomSharingBookException($ex->getMessage()); } } $success = $this->ilRoomsharingDatabase->insertBookingRecurrence($a_booking_attr_values, $a_booking_values, $a_booking_participants); if ($success) { if ($sendmessage) { $this->sendBookingNotification(); } return count($booking_ids_of_bookings_to_be_canceled); } else { throw new ilRoomSharingBookException($this->lng->txt('rep_robj_xrs_booking_add_error')); } } else { throw new ilRoomSharingBookException($this->lng->txt('rep_robj_xrs_no_permission_for_action')); } return 0; }
/** * Cancels Multiple Bookings. */ public function cancelMultipleBookingsObject() { $bookings = new ilRoomSharingBookings($this->pool_id); try { $bookings->removeMultipleBookings($_POST["booking_ids"]); } catch (ilRoomSharingBookingsException $exc) { ilUtil::sendFailure($this->lng->txt($exc->getMessage()), true); $this->showBookingsObject(); } $this->showBookingsObject(); }