コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: RoomPlan.php プロジェクト: khuyennd/dev-tasagent
    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;
    }
コード例 #3
0
 public function process()
 {
     parent::process();
     //echo "vao day";die;
     if (self::$cookie->RoleID == 1) {
         Tools::redirect('hotelpage.php?mid=' . self::$cookie->HotelID);
     }
     $continentCode = Tools::getUserContinentCode(self::$cookie->CompanyID);
     $search_form = array();
     $search_form['CityId'] = 0;
     $search_form['AreaId'] = 0;
     if ((self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) && self::$cookie->OldLoginUserName == NULL) {
         $search_form['CheckIn'] = date('Y-m-d', strtotime(date('Y-m-d') . " + 5 days"));
         $search_form['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['ContinentCode'] = $continentCode;
     $roomtype_list = RoomPlan::getRoomTypeList();
     $roomtype_form_list = array();
     foreach ($roomtype_list as $roomtype) {
         $roomTypeId = $roomtype['RoomTypeId'];
         $roomtype_form_list[$roomTypeId] = 0;
     }
     $search_form['RoomTypeVals'] = $roomtype_form_list;
     self::$smarty->assign("roomTypeList", $roomtype_list);
     self::$smarty->assign("search_form", $search_form);
     self::$smarty->assign("classList", Tools::getAllHotelClasses());
     self::$smarty->assign("areaList", Tools::getJapanAreas());
     //get Hotel List and Promotion List
     $promotionList = Promotion::getHomePromotionList(Promotion::$TYPE_PROMOTION);
     self::$smarty->assign('homePromotionList', $promotionList);
     $eventList = Promotion::getHomePromotionList(Promotion::$TYPE_EVENT);
     self::$smarty->assign('homeEventList', $eventList);
     // Get Popular Hotel List
     $poList = HotelDetail::getPopularHotelList(3);
     // 東京・横浜 - 関東 areaid = 3
     $popularList = array();
     global $cookie;
     $iso = Language::getIsoById((int) $cookie->LanguageID);
     foreach ($poList as $popular) {
         $image = HotelDetail::getFirstFileOfHotel($popular['HotelId'], 150, 150);
         if (is_file(_TAS_ROOT_DIR_ . "/asset/" . $image['w5_path'])) {
             $popular['HotelFilePath'] = $image['w5_path'];
             $popular['w5'] = $image['w5'];
             $popular['h5'] = $image['h5'];
         }
         $popular['LowestPrice'] = HotelDetail::getLowestPriceOfHotel($popular['HotelId']);
         $popular['AreaName'] = HotelDetail::getAreaName($popular['HotelArea']);
         $HotelNameKey = 'HotelName_' . $iso;
         $popular['HotelName'] = $popular[$HotelNameKey];
         $popularList[] = $popular;
     }
     //self::$smarty->assign('homeAreaList', Db::getInstance()->ExecuteS("select *, AreaName_".$this->iso." as AreaName from HT_Area where AreaId in (3, 5, 8, 12)"));
     self::$smarty->assign('homeAreaList', Db::getInstance()->ExecuteS('select  *, AreaName_' . $this->iso . ' as AreaName from `HT_Area` where isPopular = 1'));
     self::$smarty->assign("popularList", $popularList);
 }
コード例 #4
0
ファイル: HotelDetail.php プロジェクト: khuyennd/dev-tasagent
    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;
    }