Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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 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;
 }
Exemplo n.º 4
0
 function generateCalendarData($year = 0, $month = 0)
 {
     $session = JFactory::getSession();
     $userData = $_SESSION['userData'];
     $post = JRequest::get('post');
     $get = JRequest::get('get');
     if (!count($post)) {
         $post = $get;
     }
     if (!isset($post["hotel_id"])) {
         $post["hotel_id"] = JRequest::getInt('hotel_id');
     }
     $year_start = $userData->year_start;
     $month_start = $userData->month_start;
     $day_start = 1;
     $year_end = $userData->year_end;
     $month_end = $userData->month_start;
     $day_end = date('t', mktime(0, 0, 0, $userData->month_start, 1, $userData->year_start));
     $hotelId = $post["hotel_id"];
     $currentRoom = $post["current_room"];
     //dmp($currentRoom);
     $adults = $userData->adults;
     $children = $userData->children;
     //dmp($userData);
     if (isset($userData->roomGuests)) {
         $adults = $userData->roomGuests[$currentRoom - 1];
     }
     $post["guest_adult"] = $adults;
     $post["guest_child"] = $userData->children;
     $post["rooms"] = $userData->rooms;
     if ($year != 0) {
         $post["year_start"] = $year;
         $post["year_end"] = $year;
         $year_start = $year;
         $year_end = $year;
     }
     if ($month != 0) {
         $post["month_start"] = $month;
         $post["month_end"] = $month;
         $month_start = $month;
         $month_end = $month;
     }
     $number_persons = $post["guest_adult"];
     //dmp($post);
     $datasi = date("Y-m-d", mktime(0, 0, 0, $userData->month_start, $userData->day_start, $userData->year_start));
     $dataei = date("Y-m-d", mktime(0, 0, 0, $userData->month_end, $userData->day_end, $userData->year_end));
     $diff = abs(strtotime($dataei) - strtotime($datasi));
     $years = floor($diff / (365 * 60 * 60 * 24));
     $months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
     $initialNrDays = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24));
     //dmp($initialNrDays);
     $datas = date("Y-m-d", mktime(0, 0, 0, $month_start, $day_start, $year_start));
     $datae = date("Y-m-d", mktime(0, 0, 0, $month_end, $day_end + 7, $year_end));
     //echo $adults." ";
     //dmp($adults);
     /* 	dmp($year_start);
     		dmp($month_start);
     		dmp($datas);
     		dmp($datae); */
     //exit;
     $offers = HotelService::getHotelOffers($hotelId, $datas, $datae, array(), $adults, $children);
     $rooms = HotelService::getHotelRooms($hotelId, $datas, $datae, array(), $adults, $children);
     $bookingsDays = BookingService::getNumberOfBookingsPerDay($hotelId, $datas, $datae);
     $hoteAvailability = HotelService::getHotelAvailabilyPerDay($hotelId, $datas, $datae);
     $temporaryReservedRooms = BookingService::getReservedRooms($userData->reservedItems);
     $temporaryReservedRooms["datas"] = $datasi;
     $temporaryReservedRooms["datae"] = $dataei;
     //dmp($temporaryReservedRooms);
     $roomsCalendar = HotelService::getRoomsCalendar($rooms, $initialNrDays, $adults, $children, $month_start, $year_start, $bookingsDays, $temporaryReservedRooms, $hoteAvailability);
     $offersCalendar = HotelService::getOffersCalendar($offers, $initialNrDays, $adults, $children, $month_start, $year_start, $bookingsDays, $temporaryReservedRooms, $hoteAvailability);
     //dmp($roomsCalendar);
     //dmp($offersCalendar);
     //combining the calendars
     $calendar = array_combine(array_merge(array_keys($roomsCalendar), array_keys($offersCalendar)), array_merge(array_values($roomsCalendar), array_values($offersCalendar)));
     //dmp($calendar);
     return $calendar;
 }
Exemplo n.º 5
0
 function addHotelRoom()
 {
     $roomId = JRequest::getInt("roomId");
     $current = JRequest::getInt("current");
     $hotelId = JRequest::getInt("hotelId");
     $discountCode = JRequest::getVar("discountCode");
     $startDate = JHotelUtil::convertToMysqlFormat(JRequest::getVar("startDate"));
     $endDate = JHotelUtil::convertToMysqlFormat(JRequest::getVar("endDate"));
     $adults = JRequest::getInt("adults");
     $children = JRequest::getInt("children");
     $room = HotelService::getHotelRooms($hotelId, $startDate, $endDate, array($roomId), $adults, $children, $discountCode);
     $room = $room[0];
     //echo($room);
     $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();
 }
 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;
 }