public function process()
 {
     global $cookie;
     parent::process();
     $roomtype_list = RoomPlan::getRoomTypeList();
     $roomtype_form_list = array();
     $search_form = array();
     // get contient code
     self::$cookie->UserID;
     $continentCode = Tools::getUserContinentCode(self::$cookie->CompanyID);
     if (Tools::isSubmit("search")) {
         $search_form = Tools::element_copy($_REQUEST, 'CityId', 'AreaId', 'CheckIn', 'CheckOut', 'Nights', 'HotelClassId', 'HotelName', 'SortBy', 'SortOrder');
         if (self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) {
             $search_form['ContinentCode'] = $continentCode;
             $search_form['HideRQ'] = @$_REQUEST['HideRQ'];
             $search_form['Role'] = 'Agent';
         }
         foreach ($roomtype_list as $roomtype) {
             $roomTypeId = $roomtype['RoomTypeId'];
             $roomtype_form_list[$roomTypeId] = $_REQUEST['RoomType_' . $roomTypeId];
         }
         $search_form['RoomTypeVals'] = $roomtype_form_list;
         if (self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3 || $search_form['CheckIn'] && $search_form['CheckOut']) {
             $search_form['Role'] = 'Agent';
             $hotel_roomplan_count = RoomPlan::searchHotelRoomPlanCount($search_form);
             parent::pagination($hotel_roomplan_count);
             $hotel_roomplan_list = RoomPlan::searchHotelRoomPlan($search_form, $this->p, $this->n);
         } else {
             $hotel_roomplan_count = HotelDetail::getHotelByAreaCityCount($search_form);
             parent::pagination($hotel_roomplan_count);
             $hotel_roomplan_list = HotelDetail::getHotelByAreaCity($search_form, $this->p, $this->n);
         }
     } else {
         // redirect
         Tools::redirect('index.php');
     }
     self::$smarty->assign("hotel_roomplan_list", $hotel_roomplan_list);
     self::$smarty->assign("hotel_roomplan_count", $hotel_roomplan_count);
     self::$smarty->assign("search_form", $search_form);
     self::$smarty->assign("search_city_name", Tools::getCityName($search_form['CityId']));
     self::$smarty->assign("search_area_name", Tools::getAreaName($search_form['AreaId']));
     self::$smarty->assign("roomTypeList", $roomtype_list);
     self::$smarty->assign("classList", Tools::getAllHotelClasses());
     self::$smarty->assign("areaList", Tools::getJapanAreas());
 }
 public function process()
 {
     parent::process();
     global $cookie;
     $iso = Language::getIsoById((int) $cookie->LanguageID);
     $mid = $this->mid;
     //Tools::getValue("mid")!="" ? Tools::getValue("mid") : ((self::$cookie->RoleID==1) ? self::$cookie->HotelID : "");
     $hotel = new HotelDetail($mid);
     $HotelNameKey = 'HotelName_' . $iso;
     $hotel->HotelName = $hotel->{$HotelNameKey};
     $HotelAddressKey = 'HotelAddress_' . $iso;
     $hotel->HotelAddress = $hotel->{$HotelAddressKey};
     $HotelDescriptionKey = 'HotelDescription_' . $iso;
     $hotel->HotelDescription = $hotel->{$HotelDescriptionKey};
     $HotelPoliciesKey = 'HotelPolicies_' . $iso;
     $hotel->HotelPolicies = $hotel->{$HotelPoliciesKey};
     $UsefulInformationKey = 'UsefulInformation_' . $iso;
     $hotel->UsefulInformation = $hotel->{$UsefulInformationKey};
     $continentCode = Tools::getUserContinentCode(self::$cookie->CompanyID);
     // get CityName and AreaName of Hotel
     $hotel->HotelAreaName = Tools::getAreaName($hotel->HotelArea);
     $hotel->HotelCityName = Tools::getCityName($hotel->HotelCity);
     $hotel->HotelClassName = $hotel->getClassName();
     $number_star = 0;
     if ($hotel->HotelClass == 1 || $hotel->HotelClass == 4 || $hotel->HotelClass == 7) {
         $number_star = 5;
     } elseif ($hotel->HotelClass == 2 || $hotel->HotelClass == 5 || $hotel->HotelClass == 8) {
         $number_star = 4;
     } elseif ($hotel->HotelClass == 3 || $hotel->HotelClass == 6 || $hotel->HotelClass == 9) {
         $number_star = 3;
     }
     $isOnsen = 0;
     $isResort = 0;
     if ($hotel->HotelClass == 4 || $hotel->HotelClass == 5 || $hotel->HotelClass == 6) {
         $isOnsen = 1;
     } elseif ($hotel->HotelClass == 9 || $hotel->HotelClass == 8 || $hotel->HotelClass == 7) {
         $isResort = 1;
     }
     self::$smarty->assign("number_star", $number_star);
     self::$smarty->assign("isOnsen", $isOnsen);
     self::$smarty->assign("isResort", $isResort);
     self::$smarty->assign("hotel", $hotel);
     self::$smarty->assign("featureList", $hotel->getAllFeatures());
     $photoList = HotelDetail::getAllHotelFiles($hotel->HotelId);
     foreach ($photoList as $key => $var) {
         $iso_name = 'HotelFileName_' . $iso;
         $photoList[$key]['HotelFileName'] = $photoList[$key][$iso_name];
         //d($photoList[$key]);
     }
     self::$smarty->assign("photoList", $photoList);
     self::$smarty->assign("photoCount", sizeof($photoList));
     self::$smarty->assign("mid", $mid);
     // Get Similar Hotel List
     $simList = $hotel->getSimilarHotelList();
     $similarList = array();
     foreach ($simList as $similar) {
         $image = HotelDetail::getFirstFileOfHotel($similar['HotelId'], 145, 145);
         if (is_file(_TAS_ROOT_DIR_ . "/asset/" . $image['w5_path'])) {
             $similar['HotelFilePath'] = $image['w5_path'];
             $similar['w5'] = $image['w5'];
             $similar['h5'] = $image['h5'];
         }
         $similar['LowestPrice'] = HotelDetail::getLowestPriceOfHotel($similar['HotelId']);
         $similar['AreaName'] = Tools::getAreaName($similar['HotelArea']);
         $HotelNameKey = 'HotelName_' . $iso;
         $similar['HotelName'] = $similar[$HotelNameKey];
         $similarList[] = $similar;
     }
     self::$smarty->assign("similarList", $similarList);
     $roomtype_list = RoomPlan::getRoomTypeList();
     $roomtype_form_list = array();
     if (Tools::isSubmit("search")) {
         // search result
         $search_form = Tools::element_copy($_REQUEST, 'CheckIn', 'CheckOut', 'Nights', 'SortBy', 'SortOrder');
         $search_form['HotelId'] = $mid;
         foreach ($roomtype_list as $roomtype) {
             $roomTypeId = $roomtype['RoomTypeId'];
             $roomtype_form_list[$roomTypeId] = $_REQUEST['RoomType_' . $roomTypeId];
         }
         $search_form['RoomTypeVals'] = $roomtype_form_list;
         if (self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) {
             $search_form['ContinentCode'] = $continentCode;
             $search_form['Role'] = 'Agent';
         }
         $hotel_roomplan_count = RoomPlan::searchHotelRoomPlanCount($search_form);
         parent::pagination($hotel_roomplan_count);
         $hotel_roomplan_list = RoomPlan::searchHotelRoomPlan($search_form, $this->p, $this->n);
         // print_r($hotel_roomplan_list);
         self::$smarty->assign("hotel_roomplan_list", $hotel_roomplan_list);
         self::$smarty->assign("hotel_roomplan_count", $hotel_roomplan_count);
         self::$smarty->assign("search_form", $search_form);
     } else {
         $search_form = array();
         $search_form['CityId'] = 0;
         $search_form['AreaId'] = 0;
         if (self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) {
             $search_form['Role'] = 'Agent';
             $search_form['CheckIn'] = Tools::get_default_val($_REQUEST['CheckIn'], date('Y-m-d', strtotime(date('Y-m-d') . " + 5 days")));
             $search_form['Nights'] = Tools::get_default_val($_REQUEST['Nights'], 1);
             $search_form['CheckOut'] = date('Y-m-d', strtotime($search_form['CheckIn'] . " + {$search_form['Nights']} days"));
         }
         $search_form['HotelClassId'] = 0;
         $search_form['HotelName'] = '';
         $search_form['HotelId'] = $mid;
         foreach ($roomtype_list as $roomtype) {
             $roomTypeId = $roomtype['RoomTypeId'];
             $roomtype_form_list[$roomTypeId] = Tools::get_default_val($_REQUEST['RoomType_' . $roomTypeId], 0);
         }
         $search_form['RoomTypeVals'] = $roomtype_form_list;
         if (self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) {
             $search_form['ContinentCode'] = $continentCode;
             $search_form['Role'] = 'Agent';
         }
         self::$smarty->assign("search_form", $search_form);
         if (self::$cookie->RoleID == 1 && self::$cookie->HotelID == $mid || (self::$cookie->RoleID == 4 || self::$cookie->RoleID == 5)) {
             $search_form = array();
             $search_form['CityId'] = 0;
             $search_form['AreaId'] = 0;
             // $search_form['ContinentCode'] = $continentCode;
             $search_form['HotelClassId'] = 0;
             $search_form['HotelName'] = '';
             $search_form['HotelId'] = $mid;
             // $hotel_roomplan_list = RoomPlan::getRoomPlanListDetailByHotelId($mid);
             $hotel_roomplan_count = RoomPlan::searchHotelRoomPlanCount($search_form);
             parent::pagination($hotel_roomplan_count);
             $hotel_roomplan_list = RoomPlan::searchHotelRoomPlan($search_form, $this->p, $this->n);
             self::$smarty->assign("hotel_roomplan_list", $hotel_roomplan_list);
         } else {
             $temp = 0;
             foreach ($roomtype_form_list as $roomtype) {
                 if ($roomtype != 0) {
                     $temp = $roomtype;
                 }
             }
             $hotel_roomplan_count = RoomPlan::searchHotelRoomPlanCount($search_form);
             parent::pagination($hotel_roomplan_count);
             $hotel_roomplan_list = RoomPlan::searchHotelRoomPlan($search_form, $this->p, $this->n);
             if ($temp == 0) {
                 $hotel_roomplan_list = array();
             }
             self::$smarty->assign("hotel_roomplan_list", $hotel_roomplan_list);
             self::$smarty->assign("hotel_roomplan_count", $hotel_roomplan_count);
         }
     }
     self::$smarty->assign("roomTypeList", $roomtype_list);
 }
Example #3
0
 public static function buildBookingInfoFromPost($companyId)
 {
     //从Post表单中建立预定信息
     $booking_info = array();
     $booking_info = Tools::element_copy($_POST, 'order_id', 'hotel_id', 'checkin', 'checkout', 'contact_name', 'contact_email', 'contact_tel', 'contact_hp');
     $booking_info['order_id'] = Tools::get_default_val(@$_POST['order_id'], 0);
     //获取订单编号,没有则认为是0
     $nights = (strtotime($booking_info['checkout']) - strtotime($booking_info['checkin'])) / (24 * 60 * 60);
     // diff day
     $booking_info['nights'] = $nights;
     //计算预定几个晚上
     $booking_info['hotel_info'] = HotelDetail::getHotelDescription($_POST['hotel_id']);
     //获取酒店信息
     //OrderRoom表中会用到
     $ids = $_POST['ids'];
     $orid_list = array();
     $rpid_list = array();
     foreach ($ids as $id) {
         $orid_list[] = $_POST['or_ids_' . $id];
         $rpid_list[] = $_POST['roomplan_ids_' . $id];
     }
     //获取房间列表
     $roomplan_list = RoomPlan::getRoomPlanListForBooking($rpid_list, $booking_info['checkin'], $booking_info['checkout']);
     $total_price = 0.0;
     //计算总价格
     $org_total_price = 0.0;
     //计算不含手数料总价格
     $booked_roomplan_list = array();
     foreach ($roomplan_list as $key => $booked_roomplan) {
         $id = $ids[$key];
         $orid = $orid_list[$id];
         $booked_roomplan['OrderRoomId'] = $orid;
         $booked_roomplan['req_nonsmoking'] = Tools::get_default_val($_POST['req_nonsmoking_' . $id], 0);
         $booked_roomplan['req_smoking'] = Tools::get_default_val($_POST['req_smoking_' . $id], 0);
         $booked_roomplan['req_adjoin'] = Tools::get_default_val($_POST['req_adjoin_' . $id], 0);
         $booked_roomplan['req_remark'] = Tools::get_default_val($_POST['req_remark_' . $id], '');
         $customer_info_list = array();
         if (array_key_exists('customer_fnames_' . $id, $_POST)) {
             foreach ($_POST['customer_fnames_' . $id] as $i => $val) {
                 if ($_POST['customer_fnames_' . $id][$i] != '' || $_POST['customer_gnames_' . $id][$i] != '') {
                     $customer_info = array();
                     $customer_info['customer_fnames'] = $_POST['customer_fnames_' . $id][$i];
                     $customer_info['customer_gnames'] = $_POST['customer_gnames_' . $id][$i];
                     $customer_info['customer_sex'] = Tools::get_default_val($_POST['customer_sex_' . $id . "_{$i}"], 0);
                     $customer_info['customer_country'] = $_POST['customer_country_' . $id][$i];
                     $customer_info['customer_country_name'] = Tools::getCountryName($customer_info['customer_country']);
                     $customer_info_list[] = $customer_info;
                 }
             }
         } else {
             // empty customers info
             for ($i = 0; $i < $booked_roomplan['RoomMaxPersons']; $i++) {
                 // default value
                 $customer_info['customer_fnames'] = '';
                 $customer_info['customer_gnames'] = '';
                 $customer_info['customer_sex'] = 1;
                 // male
                 $customer_info['customer_country'] = 109;
                 // japan
                 $customer_info_list[] = $customer_info;
             }
         }
         $booked_roomplan['customer_info_list'] = $customer_info_list;
         $price_result = Booking::calculation_roomplan_price($booked_roomplan['RoomPlanId'], $booking_info['checkin'], $booking_info['checkout'], $companyId);
         $booked_roomplan['Price'] = $price_result['Price'];
         $booked_roomplan['PriceString'] = $price_result['PriceString'];
         $total_price += $booked_roomplan['Price'];
         $booked_roomplan['Check_0'] = $price_result['check_0'];
         $booked_roomplan['OrgPrice'] = $price_result['OrgPrice'];
         $org_total_price += $booked_roomplan['OrgPrice'];
         $booked_roomplan_list[] = $booked_roomplan;
     }
     $booking_info['TotalPrice'] = $total_price;
     $booking_info['TotalPriceString'] = Tools::money($total_price);
     $booking_info['booked_roomplan_list'] = $booked_roomplan_list;
     $booking_info['OrgTotalPrice'] = $org_total_price;
     //由于此处只有初次下订单时才经过,所以otherPrice必定为0
     $booking_info['otherPrice'] = 0;
     $booking_info['PaidIn'] = Tools::money($booking_info['otherPrice']);
     $booking_info['money'] = $booking_info['TotalPrice'] - $booking_info['otherPrice'];
     $booking_info['UnPaid'] = Tools::money($booking_info['money']);
     $booking_info['org_money'] = $booking_info['OrgTotalPrice'] - $booking_info['otherPrice'];
     return $booking_info;
 }
Example #4
0
    public static function searchHotelRoomPlan($criteria, $p, $n)
    {
        global $cookie;
        $iso = Language::getIsoById((int) $cookie->LanguageID);
        $where_cond = RoomPlan::getCriteriaWhereClause($criteria);
        $having_cond = RoomPlan::getCriteriaHavingClause($criteria);
        $price_field = RoomPlan::getCriteriaPriceField($criteria);
        $having_cond2 = RoomPlan::getCriteriaHavingClause2($criteria);
        $role = RoomPlan::getCriteriaRole($criteria);
        $usecond_cond = ' ';
        if (array_key_exists('CheckIn', $criteria) && '' != $criteria['CheckIn'] && array_key_exists('CheckOut', $criteria) && '' != $criteria['CheckOut']) {
            // $usecond_cond .= " , if(C.UseCon = 1, (DATE_ADD(\"{$criteria['CheckIn']}\", INTERVAL C.Nights-1 DAY) <= C.`ConToTime`)  AND (DATE_SUB(\"{$criteria['CheckOut']}\",INTERVAL 1 DAY) >= C.`ConFromTime`) , 0) as UseCon ";
            $usecond_cond .= " , if(C.UseCon = 1, DATEDIFF(LEAST(C.`ConToTime`, DATE_SUB(\"{$criteria['CheckOut']}\",INTERVAL 1 DAY)) , GREATEST(\"{$criteria['CheckIn']}\", C.`ConFromTime`)) >= (C.Nights - 1), 0) as UseCon ";
        }
        $order_by = '';
        if (array_key_exists('SortBy', $criteria) && '' != $criteria['SortBy'] && array_key_exists('SortOrder', $criteria) && '' != $criteria['SortOrder']) {
            if ($criteria['SortBy'] == 'price' && array_key_exists('ContinentCode', $criteria)) {
                $order_by = " MinPrice " . $criteria['SortOrder'];
            } else {
                if ($criteria['SortBy'] == 'class') {
                    $order_by = ' HotelClassName ' . $criteria['SortOrder'];
                } else {
                    if ($criteria['SortBy'] == 'name') {
                        $order_by = ' A.HotelName ' . $criteria['SortOrder'];
                    }
                }
            }
        }
        $sql = '
			select A.HotelId,A.HotelName_' . $iso . ' as HotelName, A.HotelClass, A.HotelAddress_' . $iso . ' as HotelAddress, F.HotelClassName, A.HotelCity, G.CityName_' . $iso . ' as CityName, A.HotelArea, H.AreaName_' . $iso . ' as AreaName
					,A.HotelDescription_' . $iso . ' as HotelDescription, C.RoomPlanId, C.RoomTypeId, J.`RoomTypeName`, C.RoomPlanName_' . $iso . ' as RoomPlanName, C.RoomMaxPersons,C.zaiku
					, C.Breakfast, C.Dinner, E.HotelOrder, C.`StartTime` , F.HotelClassName
					, C.`EndTime` ' . $usecond_cond . $price_field;
        if ($role == 'Agent') {
            $sql .= ', min(I.`Amount`) as MinAmount';
        }
        $sql .= '	FROM HT_Hotel as A, HT_HotelRoomPlanLink as B,  HT_RoomPlan as C';
        if ($role == 'Agent') {
            $sql .= ', `HT_RoomStockAndPrice` as I';
        }
        $sql .= ',(
					SELECT HotelId,  @curRow := @curRow + 1 AS HotelOrder
					FROM (
					    select
						    *
					    From
						    (
							select 
								(A.HotelId), A.HotelName, F.HotelClassName, C.RoomTypeId ' . $price_field . '
							from
								HT_Hotel as A, HT_HotelRoomPlanLink as B,  HT_RoomPlan as C,';
        if ($role == 'Agent') {
            $sql .= '`HT_RoomStockAndPrice` as I,';
        }
        $sql .= 'HT_HotelClass as F
							where 
								A.HotelId = B.HotelId and B.RoomPlanId = C.RoomPlanId and F.HotelClassId = A.HotelClass ';
        if ($role == 'Agent') {
            $sql .= ' AND C.`RoomPlanId` = I.`RoomPlanId`';
        }
        $sql .= $where_cond;
        if ($role == 'Agent') {
            $sql .= ' GROUP BY I.`RoomPlanId`';
        }
        $sql .= $having_cond;
        if ($order_by != '') {
            $sql .= '       ORDER BY ' . $order_by;
        }
        $sql .= '		)
						AS A GROUP BY HotelId ' . $having_cond2;
        if ($order_by != '') {
            $sql .= ' ORDER BY ' . $order_by;
        }
        $sql .= '	LIMIT ' . ($p - 1) * $n . ',' . $n;
        $sql .= ') AS A join (SELECT @curRow := 0) r
				) AS E,
				
				HT_HotelClass as F,
				HT_City as G,
				HT_Area as H,
				HT_RoomType as J
			WHERE
				A.HotelId = E.HotelId and
				A.HotelId = B.HotelId and B.RoomPlanId = C.RoomPlanId
				AND A.HotelClass = F.HotelClassId
				AND A.HotelCity = G.CityId
				AND A.HotelArea = H.AreaId
				AND C.`RoomTypeId` = J.`RoomTypeId`';
        if ($role == 'Agent') {
            $sql .= ' AND C.`RoomPlanId` = I.`RoomPlanId`';
        }
        $sql .= $where_cond;
        if ($role == 'Agent') {
            $sql .= ' GROUP BY I.`RoomPlanId`';
        }
        $sql .= $having_cond . ' ORDER BY E.HotelOrder ASC';
        if ($order_by != '') {
            $sql .= ', ' . $order_by;
        } else {
            $sql .= ', C.`RoomPlanId` ASC';
        }
        //echo $sql;
        $res = Db::getInstance()->ExecuteS($sql);
        if (!$res) {
            return null;
        }
        // indexed by hotel id
        $search_result = array();
        $pre_buy_plans = array();
        //
        foreach ($res as $hotel_roomplan) {
            if ($hotel_roomplan['zaiku'] == '1' && $hotel_roomplan['MinAmount'] == '0') {
                continue;
            }
            // key
            $hotel_id = $hotel_roomplan['HotelId'];
            $search_record = array();
            $new_roomplan = Tools::element_copy($hotel_roomplan, 'RoomPlanId', 'RoomTypeId', 'RoomTypeName', 'RoomPlanName', 'RoomMaxPersons', 'UseCon', 'Breakfast', 'Dinner', 'RoomPriceId', 'ApplyDate', 'MinPrice', 'MinAmount');
            if (array_key_exists($hotel_id, $search_result)) {
                // get hotel record
                $search_record = $search_result[$hotel_id];
            } else {
                // It's new a hotel key
                // create new hotel info
                $search_record = Tools::element_copy($hotel_roomplan, 'HotelId', 'HotelName', 'HotelClass', 'HotelClassName', 'HotelAddress', 'HotelCity', 'CityName', 'HotelArea', 'AreaName', 'HotelDescription');
                // pre-calculation price for display
                // but user can reselect room type and count
                $search_record['BookingPrice'] = 0;
                // get hotel first image
                $image = HotelDetail::getFirstFileOfHotel($search_record['HotelId']);
                $search_record['HotelFilePath'] = $image['HotelFilePath'];
                $search_record['w5_path'] = $image['w5_path'];
                $search_record['w5'] = $image['w5'];
                $search_record['h5'] = $image['h5'];
                //
                $search_record['RoomPlanList'] = array();
            }
            $new_roomplan['PreSelect'] = 0;
            if ($criteria['RoomTypeVals'][$new_roomplan['RoomTypeId']] > 0) {
                if (!array_key_exists($hotel_id, $pre_buy_plans)) {
                    $pre_buy_plans[$hotel_id] = array();
                }
                // check already selected same room type
                if (!array_key_exists($new_roomplan['RoomTypeId'], $pre_buy_plans[$hotel_id])) {
                    $new_roomplan['PreSelect'] = 1;
                    $pre_buy_plans[$hotel_id][$new_roomplan['RoomTypeId']] = 1;
                    // pre-select
                    $search_record['BookingPrice'] += $new_roomplan['MinPrice'] * $criteria['RoomTypeVals'][$new_roomplan['RoomTypeId']];
                }
            }
            // insert image information
            $rp_images = RoomFile::getRoomFileListByRoomPlanId($hotel_roomplan['RoomPlanId']);
            $file_id = $rp_images[0]['RoomFileId'];
            $res = RoomFile::getRoomFile($file_id);
            if (!$res) {
                $w2 = 0;
                $h2 = 0;
            } else {
                $filepath = $res[0]['RoomFilePath'];
                list($width, $height, $type, $attr) = getimagesize($filepath);
                if ($width < 100 && $height < 75) {
                    $w2 = width;
                    $h2 = $height;
                } else {
                    $ratio1 = $width / 100;
                    $ratio2 = $height / 75;
                    if ($ratio1 < $ratio2) {
                        $w2 = 100;
                        $h2 = intval($height / $ratio1);
                    } else {
                        $h2 = 75;
                        $w2 = intval($width / $ratio2);
                    }
                }
                $pos = strpos($filepath, "asset");
                $new_roomplan['img_path'] = substr($filepath, $pos);
            }
            $new_roomplan['img_width'] = $w2;
            $new_roomplan['img_height'] = $h2;
            // insert new roomplan-stock info
            $search_record['RoomPlanList'][] = $new_roomplan;
            // add or reset search result record
            $search_result[$hotel_id] = $search_record;
        }
        return $search_result;
    }
Example #5
0
    public static function getHotelByAreaCity($search_form, $p, $n, $iso = "")
    {
        global $cookie;
        if ($iso == "") {
            $iso = Language::getIsoById((int) $cookie->LanguageID);
        }
        $areaid = $search_form['AreaId'];
        $cityid = $search_form['CityId'];
        $hotelclass = $search_form['HotelClassId'];
        $hotelname = $search_form['HotelName'];
        $sql = '
		SELECT
			A.HotelId, A.HotelName_' . $iso . ' as HotelName, A.HotelClass, B.`HotelClassName`, A.HotelAddress_' . $iso . ' as HotelAddress,
			A.`HotelCity`, D.`CityName_' . $iso . '` as CityName, A.HotelArea, C.`AreaName_' . $iso . '` as AreaName, A.HotelDescription_' . $iso . ' as HotelDescription 
		FROM
			HT_Hotel as A LEFT JOIN (`HT_HotelClass` as B, HT_Area as C, HT_City as D) 
		ON (A.`HotelClass` = B.`HotelClassId` AND A.`HotelArea` = C.`AreaId` AND A.`HotelCity` = D.CityId) ';
        if ($cityid == 0 && $areaid == 0) {
            $sql .= 'WHERE A.`HotelArea` >0 ';
        } else {
            $sql .= 'WHERE A.`HotelArea` = ' . $areaid;
            $sql .= $cityid != 0 ? ' AND `HotelCity` = ' . $cityid : '';
            $sql .= $hotelclass != 0 ? ' AND `HotelClass` = ' . $hotelclass : '';
        }
        $sql .= $hotelname != "" ? " AND `HotelName_{$iso}` like '%{$hotelname}%' " : '';
        $sql .= ' LIMIT ' . ($p - 1) * $n . ',' . $n;
        $res = Db::getInstance()->ExecuteS($sql);
        if (!$res) {
            return null;
        }
        $search_result = array();
        foreach ($res as $hotel_roomplan) {
            $hotel_id = $hotel_roomplan['HotelId'];
            $search_record = array();
            if (array_key_exists($hotel_id, $search_result)) {
                $search_record = $search_result[$hotel_id];
            } else {
                $search_record = Tools::element_copy($hotel_roomplan, 'HotelId', 'HotelName', 'HotelClass', 'HotelClassName', 'HotelAddress', 'HotelCity', 'CityName', 'HotelArea', 'AreaName', 'HotelDescription');
                $image = HotelDetail::getFirstFileOfHotel($search_record['HotelId']);
                $search_record['HotelFilePath'] = $image['HotelFilePath'];
                $search_record['w5_path'] = $image['w5_path'];
                $search_record['w5'] = $image['w5'];
                $search_record['h5'] = $image['h5'];
            }
            $search_result[$hotel_id] = $search_record;
        }
        return $search_result;
    }