<?php
session_start();
require_once(dirname(__FILE__) . "/../../../adbcon.php");
require_once(dirname(__FILE__) . "/Expedia_rest_api.php");

$hotelIds = array (
  0 => 183329,
  1 => 223446,
  2 => 138663,
  3 => 224046,
  4 => 152639,
  5 => 230454,
  6 => 233699,
  7 => 145436,
  8 => 183330,
  9 => 278045,
  10 => 223963,
  11 => 429659,
  12 => 265103,
  13 => 235408,
  14 => 239299,
  15 => 394774,
  16 => 224808,
  17 => 190823,
  18 => 416658,
  19 => 125754,
  20 => 264099,
  21 => 230794,
  22 => 312780,
  23 => 275666
);


//$hotelIds = '183329,223446,138663,224046,152639,230454,233699,145436,183330,278045,223963,429659,265103,235408,239299,394774,224808,190823,416658,125754,264099,230794,312780,275666';

$hotel_rates = array();

$data = array(
	"arrivalDate"	=> '04/08/2013',
	"departureDate"	=> '04/11/2013',
	"numberOfBedRooms" => 1,
	"RoomGroup" => array(
					array(
						"numberOfAdults"	=> 2,
						
						"numberOfChildren"	=> 0
					)
				)
);

$exp = new Expedia_rest_api();
$ret = json_decode($exp->get_hotels_availability($hotelIds, $data), true);

if(isset($ret['HotelListResponse'])) {
	$ret_hotels = $ret['HotelListResponse']['HotelList']['HotelSummary'];
	foreach ($ret_hotels as $i=>$rh) {
		//echo '<pre>', var_export($rh, true), '</pre>';
		if(isset($rh['RoomRateDetailsList'])) {
			$room_rates = $rh['RoomRateDetailsList']['RoomRateDetails']['RateInfos']['RateInfo']['ChargeableRateInfo'];
			$hotel_rates[] = $rh['hotelId'] .' => ' . round($room_rates['@averageBaseRate'], 2);
			//echo '<pre>hotelId [', $rh['hotelId'],'][',$expedia_hotels[$rh['hotelId']], '] = ', var_export($room_rates['@averageBaseRate'], true), '</pre>';
		}
		else {
			$hotel_rates[] = $rh['hotelId'] .' => '. 'NONE';
		}
	}
}


echo '<pre>', var_export($hotel_rates, true), '</pre>';
echo '<pre>', var_export($ret, true), '</pre>';
/*

$hotelId = $_REQUEST['hotelId'];
$checkin = $_REQUEST['checkin'];
$checkout = $_REQUEST['checkout'];

$data = array(
	"arrivalDate"	=> $checkin,
	"departureDate"	=> $checkout,
	"numberOfBedRooms" => 2
);

$exp = new Expedia_rest_api();
$r = json_decode($exp->get_hotel_availability($hotelId, $data));
*/

echo '<pre>', var_export($exp, true), '</pre>';
//echo '<pre>', var_export($r, true), '</pre>';
?>