public function getReservationDetails() { $reservationDetails = null; $id = JRequest::getVar('confirmation_id'); $reservationDetails->confirmation_id = $id; $table = $this->getTable('Confirmations', 'Table'); $table->load($id); $hotelService = new HotelService(); $hotel = $hotelService->getHotel($table->hotel_id); $reservationDetails->hotelDetails = $hotel->hotel_name . ", " . $hotel->hotel_address . ", " . $hotel->hotel_city . ", " . $hotel->country_name; $reservationDetails->arrivalDate = JHotelUtil::getDateGeneralFormat($table->start_date); $reservationDetails->returnDate = JHotelUtil::getDateGeneralFormat($table->end_date); $reservationDetails->bookingPerson = $table->first_name . ", " . $table->last_name; $reservationDetails->hotelId = $table->hotel_id; return $reservationDetails; }
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 function getItem($pk = null) { // Initialise variables. $hotel = HotelService::getHotel($this->getState('hotel.id')); //dmp($hotel->hotel_currency); UserDataService::setCurrency($hotel->hotel_currency, $hotel->currency_symbol); return $hotel; }
function display($tpl = null) { $this->extraOptions = $this->get("ExtraOptions"); $this->state = $this->get('State'); $this->userData = UserDataService::getUserData(); $this->hotel = HotelService::getHotel($this->userData->hotelId); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); //dmp($this->userData); parent::display($tpl); }
function incomeReport() { $this->setReportsToolbar(); $this->itemsRoomTypes = $this->get('RoomTypes'); $this->initFilterParams(); $this->includeCharts(); $this->appSetings = JHotelUtil::getInstance()->getApplicationSettings(); $this->hotel = HotelService::getHotel($this->hotel_id); $tpl = "income"; return $tpl; }
function getReservationDetails() { $userData = UserDataService::getUserData(); $reservationData = new stdClass(); $reservationData->userData = $userData; $reservationData->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $reservationData->hotel = HotelService::getHotel($userData->hotelId); $reservationService = new ReservationService(); $reservationDetails = $reservationService->generateReservationSummary($reservationData); UserDataService::setReservationDetails($reservationDetails); $reservationDetails->reservationData = $reservationData; return $reservationDetails; }
function back() { UserDataService::removeLastRoom(); $userData = UserDataService::getUserData(); if ($userData->hotelId > 0) { $hotel = HotelService::getHotel($userData->hotelId); $link = JHotelUtil::getHotelLink($hotel); } else { $link = JRoute::_('index.php?option=com_jhotelreservation&task=excursionslisting.searchExcursions', false); UserDataService::initializeExcursions(); } $this->setRedirect($link); }
function getHotels() { $userData = $_SESSION['userData']; //dmp($userData); $this->createSeachFilter($userData->filterParams, $userData->orderBy); $this->searchParams = $this->createDBSearchParams($this->searchFilter["filterCategories"]); $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["searchType"] = JRequest::getVar('searchType'); $this->searchParams["searchId"] = JRequest::getVar('searchId'); if ($this->searchParams["searchType"] == JText::_("LNG_HOTELS")) { $hotel = $hotel = HotelService::getHotel($this->searchParams["searchId"]); $link = JHotelUtil::getHotelLink($hotel); $app = JFactory::getApplication(); $app->redirect($link); } if (!isset($userData->noDates)) { $userData->noDates = 0; } $this->searchParams["no-dates"] = $userData->noDates; $hotelTable = $this->getTable('hotels'); $hotels = $hotelTable->getHotels($this->searchParams, $this->getState('limitstart'), $this->getState('limit')); $userData->searchFilter = $this->searchFilter; $_SESSION['userData'] = $userData; $nearByHotels = array(); if (count($hotels) <= 3) { $nearByHotels = $this->getNearByHotels($this->searchParams["keyword"], $this->searchParams, $hotels); if (!empty($nearByHotels)) { foreach ($nearByHotels as &$hotel) { $hotel->nearBy = 1; } $hotels = array_merge($hotels, $nearByHotels); } } $hotels = $this->prepareHotelOffers($hotels); $this->itemHotels = $hotels; //dmp($userData->orderBy); if (isset($userData->voucher) && $userData->voucher != '' && $userData->orderBy == '' && count($this->itemHotels) > 0) { //dmp("shuffle"); shuffle($this->itemHotels); } return $this->itemHotels; }
function display($tpl = null) { $this->state = $this->get('State'); $this->reservationDetails = $this->get("ReservationDetails"); $this->paymentMethods = $this->get('paymentMethods'); $this->guestTypes = JHotelReservationHelper::getGuestTypes(); $this->userData = UserDataService::getUserData(); $this->hotel = HotelService::getHotel($this->userData->hotelId); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $doc = JFactory::getDocument(); $tag = JHotelUtil::getJoomlaLanguage(); $doc->addStyleSheet('administrator/components/' . getBookingExtName() . '/assets/js/validation/css/validationEngine.jquery.css'); $doc->addScript('administrator/components/' . getBookingExtName() . '/assets/js/validation/js/languages/jquery.validationEngine-' . $tag . '.js'); $doc->addScript('administrator/components/' . getBookingExtName() . '/assets/js/validation/js/jquery.validationEngine.js'); parent::display($tpl); }
function getOffer($offerId) { $offersTable = $this->getTable('ManageOffers'); $offer = $offersTable->getOffer($offerId); $offer->pictures = $offersTable->getOffersPictures($offer->offer_id); $offer->packages = $offersTable->getOffersPackages($offer->offer_id); $offer->hotel_name = stripslashes($offer->hotel_name); if ($offer->price_type == 0) { $offer->starting_price = $offer->starting_price / $offer->base_adults; } $offer->hotel = HotelService::getHotel($offer->hotel_id); $mediaReferer = JRequest::getVar('mediaReferer'); $voucher = JRequest::getVar('voucher'); $offersViewsTable = $this->getTable('ManageOffersViews'); $offersViewsTable->increaseViewCount($offer->offer_id, $mediaReferer, $voucher); return $offer; }
function display($tpl = null) { $this->state = $this->get('State'); $this->countries = $this->get('Countries'); $this->guestTypes = JHotelReservationHelper::getGuestTypes(); $this->userData = UserDataService::getUserData(); $this->hotel = HotelService::getHotel($this->userData->hotelId); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); if ($this->appSettings->save_all_guests_data) { UserDataService::prepareGuestDetails(); } $hotelId = JRequest::getVar("hotel_id"); $reservedItems = JRequest::getVar("reservedItems"); if (!empty($reservedItems)) { UserDataService::updateRooms($hotelId, $reservedItems); } $this->reservationDetails = $this->get("ReservationDetails"); $this->showDiscounts = true; parent::display($tpl); }
/** * @copyright Copyright (C) 2008-2009 CMSJunkie. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ // no direct access defined('_JEXEC') or die('Restricted access'); JHTML::_('stylesheet', 'modules/mod_jreservationinfo/assets/css/style.css'); require_once JPATH_SITE . '/administrator/components/com_jhotelreservation/helpers/defines.php'; require_once JPATH_SITE . '/administrator/components/com_jhotelreservation/helpers/utils.php'; // Include the syndicate functions only once require_once dirname(__FILE__) . DS . 'helper.php'; $userData = UserDataService::getUserData(); $hotel = HotelService::getHotel($userData->hotelId); $reservationData = new stdClass(); $reservationData->userData = $userData; $reservationData->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $reservationData->hotel = $hotel; $reservationService = new ReservationService(); $reservationDetails = $reservationService->generateReservationSummary($reservationData); $moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx')); require JModuleHelper::getLayoutPath('mod_jreservationinfo', $params->get('layout', 'default'));
public static function sendNoAvailabilityEmail($hotelId, $startDate, $endDate) { $log = Logger::getInstance(); $log->LogDebug("No availabaility " . $hotelId . " " . $startDate . " " . $endDate); $hotel = HotelService::getHotel($hotelId); $appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $datas = JHotelUtil::convertToFormat($startDate); $datae = JHotelUtil::convertToFormat($endDate); $mode = 1; //html $emailContent = JText::_('LNG_NO_AVAILABILITY_EMAIL', true); $emailContent = str_replace("<<hotel>>", $hotel->hotel_name, $emailContent); $emailContent = str_replace("<<start_date>>", $datas, $emailContent); $emailContent = str_replace("<<end_date>>", $datae, $emailContent); $email_subject = JText::_('LNG_NO_AVAILABILITY_EMAIL_SUBJECT', true); $email_subject = str_replace("<<hotel>>", $hotel->hotel_name, $email_subject); return self::sendEmail($appSettings->company_email, $appSettings->company_name, null, $appSettings->company_email, null, null, $email_subject, $emailContent, $mode); }
function getSelectedRooms($reservedItems, $customPrices, $hotelId, $startDate, $endDate, $roomGuests, $roomGuestsChildren, $discountCode, $checkAvailability = true, $confirmationId = null) { $selectedRooms = array(); foreach ($reservedItems as $reservedItem) { $values = explode("|", $reservedItem); if (count($values) < 2) { continue; } $nr_guests = 0; $selectedRoom = null; if (isset($roomGuests[$values[2] - 1])) { $adults = $roomGuests[$values[2] - 1]; } else { $adults = 2; } if (isset($roomGuestsChildren[$values[2] - 1])) { $children = $roomGuestsChildren[$values[2] - 1]; } else { $children = 0; } if ($values[0] == 0) { $selectedRoom = HotelService::getHotelRooms($hotelId, $startDate, $endDate, array($values[1]), $adults, $children, $discountCode, $checkAvailability, $confirmationId); } else { $selectedRoom = HotelService::getHotelOffers($hotelId, $startDate, $endDate, array($reservedItem), $adults, $children, $discountCode, $checkAvailability, $confirmationId); } if (count($selectedRoom) == 0) { $selectedRoom = new stdClass(); $selectedRoom->current = $values[2]; $selectedRoom->is_disabled = false; $selectedRoom->hasDiscounts = false; $selectedRoom->offer_id = 0; $selectedRoom->reservation_cost_val = 0; $selectedRoom->reservation_cost_proc = 0; $selectedRoom->customPrices = array(); $selectedRoom->daily = array(); $selectedRooms[$values[2] - 1] = $selectedRoom; } else { $selectedRoom = $selectedRoom[0]; $selectedRoom->current = $values[2]; $selectedRoom->customPrices = $this->getCustomPrices($selectedRoom, $customPrices); $selectedRooms[$values[2] - 1] = $selectedRoom; } } ksort($selectedRooms); return $selectedRooms; }
public function checkAvailability() { $hotelId = 110; $startDate = "2013-10-05"; $endDate = "2013-10-07"; $isHotelAvailable = HotelService::checkAvailability($hotelId, $startDate, $endDate); dmp($isHotelAvailable); if (!$isHotelAvailable) { EmailService::sendNoAvailabilityEmail($hotelId, $startDate, $endDate); } }
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; }
function back() { UserDataService::removeLastRoom(); $userData = UserDataService::getUserData(); $hotel = HotelService::getHotel($userData->hotelId); $link = JHotelUtil::getHotelLink($hotel); $this->setRedirect($link); }
public function populateReservationDetails($data) { $userData = new stdClass(); $userData->confirmation_id = $data["reservationId"]; //dmp($data["roomdetails"]); $guestInfo = $this->getNumberOfGuests($data["roomdetails"]); $userData->roomGuests = $guestInfo->adults; //dmp($userData->roomGuests); $userData->total_adults = 0; if (isset($userData->roomGuests) && count($userData->roomGuests) >= 1) { foreach ($userData->roomGuests as $guestPerRoom) { $userData->total_adults += $guestPerRoom; } } $userData->adults = $userData->total_adults; $userData->children = 0; $userData->first_name = $data["first_name"]; $userData->last_name = $data["last_name"]; $userData->address = $data["address"]; $userData->city = $data["city"]; $userData->state_name = $data["state_name"]; $userData->country = $data["country"]; $userData->postal_code = $data["postal_code"]; $userData->phone = $data["phone"]; $userData->email = $data["email"]; $userData->company_name = $data["company_name"]; $userData->guest_type = isset($data["guest_type"]) ? $data["guest_type"] : 0; $userData->discount_code = $data["discount_code"]; $userData->reservedItems = $data["reservedItem"]; $userData->hotelId = $data["hotelId"]; $userData->totalPaid = $data["totalPaid"]; $userData->voucher = $data["voucher"]; $userData->remarks = $data["remarks"]; $userData->remarks_admin = $data["remarks_admin"]; $userData->start_date = JHotelUtil::convertToMysqlFormat($data["start_date"]); $userData->end_date = JHotelUtil::convertToMysqlFormat($data["end_date"]); $hotel = HotelService::getHotel($userData->hotelId); $userData->currency = HotelService::getHotelCurrency($hotel); $userData->arrival_time = $data["arrival_time"]; $userData->rooms = count($data["roomdetails"]); if ($data["update_price_type"] == 2 || empty($data["update_price_type"])) { $userData->roomCustomPrices = $this->prepareCustomPrices($userData->reservedItems, $data["roomdetails"], $userData->start_date); } if (!empty($data["extraOptionIds"])) { $extraOptions = array(); if (isset($data["extraOptionIds"])) { foreach ($data["extraOptionIds"] as $key => $value) { $extraOption = explode("|", $value); if ($extraOption[5] > 0 || $extraOption[6] > 0) { continue; } if (isset($data["extra-option-days-" . $extraOption[3]])) { $extraOption[6] = $data["extra-option-days-" . $extraOption[3]]; } if (isset($data["extra-option-persons-" . $extraOption[3]])) { $extraOption[5] = $data["extra-option-persons-" . $extraOption[3]]; } $extraOptions[$key] = implode("|", $extraOption); } } $userData->extraOptionIds = $extraOptions; } $guestDetails = array(); if (isset($data["guest_first_name"])) { for ($i = 0; $i < count($data["guest_first_name"]); $i++) { $guestDetail = new stdClass(); $guestDetail->first_name = $data["guest_first_name"][$i]; $guestDetail->last_name = $data["guest_last_name"][$i]; $guestDetail->identification_number = $data["guest_identification_number"][$i]; $guestDetails[] = $guestDetail; } } $userData->guestDetails = $guestDetails; return $userData; }
function getSelectedRooms($reservationData, $reservedItems, $customPrices, $hotelId, $startDate, $endDate, $roomGuests, $roomGuestsChildren, $discountCode, $checkAvailability = true, $confirmationId = null) { /*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ $selectedRooms = array(); foreach ($reservedItems as $key => $reservedItem) { //MICOD. Clave "$key" agregado para contar las interacciones $values = explode("|", $reservedItem); if (count($values) < 2) { continue; } $nr_guests = 0; $selectedRoom = null; if (isset($roomGuests[$values[2] - 1])) { $adults = $roomGuests[$values[2] - 1]; } else { $adults = 2; } if (isset($roomGuestsChildren[$values[2] - 1])) { $children = $roomGuestsChildren[$values[2] - 1]; } else { $children = 0; } if ($values[0] == 0) { /*------------------------------------------------------------------------------------------*/ /*MICOD Nuevo pase de parámetros donde capturo el número de habitaciones por interacción del FOREACH. También anexado el "$reservationData"*/ $selectedRoom = HotelService::getHotelRooms($hotelId, $startDate, $endDate, array($values[1]), $adults, $children, $discountCode, $checkAvailability, $confirmationId, $key, $reservationData); /*------------------------------------------------------------------------------------------*/ } else { $selectedRoom = HotelService::getHotelOffers($hotelId, $startDate, $endDate, array($reservedItem), $adults, $children, $discountCode, $checkAvailability, $confirmationId); } if (count($selectedRoom) == 0) { $selectedRoom = new stdClass(); $selectedRoom->current = $values[2]; $selectedRoom->is_disabled = false; $selectedRoom->hasDiscounts = false; $selectedRoom->offer_id = 0; $selectedRoom->reservation_cost_val = 0; $selectedRoom->reservation_cost_proc = 0; $selectedRoom->customPrices = array(); $selectedRoom->daily = array(); $selectedRooms[$values[2] - 1] = $selectedRoom; } else { $selectedRoom = $selectedRoom[0]; $selectedRoom->current = $values[2]; $selectedRoom->customPrices = $this->getCustomPrices($selectedRoom, $customPrices); $selectedRooms[$values[2] - 1] = $selectedRoom; } } ksort($selectedRooms); return $selectedRooms; }
public static function getHotelExcursions($type = -1, $hotelId, $startDate, $endDate, $excursionIds = array(), $nrBooked = array(2), $children = 0, $discountCode = null, $checkAvailability = true, $confirmationId = null) { $db = JFactory::getDBO(); $excursionFilter = ""; if ($hotelId != -1) { $excursionFilter = " and e.hotel_id= {$hotelId} "; } if (count($excursionIds) > 0) { $excursionFilter .= " and e.id in ("; foreach ($excursionIds as $id) { $excursionFilter .= $id . ','; } $excursionFilter = substr($excursionFilter, 0, -1); $excursionFilter .= ")"; } $availabilityFilter = ""; if ($type != -1) { $availabilityFilter = " and e.type = " . $type; } $languageTag = JRequest::getVar('_lang'); $availabilityFilter .= " and e.is_available = 1"; if (!$checkAvailability) { $availabilityFilter = ""; } //get hotel excursions $query = "select *,e.id as excursion_id,e.name as excursion_name,e.ignored_dates as excursionIgnoredDates,hlt.content as excursion_main_description,er.name as rate_name, er.id as rate_id ,h.reservation_cost_val AS reservation_cost_val, h.reservation_cost_proc AS reservation_cost_proc\r\n\t\t\t\tfrom #__hotelreservation_excursions e\r\n\t\t\t\tinner join #__hotelreservation_excursion_rates er on e.id = er.excursion_id\r\n\t\t\t\tinner join #__hotelreservation_hotels h\tON h.hotel_id = e.hotel_id\r\n\t\t\t\tleft join #__hotelreservation_currencies hc on h.currency_id= hc.currency_id\r\n\t\t\t\tleft join #__hotelreservation_countries hrc on h.country_id= hrc.country_id\r\n\t\t\t\tleft join\r\n\t\t\t\t\t(select * from\r\n\t\t\t\t\t #__hotelreservation_language_translations\r\n\t\t\t\t\t where type = " . EXCURSION_TRANSLATION . "\r\n\t\t\t\t\t and language_tag = '{$languageTag}'\r\n\t\t\t\t\t ) as hlt on hlt.object_id = e.id\r\n\t\t\t\twhere 1 {$availabilityFilter} \r\n\t\t\t\tand e.front_display=1 \r\n\t\t\t\t{$excursionFilter}\r\n\t\t\t\torder by e.excursion_order"; //echo($query); $db->setQuery($query); $excursions = $db->loadObjectList(); $number_days = (strtotime($startDate) - strtotime($endDate)) / (60 * 60 * 24); //get hotel rates $totalPrice = 0; $totalExcursionsPrice = 0; $excursionIds = array(); foreach ($excursions as $excursion) { $hotelId = $excursion->hotel_id; array_push($excursionIds, $excursion->excursion_id); $query = "select * from #__hotelreservation_excursion_rate_prices r\r\n\t\t\twhere rate_id={$excursion->rate_id} and '{$startDate}'<= date and date<='{$endDate}'"; //dmp($query); $db->setQuery($query); $excursionRateDetails = $db->loadObjectList(); $excursion->excursionRateDetails = $excursionRateDetails; //calculate available number of room $excursion->nrExcursionsAvailable = $excursion->availability; //dmp("id: ".$room->room_id); //dmp($room->nrRoomsAvailable); $excursion->is_disabled = false; $daily = array(); $number_days = (strtotime($endDate) - strtotime($startDate)) / (60 * 60 * 24); $isHotelAvailable = true; if (!HotelService::isHotelAvailable($hotelId, $startDate, $endDate) && $checkAvailability) { $isHotelAvailable = false; } if (!$isHotelAvailable) { $excursion->is_disabled = true; } $d = strtotime($startDate); $currentDayNr = 1; $nr_d = 'excursion_day_' . date("N", $d); if ($excursion->{$nr_d} == 0) { $excursion->is_disabled = true; } // $ignoredDates = explode(",", $excursion->excursionIgnoredDates); //determine aspects for each day of booking period for ($d = strtotime($startDate); $d < strtotime($endDate);) { $dayString = date('Y-m-d', $d); if (array_search($dayString, $ignoredDates)) { $excursion->is_disabled = true; } //set default price from rate $weekDay = date("N", $d); $string_price = "price_" . $weekDay; $dayPrice = $excursion->{$string_price}; $childPrice = $excursion->child_price; //check if a custom price is set if (count($excursionRateDetails)) { foreach ($excursionRateDetails as $excursionRateDetail) { if ($excursionRateDetail->date == $dayString) { $dayPrice = $excursionRateDetail->price; $childPrice = $excursionRateDetail->child_price; $excursion->nrExcursionsAvailable = $excursionRateDetail->availability; } } } $eId = $excursion->excursion_id; $nrItemsBooked = 0; if (isset($nrBooked[$eId])) { $nrItemsBooked = $nrBooked[$eId]; } $excursion->nrItemsBooked = $nrItemsBooked; //apply current discounts $query = " SELECT\r\n\t\t\t\t\t\t\t\t\tdiscount_id,\r\n\t\t\t\t\t\t\t\t\tdiscount_name,\r\n\t\t\t\t\t\t\t\t\tdiscount_datas,\r\n\t\t\t\t\t\t\t\t\tdiscount_datae,\r\n\t\t\t\t\t\t\t\t\tdiscount_value as discount_value,\r\n\t\t\t\t\t\t\t\t\tpercent,\r\n\t\t\t\t\t\t\t\t\tminimum_number_days,\r\n\t\t\t\t\t\t\t\t\tmaximum_number_days,\r\n\t\t\t\t\t\t\t\t\tminimum_number_persons,\r\n\t\t\t\t\t\t\t\t\tcheck_full_code,\r\n\t\t\t\t\t\t\t\t\tcode,\r\n\t\t\t\t\t\t\t\t\tprice_type\r\n\t\t\t\t\t\t\t\tFROM #__hotelreservation_discounts\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\tis_available = 1 and only_on_offers = 0\r\n\t\t\t\t\t\t\t\t\tAND FIND_IN_SET( " . $excursion->excursion_id . ", excursion_ids )\r\n\t\t\t\t\t\t\t\t\tAND\t'" . date('Y-m-d', $d) . "' BETWEEN discount_datas AND discount_datae\r\n\t\t\t\t\t\t\t\t\tAND\tIF( minimum_number_days > 0, minimum_number_days <= {$currentDayNr}, 1 )\r\n\t\t\t\t\t\t\t\t\tAND\tIF( minimum_number_persons > 0, minimum_number_persons <= {$nrItemsBooked}, 1 )\r\n\t\t\t\t\t\t\t\t\tAND\tIF( maximum_number_days> 0, maximum_number_days >= {$currentDayNr}, 1 )\r\n\t\t\t\t\t\t\t\t\tAND\tIF( minimum_amount> 0, minimum_amount <= {$totalPrice}, 1 )\r\n\t\t\t\t\t\t\t\tORDER BY discount_datas"; $db->setQuery($query); $discounts = $db->loadObjectList(); $selectedDiscounts = array(); $discountValue = 0; $discountPercent = 0; $excursion->hasDiscounts = count($discounts) > 0; //dmp($discounts); foreach ($discounts as $discount) { $match = false; if (isset($discount->code) && isset($discountCode) && strlen($discount->code) > 0) { if ($discount->check_full_code == 1) { $match = $discountCode == $discount->code; } else { $match = strpos($discountCode, $discount->code) === 0; } } if ($match || !isset($discount->code) || strlen($discount->code) == 0) { $selectedDiscounts[] = $discount; if ($discount->percent) { $discountPercent += $discount->discount_value; } else { $discountValue += $discount->discount_value; } } } //dmp($selectedDiscounts); //apply percent $dayPrice = round($dayPrice - $dayPrice * ($discountPercent / 100), 2); //apply value $dayPrice = $dayPrice - $discountValue; if ($excursion->nrExcursionsAvailable == 0) { $excursion->is_disabled = true; } $day = array('date' => $dayString, 'price' => $dayPrice, 'price_final' => $dayPrice, 'display_price_final' => $dayPrice, 'discounts' => $selectedDiscounts, 'nrExcursionsAvailable' => $excursion->nrExcursionsAvailable); $totalPrice += $dayPrice; $currentDayNr += 1; $totalExcursionsPrice += $dayPrice * $nrItemsBooked; $daily[$dayString] = $day; $d = strtotime(date('Y-m-d', $d) . ' + 1 day '); } $excursion->daily = $daily; //average price per excursion $excursion->excursion_average_price = JHotelUtil::fmt($totalPrice / $number_days, 2); $excursion->pers_total_price = JHotelUtil::fmt($totalPrice / $number_days, 2); //dmp($excursion->excursion_average_price); //set pictures $query = " SELECT *\r\n\t\t\t\t\tFROM #__hotelreservation_excursion_pictures\r\n\t\t\t\t\tWHERE excursion_id = " . $excursion->excursion_id . " AND picture_enable = 1\r\n\t\t\t\t\tORDER BY picture_id\r\n\t\t\t\t\t"; $db->setQuery($query); $excursion->pictures = $db->loadObjectList(); } self::setExcursionDisplayPrice($excursions); if (is_array($nrBooked)) { $excursions = self::applyPackageDiscounts($excursions, $totalExcursionsPrice, implode(",", array_keys($nrBooked)), $startDate); } $excursions = self::checkExcursionAvailability($excursions, array(), $hotelId, $startDate, $endDate, $confirmationId); return $excursions; }
} return $response; } /** * This method is looking for a character in a * string and removes all characters between the * selected character and end of the string. * * @param string Text to be trimmed. * @param string Start character. * * @return string */ private function trimString($string, $char) { $pos = strrpos($string, $char); if ($pos !== false) { $string = substr($string, 0, $pos); } return $string; } } /** * Initializes an instance of the HotelService class and uses * the public method getHotel to search for suitable hotel. * The result is presentad as JSON. */ $priceMin = @$_GET['priceMin']; $priceMax = @$_GET['priceMax']; $service = new HotelService(); print_r($service->getHotel($priceMin, $priceMax));
public function processRequest() { $post = JRequest::get('post'); $xml = JRequest::getVar('xml', '', 'post', 'string', JREQUEST_ALLOWRAW); $xml = urldecode($xml); $this->log->LogDebug("Cubilis :: call function processRequest()"); //$this->log->LogDebug(serialize($post)); $this->log->LogDebug(serialize($xml)); //dmp($xml); $result = ""; $cubilisXml = new CublisXml(); if (strrpos($xml, "OTA_HotelRoomListRQ") > 0) { $hotelIdentifier = $cubilisXml->getHotelId($xml); //dmp($hotelIdentifier); $credentials = HotelService::getCredential($hotelIdentifier); $hotelId = $credentials->hotel_id; $startDate = date('Y-m-d'); $endDate = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 10, date("Y"))); $rooms = HotelService::getHotelRooms($hotelId, $startDate, $endDate, array(), 2); $result = $cubilisXml->generateHotelRoomList($hotelId, $credentials->user, $credentials->password, $rooms, $startDate, $endDate); echo $result; } else { if (strrpos($xml, "OTA_HotelAvailNotifRQ") > 0) { $rates = $cubilisXml->parseAvailNotifRequest($xml); $model = $this->getModel("roomrateprices"); $model->saveCustomDates($rates); } else { if (strrpos($xml, "OTA_HotelRoomListRS") > 0) { } else { if (strrpos($xml, "OTA_HotelAvailNotifRQ") > 0) { } else { if (strrpos($xml, "OTA_HotelResRQ") > 0) { $this->log->LogDebug("OTA_HotelResRQ"); $model = $this->getModel("Cubilis"); $hotelIdentifier = $cubilisXml->getHotelId($xml); $credentials = HotelService::getCredential($hotelIdentifier); $hotelId = $credentials->hotel_id; $reservations = $model->getNewReservations($hotelId); //$this->log->LogDebug(serialize($reservations)); //dmp($reservations); $result = $cubilisXml->generateHotelReservations($hotelId, $credentials->user, $credentials->password, $reservations); $model->setReservationCubilisStatus($reservations); $this->log->LogDebug($result); echo $result; } } } } } //header("Content-type:text/xml"); //ob_clean(); //echo $result; //http_response_code(200); JFactory::getApplication()->close(); }
function addHotelOffer() { $offerId = JRequest::getInt("offerId"); $current = JRequest::getInt("current"); $hotelId = JRequest::getInt("hotelId"); $startDate = JRequest::getVar("startDate"); $endDate = JRequest::getVar("endDate"); $room = HotelService::getHotelOffers($hotelId, $startDate, $endDate, array($offerId)); $room = $room[0]; $room->current = $current; $model = $this->getModel('reservation'); $buff = $model->getRoomHtmlContent($room, $startDate, $endDate); //header("Content-type:text/xml"); echo '<?xml version="1.0" encoding="utf-8" ?>'; echo '<room_statement>'; echo '<answer error="0" content_records="' . $buff . '" />'; echo '</room_statement>'; echo '</xml>'; JFactory::getApplication()->close(); }
public function populateReservationDetails($data) { $userData = new stdClass(); $userData->confirmation_id = $data["reservationId"]; //dmp($data["roomdetails"]); $guestInfo = $this->getNumberOfGuests($data["roomdetails"]); $userData->roomGuests = $guestInfo->adults; //dmp($userData->roomGuests); $userData->total_adults = 0; if (isset($userData->roomGuests) && count($userData->roomGuests) >= 1) { foreach ($userData->roomGuests as $guestPerRoom) { $userData->total_adults += $guestPerRoom; } } $userData->adults = $userData->total_adults; $userData->children = 0; $userData->first_name = $data["first_name"]; $userData->last_name = $data["last_name"]; $userData->address = $data["address"]; $userData->city = $data["city"]; $userData->state_name = $data["state_name"]; $userData->country = $data["country"]; $userData->postal_code = $data["postal_code"]; $userData->phone = $data["phone"]; $userData->email = $data["email"]; $userData->company_name = $data["company_name"]; $userData->guest_type = isset($data["guest_type"]) ? $data["guest_type"] : 0; $userData->discount_code = $data["discount_code"]; $userData->reservedItems = $data["reservedItem"]; $userData->hotelId = $data["hotelId"]; $userData->totalPaid = $data["totalPaid"]; /*--------------------------------------------------------------*/ //MICOD //Aquí anexamos el nuevo campo de edades a la variable $userSata $edades = array($data["edad-1"], $data["edad-2"], $data["edad-3"], $data["edad-4"], $data["edad-5"], $data["edad-6"]); //Concatenar todo en un nuevo Array $string_edades = implode("|", $edades); //Pegar todo en un nuevo string $userData->child_age = $string_edades; //Pasar la variable al userData $_SESSION["child_age"] = $userData->child_age; //Pasar la variable a una sesión para cargarlo en el archivo ReservationService.php /*dmp($_SESSION["child_age"]); die;*/ /*--------------------------------------------------------------*/ $userData->voucher = $data["voucher"]; $userData->remarks = $data["remarks"]; $userData->remarks_admin = $data["remarks_admin"]; $userData->start_date = JHotelUtil::convertToMysqlFormat($data["start_date"]); $userData->end_date = JHotelUtil::convertToMysqlFormat($data["end_date"]); $hotel = HotelService::getHotel($userData->hotelId); $userData->currency = HotelService::getHotelCurrency($hotel); $userData->arrival_time = $data["arrival_time"]; $userData->rooms = count($data["roomdetails"]); if ($data["update_price_type"] == 2 || empty($data["update_price_type"])) { $userData->roomCustomPrices = $this->prepareCustomPrices($userData->reservedItems, $data["roomdetails"], $userData->start_date); } if (!empty($data["extraOptionIds"])) { $extraOptions = array(); if (isset($data["extraOptionIds"])) { foreach ($data["extraOptionIds"] as $key => $value) { $extraOption = explode("|", $value); if ($extraOption[5] > 0 || $extraOption[6] > 0) { continue; } if (isset($data["extra-option-days-" . $extraOption[3]])) { $extraOption[6] = $data["extra-option-days-" . $extraOption[3]]; } if (isset($data["extra-option-persons-" . $extraOption[3]])) { $extraOption[5] = $data["extra-option-persons-" . $extraOption[3]]; } $extraOptions[$key] = implode("|", $extraOption); } } $userData->extraOptionIds = $extraOptions; } $guestDetails = array(); if (isset($data["guest_first_name"])) { for ($i = 0; $i < count($data["guest_first_name"]); $i++) { $guestDetail = new stdClass(); $guestDetail->first_name = $data["guest_first_name"][$i]; $guestDetail->last_name = $data["guest_last_name"][$i]; $guestDetail->identification_number = $data["guest_identification_number"][$i]; $guestDetails[] = $guestDetail; } } $userData->guestDetails = $guestDetails; return $userData; }
/** * Overrides the getItems method to attach additional metrics to the list. * * @return mixed An array of data items on success, false on failure. * * @since 1.6.1 */ public function getItems() { // Get a storage key. $store = $this->getStoreId('getItems'); // Try to load the data from internal storage. //if (!empty($this->cache[$store])) //{ // return $this->cache[$store]; //} // Load the list items. $items = parent::getItems(); // If emtpy or an error, just return. $month = $this->getState('filter.month'); $year = $month < date("n") ? date("Y") + 1 : date("Y"); $startDate = date("Y-m-d", mktime(0, 0, 0, $month, 1, $year)); $endDate = date("Y-m-d", mktime(0, 0, 0, $month + 1, 0, $year)); $app = JFactory::getApplication('administrator'); $hotelId = $app->getUserState('com_jhotelreservation.rooms.filter.hotel_id'); $roomId = $app->getUserState('com_jhotelreservation.edit.room.room_id'); $rId = JRequest::getVar("room_id", null); if (!empty($rId)) { $roomId = $rId; $app->setUserState('com_jhotelreservation.edit.room.room_id', $roomId); } if (empty($items)) { $items = $this->getDefaultRates($month, $year); $this->setState('filter.newRates', true); } $this->setState('filter.start_date', JHotelUtil::convertToFormat($startDate)); $this->setState('filter.end_date', JHotelUtil::convertToFormat($endDate)); JRequest::setVar("filter_start_date", $startDate); JRequest::setVar("filter_end_date", $endDate); JRequest::setVar("filter_room_type", $endDate); JRequest::setVar("hotel_id", $hotelId); JRequest::setVar("filter_room_type", $roomId); $hotelAvailability = HotelService::getHotelAvailabilyPerDay($hotelId, $startDate, $endDate); //dmp($roomId); $report = new JHotelReservationModelReports(); $availabilty = $report->getAvailabilityReport(); //dmp($availabilty); //dmp($roomId); foreach ($items as $item) { //dmp($item->date); if (isset($availabilty[$item->date][$roomId])) { $item->booked = $availabilty[$item->date][$roomId][1]; } else { $item->booked = 0; } //dmp($item->booked); if (isset($availabilty[$item->date][$roomId])) { $item->available = intval($item->availability) - intval($availabilty[$item->date][$roomId][1]); } else { $item->available = $item->availability; } $item->isHotelAvailable = $hotelAvailability[$item->date]; } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }