Example #1
0
 function CheckHotelAvailRequest($request_id)
 {
     $json = $json = "[{\"request_id\":\"{$request_id}\"}]";
     $c = $this->sendRequest('HotelAvailResponse', $json);
     //check error status
     if (isset($c['err']['code']) && $c['err']['code'] != 0) {
         return json_encode($c);
     }
     //echo json_encode($c);
     //exit;
     $Hotels = array();
     $Hotels['min'] = 0;
     $Hotels['max'] = 0;
     foreach ($c as $hotel) {
         $Hotels[$hotel['id']]['id'] = $hotel['id'];
         $Hotels[$hotel['id']]['name'] = $hotel['name'];
         $Hotels[$hotel['id']]['en_name'] = $hotel['en_name'];
         $Hotels[$hotel['id']]['star'] = $hotel['star'];
         //$Hotels[$hotel['id']]['desc'] = $hotel['description'];
         //$Hotels[$hid]['thu'] = $hotel->hotel->thu;
         //$Hotels[$hotel['id']]['en_des'] = $hotel['en_description'];
         $Hotels[$hotel['id']]['price'] = 0;
         $cvtr = new CurrencyConvertor();
         foreach ($hotel['rooms'] as $rm) {
             $temp = array();
             $temp[$rm['id']]['id'] = $rm['id'];
             $temp[$rm['id']]['name'] = $rm['name'];
             $temp[$rm['id']]['en_name'] = $rm['en_name'];
             //$temp[$rm['id']]['capa'] = $rm['id'];
             $temp[$rm['id']]['price'] = $rm['price'];
             if (!isset($_SESSION['currency_unit'])) {
                 $_SESSION['currency_unit'] = 'IRR';
             }
             $temp[$rm['id']]['currency'] = $rm['currency'];
             if ($_SESSION['currency_unit'] !== $temp[$rm['id']]['currency']) {
                 $temp[$rm['id']]['price'] = $cvtr->Convert($temp[$rm['id']]['currency'], $_SESSION['currency_unit'], $temp[$rm['id']]['price']);
                 $temp[$rm['id']]['currency'] = $_SESSION['currency_unit'];
             }
             $p = (int) $temp[$rm['id']]['price'];
             if ((int) $p > (int) $Hotels[$hotel['id']]['price']) {
                 $Hotels[$hotel['id']]['price'] = (int) $p;
             }
             if ((int) $p < (int) $Hotels['min']) {
                 $Hotels['min'] = $p;
             }
             if ((int) $p > (int) $Hotels['max']) {
                 $Hotels['max'] = (int) $p;
             }
             $Hotels[$hotel['id']]['rooms'][] = $temp;
         }
     }
     return array('Hotels' => $Hotels, 'min' => $Hotels['min'], 'max' => $Hotels['max']);
 }
Example #2
0
        ?>
</div>
                        <?php 
        $rooms = array();
        $totalprice = 0;
        $rooms_id = '';
        $rooms_attr = array();
        $cvtr = new CurrencyConvertor();
        for ($f = 0; $f < $_SESSION['room-num']; $f++) {
            $rooms[$f] = $hotel['rooms'][$f];
        }
        for ($f = 0; $f < $_SESSION['room-num']; $f++) {
            $k = 1;
            foreach ($rooms[$f] as $rmindx => $room) {
                if ($_SESSION['currency_unit'] !== $room['currency']) {
                    $room['price'] = $cvtr->Convert($room['currency'], $_SESSION['currency_unit'], $room['price']);
                    $room['currency'] = $_SESSION['currency_unit'];
                }
                $totalprice += $room['price'];
                $MoneyUnit = $room['currency'];
                $rooms_id .= trim($room['id']) . ',';
                $attr = array('id' => $room['id'], 'en_name' => $room['en_name'], 'price' => $room['price']);
                array_push($rooms_attr, $attr);
                ?>
                                <div class="room-row clearfix">
                                    <input type="hidden"  name="room[id][]" value="<?php 
                echo $room['id'];
                ?>
"/>
                                    <input type="hidden"  name="room[price][]" value="<?php 
                echo $room['price'];
Example #3
0
 function get_availByCity($city_id = '', $checkin, $checkout, $roomscount, $passengers)
 {
     $json = json_encode(array(array('city_id' => strval($city_id), 'check_in' => str_replace('/', '-', $checkin), 'check_out' => str_replace('/', '-', $checkout), 'rooms' => $roomscount, 'passengers' => $passengers)));
     $c = $this->sendRequest('chk_avail_hotel_city', $json);
     $Hotels = array();
     $Hotels['min'] = 0;
     $Hotels['max'] = 1;
     foreach ($c as $hid => $hotel) {
         $Hotels[$hid]['id'] = $hid;
         $Hotels[$hid]['name'] = $hotel->hotel->name;
         $Hotels[$hid]['en_name'] = $hotel->hotel->en_name;
         $Hotels[$hid]['star'] = $hotel->hotel->star;
         $Hotels[$hid]['desc'] = $hotel->hotel->des;
         $Hotels[$hid]['thu'] = $hotel->hotel->thu;
         $Hotels[$hid]['en_des'] = $hotel->hotel->en_des;
         $Hotels[$hid]['price'] = 0;
         $cvtr = new CurrencyConvertor();
         foreach ($hotel->rooms as $k => $room) {
             $temp = array();
             foreach ($room as $j => $rm) {
                 $Hotels[$hid]['en_des'] = $hotel->hotel->en_des;
                 $temp[$j]['id'] = $j;
                 $temp[$j]['name'] = $rm->name;
                 $temp[$j]['en_name'] = $rm->en_name;
                 $temp[$j]['capa'] = $rm->capa_adult;
                 $temp[$j]['price'] = $rm->price;
                 if (!isset($_SESSION['currency_unit'])) {
                     $_SESSION['currency_unit'] = 'IRR';
                 }
                 $temp[$j]['currency'] = $rm->currency;
                 if ($_SESSION['currency_unit'] !== $temp[$j]['currency']) {
                     $temp[$j]['price'] = $cvtr->Convert($temp[$j]['currency'], $_SESSION['currency_unit'], $temp[$j]['price']);
                     $temp[$j]['currency'] = $_SESSION['currency_unit'];
                 }
                 $p = $temp[$j]['price'];
                 //                        if($p > $Hotels[$hid]['price'])
                 //                            $Hotels[$hid]['price'] = $p;
                 //                        if($p < $Hotels['min'])
                 //                            $Hotels['min'] = $p;
                 //                        if($p > $Hotels['max'])
                 //                            $Hotels['max'] =$p;
                 if ($p > $Hotels[$hid]['price']) {
                     $Hotels[$hid]['price'] = $p;
                 }
                 if ($p < $Hotels['min']) {
                     $Hotels['min'] = $p;
                 }
                 if ((int) $p > (int) $Hotels['max']) {
                     $Hotels['max'] = (int) $p;
                 }
                 //                            $Hotels['max'] = $p;
             }
             $Hotels[$hid]['rooms'][$k] = $temp;
         }
     }
     //echo '<pre>';
     //print_r($Hotels);exit;
     return $Hotels;
 }