Jump to content

hotel booking check next available dates


iimarah

Recommended Posts

Hello, I am using the templatic hotel booking theme to enable users to book rooms through our website.

 

If there is no room available for the queried dates, it shows a message that there is no room available.

 

However, I wish to display the availability of that room for the next 5 days to enable them to book hotels for the next check in date.

 

The form is using dhtmlgoodies calender to gather the dates.

 

Is there any ways to display the stuff that I want.

 

I have included the booking result page here...

 

http://pastebin.com/795hFwMh

This is a purchased script/theme for WordPress. I recommend that you search/post your question on the templatic forum. Perhaps someone on that forum has already done what you are asking.

 

Moving thread to the 3rd party script forum section, since the forum section where you posted it is for regular expression help...

You should be able to do this with a single SQL Query but unless we know you're database schema we can't help.

 

I do know db a bit, so here is what I did...

 

$booking_check_avilability_table = $wpdb->prefix . 'booking_check_avilability';
$fetch_booking_schedule_sql = $wpdb->get_results("select sum(total_room) as total_room from $booking_check_avilability_table where room_type_id = '".$room_type."' and ((check_in_date between '".$_SESSION['side_check_in_date']."' and '".$_SESSION['side_check_out_date']."') or (check_out_date between '".$_SESSION['side_check_in_date']."' and '".$_SESSION['side_check_out_date']."') or (check_in_date <= '".$_SESSION['side_check_in_date']."' and check_out_date >= '".$_SESSION['side_check_in_date']."') or (check_in_date >= '".$_SESSION['side_check_out_date']."' and check_out_date <= '".$_SESSION['side_check_out_date']."'))");


if(count($fetch_booking_schedule_sql) > 0){
foreach($fetch_booking_schedule_sql as $fetch_booking_schedule_res){
$chk_room_cnt = $no_room - $fetch_booking_schedule_res->total_room;
echo '<th>'.$check_in_date.'</th>';
echo '<td>'.$chk_room_cnt.'</td>';
}
}

 

This is the part which shows the availability for the current day which is working fine.

 

$one_check_in_date = date('d',strtotime($_SESSION['side_check_in_date']));
$one_check_out_date = date('d',strtotime($_SESSION['side_check_out_date']));
$one_no_rooms = $_SESSION['side_no_rooms'];
$onenext_check_in_date = $one_check_in_date + 1;
$onenext_check_out_date = $one_check_out_date + 1;
$onenext_check_in_date_out = date('Y-m-'.$onenext_check_in_date.'',strtotime($_SESSION['side_check_in_date']));
$onenext_check_out_date_out = date('Y-m-'.$onenext_check_out_date.'',strtotime($_SESSION['side_check_out_date']));
$one_no_room = get_post_meta($room_type,'no_rooms',true);

if($one_no_room == 0){
echo '<th>'.$onenext_check_in_date_out.'</th>';
echo '<td>Not Available</td>';
}

elseif ($one_no_room == $one_no_rooms || $one_no_room > $one_no_rooms) {

$one_fetch_booking_schedule_sql = $wpdb->get_results("select sum(total_room) as total_room from $booking_check_avilability_table where room_type_id = '".$room_type."' and ((check_in_date between '".$onenext_check_in_date_out."' and '".$onenext_check_out_date_out."') or (check_out_date between '".$onenext_check_in_date_out."' and '".$onenext_check_out_date_out."') or (check_in_date <= '".$onenext_check_in_date_out."' and check_out_date >= '".$onenext_check_in_date_out."') or (check_in_date >= '".$onenext_check_out_date_out."' and check_out_date <= '".$onenext_check_out_date_out."'))");

if(count($one_fetch_booking_schedule_sql) > 0){
foreach($one_fetch_booking_schedule_sql as $one_fetch_booking_schedule_res){
$one_chk_room_cnt = $one_no_room - $fetch_booking_schedule_res->total_room;
echo '<th>'.$onenext_check_in_date_out.'</th>';
echo '<td>'.$one_chk_room_cnt.'</td>';
}
}
}

 

This shows of the next day which isn't working, it always shows 0 !

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.