function getRooms() { $userData = UserDataService::getUserData(); $rooms = HotelService::getHotelRooms($this->getState('hotel.id'), $userData->start_date, $userData->end_date, array(), $userData->adults, $userData->children); BookingService::setRoomAvailability($rooms, $userData->reservedItems, $this->getState('hotel.id'), $userData->start_date, $userData->end_date); return $rooms; }
public static function checkRoomListingAvailability(&$rooms, $items_reserved, $datas, $datae, $confirmationId = null) { //number of reserved rooms for each room type $temporaryReservedRooms = BookingService::getReservedRooms($items_reserved); //dmp("T"); //dmp($temporaryReservedRooms); $ingoreNrRooms = !empty($confirmationId) ? 1 : 0; if (isset($rooms) && count($rooms) > 0) { foreach ($rooms as $room) { $rooms_reserved = BookingService::getNumberOfBookingsPerDay($room->hotel_id, $datas, $datae, $confirmationId); //dmp($rooms); // dmp("NR: ".$room->room_id." ".$room->nrRoomsAvailable); //dmp($room->daily); foreach ($room->daily as $day) { $totalNumberRoomsReserved = 0; //dmp($day["data"]); if (isset($rooms_reserved[$room->room_id][$day["date"]])) { $totalNumberRoomsReserved = $rooms_reserved[$room->room_id][$day["date"]]; } if (isset($temporaryReservedRooms[$room->room_id])) { $totalNumberRoomsReserved += $temporaryReservedRooms[$room->room_id]; } //dmp($totalNumberRoomsReserved); //dmp($day["nrRoomsAvailable"]); if ($day["nrRoomsAvailable"] <= $totalNumberRoomsReserved - $ingoreNrRooms) { $room->is_disabled = true; //dmp("disable"); } } } } }
function processAutomaticResponse() { $this->log->LogDebug("process automatic response"); $data = JRequest::get('post'); $this->log->LogDebug(serialize($data)); $processorType = JRequest::getVar("processor"); $processor = PaymentService::createPaymentProcessor($processorType); $paymentDetails = $processor->processResponse($data); $this->log->LogDebug("Payment Details: " . serialize($paymentDetails)); if (empty($paymentDetails->confirmation_id)) { return; } $intialPaymentDetails = PaymentService::getConfirmationPaymentDetails($paymentDetails->confirmation_id); $this->log->LogDebug("Initial payment details: " . serialize($intialPaymentDetails)); if ($intialPaymentDetails->payment_status == PAYMENT_STATUS_PAID) { return; } //prevent e-mails to be send again to hotels and customers if ($intialPaymentDetails->payment_status == $paymentDetails->payment_status) { header("HTTP/1.1 200 OK"); return; } //check if the response is a reponse for a waiting transaction $sendMailOnlyToAdmin = $intialPaymentDetails->payment_status == PAYMENT_STATUS_WAITING && $paymentDetails->payment_status == PAYMENT_STATUS_PAID; $this->log->LogDebug("Send only to admin " . serialize($sendMailOnlyToAdmin)); PaymentService::updatePayment($paymentDetails); if ($paymentDetails->status == PAYMENT_CANCELED || $paymentDetails->status == PAYMENT_ERROR) { BookingService::cancelReservation($paymentDetails->confirmation_id); } else { $confirmationModel = $this->getModel("Confirmation"); $reservationDetails = $confirmationModel->getReservation($paymentDetails->confirmation_id); EmailService::sendConfirmationEmail($reservationDetails, $sendMailOnlyToAdmin); //check if hotels has more rooms available $hotelId = $reservationDetails->reservationData->userData->hotelId; $startDate = $reservationDetails->reservationData->userData->start_date; $endDate = $reservationDetails->reservationData->userData->end_date; $isHotelAvailable = HotelService::checkAvailability($hotelId, $startDate, $endDate); if (!$isHotelAvailable) { EmailService::sendNoAvailabilityEmail($hotelId, $startDate, $endDate); } } //http_response_code(200); header("HTTP/1.1 200 OK"); }
public function generateReservationSummary($reservationData, $checkAvailability = true) { //generate data for rooms $startDate = $reservationData->userData->start_date; $endDate = $reservationData->userData->end_date; $hotelId = $reservationData->userData->hotelId; $currency = $reservationData->userData->currency; $discountCode = $reservationData->userData->discount_code; $reservedItems = $reservationData->userData->reservedItems; $roomsPrices = array(); if (isset($reservationData->userData->room_prices)) { $roomsPrices = explode(",", $reservationData->userData->room_prices); } if (isset($reservationData->userData->roomCustomPrices)) { $roomsPrices = $reservationData->userData->roomCustomPrices; } //dmp($reservationData->userData->roomGuests); $selectedRooms = $this->getSelectedRooms($reservedItems, $roomsPrices, $hotelId, $startDate, $endDate, $reservationData->userData->roomGuests, $reservationData->userData->roomGuestsChildren, $discountCode, $checkAvailability, $reservationData->userData->confirmation_id); $roomsInfo = $this->getReservationDetailsRooms($reservationData->userData, $selectedRooms, $currency); BookingService::setRoomAvailability($selectedRooms, array(), $hotelId, $startDate, $endDate, $reservationData->userData->confirmation_id); $nrRooms = count($selectedRooms); $roomNotAvailable = array(); $showDiscounts = false; foreach ($selectedRooms as $room) { //dmp($room); if ($room->is_disabled) { $roomNotAvailable[] = $room; } //dmp($room->hasDiscounts); if ($room->hasDiscounts) { $showDiscounts = true; } } //exit; //generate extra options $extraOptionsInfo = null; $extraOptionIds = isset($reservationData->userData->extraOptionIds) ? $reservationData->userData->extraOptionIds : null; //dmp($extraOptionIds); $extraOptions = array(); if (is_array($extraOptionIds) && count($extraOptionIds) > 0) { foreach ($extraOptionIds as $key => $value) { if (strlen($value) > 1) { $extraOption = explode("|", $value); $extraOptions[$key] = $extraOption; } } } //micod //Mi código modificado para poder aceptar la cotización de niños en el pasaje aereo en Extras //------------------------------------------------------------------------------------------- //unset($_SESSION["ver"]); if (count($extraOptions, COUNT_RECURSIVE) == 17) { $_SESSION["extras"] = $extraOptions; //echo "<script> alert('TRUE'); </script>"; $verificar = true; } else { //echo "<script> alert('FALSE'); </script>"; $verificar = false; } //dmp($_SESSION["extras"]); //dmp($_SESSION["ver"]); $selectedExtraOptions = array(); if ($verificar == true) { if (isset($_SESSION["extras"]) && count($_SESSION["extras"]) > 0) { $selectedExtraOptions = ExtraOptionsService::getHotelExtraOptions($hotelId, $startDate, $endDate, $_SESSION["extras"], 0, 0); $extraOptionsInfo = $this->getReservationDetailsExtraOptions($selectedExtraOptions, $_SESSION["extras"], $nrRooms, $currency); /*if ($_SESSION["ver"] == false){ $_SESSION["ver"] = false; }else{ }*/ $_SESSION["ver"] = true; //echo "<script> alert('Entro en TRUE'); </script>"; } } if ($verificar == false) { if (isset($extraOptions) && count($extraOptions) > 0) { $selectedExtraOptions = ExtraOptionsService::getHotelExtraOptions($hotelId, $startDate, $endDate, $extraOptions, 0, 0); $extraOptionsInfo = $this->getReservationDetailsExtraOptions($selectedExtraOptions, $extraOptions, $nrRooms, $currency); //echo "<script> alert('Entro en FALSE'); </script>"; //$_SESSION["ver"] = false; if ($_SESSION["ver"] == true) { if (isset($_SESSION["extras"]) && count($_SESSION["extras"]) > 0) { $selectedExtraOptions = ExtraOptionsService::getHotelExtraOptions($hotelId, $startDate, $endDate, $_SESSION["extras"], 0, 0); $extraOptionsInfo = $this->getReservationDetailsExtraOptions($selectedExtraOptions, $_SESSION["extras"], $nrRooms, $currency); //echo "<script> alert('Entro en el que queríamos'); </script>"; //unset($_SESSION["ver"]); } } } } //------------------------------------------------------------------------------------------- //dmp($selectedExtraOptions); //generate course/excursions $excursionsInfo = null; $selectedExcursions = null; if ($reservationData->appSettings->enable_excursions && count($reservationData->userData->excursions) > 0) { $excursionData = $reservationData->userData->excursions; if (!is_array($reservationData->userData->excursions)) { $excursionData = explode(",", $reservationData->userData->excursions); } $selectedExcursions = ExcursionsService::getSelectedExcursions($excursionData, $reservedItems, $hotelId, $startDate, $endDate, $reservationData->userData->roomGuests, $reservationData->userData->roomGuestsChildren, $discountCode, $checkAvailability, $reservationData->userData->confirmation_id); $excursionsInfo = $this->getReservationDetailsExcursions($reservationData->userData, $selectedExcursions, $currency); } $costData = $this->getReservationCostData($selectedRooms); //LA CUOTA A PAGAR!!!!!!!! $guestDetails = array(); if (isset($reservationData->userData->guestDetails)) { $guestDetails = $reservationData->userData->guestDetails; } $taxes = TaxService::getTaxes($hotelId); $reservationDetails = $this->getReservationDetails($reservationData, $roomsInfo, $extraOptionsInfo, $excursionsInfo, $taxes, $guestDetails, $currency, $costData); $reservationDetails->rooms = $selectedRooms; $reservationDetails->roomsInfo = $roomsInfo; $reservationDetails->extraOptions = $selectedExtraOptions; $reservationDetails->extraOptionsInfo = $extraOptionsInfo; //dmp($extraOptions); $reservationDetails->roomNotAvailable = $roomNotAvailable; $reservationDetails->showDiscounts = $showDiscounts; $reservationDetails->costData = $costData; $reservationDetails->excursions = $selectedExcursions; $reservationDetails->excursionsInfo = $excursionsInfo; return $reservationDetails; }
function cancelReservation() { $confirmationId = JRequest::getVar('reservationId'); BookingService::cancelReservation($confirmationId); $msg = JText::_('LNG_RESERVATION_CANCELED'); $reservationService = new ReservationService(); $reservationDetails = $reservationService->getReservation($review->confirmation_id); $emailService = new EmailService(); $emailService->sendCancelationEmail($reservationDetails); $this->setRedirect(JRoute::_('index.php?option=' . getBookingExtName() . '&task=customeraccount.managereservations'), $msg); }
public function checkReservationPendingPayments() { BookingService::checkReservationPendingPayments(); JFactory::getApplication()->close(); }
function getAllRooms() { $userData = $_SESSION['userData']; $orderBy = ""; $this->searchParams = array(); $this->searchParams["orderBy"] = $userData->orderBy; $this->searchParams["keyword"] = $userData->keyword; $this->searchParams["orderBy"] = $userData->orderBy; $this->searchParams["adults"] = $userData->adults; $this->searchParams["voucher"] = $userData->voucher; $this->searchParams["startDate"] = $userData->start_date; $this->searchParams["endDate"] = $userData->end_date; $this->searchParams["languageTag"] = JRequest::getVar('_lang'); $this->searchParams["city"] = JRequest::getVar('city'); $this->searchParams["showAll"] = JRequest::getVar('showAll'); $this->searchParams["adults"] = $userData->adults; $this->searchParams["children"] = $userData->children; $this->searchParams["type"] = JRequest::getVar('jhotelreservation_type'); $orderByPrice = false; if ($userData->orderBy == 'lowest_hotel_price asc' || $userData->orderBy == 'starting_price_offers asc') { $orderByPrice = true; } if (!isset($userData->noDates)) { $userData->noDates = 0; } $this->searchParams["no-dates"] = $userData->noDates; $roomQuery = $this->getSearchQuery($this->searchParams); $db = JFactory::getDBO(); $db->setQuery($roomQuery, $this->getState('limitstart'), $this->getState('limit')); $rooms = $db->loadObjectList(); $rooms = HotelService::getAllRooms($rooms, $userData->start_date, $userData->end_date, $userData->adults, $userData->children, $orderByPrice); BookingService::setRoomAvailability($rooms, $userData->reservedItems, $this->getState('hotel.id'), $userData->start_date, $userData->end_date); return $rooms; }
public static function checkExcursionAvailability($excursions, $items_reserved, $hotel_id, $datas, $datae, $confirmationId = null) { //number of reserved rooms for each room type $excursions_reserved = BookingService::getExcursionBookingsPerDay($hotel_id, $datas, $datae, $confirmationId); $temporaryReservedExcursions = BookingService::getReservedRooms($items_reserved); //dmp("T"); //dmp($temporaryReservedExcursions); //dmp($confirmationId); $ingoreNrExcursions = !empty($confirmationId) ? 1 : 0; if (isset($excursions) && count($excursions) > 0) { foreach ($excursions as $excursion) { // dmp("NR: ".$room->room_id." ".$room->nrRoomsAvailable); //dmp($room->daily); foreach ($excursion->daily as $day) { $totalNumberExcursionsReserved = 0; //dmp($day["data"]); if (isset($excursions_reserved[$excursion->excursion_id][$day["date"]])) { $totalNumberExcursionsReserved = $excursions_reserved[$excursion->excursion_id][$day["date"]]; } if (isset($temporaryReservedExcursions[$excursion->excursion_id])) { $totalNumberExcursionsReserved += $temporaryReservedExcursions[$excursion->excursion_id]; } if ($day["nrExcursionsAvailable"] <= $totalNumberExcursionsReserved - $ingoreNrExcursions) { $excursion->is_disabled = true; } else { $excursion->capacity = $day["nrExcursionsAvailable"] - ($totalNumberExcursionsReserved - $ingoreNrExcursions); } } } } return $excursions; //exit; }