public static function insertRoomFiles($file, $type) { $img_ids = array(); $uploads_dir = UPLOAD_DIR; foreach ($_FILES["myfile"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["myfile"]["tmp_name"][$key]; $ext = end(explode(".", $_FILES["myfile"]["name"][$key])); //pathinfo($tmp_name, PATHINFO_EXTENSION); $name = date("YmdHis") . rand() . "." . $ext; // $name = $_FILES["myfile"]["name"][$key]; $fullfilepath = "{$uploads_dir}/fullsized/{$name}"; @move_uploaded_file($tmp_name, $fullfilepath); // RoomFile::createThumbnail($name, "{$uploads_dir}/fullsized/", "{$uploads_dir}/thumbs/", 100); $fn = $name; $fp = mysql_real_escape_string($fullfilepath); $ft = $type; $fi = $key + 1; $sql = 'INSERT INTO ' . _DB_PREFIX_ . 'RoomFile(RoomFileName,RoomFileName_jp,RoomFileName_en,RoomFileName_S_CN,RoomFileName_T_CN, RoomFilePath, RoomFileType, RoomFileIndex) '; $sql .= "values('{$fn}','{$fn}','{$fn}','{$fn}','{$fn}', '{$fp}', '{$ft}', '{$fi}')"; Db::getInstance()->ExecuteS($sql); $img_ids[] = Db::getInstance()->Insert_ID(); } } // get new inserted file id return $img_ids; }
public function preProcess() { parent::preProcess(); $method = 'fullsized'; if ($_REQUEST['rpid']) { $rp_images = RoomFile::getRoomFileListByRoomPlanId($_REQUEST['rpid']); if (!rp_images) { exit; } $file_id = $rp_images[0]['RoomFileId']; $method = 'thumbs'; } else { $file_id = $_REQUEST['fid']; } $res = RoomFile::getRoomFile($file_id); if (!$res) { echo 'error'; exit; } $file = $res[0]['RoomFilePath']; //UPLOAD_DIR.'/homepage_adimg.jpg'; if ($method == 'thumbs') { $file = str_replace('/fullsized/', '/thumbs/', $file); } if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } // $type = 'image/jpeg'; // header('Content-Type:'.$type); // header('Content-Length: '.filesize($file)); // $fp = fopen($file, 'rb'); // fpassthru($fp); //readfile($file); header('Location: /asset/' . $method . '/' . basename($file)); // echo filesize($file); exit; }
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 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; }