/** * Cancel a booking * @param type $a_usr_id * @param type $a_app_id * @return bool */ public static function cancelBooking($a_usr_id, $a_app_id, $a_send_notification = true) { // Delete personal copy of appointment include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; $app = new ilCalendarEntry($a_app_id); include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php'; $user_apps = ilConsultationHourAppointments::getAppointmentIds($a_usr_id, $app->getContextId(), $app->getStart(), ilCalendarCategory::TYPE_CH, false); foreach ($user_apps as $uapp_id) { $uapp = new ilCalendarEntry($uapp_id); $uapp->delete(); include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; ilCalendarCategoryAssignments::_deleteByAppointmentId($uapp_id); break; } // Delete booking entries // Send notification $booking = new ilBookingEntry($app->getContextId()); if ($a_send_notification) { $booking->cancelBooking($a_app_id, $a_usr_id); } else { $booking->deleteBooking($a_app_id, $a_usr_id); } return true; }
/** * Cancel consultation appointment or ressource booking, was confirmed * This will delete the calendar entry */ public function cancelConfirmed() { global $ilUser; $entry = (int) $_POST['app_id']; $user = (int) $_GET['bkid']; include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry($entry); $category = $this->calendarEntryToCategory($entry); if ($category->getType() == ilCalendarCategory::TYPE_CH) { // find cloned calendar entry in user calendar include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php'; $GLOBALS['ilLog']->dump($entry->getStart()); $apps = ilConsultationHourAppointments::getAppointmentIds($ilUser->getId(), $entry->getContextId(), $entry->getStart(), ilCalendarCategory::TYPE_CH, false); $GLOBALS['ilLog']->dump($apps); // Fix for wrong, old entries foreach ((array) $apps as $own_app) { $ref_entry = new ilCalendarEntry($own_app); $ref_entry->delete(); } include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $booking = new ilBookingEntry($entry->getContextId()); $booking->cancelBooking($entry->getEntryId()); // do NOT delete original entry } else { if ($category->getType() == ilCalendarCategory::TYPE_BOOK) { include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $booking = new ilBookingReservation($entry->getContextId()); $booking->setStatus(ilBookingReservation::STATUS_CANCELLED); $booking->update(); $entry->delete(); } } ilUtil::sendSuccess($this->lng->txt('cal_cancel_booking_confirmed'), true); $this->ctrl->returnToParent($this); }