Disabling Expired Dates

Disabling Expired Dates

Postby davemarsh » Tue Feb 10, 2009 3:07 pm

Hi Chris,

Thanks for all your help so far, I'm really fine tuning this now and have a new question for you.

How do I make old dates unavailable for selection? Ie, today is the 10th Feb so i'd like everything before this date to automaitcally show as booked out (and therefore be unselectable). How would I go about doing this?

The booking form is here is here: http://www.waterhallcountryhouse.co.uk/bookings.html

Cheers,
Dave
davemarsh
 
Posts: 11
Joined: Wed Jan 07, 2009 2:08 am

Re: Disabling Expired Dates

Postby chris » Tue Feb 10, 2009 10:02 pm

Similar questions to this have been asked (and anwsered) before in the forum.

Basicially you need to modify functions.inc.php so as to check the date being shown against the current date and "simply" not add the link if it is previous to the current day.

In this file somewhere towards the begining of the draw_cal() function add this line to define the current timestamp:
Code: Select all
$today_timestamp=   mktime(0,0,0,date('m'),date('d'),date('Y'));


Then, down below within the loop that goes through each day of the month add this:
Code: Select all
if(CAL_START_DAY=="sun")      $date_timestamp =   mktime(0,0,0, $month,$day_counter,$year);
else                        $date_timestamp =   mktime(0,0,0, $month,($day_counter+1),$year);

(the loop in question starts like this: for($day_counter = 1; $day_counter <= $days_in_this_month; $day_counter++){

Finally you need to condition the links so that they will not be defined if the date is previous to today.
Currently in your version you have this:
Code: Select all
//   show ajax link or not
if($show_link==1){
  $day_link_start   ='<a href="#" onclick="ajax_mod_state(\''.$id.'\',\''.$this_date.'\',\''.$day_counter.'\',event); return false" title="'.$lang["modify_availability_for"].' '.$lang["day_".$week_day.""].' '. $date_format.'" class="cal_day">';
  $day_link_end   ='</a>';
}else{
  $day_link_start   ="";
  $day_link_end   ="";
}

You need to change that to this:
Code: Select all
$day_link_start   ="";
$day_link_end   ="";
if( $date_timestamp>=$today_timestamp){
  //   show ajax link or not
  if($show_link==1){
   $day_link_start   ='<a href="#" onclick="ajax_mod_state(\''.$id.'\',\''.$this_date.'\',\''.$day_counter.'\',event); return false" title="'.$lang["modify_availability_for"].' '.$lang["day_".$week_day.""].' '. $date_format.'" class="cal_day">';
   $day_link_end   ='</a>';
  }
}

That should be it.
You will see from this that I haven't actually done what you requested as regards making the previous days "appear" to be all booked as I am not convinced that that is really what you want.
However, if it is, you could add a condition so that if the date is previous to current, the image to be used is always the "booked" one (or create another one especially for the ocasion), something like this (following on from the previous "if" clause):
Code: Select all
}else{
  // show all previous days as booked
$day_image='cal_on_'.$day_counter.'.png';
}


Well, I hope you can follow these steps.

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Disabling Expired Dates

Postby chris » Fri Feb 13, 2009 1:22 pm

he there,
Have you had a chance to make the changes to get this working?

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Disabling Expired Dates

Postby Lora » Thu Aug 27, 2009 6:39 pm

I got this to work. It is a great option.

Thanks again,

Lora
Lora
 
Posts: 16
Joined: Thu Jun 25, 2009 5:46 pm

Re: Disabling Expired Dates

Postby Matjan » Tue Feb 02, 2010 9:23 pm

Hi Chris,

can you please tell me where to add these lines? I've tried a few combinations, but after uploading the functions.inc.php the calendar doesn't show. Can you have a look at the file and give me instructions?

:D
Attachments
functions.inc.rar
my functions.inc.php
(2.04 KiB) Downloaded 351 times
Matjan
 
Posts: 3
Joined: Sat Jan 30, 2010 7:15 pm

Re: Disabling Expired Dates

Postby chris » Thu Feb 04, 2010 11:51 am

Hi,
I have taken a look at the file that you sent but can't see any of the changes outlined in the previous post.

Try making the changes that are outlined a couple of posts here: viewtopic.php?f=9&t=71&p=949#p477
There are only a couple of things to do and if you follow the steps you should have no problems.

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron