예제 #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);
 }
 public function preProcess()
 {
     global $cookie;
     $iso = Language::getIsoById((int) $cookie->LanguageID);
     if (Tools::isSubmit("getcity")) {
         $areaid = (int) Tools::getValue("cityid");
         $cityList = Tools::getCitys($areaid);
         $rstr = "";
         foreach ($cityList as $city) {
             $rstr .= $city['CityId'] . "," . $city['CityName'] . "," . $city['HotelNum'] . "|";
         }
         echo substr($rstr, 0, strlen($rstr) - 1);
         exit;
     }
     if (!Tools::hasFunction('hotel_detail_edit')) {
         Tools::redirect('index.php');
     }
     $mid = (int) Tools::getValue("mid");
     if ($mid == 0) {
         $this->brandNavi[] = array("name" => "Add Hotel", "url" => "hoteldetail.php");
     } else {
         if (self::$cookie->RoleID > 1) {
             $hotel = new HotelDetail($mid);
             $HotelNameKey = 'HotelName_' . $iso;
             $this->brandNavi[] = array("name" => $hotel->{$HotelNameKey}, "url" => "hotelpage.php?mid=" . $this->mid);
         }
         $this->brandNavi[] = array("name" => "Hotel Detail Edit", "url" => "hoteldetail.php");
     }
     if ($mid == 0 && self::$cookie->RoleID == 1) {
         $mid = self::$cookie->HotelID;
     }
     if ($mid == 0 && self::$cookie->RoleID > 1) {
         $hotelDetail = new HotelDetail();
         $hotelDetail->HotelCode = "_";
         $hotelDetail->HotelClass = 0;
         $hotelDetail->HotelCity = 0;
         $hotelDetail->HotelArea = 0;
         $hotelDetail->add(true, false);
         $hotelDetail->HotelCode = "JP" . str_pad($hotelDetail->HotelId, 6, "0", STR_PAD_LEFT);
         $hotelDetail->update(false);
         $mid = $hotelDetail->HotelId;
     }
     $hotel = new HotelDetail($mid);
     if (Tools::isSubmit("Submit")) {
         //$hotel->HotelCode = trim(Tools::getValue("HotelCode"));
         $HotelNameKey = 'HotelName_' . $iso;
         $hotel->{$HotelNameKey} = trim(Tools::getValue("HotelName"));
         $hotel->HotelCity = trim(Tools::getValue("HotelCity"));
         $hotel->HotelArea = trim(Tools::getValue("HotelArea"));
         $HotelAddressKey = 'HotelAddress_' . $iso;
         $hotel->{$HotelAddressKey} = trim(Tools::getValue("HotelAddress"));
         //$hotel->HotelCode = trim(Tools::getValue("HotelCode"));
         $hotel->HotelClass = trim(Tools::getValue("HotelClass"));
         $hotel->HotelContactNo = trim(Tools::getValue("HotelContactNo"));
         $HotelDescriptionKey = 'HotelDescription_' . $iso;
         $hotel->{$HotelDescriptionKey} = trim(Tools::getValue("HotelDescription"));
         $HotelPoliciesKey = 'HotelPolicies_' . $iso;
         $hotel->{$HotelPoliciesKey} = trim(Tools::getValue("HotelPolicies"));
         $UsefulInformationKey = 'UsefulInformation_' . $iso;
         $hotel->{$UsefulInformationKey} = trim(Tools::getValue("UsefulInformation"));
         $hotel->HotelFax = trim(Tools::getValue("HotelFax"));
         $hotel->HotelEmail = trim(Tools::getValue("HotelEmail"));
         $prefCon = trim(Tools::getValue("prefCon"));
         if ($prefCon == 'prefFax') {
             $hotel->PrefEmail = 0;
             $hotel->PrefFax = 1;
         } elseif ($prefCon == 'prefEmail') {
             $hotel->PrefEmail = 1;
             $hotel->PrefFax = 0;
         } elseif ($prefCon == 'prefAll') {
             $hotel->PrefEmail = 1;
             $hotel->PrefFax = 1;
         } elseif ($prefCon == 'prefNone') {
             $hotel->PrefEmail = 0;
             $hotel->PrefFax = 0;
         } else {
             $hotel->PrefEmail = 0;
             $hotel->PrefFax = 0;
         }
         /*if (empty($hotel->HotelCode)) {
         			$this->errors[] = Tools::displayError("Hotel Code required");
         		}*/
         if (empty($hotel->{$HotelNameKey})) {
             $this->errors[] = Tools::displayError("Hotel Name required");
         }
         if ((int) $hotel->HotelCity == 0) {
             $this->errors[] = Tools::displayError("Hotel City required");
         }
         if (empty($hotel->{$HotelAddressKey})) {
             $this->errors[] = Tools::displayError("Hotel Address required");
         }
         if (!sizeof($this->errors)) {
             if ($hotel->HotelId > 0) {
                 //echo $hotel->getHotelName($hotel->HotelId, 'en');
                 $hid = $hotel->HotelId;
                 $HotelName = trim(Tools::getValue("HotelName"));
                 $HotelAddress = trim(Tools::getValue("HotelAddress"));
                 $HotelDescription = trim(Tools::getValue("HotelDescription"));
                 $HotelPolicies = trim(Tools::getValue("HotelPolicies"));
                 $UsefulInformation = trim(Tools::getValue("UsefulInformation"));
                 if ($hotel->getHotelName($hotel->HotelId, 'en') == null) {
                     $hotel->HotelName_en = $HotelName;
                 }
                 if ($hotel->getHotelName($hotel->HotelId, 'jp') == null) {
                     $hotel->HotelName_jp = $HotelName;
                 }
                 if ($hotel->getHotelName($hotel->HotelId, 'S_CN') == null) {
                     $hotel->HotelName_S_CN = $HotelName;
                 }
                 if ($hotel->getHotelName($hotel->HotelId, 'T_CN') == null) {
                     $hotel->HotelName_T_CN = $HotelName;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelAddress', 'en') == null) {
                     $hotel->HotelAddress_en = $HotelAddress;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelAddress', 'jp') == null) {
                     $hotel->HotelAddress_jp = $HotelAddress;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelAddress', 'S_CN') == null) {
                     $hotel->HotelAddress_S_CN = $HotelAddress;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelAddress', 'T_CN') == null) {
                     $hotel->HotelAddress_T_CN = $HotelAddress;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelDescription', 'en') == null) {
                     $hotel->HotelDescription_en = $HotelDescription;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelDescription', 'jp') == null) {
                     $hotel->HotelDescription_jp = $HotelDescription;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelDescription', 'S_CN') == null) {
                     $hotel->HotelDescription_S_CN = $HotelDescription;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelDescription', 'T_CN') == null) {
                     $hotel->HotelDescription_T_CN = $HotelDescription;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelPolicies', 'en') == null) {
                     $hotel->HotelPolicies_en = $HotelPolicies;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelPolicies', 'jp') == null) {
                     $hotel->HotelPolicies_jp = $HotelPolicies;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelPolicies', 'S_CN') == null) {
                     $hotel->HotelPolicies_S_CN = $HotelPolicies;
                 }
                 if ($hotel->getHotelInfo($hid, 'HotelPolicies', 'T_CN') == null) {
                     $hotel->HotelPolicies_T_CN = $HotelPolicies;
                 }
                 if ($hotel->getHotelInfo($hid, 'UsefulInformation', 'en') == null) {
                     $hotel->UsefulInformation_en = $UsefulInformation;
                 }
                 if ($hotel->getHotelInfo($hid, 'UsefulInformation', 'jp') == null) {
                     $hotel->UsefulInformation_jp = $UsefulInformation;
                 }
                 if ($hotel->getHotelInfo($hid, 'UsefulInformation', 'S_CN') == null) {
                     $hotel->UsefulInformation_S_CN = $UsefulInformation;
                 }
                 if ($hotel->getHotelInfo($hid, 'UsefulInformation', 'T_CN') == null) {
                     $hotel->UsefulInformation_T_CN = $UsefulInformation;
                 }
                 $hotel->update(false);
             } else {
                 $hotel->HotelId = $mid;
                 $hotel->add();
                 self::$cookie->HotelID = $mid;
             }
             // Update HotelFeatureLink
             $fidList = $_POST['fids'] == '' ? '' : $_POST['fids'];
             $hotel->deleteAllFeatures();
             $hotel->updateFeatures($fidList);
             // Update Name and Order of hotel images
             $imageids = Tools::getValue("hotelFileId");
             $imagenames = Tools::getValue("hotelFileName");
             if ($imageids != "" && sizeof($imageids)) {
                 for ($i = 0; $i < sizeof($imageids); $i++) {
                     HotelDetail::updateHotelImage($imageids[$i], $imagenames[$i], $i, $iso);
                 }
             }
             if ($_POST['admin_add_hotel'] == 1) {
                 Tools::redirect('auth.php?prev_page=hotellist&nohotel=1&hid=' . $mid);
             } else {
                 Tools::redirect('hotelpage.php?mid=' . $mid);
             }
         }
     } else {
         if ('upload' == $_REQUEST['action']) {
             // insert image file
             $fileArray = HotelDetail::insertHotelFiles($mid, 1);
             foreach ($fileArray as $file) {
                 echo $file[0] . "|||" . $file[1] . "|||" . $file[2] . "*";
             }
             exit;
         } else {
             if (Tools::isSubmit("delimage")) {
                 $fid = Tools::getValue("fid");
                 HotelDetail::delHotelFile($fid);
                 exit;
             }
         }
     }
     $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};
     self::$smarty->assign("mid", $mid);
     self::$smarty->assign("hotel", $hotel);
     if ($hotel->HotelCity > 0) {
         self::$smarty->assign("cityList", Tools::getCitys($hotel->HotelArea));
     }
     self::$smarty->assign("featureList", $hotel->getAllFeatures());
     $photoList = HotelDetail::getAllHotelFiles($mid);
     foreach ($photoList as $key => $var) {
         $iso_name = 'HotelFileName_' . $iso;
         $photoList[$key]['HotelFileName'] = $photoList[$key][$iso_name];
         //d($photoList[$key]);
     }
     self::$smarty->assign("photoList", $photoList);
 }