示例#1
0
 public static function fetchFromDb($roomId, $imageId)
 {
     global $logger;
     $logger->LogDebug("Fetching all room images for room id: {$roomId}");
     $sql = "SELECT ri.*, gi.* FROM bsi_room_images ri INNER JOIN bsi_gallery_images gi ON ri.image_id = gi.id WHERE ri.room_id = {$roomId} AND image_id = {$imageId} ORDER BY gi.display_order";
     $query = mysql_query($sql);
     if (!$query) {
         $logger->LogFatal("Database error: " . mysql_errno() . ". Message: " . mysql_error());
         $logger->LogError("SQL: " . $sql);
         die("Database error: " . mysql_errno() . ". Message: " . mysql_error());
     }
     if ($row = mysql_fetch_assoc($query)) {
         $roomImage = RoomImage::fetchFromParameters($row);
         return $roomImage;
     }
     mysql_free_result($query);
     return null;
 }
示例#2
0
		foreach($images as $iK => $image){
			$nIType = $roomImages['type'][$iK];
			$nIType = explode('/', $nIType);
			$nIType1 = $nIType[0];
			$nIType2 = $nIType[1];
			if($nIType1 == 'image'){
				if($nIType2 == 'jpeg' || $nIType2 == 'pjpeg'){ $ext = '.jpg'; }
				else if($nIType2 == 'png'){ $ext = '.png'; }
				else{ $ext = '.noExt_'; }
				$nITemp = $roomImages['tmp_name'][$iK];
				$newName = $prefix . '_' . md5(time() . rand(111111111,999999999));
				$newName .= '_' . md5(time() . rand(111111111,999999999));
				$newName .= $ext;
				if(move_uploaded_file($nITemp, $uploadDir . $newName)){
					$roomImage = new RoomImage();
					$roomImage->hotel_id = $hotel_id;
					$roomImage->room_id = $rObj->id;
					$roomImage->image = $newName;
					$roomImage->save();
				}
			}
		}

		$_SESSION['step_03_completed'] = true;
		if($_POST['submit'] == 'next'){
			die(header('Location: ' . DOMAIN . 'dashboard/add-hotel/step-04'));
		}else{
			die(header('Location: ' . DOMAIN . 'dashboard/add-hotel/step-03'));
		}
	}
示例#3
0
 public function getImages()
 {
     //$images = GalleryImage::fetchFromDbWhere(" WHERE id IN (SELECT image_id FROM bsi_room_images WHERE room_id = " . $this->id . ")");
     $images = RoomImage::fetchFromDbForRoom($this->id);
     return $images;
 }
示例#4
0
<?php

$oRoom = new Room();
$oRoomImage = new RoomImage();
$roomAll = $oRoom->findAllFrom("Room", "1=1 order by sequence");
$idx = 1;
$index = 90;
$count = 1;
$title = 1;
if ($oRoom->countFrom('Room', "1=1") > 0) {
    foreach ($roomAll as $room) {
        $roomgalleries = $oRoomImage->findByRoomId($room->id);
        $index--;
        if ($title == 1) {
            $title_m = 'first-content';
        } else {
            $title_m = '';
        }
        ?>

            <div class="col-full-room <?php 
        echo $title_m;
        ?>
 col<?php 
        echo $idx;
        ?>
" id="" style="background-size:100% 100%;z-index:<?php 
        echo $index;
        ?>
;">
                <?php 
示例#5
0
 public function save_imageorder()
 {
     $room_array = $_POST['roomimage_id'];
     $room_id = $_POST['room_id'];
     $order_array = $_POST['order'];
     $roomImg = new RoomImage();
     foreach ($room_array as $key => $value) {
         $roomimg_id = $value;
         $roomimg_order = $order_array[$key];
         $roomImg->update('RoomImage', array('sequence' => $roomimg_order), 'id=' . $roomimg_id);
     }
     Flash::set('success', __('The room image sequence has been saved.'));
     redirect(get_url('room/edit/' . $room_id));
 }
示例#6
0
		die(header('Location: ' . $_SESSION['page_url']));
	}else{
		$prop = $_POST['prop'];

		$hotel = new Hotel();
		$hotel = $hotel->find($hotel_id);
		if(!$hotel){ die(header('Location: ' . DOMAIN . '404')); }

		$memberId = $hotel->member_id;
		if(!isset($_SESSION['user']['id']) || ($memberId != $_SESSION['user']['id'])){
			die(header('Location: ' . DOMAIN . 'dashboard/add-hotel/step-01'));
		}

		$toRemove = new Room();
		$roomType = new RoomType();
		$roomImage = new RoomImage();

		$toRemove = $toRemove->find($prop);
		if(!$toRemove){ die(header('Location: ' . $_SESSION['page_url'])); }
		if($toRemove->hotel_id != $hotel_id){ die(header('Location: ' . $_SESSION['page_url'])); }
		$remRoomType = $roomType->find($toRemove->room_type_id);
		$remRoomType->delete();
		$remRoomImage = $roomImage->where('hotel_id', '=', $hotel_id)
			->where('room_id', '=', $toRemove->id)
			->get();
		$delImageIds = [];
		$delImages = [];
		foreach($remRoomImage as $remImage){
			$delImageIds[] = $remImage->id;
			$delImages[] = $remImage->image;
		}
示例#7
0
		$fItems = $fItems->whereIn('id', $fIds)->get();
		foreach($fItems as $fItem){
			$hFeatureList[$fTypeName->type][] = $fItem->feature;
		}
	}

	$hAttribute = new HotelAttribute();
	$hAttribute = $hAttribute->where('hotel_id', '=', $hotel->id)->first();
	$usefulInfo = [];
	$usefulInfo['Airport transfer availability by hotel'] = (isset($hAttribute->is_airport_transfer) && (strlen($hAttribute->is_airport_transfer) > 0)) ? 'Yes' : 'No';
	$usefulInfo['Average airport transfer fee'] = (isset($hAttribute->airport_transfer_fee) && (strlen($hAttribute->airport_transfer_fee) > 0)) ? $hAttribute->airport_transfer_fee . ' USD' : '';
	$usefulInfo['Distance to airport'] = (isset($hAttribute->distance_to_airport) && (strlen($hAttribute->distance_to_airport) > 0)) ? $hAttribute->distance_to_airport . ' km' : '';
	$usefulInfo['Check-In from'] = (isset($hAttribute->check_in) && (strlen($hAttribute->check_in) > 0)) ? $hAttribute->check_in : '';
	$usefulInfo['Check-Out until'] = (isset($hAttribute->check_out) && (strlen($hAttribute->check_out) > 0)) ? $hAttribute->check_out : '';

	$roomImage = new RoomImage();
	$hotelImages = $roomImage->where('hotel_id', '=', $hotel->id)->get();

	$roomRate = new RoomRate();
	$roomRates = $roomRate->where('hotel_id', '=', $hotel->id)->get();

	$searchBag['check_in'] = isset($_POST['date_arriving']) ? date('Y-m-d', strtotime($_POST['date_arriving'])) : date('Y-m-d');
	$searchBag['check_out'] = isset($_POST['date_departure']) ? date('Y-m-d', strtotime($_POST['date_departure'])) : date('Y-m-d', time() + 86400);
	$searchBag['rooms'] = isset($_POST['search_num_of_room']) ? intval($_POST['search_num_of_room']) : 1;

	$bookedDate = new BookedDate();
	$room = new Room();
	$rmvdRoomIds = [];
	$bookedRooms = [];
	$avlblHotels = [];
示例#8
0
文件: index.php 项目: jcodesdotme/pp
	$seo_url = $_GET['seo_url'];
	$hotel = new Hotel();
	$hotel = $hotel->where('seo_url', '=', $seo_url)->first();
	if(!$hotel){ die(header('Location: ' . DOMAIN . '404')); }

	if(isset($hotel->cover_photo) && (strlen($hotel->cover_photo) > 1)){
		$herCoverPhotos = explode(',', $hotel->cover_photo);
		foreach($herCoverPhotos as $photoKey => $herCoverPhoto){
			if(!file_exists(DOC_ROOT . 'uploads/hotel-cover-photos/' . $herCoverPhoto)){ unset($herCoverPhotos[$photoKey]); };
		}
	}else{
		$herCoverPhotos = ['default-cover-photo.jpg'];
	}

	$roomImage = new RoomImage();
	$roomImages = $roomImage->where('hotel_id', '=', $hotel->id)->get();

	$hFeature = new HotelFeature();
	$hFeatures = $hFeature->where('hotel_id', '=', $hotel->id)->get();
	$hFeatureList = [];
	foreach($hFeatures as $hFeature){
		$fTypeName = new HotelFeatureType();
		$fTypeName = $fTypeName->find($hFeature->feature_type_id);
		$fIds = $hFeature->feature_ids;
		$fIds = explode(',', $fIds);
		$fItems = new HotelFeatureList();
		$fItems = $fItems->whereIn('id', $fIds)->get();
		foreach($fItems as $fItem){
			$hFeatureList[$fTypeName->type][] = $fItem->feature;
		}
    if (is_null($roomImage) || !$roomImage->save()) {
        $logger->LogError("Error saving room image.");
        foreach ($roomImage->errors as $error) {
            $logger->LogError($error);
            $errors[] = $error;
        }
    } else {
        $message = "Values were updated successfully!";
        header("Location: room_images_list.php?room_id=" . $roomImage->roomId);
    }
} else {
    if (isset($_REQUEST['room_id']) && is_numeric($_REQUEST['room_id']) && isset($_REQUEST['image_id']) && is_numeric($_REQUEST['image_id'])) {
        $roomId = intval($_REQUEST['room_id']);
        $imageId = intval($_REQUEST['image_id']);
        $logger->LogInfo("Page was called for image edit of room id: {$roomId} and image id: {$imageId}");
        $roomImage = RoomImage::fetchFromDb($roomId, $imageId);
        if ($roomImage == null) {
            $logger->LogError("Invalid request. No gallery image with room id: {$roomId} and image id: {$imageId} exists.");
            $errors[] = "Invalid request. No gallery image with room id: {$roomId} and image id: {$imageId} exists.";
        }
    } else {
        if (isset($_REQUEST['room_id']) && is_numeric($_REQUEST['room_id'])) {
            $roomId = intval($_REQUEST['room_id']);
            $logger->LogInfo("Page was called for image add of room id: {$roomId}");
            $roomImage->roomId = $roomId;
        } else {
            $logger->LogError("Invalid request. No room id was specified");
            $errors[] = "Invalid request. No room id was specified";
        }
    }
}
 /**
  * Show the form for editing the specified resource.
  * GET /room/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     /*VARIABLES
     		$r = room
     		$i = all inputs
     		$rq = Room Quantity
     		***************/
     $r = Room::where('id', $id)->first();
     if (!empty($r)) {
         $i = Input::all();
         $r->name = $i['name'];
         $r->short_desc = $i['short_desc'];
         $r->full_desc = $i['full_desc'];
         $r->max_adults = $i['max_adults'];
         $r->max_children = $i['max_children'];
         $r->beds = $i['beds'];
         $r->bathrooms = $i['bathrooms'];
         $r->area = $i['area'];
         $r->price = $i['price'];
         if ($r->save()) {
             $a = new Activity();
             $a->actor = Auth::id();
             $a->location = 2;
             $a->logs = 'Updated room information of room type: ' . $r->name;
             $a->save();
             $images = RoomImage::where('room_id', $id)->delete();
             if (isset($i['images']) || !empty($i['images'])) {
                 if (is_array($i['images'])) {
                     foreach ($i['images'] as $image) {
                         $upload = new RoomImage();
                         $upload->room_id = $r->id;
                         $upload->image_id = $image['photo']['id'];
                         $upload->save();
                     }
                 } else {
                 }
             }
             return $r;
         } else {
             return '0';
         }
     }
 }