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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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 !

Edited by iimarah
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.