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); }
public function preProcess() { parent::preProcess(); // if (!Tools::hasFunction('room_plan_edit')) Tools::redirect('index.php'); $rpid = Tools::getValue("rpid"); $roomplan_sales = RoomPlan::getRoomPlanSales($rpid); // $roomplan_sales['Nights'] =(strtotime($roomplan_sales['ConToTime']) - strtotime($roomplan_sales['ConFromTime'])) / (24 * 60 * 60); // diff day self::$smarty->assign("roomplan_sales", $roomplan_sales); parent::displayContent(); self::$smarty->display(_TAS_THEME_DIR_ . 'roomplan_sales.tpl'); exit; }
public function preProcess() { parent::preProcess(); // if (!Tools::hasFunction('room_plan_edit')) Tools::redirect('index.php'); $rpid = Tools::getValue("rpid"); $price = Tools::getValue("price"); $roomplan_summary = RoomPlan::getRoomPlanSummary($rpid); self::$smarty->assign("roomplan_summary", $roomplan_summary); self::$smarty->assign('price', $price); parent::displayContent(); self::$smarty->display(_TAS_THEME_DIR_ . 'roomplan_summary.tpl'); exit; }
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); }
public function process() { global $cookie; parent::process(); // get hotel id // its value will retain from session. // get room plan list by hotel id $hotelId = $this->hotelId; // // action switch global $cookie; $iso = Language::getIsoById((int) $cookie->LanguageID); // show default list page $resRoomPlanList = RoomPlan::getRoomPlanListByHotelId($hotelId); // print_r($resRoomPlanList); $roomPlanList = array(); foreach ($resRoomPlanList as $roomPlan) { $RoomPlanNameKey = 'RoomPlanName_' . $iso; $roomPlan['RoomPlanName'] = $roomPlan[$RoomPlanNameKey]; $RoomPlanDescriptionKey = 'RoomPlanDescription_' . $iso; $roomPlan['RoomPlanDescription'] = addslashes($roomPlan[$RoomPlanDescriptionKey]); $roomPlan['FileIdList'] = RoomFile::getRoomFileListByRoomPlanId($roomPlan['RoomPlanId']); $photoList = RoomFile::getRoomFileListByRoomPlanId($roomPlan['RoomPlanId']); foreach ($photoList as $key => $var) { $iso_name = 'RoomFileName_' . $iso; $photoList[$key]['RoomFileName'] = $photoList[$key][$iso_name]; } $roomPlan['FileIdList'] = $photoList; $roomPlanList[] = $roomPlan; } $roomTypeList = RoomPlan::getRoomTypeList(); $today = date('Y-m-d'); $tomorrow = date('Y-m-d', strtotime($today . " + 1 days")); self::$smarty->assign("roomPlanList", $roomPlanList); self::$smarty->assign("roomTypeList", $roomTypeList); self::$smarty->assign("hid", $hotelId); self::$smarty->assign("today", $today); self::$smarty->assign("tomorrow", $tomorrow); }
public function process() { global $cookie; if ($_POST["booking"] != 'confirm' && $_POST["booking"] != 'calculate' && $_REQUEST['booking'] != 'view' && $_POST['booking'] != 'payment' && $_POST["booking"] != 'finish' && $_POST["booking"] != 'save') { Tools::redirect('index.php'); } if ($_REQUEST['booking'] == 'view') { // view page if ($_REQUEST['vouch_info'] == 1 || $_REQUEST['savepdf'] == 1) { $orderId = $_GET['oid']; //获取订单编号 if ($_REQUEST['savepdf'] == 1) { $booking_info = Booking::getBookingInfo($_GET['oid'], "en"); } else { $booking_info = Booking::getBookingInfo($_GET['oid']); } $booking_info['agent_info'] = new Member($booking_info['OrderUserId']); // make string of "Total No or rooms" $_rooms = array(); foreach ($booking_info['booked_roomplan_list'] as $roomplan) { if ($_rooms[$roomplan[RoomPlanId]]) { $_rooms[$roomplan[RoomPlanId]]['count']++; } else { $_rooms[$roomplan[RoomPlanId]]['count'] = 1; $_rooms[$roomplan[RoomPlanId]]['name'] = $roomplan[RoomPlanName]; } } $_roomsString = ""; foreach ($_rooms as $_room) { if ($_roomsString != "") { $_roomsString .= "& "; } $_roomsString .= $_room['count'] . " " . $_room['name']; } $booking_info['roomString'] = $_roomsString; if ($_REQUEST['savepdf'] == 1) { $this->printPDF($booking_info); exit; } else { self::$smarty->assign("booking_info", $booking_info); } } // move the engine to preprocess function /* $booking_info = Booking::getBookingInfo ( $_GET ['oid'] ); if (! $booking_info) Tools::redirect ( 'index.php' ); if ($_REQUEST ['payment']) self::$smarty->assign ( "payment", $_REQUEST ['payment'] ); self::$smarty->assign ( "method", 'view' ); */ } else { // other(build booking info from post variable for edit, confirm, finish) $booking_info = Booking::buildBookingInfoFromPost(self::$cookie->CompanyID); self::$smarty->assign("method", 'order'); self::$smarty->assign("booking_info", $booking_info); foreach ($booking_info['booked_roomplan_list'] as $bi) { //echo $bi['Check_0']; if ($bi['Check_0'] == '0') { $error['message'] = "満室のためご希望の日程には変更できません"; self::$smarty->assign("error", $error); self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl'); exit; } } //p($booking_info['booked_roomplan_list']); } if ($_POST["booking"] == 'calculate') { $checkin = $_POST['checkin']; //获取checkin的值 $checkout = $_POST['checkout']; //获取checkout的值 //获取roomPlanId $ids = $_POST['ids']; $rpid_list = array(); foreach ($ids as $id) { $rpid_list[] = $_POST['roomplan_ids_' . $id]; } //计算房间数量是否满足条件,如果有一条不满足则发出错误报告 $roomplan_list = RoomPlan::getRoomPlanListForBooking($rpid_list, $checkin, $checkout); $plan_list = array(); foreach ($roomplan_list as $record) { $plan_list[$record['RoomPlanId']] = $record; } //查看是否有房间不满足条件 $isOk = true; foreach ($rpid_list as $rpid) { if (empty($plan_list[$rpid])) { $isOk = false; break; } } if (!$isOk) { $error['message'] = "There is not any room as requested"; self::$smarty->assign("error", $error); self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl'); exit; } self::$smarty->assign("countries", Tools::getCountries()); self::$smarty->assign("method", 'edit'); } //添加修改的情况 if ($_POST["booking"] == 'save') { if ($booking_info['order_id'] == 0) { //如果订单ID没有,则报错 $error['message'] = "订单编号不存在"; self::$smarty->assign("error", $error); self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl'); exit; } $checkin = $_POST['checkin']; //获取checkin的值 $checkout = $_POST['checkout']; //获取checkout的值 //获取roomPlanId $ids = $_POST['ids']; $rpid_list = array(); foreach ($ids as $id) { $rpid_list[] = $_POST['roomplan_ids_' . $id]; } //计算房间数量是否满足条件,如果有一条不满足则发出错误报告 $roomplan_list = RoomPlan::getRoomPlanListForBooking($rpid_list, $checkin, $checkout); $plan_list = array(); foreach ($roomplan_list as $record) { $plan_list[$record['RoomPlanId']] = $record; } //查看是否有房间不满足条件 $isOk = true; foreach ($rpid_list as $rpid) { if (empty($plan_list[$rpid])) { $isOk = false; break; } } if (!$isOk) { $error['message'] = "There is not any room as requested"; self::$smarty->assign("error", $error); self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl'); exit; } $booking_info['paymentMethod'] = Member::getPaymentMethod(self::$cookie->CompanyID); //获取支付方式,是前支付还是后支付 $order_id = Booking::modifyBooking($booking_info); if (empty($order_id)) { $error['message'] = "修改失败, 您修订的房间信息不存在。"; self::$smarty->assign("error", $error); self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl'); } else { //下订单成功,此时需要发送邮件 Tools::ordermail($order_id); Tools::emailHotel($order_id, 11); Tools::redirect('booking_list.php'); } exit; } if ($_POST["booking"] == 'finish') { // $_POST ["booking"] == 'save' if ($booking_info['order_id'] == 0) { $booking_info['OrderUserId'] = self::$cookie->UserID; } //获取用户ID $booking_info['paymentMethod'] = Member::getPaymentMethod(self::$cookie->CompanyID); $order_id = Booking::insertNewBooking($booking_info); if ($order_id) { $booking_info = Booking::getBookingInfo($order_id); //下订单成功,此时需要发送邮件 Tools::ordermail($order_id); Tools::emailHotel($order_id, 10); } else { $error['message'] = "Booking has time out!"; self::$smarty->assign("error", $error); self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl'); exit; } //$booking_info = Booking::getBookingInfo ( $order_id ); self::$smarty->assign("booking_info", $booking_info); //if ($_POST ["booking"] == 'save') // Tools::redirect ( 'booking_list.php' ); } if ($_POST['booking'] == 'payment') { //支付接口调用 $url = "http://localhost/payment.php"; //支付站点网址 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); //$content = $response = curl_getinfo($ch); curl_close($ch); if ($response['http_code'] == 200) { //判断是否支付成功,此处只是模拟使用 Booking::changeBookingStatus($booking_info['order_id'], 4); Booking::changePayStatus($booking_info['order_id'], 2); Booking::payment($booking_info['order_id'], $_POST['money']); //下订单成功,此时需要发送邮件 Tools::ordermail($order_id); } else { //模拟支付失败的情况 $error = array(); $error['message'] = 'sorroy charge fail'; self::$smarty->assign("error", $error); self::$smarty->display(_TAS_THEME_DIR_ . 'error_redirect.tpl'); exit; } } parent::process(); }
public static function emailHotel($orderid, $orderstatus) { //1.获取订单信息 $bookingInfo = Booking::getBookingOrder($orderid); $BookingNo = $bookingInfo['BookingNo']; //订单编号 $ContactName = $bookingInfo['contact_name']; //1.Customer Information $ContactEmail = $bookingInfo['contact_email']; $ContactTel = $bookingInfo['contact_tel']; $CheckIn = $bookingInfo['checkin']; $CheckOut = $bookingInfo['checkout']; //2.获取下订单的用户信息 $userid = $bookingInfo['OrderUserId']; $userinfo = Member::getUserInfoById($userid); $AgentName = $userinfo['Name']; $AgentPhoneNo = $userinfo['Tel']; $AgentEmail = $userinfo['Email']; //3.获取酒店用户信息 $hotelid = $bookingInfo['hotel_id']; $hoteluserinfo = Member::getUserInfoByHotelId($hotelid); $UserName = $hoteluserinfo['Name']; $prefFax = $hoteluserinfo['PrefFax']; $prefEmail = $hoteluserinfo['PrefEmail']; $Fax = $hoteluserinfo['Fax']; $to = $hoteluserinfo['Email']; $languageid = $hoteluserinfo['LanguageID']; $iso = $hoteluserinfo['LanguageShortName']; if (!isset($hoteluserinfo['LanguageID'])) { $languageid = 4; } //4.获取酒店信息 $hotelinfo = HotelDetail::getHotelDescription($hotelid, $iso); $HotelName = $hotelinfo['HotelName']; $HotelAddress = $hotelinfo['HotelAddress']; $HotelContactNo = $hotelinfo['HotelContactNo']; $orderroominfo = RoomPlan::getOrderRoomInfo($orderid, $iso); $RoomList = ''; $RoomListFax = ''; $id = 1; foreach ($orderroominfo as $orderroom) { $RoomList .= "<table width='100%' cellspacing='10' style='font-size:12px;'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2><span style='color:#000000;font-weight:bold;font-zie:14px;'>- Room " . $id . "</span></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2><span>Room Plan(宿泊プラン):</span> " . $orderroom['RoomPlanName'] . " </td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2><span>Room Type(ルームタイプ):</span> " . $orderroom['RoomTypeName'] . " </td>\t\t\t\t\n\t\t\t\t</tr> \n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2><span>Guest Name(宿泊者名):</span> " . $orderroom['CustomerName'] . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td width='30%'><span>Breakfast(朝食):</span> " . $orderroom['Breakfast'] . "</td>\t\t\t\n\t\t\t\t\t<td><span>Dinner(夕食):</span> " . $orderroom['Dinner'] . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2><span>Special Request(特別リクエスト):</span> " . $orderroom['Special'] . " </td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2><span>* All Special request are subjects to availability </span></td>\n\t\t\t\t</tr>\n\t\t\t</table>"; $RoomListFax .= "<table width=190 >\n \t\t\t\t<tr>\n \t\t\t\t\t<td width=5></td><td colspan=2 size=11>- Room " . $id . "</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td width=5></td><td colspan=2>Room Plan(宿泊プラン): " . $orderroom['RoomPlanName'] . " </td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td width=5></td><td colspan=2>Room Type(ルームタイプ): " . $orderroom['RoomTypeName'] . " </td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td width=5></td><td colspan=2>Guest Name(宿泊者名): " . $orderroom['CustomerName'] . "</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td width=5></td><td>Breakfast(朝食): " . $orderroom['Breakfast'] . "</td>\n \t\t\t\t\t<td>Dinner(夕食): " . $orderroom['Dinner'] . "</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td width=5></td><td colspan=2>Special Request(特別リクエスト): " . $orderroom['Special'] . " </td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td width=5></td><td colspan=2>* All Special request are subjects to availability </td>\n \t\t\t\t</tr>\n \t\t\t</table>"; $id++; } $RoomString = RoomPlan::getRoomString($orderid, $iso); include_once substr(dirname(__FILE__), 0, -8) . '/config/mail.config.php'; global $from, $message, $subject; $search = array('{#BookingNo}', '{#HotelName}', '{#UserName}', '{#HotelAddress}', '{#HotelContactNo}', '{#ContactName}', '{#ContactEmail}', '{#ContactTel}', '{#CheckIn}', '{#CheckOut}', '{#RoomString}', '{#RoomList}', '{#AgentName}', '{#AgentPhoneNo}', '{#AgentEmail}'); $replace = array($BookingNo, $HotelName, $UserName, $HotelAddress, $HotelContactNo, $ContactName, $ContactEmail, $ContactTel, $CheckIn, $CheckOut, $RoomString, $RoomList, $AgentName, $AgentPhoneNo, $AgentEmail); $replaceFax = array($BookingNo, $HotelName, $UserName, $HotelAddress, $HotelContactNo, $ContactName, $ContactEmail, $ContactTel, $CheckIn, $CheckOut, $RoomString, $RoomListFax, $AgentName, $AgentPhoneNo, $AgentEmail); $msg = str_replace($search, $replace, $message[10][5][$languageid]); // $faxmsg = str_replace($search, $replaceFax, $message[21][5][$languageid]); $faxmsg = str_replace($search, $replaceFax, $message[21][5][4]); $sub = str_replace('{#BookingNo}', $BookingNo, $subject[$orderstatus][5][$languageid]); if ($orderstatus == 7) { $msg = str_replace('下記の予約をお願いいたします', '下記の予約のキャンセルをお願いいたします', $msg); $faxmsg = str_replace('下記の予約をお願いいたします', '下記の予約のキャンセルをお願いいたします', $faxmsg); } if ($prefEmail) { $headers = "From: {$from}" . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type: text/html; charset=utf-8' . "\r\n"; $headers .= 'Bcc: booking@tas-agent.com'; //echo $sub."<br/><br/><br/>".$msg; if ($sub != '' && $msg != '') { global $emailTail; $msgBody = $msg . $emailTail; self::sendEmail($to, $sub, $msg); //@mail($to, $sub, $msgBody, $headers); $Insertmsg = htmlentities($msg); $sql = 'insert into `HT_Mail`(MailTo, MailFrom, SubjectName, Body) value("' . $to . '", "' . $from . '", "' . $sub . '", "' . $Insertmsg . '")'; Db::getInstance()->ExecuteS($sql); } } if ($prefFax) { global $toemail, $faxTail, $faxHead; $emailBody = "<p>需要给酒店发送传真.</p>\n\t\t\t\t\t\t<p>传真号为: {$Fax}</p>\n\t\t\t\t\t\t<p>订单状态为: {$orderstatus}</p>"; $emailBody = "fax"; $faxsub = $faxHead[$orderstatus]; $faxsub2 = "<TAS-Agent.com> Booking ID:" . $BookingNo; $prefix = time(); require_once _TAS_TOOL_DIR_ . "/tfpdf/pdffax.inc.php"; $defFont = 'MyFont'; $pdf = new PDFTable(); $pdf->AddFont($defFont, '', 'ARIALUNI.TTF', true); $pdf->AddFont($defFont . 'B', '', 'ARIALUNI.TTF', true); $pdf->SetMargins(10, 2); $pdf->SetDrawColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0); $pdf->SetPadding(0); $pdf->SetSpacing(0, 0); $pdf->AddPage(); //header $pdf->SetFont($defFont, '', 10); $pdf->Image(_TAS_THEME_DIR_ . "/img/logo_pdf.png", 140, 15, 60); $pdf->htmltable("<table width=190><tr><td size=20 > </td></tr></table>", 1); $pdf->Ln(2); $pdf->htmltable("<table width=190><tr><td size=14 colspan=2>" . $faxsub . " </td></tr>\n \t </table>", 1); $pdf->Image(_TAS_THEME_DIR_ . "/img/linep.png", 10, $pdf->y, 190); //内容 $pdf->htmltable($faxmsg); //footer $pdf->SetY(-30); $pdf->Image(_TAS_THEME_DIR_ . "/img/linep.png", 10, $pdf->y, 190); $pdf->Ln(1); $pdf->Image(_TAS_THEME_DIR_ . "/img/bottom_logo_pdf.png", 12, $pdf->y + 2, 20); $pdf->x = 35; $pdf->htmltable("<table width=90>\n \t <tr><td size=9>TAS Agent / TAS Co.Ltd<br>TEL 03-5565-5850<br>FAX 03-5565-5850<br>booking@tas-agent.com</td></tr>\n \t </table>", 0); $pdf->htmltable("<table width=190>\n \t <tr><td size=9>※TAS Agent はTAS Co.,Ltdが運営しております。 上記予約の内容については直接TASまでご連絡ください。\n \t </td></tr></table>", 1); $attachment_file = _TAS_ROOT_DIR_ . "/classes/temp/attachment_" . $prefix . ".pdf"; //$attachment_file=_TAS_ROOT_DIR_."/config/attachment_".$prefix.".pdf"; $pdf->Output($attachment_file); require_once _TAS_TOOL_DIR_ . "/PHPMailer/class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "******"; // GMAIL username $mail->Password = "******"; // GMAIL password $mail->SetFrom('*****@*****.**', 'fax'); $mail->AddReplyTo("*****@*****.**", "fax"); $mail->Subject = $faxsub2; $mail->MsgHTML($emailBody); $toemail = $Fax . "@efaxsend.com"; $mail->AddAddress($toemail, $Fax); $mail->AddAttachment($attachment_file); // attachment $mail->Send(); //发邮件 if (file_exists($attachment_file)) { unlink($attachment_file); //删除文件 } } }
public static function calculation_roomplan_price($rpid, $checkin, $checkout, $companyId) { $price_result = array(); $price_result['Price'] = 0; $price_result['OrgPrice'] = 0; $price_result['PriceString'] = ''; $continentCode = Tools::getUserContinentCode($companyId); // @TODO validation room plan info // // fetch roomplan info for consecutive information $rp_sales = RoomPlan::getRoomPlanSales($rpid); // fetch roomplan price info list $sql = "\n SELECT DATE_FORMAT(A.ApplyDate, '%Y-%m-%d') as ApplyDate, (\n\n \t\t\t\t\t\tIF('{$continentCode}' = 'AS',\n \t\t\t\t\t\t\t\tIF(A.`Asia` > 0, A.Asia, A.Price) ,\n \t\t\t\t\t\t\t\tIF('{$continentCode}' = 'EU',\n \t\t\t\t\t\t\t\t\tIF(A.`Euro` > 0, A.Euro, A.Price) ,\n \t\t\t\t\t\t\t\t\tA.Price) )\n \t\t\t\t\t) as Price\n FROM HT_RoomStockAndPrice as A, HT_RoomPlan as B\n WHERE A.`ApplyDate` between '{$checkin}' and DATE_SUB('{$checkout}', INTERVAL 1 DAY) and A.`RoomPlanId` = {$rpid} and B.RoomPlanId = {$rpid}\n ORDER BY A.`ApplyDate`\n "; //echo $sql; $price_list = Db::getInstance()->ExecuteS($sql); // @TODO refactoring grouping code // sales duration recalc for checkin-checkout if ($rp_sales['ConFromTime'] < $checkin) { $rp_sales['ConFromTime'] = $checkin; } if ($rp_sales['ConToTime'] > $checkout && $checkout >= $rp_sales['ConFromTime']) { $rp_sales['ConToTime'] = $checkout; } // calc var that we can apply consecutive price $apply_con_var = 0; if ($rp_sales['UseCon'] == 1) { $diff_days = (strtotime($rp_sales['ConToTime']) - strtotime($rp_sales['ConFromTime'])) / (24 * 60 * 60); $apply_con_var = (int) ($diff_days / $rp_sales['Nights']); // echo 'apply : '.$apply_con_var; } // ============================================================ // grouping price string // ============================================================ // each price will be demonstrated by [Price]/[Days]. For example 100$ / 1 day, 200$ / 2 days // we will group each values for showing. Grouping condition is that price and days value are all the same and sequential. // For example : // 100$/1day + 100$/1day + 200$/3days + 200$/3days + 200$/1day + 100$/1day will be // 100$/1day * 2 + 200$/3days * 2 + 200$/1day + 100$/1day // // initialize variables $rp_price = 0; // roomplan total price $rp_price_string = ''; // roomplan total price string // calc price / [n per day] $price = 0; // current price value $per_day = 1; // day $prev_price = 0; // previous price val $prev_per_day = 1; // previous day val $prev_day_count = 0; // counting previous same price/day pair $check_0 = 1; $shoushu_price = 0; $shoushu_prev_price = 0; foreach ($price_list as $price_info) { // if there is sales price if ($rp_sales['UseCon'] == 1 && $price_info['ApplyDate'] >= $rp_sales['ConFromTime'] && $price_info['ApplyDate'] <= $rp_sales['ConToTime']) { // check we can apply sales condition espetially nights $diff_days = (strtotime($price_info['ApplyDate']) - strtotime($rp_sales['ConFromTime'])) / (24 * 60 * 60); if ($diff_days / $rp_sales['Nights'] < $apply_con_var) { // sales price if ($diff_days % $rp_sales['Nights'] == 0) { if ($continentCode == 'AS') { $price_info['Price'] = $rp_sales['PriceAsia'] > 0 ? $rp_sales['PriceAsia'] : $rp_sales['PriceAll']; } else { if ($continentCode == 'EU') { $price_info['Price'] = $rp_sales['PriceEuro'] > 0 ? $rp_sales['PriceEuro'] : $rp_sales['PriceAll']; } else { $price_info['Price'] = $rp_sales['PriceAll']; } } $price = $price_info['Price']; $per_day = $rp_sales['Nights']; // sales day price } else { // other sales day, we can skip that continue; } } else { // Even sales day, the sales condition is not acceptable so that we can't apply sales price. $price = $price_info['Price']; // room stock price $per_day = 1; } } else { // normal day, we apply room stock price $price = $price_info['Price']; $per_day = 1; } // check grouping if ($prev_price == $price && $prev_per_day == $per_day) { $prev_day_count++; // } else { // the pair isn't same, the price string will be generated. if ($prev_day_count > 0) { $rp_price_string .= "+ [ " . Tools::money(self::shoushuliao($prev_price, $rpid)) . "/{$prev_per_day}day(s) X {$prev_day_count} ]"; } // $prev_price = $price; $prev_per_day = $per_day; $prev_day_count = 1; } $rp_price += $price_info['Price']; if ($check_0 == '0') { continue; } $check_0 = $price_info['Price']; } // finally we recheck price string. if ($prev_day_count > 0) { $rp_price_string .= "+ [ " . Tools::money(self::shoushuliao($prev_price, $rpid)) . "/{$prev_per_day}day(s) X {$prev_day_count} ]"; } $price_result['OrgPrice'] = $rp_price; $price_result['Price'] = self::shoushuliao($rp_price, $rpid); //$rp_price; $price_result['PriceString'] = "" . trim($rp_price_string, '+') . " = " . Tools::money($price_result['Price']); $price_result['check_0'] = $check_0; //echo $check_0; return $price_result; }
function addRoomPlan($hotelId, $roomplaninfo) { $roomTypeId = $this->getRoomTypeId($roomplaninfo['RoomTypeName']); return RoomPlan::addExcelRoomPlan($hotelId, $roomTypeId, $roomplaninfo); }
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; }