public function getRoom() { global $logger; $logger->LogDebug(__METHOD__ . "Getting room for booking with room id: " . $this->roomId); $room = Room::fetchFromDb($this->roomId); if ($room == null) { $logger->LogError("There is no room with id: " . $this->roomId); $this->errors = Room::$staticErrors; } else { $logger->LogDebug("Found room with id: " . $this->clientId); } return $room; }
$systemConfiguration->assertReferer(); $logger->LogInfo("Getting session object ..."); if (!isset($_SESSION['bookingDetails'])) { $logger->LogError("Session object is not set!"); header("Location: booking-failure.php?error_code=9"); } // Get booking details from session $bookingDetails = unserialize($_SESSION['bookingDetails']); // Get selected room $logger->LogInfo("Getting selected room ..."); if (!isset($_POST['roomId']) || !is_numeric($_POST['roomId'])) { $logger->LogError("No roomId variable in POST!"); $_SESSION['errors'] = array(0 => BOOKING_FAILURE_INVALID_REQUEST); header("Location: booking-failure.php"); } $selectedRoom = Room::fetchFromDb(intval($_POST['roomId'])); if (is_null($selectedRoom) || is_null($bookingDetails->searchCriteria)) { $logger->LogError("No room for roomId: " . $_POST['roomId'] . " could be foudn in the database!"); $_SESSION['errors'] = array(0 => BOOKING_FAILURE_INVALID_REQUEST); header("Location: booking-failure.php"); } $logger->LogInfo("Selected room is: " . $selectedRoom->roomName . " #" . $selectedRoom->roomNumber); $bookingDetails->room = $selectedRoom; // Save booking details to session $bookingDetailsSerialized = serialize($bookingDetails); $_SESSION['bookingDetails'] = $bookingDetailsSerialized; // Get all extra services $logger->LogInfo("Fetching all extra services ..."); $extraServices = ExtraService::fetchAllFromDb(); $logger->LogInfo("Fetched " . count($extraServices) . " extra services."); // If there are no extra bed option or other services available, skip
session_start(); global $systemConfiguration; global $logger; if (!isset($_SESSION['bookingDetailsAdmin'])) { $_SESSION['errors'] = array(0 => "Invalid request: could not find search data in session"); header("Location: error.php"); } // Get booking details from session $bookingDetails = unserialize($_SESSION['bookingDetailsAdmin']); // Get selected room if (!isset($_POST['roomId']) || !is_numeric($_POST['roomId'])) { $_SESSION['errors'] = array(0 => "Invalid request: could not find selected room to book"); header("Location: booking-failure.php"); } $roomId = intval($_POST['roomId']); $selectedRoom = Room::fetchFromDb($roomId); if ($selectedRoom == null) { $_SESSION['errors'] = array(0 => "Invalid request: there is no room/apartment with id {$roomId}"); header("Location: error.php"); } $bookingDetails->room = $selectedRoom; // Save booking details to session $bookingDetailsSerialized = serialize($bookingDetails); $_SESSION['bookingDetailsAdmin'] = $bookingDetailsSerialized; // Get all extra services $extraServices = ExtraService::fetchAllFromDb(); // If there are no extra bed option or other services available, skip if (!$bookingDetails->room->hasExtraBed == 0 && sizeof($extraServices) == 0) { header("Location booking_step4.php"); } $logger->LogDebug("booking-services date:");
<?php // TODO: umcomment include "access.php"; require_once "../includes/SystemConfiguration.class.php"; global $systemConfiguration; global $logger; $errors = array(); $roomImages = array(); $roomId = 0; if (isset($_GET['room_id']) && is_numeric($_GET['room_id'])) { $roomId = intval($_GET['room_id']); $room = Room::fetchFromDb($roomId); if ($room == null) { $errors[] = "There is no room with id: {$roomId}"; } else { $logger->LogDebug("Fetching room images for room id {$roomId} ..."); //$roomImages = RoomImage::fetchFromDbForRoom($roomId); $roomImages = $room->getImages(); } } else { $errors[] = "Invalid room id"; } $logger->LogDebug("Fetching default language ..."); $defaultLanguage = Language::fetchDefaultLangauge(); if ($defaultLanguage == null) { $logger->LogError("There were errors fetching default language."); foreach (Language::$staticErrors as $error) { $logger->LogError($error); $errors[] = $error; }
$logger->LogError("Error saving room."); foreach ($room->errors as $error) { $logger->LogError($error); $errors[] = $error; } } else { header("Location: rooms_list.php"); $message = "Values were updated successfully!"; } } } else { if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $logger->LogInfo("Page was called for edit of id: " . $_REQUEST['id']); $id = intval($_REQUEST['id']); $logger->LogDebug("Numeric id is: {$id}"); $room = Room::fetchFromDb($id); if ($room == null) { $logger->LogError("Invalid request. No room with id: {$id} exists."); $errors[] = "Invalid request. No room with id: {$id} exists."; } else { $roomPricePlan = $room->getDefaultPricePlan(); if ($roomPricePlan == null) { $logger->LogError("Invalid configuration. No default price plan exists fro room with id: {$roomId}."); $errors[] = "Invalid configuration. No default price plan exists fro room with id: {$roomId}."; } } } } $defaultLanguage = Language::fetchDefaultLangauge(); include "header.php"; ?>