Пример #1
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();
 }