Jump to content


Photo

hotel booking check next available dates

hotel booking available dates

  • Please log in to reply
3 replies to this topic

#1 iimarah

iimarah

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 20 January 2013 - 06:39 AM

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

#2 cpd

cpd

    ¬_¬

  • Members
  • PipPipPip
  • 890 posts
  • LocationLondon, UK

Posted 20 January 2013 - 10:49 AM

You should be able to do this with a single SQL Query but unless we know you're database schema we can't help.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."

#3 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 20 January 2013 - 10:59 AM

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...
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#4 iimarah

iimarah

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 21 January 2013 - 08:03 AM

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, 21 January 2013 - 08:03 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com