Hello all, i got a problem with a reservation system i bought from a website.
It's a Joomla Component and i try to develop it to do the job i want.

So, here's the deal, what i want to do and what i have.
There are 2 fields that u can select the "From Date" and the "To Date" where you select the dates. You can type the dates, or you can select them from the calendar that pop-ups.

So far so good.

Now, what i have to do... i want the guest/client to be able to book a room from today+5 days.
So let's say that today it's 15/1/2011. The client will be able to make a booking AFTER or AT 20/1/2011.

What i did, was to predefine the value of the textbox that contains the date and they are working fine (they show the dates i want) but if the client/guest choose a date not "acceptable" (17/1/2011) the system does not stop and continues to the reservation, telling him that rooms are available.

I'd like to stop the reservation proccedure and give him an error.

You can check the webpage at http://akti.thessite.gr (Sorry if that counts as an Adv.), it's still under development ofc. and the source code it's attached in txt.

ps: Sorry for my English, it's not my main language!
ps2: I hope you understand from my explenations..

    You're going to have to reformat yours dates, as in that style they can not be converted. The next thing you want to do is convert them to unix timestamps, as you can then do a "If greater than" or "If less than" on your two dates.

    $reserve_date = strtotime($_POST['input_date']);//may need to be reformatted
    $min_date = strtotime('now +5 days');
    
    //now we have two timestamps, seconds past since 1970, so we
    //can compare the numbers
    if($reserve_date > $min_date){
       //reservation logic
    }else{
       echo "Reservations may not be made prior to".date('m/d/y', $min_date)."<br/>";
    }
    

    -- edit --
    looking at your dates you may not have to convert them. Try using strtotime to convert them to a timestamp, then using date to convert them back, making sure the end result isn't 1969-12-31, as this would indicate it's in the wrong format.

    $date = strtotime($date);
    echo date('Y-m-d', $date);
    

      Thanks for your time Res!
      Altho, i didn't followed what you said, i tried a different approach to solve my problem..
      that's what i did... (Hope you guys can read Git)

      https://github.com/renjinsk/ThesSite.gr---BooKiT/commit/75a4977ba06164207aa3ff8e6631fa50485ab6fd

      Looks like a fix to me! 😉

      For those that can't read Git:
      What i did, was to change the Javascript code to disable the button when the user checked the incorrect dates from the callendar.
      I also added a div to be visible for that event too...

      Thank's again for ur time spend to read my issue 😉

        Write a Reply...