PageRenderTime 56ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/find_rooms.php

https://github.com/HackITtoday/ota
PHP | 597 lines | 490 code | 67 blank | 40 comment | 168 complexity | aa80e9d5be215f6979f3acce4b299d7c MD5 | raw file
  1. <?php
  2. //
  3. // Find Roooms
  4. //
  5. if (!isset($display_cont)) {$display_cont = 0; };
  6. $title = "";
  7. $site = 'essentialhotels.co.uk';
  8. //connection, auth
  9. include './auth.php';
  10. //variables
  11. $dateFrom = date('Y-m-d', strtotime($_GET['date']));
  12. // if ((int) $_GET['debug'] > 3){
  13. // print_r($_GET['date-out'],1);
  14. // print "asdf -- ". print_r($dateFrom . ' + ' . $_GET['nights'] .' days',1);
  15. // }
  16. $dateTo = date('Y-m-d', strtotime($dateFrom . ' + ' . $_GET['nights'] .' days'));
  17. $nights = $_GET['nights'];
  18. // $dateTo = date('Y-m-d', strtotime($_GET['date-out']));
  19. if (((int) $_GET['hdura']) < ((int) $_GET['hdurr']) ) $_GET['hdura'] = $_GET['hdurr'] ; // if big people < rooms then big people = rooms
  20. $hotelId = (int) $_GET['id'];
  21. if ($hotelId == 0) {
  22. $hotel_name = $_GET['id'];
  23. }
  24. $people = ((int) $_GET['hdurc']) + ((int) $_GET['hdura']);
  25. if ($people == 1) {
  26. $people_display = $people . " guest";
  27. } else {
  28. $people_display = $people . " guests";
  29. }
  30. $rooms = ((int) $_GET['hdurr']);
  31. //xml post structure
  32. include './template.php';
  33. $images = Array();
  34. $images['Single'] = "/wp-content/uploads/" . $_GET['images']['Single'] ;
  35. $images['Double'] = "/wp-content/uploads/" . $_GET['images']['Double'] ;
  36. $images['Deluxe'] = "/wp-content/uploads/" . $_GET['images']['Deluxe'] ;
  37. $images['Family'] = "/wp-content/uploads/" . $_GET['images']['Family'] ;
  38. $images['Suite'] = "/wp-content/uploads/" . $_GET['images']['Suite'] ;
  39. $map = Array();
  40. $map['Single'] = strtolower($_GET['map']['Single']) ;
  41. $map['Double'] = strtolower($_GET['map']['Double']) ;
  42. $map['Deluxe'] = strtolower($_GET['map']['Deluxe']) ;
  43. $map['Family'] = strtolower($_GET['map']['Family']) ;
  44. $map['Suite'] = strtolower($_GET['map']['Suite'] ) ;
  45. $display_title = Array();
  46. $display_title['Single'] = $_GET['display']['Single'] ;
  47. $display_title['Double'] = $_GET['display']['Double'] ;
  48. $display_title['Deluxe'] = $_GET['display']['Deluxe'] ;
  49. $display_title['Family'] = $_GET['display']['Family'] ;
  50. $display_title['Suite'] = $_GET['display']['Suite'] ;
  51. $display = Array();
  52. $display['Single'] = Array();
  53. $display['Double'] = Array();
  54. $display['Deluxe'] = Array();
  55. $display['Family'] = Array();
  56. $display['Suite'] = Array();
  57. $mapped = Array();
  58. foreach ($map as $type => $mapping) {
  59. if (isset( $map[$type] ) && isset( $display_title[$type] ) && isset( $images[$type] ) ) {
  60. $mapped[ $map[$type] ]['images'] = $images[$type];
  61. $mapped[ $map[$type] ]['display_title'] = $display_title[$type];
  62. }
  63. }
  64. if (isset($_GET['ota'])) $ota = $_GET['ota'];
  65. if ($ota == "1") { // verene
  66. $xml_post_string = $template[0];
  67. // print "<!-- sending " . print_r($xml_post_string,1) ." -->";
  68. $headers = array(
  69. "Content-type: text/xml;charset=\"utf-8\"",
  70. "Accept: text/xml",
  71. "Cache-Control: no-cache",
  72. "Pragma: no-cache",
  73. "SOAPAction: ". $soapUrl ,
  74. "Content-length: ".strlen($xml_post_string),
  75. );
  76. $url = $soapUrl;
  77. // PHP cURL for https connection with auth
  78. $ch = curl_init();
  79. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  80. curl_setopt($ch, CURLOPT_URL, $url);
  81. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  82. curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
  83. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  84. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  85. curl_setopt($ch, CURLOPT_POST, true);
  86. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
  87. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  88. // converting
  89. $response = curl_exec($ch);
  90. // print "<!-- response " . print_r($response,1) ." -->";
  91. curl_close($ch);
  92. // converting
  93. $response1 = str_replace("<soap:Body>","",$response);
  94. $response2 = str_replace("</soap:Body>","",$response1);
  95. // converting to XMLsimplexml_load_string($response2);
  96. $xml = simplexml_load_string($response2);
  97. $array = json_decode(json_encode((array) $xml), 1);
  98. if ($_GET['price']==1) {
  99. if (isset($array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['minCostOfStay'])) {
  100. print $array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['minCostOfStay'];
  101. }
  102. } else {
  103. //
  104. // print "<!-- array " . print_r($array,1) ." -->";
  105. //
  106. $title = "";
  107. if ($array['XHI_HotelAvailRS']['@attributes']['success'] == 'true' && isset($array['XHI_HotelAvailRS']) ) {
  108. if ( isset($array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['name'])){
  109. if ($_GET['nights'] == "1") {
  110. $title .= "Booking at the ".$array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['name']." staying ".$_GET['date-in']." for ".$_GET['nights'] . " Night";
  111. } else {
  112. $title .= "Booking at the ".$array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['name']." staying ".$_GET['date-in']." for ".$_GET['nights'] . " Nights";
  113. }
  114. } else {
  115. if ($_GET['nights'] == "1") {
  116. $title .= "Booking for staying ".$_GET['date-in']." for ".$_GET['nights'] . " Night for " .$people_display ;
  117. } else {
  118. $title .= "Booking for staying ".$_GET['date-in']." for ".$_GET['nights'] . " Nights for " .$people_display ;
  119. }
  120. }
  121. } elseif (isset($hotel_name) ){
  122. if ($_GET['nights'] == "1") {
  123. $title .= "Booking at the ". $hotel_name ." staying ".$_GET['date-in']." for ".$_GET['nights'] . " Night for " .$people_display ;
  124. } else {
  125. $title .= "Booking at the ". $hotel_name ." staying ".$_GET['date-in']." for ".$_GET['nights'] . " Nights for " .$people_display;
  126. }
  127. } else {
  128. if ($_GET['nights'] == "1") {
  129. $title .= "Booking for staying ".$_GET['date-in']." for ".$_GET['nights'] . " Night for " .$people_display ;
  130. } else {
  131. $title .= "Booking for staying ".$_GET['date-in']." for ".$_GET['nights'] . " Nights for " .$people_display ;
  132. }
  133. }
  134. include('../inc/top.php');
  135. include('../inc/header.php');
  136. print "<div class='status-bar'><h3> " . $title . " </h3></div>";
  137. ?>
  138. <div id="specialoff" style="text-align:center;">
  139. <img src="/wp-content/uploads/2014/03/Phone-Only-Bookings-on-Rooms-V4.png" alt="Phone Only Special Offer">
  140. </div>
  141. <center class="find-rooms">
  142. <?php
  143. if ($array['XHI_HotelAvailRS']['@attributes']['success'] == 'true' ) {
  144. if (isset($array['XHI_HotelAvailRS']['AvailResults']))
  145. foreach ($array['XHI_HotelAvailRS']['AvailResults'] as $results ) {
  146. foreach ($results as $result ) {
  147. if (isset($result['AvailStay']))
  148. foreach ($result['AvailStay'] as $rooms ) {
  149. if (isset($rooms['AvailRooms'])) {
  150. if ($map['Single'] == strtolower(trim($rooms['AvailRooms']['AvailRoom']['@attributes']['roomName'])) ) {
  151. $display['Single'][ $rooms['@attributes']['totalPrice'] ] = $rooms;
  152. } else if ($map['Double'] == strtolower(trim($rooms['AvailRooms']['AvailRoom']['@attributes']['roomName'])) ) {
  153. $display['Double'][ $rooms['@attributes']['totalPrice'] ] = $rooms;
  154. } else if ($map['Deluxe'] == strtolower(trim($rooms['AvailRooms']['AvailRoom']['@attributes']['roomName'])) ) {
  155. $display['Deluxe'][ $rooms['@attributes']['totalPrice'] ] = $rooms;
  156. } else if ($map['Family'] == strtolower(trim($rooms['AvailRooms']['AvailRoom']['@attributes']['roomName'])) ) {
  157. $display['Family'][ $rooms['@attributes']['totalPrice'] ] = $rooms;
  158. } else if ($map['Suite'] == strtolower(trim($rooms['AvailRooms']['AvailRoom']['@attributes']['roomName'])) ) {
  159. $display['Suite'][ $rooms['@attributes']['totalPrice'] ] = $rooms;
  160. } else {
  161. $missing_rooms[] = $rooms['AvailRooms']['AvailRoom']['@attributes']['roomName'];
  162. }
  163. // print "<!-- more rooms " . print_r($rooms['AvailRooms']['AvailRoom']['@attributes']['totalPrice'],1) ." -->";
  164. } elseif( isset($rooms['AvailRoom']) ) {
  165. if ($map['Single'] == strtolower(trim($rooms['AvailRoom']['@attributes']['roomName'])) ) {
  166. $display['Single'][ $rooms['AvailRoom']['@attributes']['totalPrice'] ]= $rooms;
  167. } else if ($map['Double'] == strtolower(trim($rooms['AvailRoom']['@attributes']['roomName'])) ) {
  168. $display['Double'][ $rooms['AvailRoom']['@attributes']['totalPrice'] ]= $rooms;
  169. } else if ($map['Deluxe'] == strtolower(trim($rooms['AvailRoom']['@attributes']['roomName'])) ) {
  170. $display['Deluxe'][ $rooms['AvailRoom']['@attributes']['totalPrice'] ]= $rooms;
  171. } else if ($map['Family'] == strtolower(trim($rooms['AvailRoom']['@attributes']['roomName'])) ) {
  172. $display['Family'][ $rooms['AvailRoom']['@attributes']['totalPrice'] ]= $rooms;
  173. } else if ($map['Suite'] == strtolower(trim($rooms['AvailRoom']['@attributes']['roomName'])) ) {
  174. $display['Suite'][ $rooms['AvailRoom']['@attributes']['totalPrice'] ]= $rooms;
  175. } else {
  176. $missing_rooms[] = $rooms['AvailRooms']['AvailRoom']['@attributes']['roomName'];
  177. }
  178. // print "<!-- 1 rooms ";
  179. // print_r($rooms['AvailRoom']['@attributes']['totalPrice'],1);
  180. // print " -->";
  181. }
  182. }
  183. }
  184. }
  185. }
  186. $display_cont == 0;
  187. if (count($missing_rooms)) {
  188. $fp = fopen("./.ht.missing_rooms", "a");
  189. fwrite($fp, json_encode(Array("Venere" => $rooms_array )));
  190. fwrite($fp, PHP_EOL);
  191. fclose($fp);
  192. }
  193. print "<!-- display ". print_r($display ,1 ) ." -->";
  194. print "<!-- images ". print_r($images ,1 ) ." -->";
  195. foreach ($display as $type => $rooms ) {
  196. // ksort( $rooms );
  197. if (isset($map[$type]) && isset($images[$type]) && ($images[$type] != "/wp-content/uploads" || $images[$type] != "/wp-content/uploads/") ) {
  198. print "<!-- debug rooms out ". print_r( $rooms, 1 )." -->";
  199. if (is_array($rooms) && ( count($rooms, COUNT_RECURSIVE) > 1) ) { // is from venere?
  200. print "<div class='topbox'>";
  201. print " <img class='room online' src=" . $images[$type] . " />";
  202. if ((int) $room['AvailRooms']['AvailRoom']['@attributes']['quantity'] > 1 ) {
  203. $display_r = "<h3>" . $rooms[0]['AvailRooms']['AvailRoom']['@attributes']['quantity'] . ' x ' . $display_title[ $type ] . "</h3>";
  204. } elseif ((int) $rooms[0]['AvailRoom']['@attributes']['quantity'] > 1 ) {
  205. $display_r = "<h3>" . $rooms[0]['AvailRoom']['@attributes']['quantity'] . ' x ' . $display_title[ $type ] . "</h3>";
  206. } else {
  207. $display_r = "<h3>" .$display_title[ $type ]. "</h3>";
  208. }
  209. print $display_r . " <div> ";
  210. foreach ($rooms as $room) {
  211. // print "<!--debug room out ". print_r( $room, 1 )." -->";
  212. if ( isset ($room['AvailRooms'])) {
  213. $ValueAddDisplay = "";
  214. if (isset( $room['AvailRooms']['AvailRoom']['ValueAddList']['ValueAdd'] )) {
  215. foreach ( $room['AvailRooms']['AvailRoom']['ValueAddList']['ValueAdd'] as $ValueAdd ) {
  216. $ValueAddDisplay .= "<div>" . $ValueAdd['@attributes']['label'] . "</div>";
  217. }
  218. }
  219. if (isset( $room['AvailRooms']['AvailRoom']['ValueAddList'] ) ) {
  220. foreach ( $room['AvailRooms']['AvailRoom']['ValueAddList'] as $ValueAdd ) {
  221. if (isset($ValueAdd['@attributes']['label'])) $ValueAddDisplay .= "<div>" . $ValueAdd['@attributes']['label'] . "</div>";
  222. }
  223. }
  224. if ($room['AvailRooms']['AvailRoom']['@attributes']['prepaid'] == "false") {
  225. $pay_at = "<span class='pay_at'>Pay at hotel</span>";
  226. } else {
  227. $pay_at = "<span class='pay_at'>Advanced Purchase-Non Cancellable</span>";
  228. }
  229. print '<form class="roomcards top" action="/ota/lib/booking.php" method="post" data-ajax="false">';
  230. print '<div class="roomcards" id="roomcards">';
  231. print '<span class="extra" style=" display: inline-block;" >';
  232. print '<h4>Includes</h4>';
  233. print str_ireplace(array("Included","Free"), "", $ValueAddDisplay);
  234. print '</span>';
  235. print '<a href="#!" class="cancelpolicy" class="tip" title="'. $room['GlobalCancellationPolicy']['@attributes']['policyDescription'] .'" >' . $room['GlobalCancellationPolicy']['@attributes']['policyLabel'] .' ' . $pay_at . '<img src="/ota/inc/images/information.gif" height="10" width="10" /> </a>' ;
  236. print '<div id="totprice">';
  237. print '<div id="smalltot">Total</div>';
  238. print '<button data-theme="f" title="'. $room['@attributes']['currencyCode'] . '" > £ '.number_format($room['@attributes']['totalPrice'], 2) .' </button>';
  239. print '</div>';
  240. // print '</span>';
  241. print '</div>';
  242. print '<input type="hidden" name="HotelID" value="'. $_GET['id'] .'" />';
  243. print '<input type="hidden" name="roomID" value="'.$room['AvailRooms']['AvailRoom']['@attributes']['roomID'].'" />';
  244. print '<input type="hidden" name="totalPrice" value="'.$room['@attributes']['totalPrice'].'" />';
  245. print '<input type="hidden" name="ratePlanID" value="'.$room['AvailRooms']['AvailRoom']['AvailRatePlan']['@attributes']['ratePlanID'].'" />';
  246. print '<input type="hidden" name="quantity" value="'.(int) $room['AvailRooms']['AvailRoom']['@attributes']['quantity'] .'" />';
  247. print '<input type="hidden" name="AvailBookingToken" value="'.$room['AvailBookingToken'] .'" />';
  248. print '<input type="hidden" name="date-in" value="'. $dateFrom .'" />';
  249. print '<input type="hidden" name="price" value="'. number_format($room['@attributes']['totalPrice'], 2) .'" />';
  250. print '<input type="hidden" name="date-out" value="'. $dateTo .'" />';
  251. print '<input type="hidden" name="status" value="'. $title .' in the '. $display_r .' for a Total Amount of £'. number_format($room['@attributes']['totalPrice'], 2) .' for '. strip_tags($people_display) .'" />';
  252. print '<input type="hidden" name="Clause" value="'. $room['GlobalCancellationPolicy']['Clause'] .'" />';
  253. print '<input type="hidden" name="sellingMethod" value="'. $room['@attributes']['sellingMethod'] .'" />';
  254. print '<input type="hidden" name="prepaid" value="'.$room['AvailRooms']['AvailRoom']['@attributes']['prepaid'].'" />';
  255. print '<input type="hidden" name="hotel" value="'.$array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['name'].'" />';
  256. @print '<input type="hidden" name="ota" value="'. $_GET['ota'] .'" />';
  257. print '</form><div style="clear:both"> </div>';
  258. } else {
  259. // print "<!--debug room gsegtrwe in ". print_r( $room, 1 )." -->";
  260. $ValueAddDisplay = "";
  261. if (isset( $room['AvailRooms']['AvailRoom']['ValueAddList']['ValueAdd'] )) {
  262. foreach ( $room['AvailRooms']['AvailRoom']['ValueAddList']['ValueAdd'] as $ValueAdd ) {
  263. $ValueAddDisplay .= "<div>" . $ValueAdd['@attributes']['label'] . "</div>";
  264. }
  265. }
  266. if (isset( $room['AvailRooms']['AvailRoom']['ValueAddList'] )) {
  267. foreach ( $room['AvailRooms']['AvailRoom']['ValueAddList'] as $ValueAdd ) {
  268. $ValueAddDisplay .= "<div>" . $ValueAdd['@attributes']['label'] . "</div>";
  269. }
  270. }
  271. if (isset( $room['AvailRoom']['ValueAddList'] )) {
  272. foreach ( $room['AvailRoom']['ValueAddList'] as $ValueAdd ) {
  273. $ValueAddDisplay .= "<div>" . $ValueAdd['@attributes']['label'] . "</div>";
  274. }
  275. }
  276. if (isset($room['GlobalCancellationPolicy']['@attributes'])) {
  277. $policy['Description'] = $room['GlobalCancellationPolicy']['@attributes']['policyDescription'];
  278. $policy['Label'] = $room['GlobalCancellationPolicy']['@attributes']['policyLabel'];
  279. } elseif(isset($array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['AvailStays']['AvailStay']['GlobalCancellationPolicy'])){
  280. $policy['Description'] = $array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['AvailStays']['AvailStay']['GlobalCancellationPolicy']['@attributes']['policyDescription'];
  281. $policy['Label'] = $array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['AvailStays']['AvailStay']['GlobalCancellationPolicy']['@attributes']['policyLabel'];
  282. }
  283. /*Secound Pay Now Field
  284. if ($room['AvailRoom']['@attributes']['prepaid'] == "false") {
  285. $pay_at = "<span class='pay_at'>Pay at hotel</span>";
  286. } else {
  287. $pay_at = "<span class='pay_at'>Pay now</span>";
  288. }
  289. */
  290. print '<form class="roomcards" action="/ota/lib/booking.php" method="post" data-ajax="false">';
  291. print '<div class="roomcards" id="roomcards">';
  292. if (trim(strip_tags($ValueAddDisplay))) {
  293. print '<span class="extra" style="display: inline-block;" >';
  294. print '<h4>Includes</h4>';
  295. print str_ireplace(array("Included","Free"), "", $ValueAddDisplay);
  296. print '</span>';
  297. }
  298. print '<a href="#!" class="cancelpolicy ui-link" style="display:inline-block;" class="tip" title="'. $policy['Description'] .'" >' . $policy['Label'] .' ' . $pay_at . '</a>' ;
  299. print '<span style=" text-align: right; display: inline-block;" >';
  300. print '</span>';
  301. print '<span style="text-align: right; display: inline-block;" >';
  302. print '<button style="text-align: right;" data-theme="f" title="'. $room['AvailRoom']['@attributes']['currencyCode'] . '" > £ '.number_format($room['AvailRoom']['@attributes']['totalPrice'], 2) .' </button>';
  303. print '</span>';
  304. print '</div>';
  305. print '<input type="hidden" name="HotelID" value="'. $_GET['id'] .'" />';
  306. print '<input type="hidden" name="roomID" value="'.$room['AvailRoom']['@attributes']['roomID'].'" />';
  307. print '<input type="hidden" name="totalPrice" value="'.$room['AvailRoom']['@attributes']['totalPrice'].'" />';
  308. print '<input type="hidden" name="ratePlanID" value="'.$room['AvailRoom']['AvailRatePlan']['@attributes']['ratePlanID'].'" />';
  309. print '<input type="hidden" name="price" value="'. number_format($room['AvailRoom']['@attributes']['totalPrice'], 2) .'" />';
  310. print '<input type="hidden" name="quantity" value="'.(int) $room['AvailRoom']['@attributes']['quantity'] .'" />';
  311. print '<input type="hidden" name="AvailBookingToken" value="'.$array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['AvailStays']['AvailStay']['AvailBookingToken'] .'" />';
  312. print '<input type="hidden" name="date-in" value="'. $dateFrom .'" />';
  313. print '<input type="hidden" name="status" value="'. $title .' in the '. $display_r .' for a Total Amount of £'. number_format($room['AvailRoom']['@attributes']['totalPrice'], 2) .' for '. strip_tags($people_display) .'" />';
  314. print '<input type="hidden" name="Clause" value="'. $room['GlobalCancellationPolicy']['Clause'] .'" />';
  315. print '<input type="hidden" name="date-out" value="'. $dateTo .'" />';
  316. print '<input type="hidden" name="sellingMethod" value="'. $array['AvailResults']['AvailResult']['AvailStays']['AvailStay']['@attributes']['sellingMethod'] .'" />';
  317. print '<input type="hidden" name="prepaid" value="'.$room['AvailRoom']['@attributes']['prepaid'].'" />';
  318. print '<input type="hidden" name="hotel" value="'.$array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['name'].'" />';
  319. @print '<input type="hidden" name="ota" value="'. $_GET['ota'] .'" />';
  320. print '</form><div style="clear:both"> </div>';
  321. }
  322. }
  323. print "</div>"; // topbox
  324. } else {
  325. print "<div class='topbox'>";
  326. print " <img class='room phone-only' src=" . $images[$type] . " />";
  327. if ((int) $rooms > 1 ) {
  328. print "<h3>" . $rooms . ' x ' . $display_title[ $type ] . "</h3>";
  329. } else {
  330. print "<h3>" .$display_title[ $type ]. "</h3>";
  331. }
  332. print '<a href="tel:01189714700"> Phone only for Availability/Price </a>';
  333. print "</div>";
  334. }
  335. print "</div>";
  336. }
  337. $display_cont++;
  338. }
  339. if ($display_cont == 0) {
  340. print '<div id="norooms" style="font-family:Roboto, sans-serif; font-size:50px; color:#ff3300; font-weight:300;"> These rooms have not been advertised on-line you will need to phone us: <a href="tel:01189714700" >0118 971 4700</a>';
  341. }
  342. if ( isset($array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['amenities'] )) {
  343. $amenities = $array['XHI_HotelAvailRS']['AvailResults']['AvailResult']['PropertyDetails']['@attributes']['amenities'];
  344. $facilities = explode(",", $amenities);
  345. }
  346. }
  347. if (count($rooms_array)) {
  348. $fp = fopen("./.ht.missing_rooms", "a");
  349. fwrite($fp, json_encode(Array("Laterooms" => $rooms_array )));
  350. fwrite($fp, PHP_EOL);
  351. fclose($fp);
  352. }
  353. } else { // laterooms
  354. $xml = simplexml_load_string(file_get_contents($template['lateroom_url']));
  355. $array = json_decode(json_encode((array) $xml), 1);
  356. if (isset($_GET['debug']) && (int) $_GET['debug'] != 0) {
  357. if ((int) $_GET['debug'] > 1 ) print '<pre> ' . print_r ($array,1) . ' </pre>';
  358. print '<pre> ' . print_r ($mapped,1) . ' </pre>';
  359. }
  360. if (!isset($hotel_name) || (isset($hotel_name) && trim($hotel_name) == "")) {
  361. $hotel_name = $array['hotel']['hotel_name'];
  362. }
  363. $title = "";
  364. if ($array['response']['@attributes']['status'] == '1' ) {
  365. if ($_GET['nights'] == "1") {
  366. $title .= "Booking at the ". $hotel_name ." staying ".$_GET['date-in']." for ".$_GET['nights'] . " night for " . $people_display;
  367. } else {
  368. $title .= "Booking at the ". $hotel_name ." staying ".$_GET['date-in']." for ".$_GET['nights'] . " nights for " . $people_display;
  369. }
  370. } else {
  371. $title = "Phone us";
  372. }
  373. include('../inc/top.php');
  374. include('../inc/header.php');
  375. print "<div class='status-bar'><h3> " . $title . " </h3></div>";
  376. ?>
  377. <div id="specialoff" style="text-align:center;">
  378. <img src="/wp-content/uploads/2014/03/Phone-Only-Bookings-on-Rooms-V4.png" alt="Phone Only Special Offer">
  379. </div>
  380. <?php if ($_GET['debug'] == 2) {
  381. print '<pre> $array[hotel][lr_rates][hotel_rooms][room] :' . print_r ($array['hotel']['lr_rates']['hotel_rooms']['room'],1) . '</pre>';
  382. print '<pre> count($array[hotel][lr_rates][hotel_rooms][room]) :' . print_r (count($array['hotel']['lr_rates']['hotel_rooms']['room']),1) . '</pre>';
  383. }
  384. if (count($array['hotel']['lr_rates']['hotel_rooms']['room']) == 1){
  385. $temp = $array['hotel']['lr_rates']['hotel_rooms'];
  386. unset($array['hotel']['lr_rates']['hotel_rooms']);
  387. $array['hotel']['lr_rates']['hotel_rooms']['room'][] = $temp;
  388. }
  389. if ($_GET['debug'] == 2) {
  390. print '<pre> $array[hotel][lr_rates][hotel_rooms] after :' . print_r ($array['hotel']['lr_rates']['hotel_rooms']['room'],1) . '</pre>';
  391. print '<pre> count($array[hotel][lr_rates][hotel_rooms]) after :' . print_r (count($array['hotel']['lr_rates']['hotel_rooms']),1) . '</pre>';
  392. }
  393. ?>
  394. <center class="find-rooms">
  395. <?php
  396. if (isset($array['hotel']['lr_rates']['hotel_rooms']['room'])) foreach ($array['hotel']['lr_rates']['hotel_rooms']['room'] as $room) {
  397. if ($_GET['debug'] == 1) {
  398. print '<pre> room :' . print_r ($room,1) . '</pre>';
  399. }
  400. $Id = $room['ref'];
  401. $Type = strtolower($room['typedescription']);
  402. if ((int) $_GET['debug'] != 0) {
  403. print '<pre> Type >> ' . print_r ($Type,1) . '</pre>';
  404. print '<pre> room >> ' . print_r ($room,1) . '</pre>';
  405. }
  406. if (isset($room['rate']['price'])) {
  407. $Price = $room['rate']['price'];
  408. } elseif(is_array($room['rate'])) {
  409. foreach ($room['rate'] as $price_for_night ) {
  410. $Price += (float) $price_for_night['numeric_price'];
  411. }
  412. $Price = "£" . number_format($Price, 2, '.', '');
  413. }
  414. $Cancellation_policy = $room['cancellation_policy'];
  415. $breakfast = $room['breakfast'];
  416. $ValueAddDisplay = Array();
  417. if ($room['breakfast'] == "true") {
  418. $ValueAddDisplay[] = 'Breakfast';
  419. }
  420. $dinner = $room['dinner'];
  421. if ($room['dinner'] == "true") {
  422. $ValueAddDisplay[] = 'Dinner';
  423. }
  424. if (isset($mapped[$Type])) {
  425. $rooms_array[$Type][] = Array("Id" => $Id,'Price' => $Price, 'Formatted_cancellation_policy' => rtrim($room['formatted_cancellation_policy'], ">"),'room_description' => trim($room['room_description'] , " \t\n\r."), 'Cancellation_policy'=> $Cancellation_policy,'ValueAddDisplay'=> $ValueAddDisplay);
  426. }
  427. }
  428. foreach ($mapped as $Type => $map ) {
  429. print_room_type($map, $Type, $rooms, $rooms_array[$Type], $title, $people_display, $dateFrom, $nights, $people, $hotel_name);
  430. unset($rooms_array[$Type]);
  431. }
  432. if (count($rooms_array)) {
  433. $fp = fopen("./.ht.missing_rooms", "a");
  434. fwrite($fp, json_encode(Array("Laterooms" => $rooms_array )));
  435. fwrite($fp, PHP_EOL);
  436. fclose($fp);
  437. }
  438. $facilities = $array['hotel']['facilities']['facility'];
  439. print '<div id=facilities style="text-align: left; margin-left: 230px; font-family: Roboto, sans-serif; font-weight: 300;">
  440. <h3 style="
  441. font-family: Roboto, sans-serif;
  442. font-weight: 300;
  443. ">Facilities</h3>
  444. <ul style="-webkit-columns:2; columns:2;"><li>'.implode("</li><li>", $facilities) . "</li></ul>";
  445. // print_r($array['hotel']);
  446. }
  447. function print_room_type($map, $Type, $num_rooms, $rooms_array, $title, $people_display, $dateFrom, $nights, $people, $hotel_name) {
  448. if ($Type) {
  449. foreach ($rooms_array as $room) {
  450. print "<div class='topbox'>";
  451. print "<img class='room phone-only' src=" . $map['images'] . " />";
  452. if ((int) $rooms > 1 ) {
  453. print "<h3>" . $num_rooms . ' x ' . $map['display_title'] . "</h3>";
  454. } else {
  455. print "<h3>" . $map['display_title'] . "</h3>";
  456. }
  457. print_room($mapped, $room['Id'], $Type, $num_rooms, $room, $title, $people_display, $dateFrom, $nights, $people,$hotel_name );
  458. if ( count($rooms_array) == 0 ) {
  459. print '<div id="norooms" style="font-family:Roboto, sans-serif; font-size:20px; color:#ff3300; font-weight:300;"> This room have not been advertised on-line you will need to phone us: <a href="tel:01189714700" >0118 971 4700</a></div>';
  460. }
  461. print "</div><div style='clear:both' ></div>";
  462. }
  463. }
  464. }
  465. function print_room($mapped, $Id, $Type, $num_rooms, $room, $title, $people_display, $dateFrom, $nights, $people, $hotel_name) {
  466. $Price = $room['Price'];
  467. $Cancellation_policy = $room['Cancellation_policy'] ;
  468. $ValueAddDisplay = $room['ValueAddDisplay'];
  469. static $last_price;
  470. if ( $Price ) { // && $Price != $last_price) {
  471. $last_price = $Price;
  472. print '<form data-ajax="false" method="post" action="/ota/lib/booking.php" class="roomcards top"><div id="roomcards" class="roomcards">';
  473. if (count($ValueAddDisplay)) {
  474. print '<span style=" display: inline-block;" class="extra">';
  475. print '<h4>Includes</h4>';
  476. foreach ($ValueAddDisplay as $ValueAdd) {
  477. print '<div>'. $ValueAdd .'</div>';
  478. }
  479. print '</span>';
  480. }
  481. print "<div class='info' >";
  482. print '<a title="' . $room['Formatted_cancellation_policy'] . '" class="cancelpolicy ui-link" href="#!">';
  483. if (strpos($room['Formatted_cancellation_policy'] , 'advance purchase rate')) {
  484. print 'Advanced Purchase-Non Cancellable';
  485. } else {
  486. print 'Cancellation policy';
  487. }
  488. print '<img width="10" height="10" src="/ota/inc/images/information.gif"></a>';
  489. print '<a title="' . $room['room_description'] . '" class="offersandnotes ui-link" href="#!">';
  490. print 'Offers and Notes';
  491. print '<img width="10" height="10" src="/ota/inc/images/information.gif"> </a>';
  492. if (strlen ($room['room_description']) > 100 ) $dots = ' ...';
  493. print '<span title="' . $room['room_description'] . '" > ' .substr($room['room_description'], 0, 100). $dots .' </span>';
  494. print '</div>'; // info
  495. print '<div id="totprice">';
  496. print '<div id="smalltot">Total</div>';
  497. print '<span>';
  498. print '<button data-theme="f" title="GBP" > '.$Price.' </button>';
  499. print '</span>';
  500. print '</div>';
  501. print '<input type="hidden" name="HotelID" value="'. $_GET['id'] .'" />';
  502. print '<input type="hidden" value="' . $Id . '" name="roomID">';
  503. print '<input type="hidden" name="totalPrice" value="' . $Price . '" />';
  504. print '<input type="hidden" name="ratePlanID" value="'.'" />';
  505. print '<input type="hidden" name="price" value="'. $Price .'" />';
  506. print '<input type="hidden" name="quantity" value="'. $num_rooms .'" />';
  507. print '<input type="hidden" name="AvailBookingToken" value="laterooms" />';
  508. print '<input type="hidden" name="date-in" value="'. $dateFrom .'" />';
  509. print '<input type="hidden" name="date-out" value="'. $dateTo .'" />';
  510. print '<input type="hidden" name="nights" value="'. $nights .'" />';
  511. print '<input type="hidden" name="people" value="'. $people .'" />';
  512. print '<input type="hidden" name="status" value="'. $title .' in the '. $display_r .' for a Total Amount of '. $Price .' for '. strip_tags($people_display) .'" />';
  513. print '<input type="hidden" name="Clause" value="'. $room['Formatted_cancellation_policy'] . '" />';
  514. print '<input type="hidden" name="date-out" value="'.$dateTo.'" />';
  515. print '<input type="hidden" name="sellingMethod" value="'.'" />';
  516. print '<input type="hidden" name="prepaid" value="'.'" />';
  517. print '<input type="hidden" name="hotel" value="'. $hotel_name .'" />';
  518. @print '<input type="hidden" name="ota" value="'. $_GET['ota'] .'" />';
  519. if (isset( $_GET['debug'] )) { print '<input type="hidden" name="debug" value="'. $_GET['debug'] .'" />'; }
  520. if (isset( $_GET['debug'] )) { print '<input type="hidden" name="debug" value="'. $_GET['debug'] .'" />'; }
  521. print '</div></form><div style="clear:both" > </div>';
  522. }
  523. }
  524. // debug https://essentialhotels.co.uk/ota/out.php?doubleroom=&deluxeroom=&familyroom=&suiteroom=/2012/02/Mercure-Shakespeare-Hotel-Stratford-Junior-Suite.jpg&singleroom=/2012/02/Mercure-Shakespeare-Hotel-Stratford-Classic-Room.jpg&doublemap=&deluxemap=&familymap=&suitemap=Junior%20Suite,%201%20King%20Bed&singlemap=Classic&id=575&doubledisplay=Classic%20Twin%20Room&deluxedisplay=Executive%20Double%20Room&familydisplay=Executive%20Twin%20Room&ota=3&suitAedisplay=Junior%20Suite,%201%20King%20Bed&singledisplay=Classic%20Double%20or%20Twin%20Room,%201%20Double%20Bed
  525. // print_r( $_POST );
  526. // print_r( $_GET );
  527. // print_r($array['XHI_HotelAvailRS']);
  528. ?></center>
  529. </body>
  530. </html>