next three months

Re: next three months

Postby chris » Wed Apr 09, 2008 11:42 am

Thanks,
no I missed that one -thanks for pointing it out ;)

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

Re: next three months

Postby boldfish » Wed Apr 09, 2008 11:53 am

There's a bug somewhere.

if you set months to 12 it doesn't work properly.

setting months to 1 shows the issue on year rollover. when you get to november the last month is 10 but the next month is next year month 0 which isn't right.

I'll see if I can figure it out.
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: next three months

Postby chris » Wed Apr 09, 2008 12:44 pm

it is clear that you don't want me to do any work this week ;)

I think that I have sorted out my version to correct these errors.

Could you take a look : http://www.cbolson.com/code/availabilit ... /index.php
I have put back the number of months selector though it isn't very compatible with the block selector but it does ease testing.

I have removed a lot of excess code from the month selectors where I was trying to actually write the months for jumping rather than the periods (eg march 2008 - sept 2008) - this code is not needed now and was just confusing things

This is the code I now use to define the select list options:
Code: Select all
//   define LAST block - START
$last_month_start   =    (START_MONTH-MONTHS_TO_SHOW);   #   remove months_to_show x 2 to go back this block and then 1 more
$last_year_start   =   START_YEAR;
if($last_month_start<0){
   $last_month_start=$last_month_start+12;
   --$last_year_start;
}

$last_month_start=sprintf("%02s",$last_month_start);

//   define NEXT block - START
$next_month_start   =    $this_month;   #   just use MONTH number that the loop has ended on
$next_year_start   =   $this_year;      #   just use YEAR number that the loop has ended on
if($next_month_start>12){
   $next_month_start=$next_month_start-12;
   ++$next_year_start;
}

$next_month_start=sprintf("%02s",$next_month_start);

and in the select list (in case you need it):
Code: Select all
<select name="year_month" onchange="this.form.submit()">
               <option value=""> - select months to show - </option>
               <option value=""> Current '.MONTHS_TO_SHOW.' months </option>
               <option value="'.$last_year_start.'-'.$last_month_start.'">Previous '.MONTHS_TO_SHOW.' months</option>
               <option value="'.$next_year_start.'-'.$next_month_start.'" >Following '.MONTHS_TO_SHOW.' months</option>
            </select>

I have also added $num_months_shown=0; right before while($num_months_shown<MONTHS_TO_SHOW){ which was the cause of the 1 month display problem (another silly mistake)

I can send you more code if you need it, I realise that just posting bits of code might be confusing but on the other hand, posting the whole lot isn't particularrly helpful either :(

let me know how it goes ;)

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

Re: next three months

Postby boldfish » Wed Apr 09, 2008 1:04 pm

Okay.

I made a couple of changes to your posted code and it now rolls over in a 1 month at a time scenario and shows 12 months at a time too.
from:
Code: Select all
//   define LAST block - START
$last_month_start   =    (START_MONTH-MONTHS_TO_SHOW);   #   remove months_to_show x 2 to go back this block and then 1 more
$last_year_start   =   START_YEAR;
if($last_month_start<0){
   $last_month_start=$last_month_start+12;
   --$last_year_start;
}

to
Code: Select all
//   define LAST block - START
$last_month_start   =    (START_MONTH-MONTHS_TO_SHOW);   #   remove months_to_show x 2 to go back this block and then 1 more
$last_year_start   =   START_YEAR;
if($last_month_start<1){
   $last_month_start=$last_month_start+12;
   --$last_year_start;
}

and
Code: Select all
//   define NEXT block - START
$next_month_start   =    $this_month;   #   just use MONTH number that the loop has ended on
$next_year_start   =   $this_year;      #   just use YEAR number that the loop has ended on
if($next_month_start>11){
   $next_month_start=$next_month_start-12;
   ++$next_year_start;
}

to
Code: Select all
//   define NEXT block - START
$next_month_start   =    $this_month;   #   just use MONTH number that the loop has ended on
$next_year_start   =   $this_year;      #   just use YEAR number that the loop has ended on
if($next_month_start>12){
   $next_month_start=$next_month_start-12;
   ++$next_year_start;
}


hope that helps
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: next three months

Postby boldfish » Wed Apr 09, 2008 1:06 pm

timing and post crossover!

will look at your code.

;)
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: next three months

Postby boldfish » Wed Apr 09, 2008 4:25 pm

I went with my amendments in the end.

see:
http://www.lanzluxuryvillas.com/propdetail.php?id=105

note the "more availability" buttons bottom right for stepping 12 months at a time into the future.

;o)
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: next three months

Postby chris » Wed Apr 09, 2008 5:05 pm

Excellent - that looks really good! - it shows off perfectly the flexibility of the calendar and demonstrates the fact that it really has no limits as regards number of "items" and time span that it can cover (not that I can see many people needing to update the calendar 10 years from now ;) ).

In my short experience in the world of "availability calendars", I haven't found anything out there quite like this one (OK, so I haven't actually tried the comercial scripts) but of course, that is why I am developing it. I am really quite happy about the way it is going forward and the response it is getting.

Thanks for using it, for helping me debug and correct it and, of course, for donating - that really encourages one to "keep at it" :)


Cheers,
Chris

PS. one thing I forgot to ask.... how did you "find" this script?
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: next three months

Postby boldfish » Wed Apr 09, 2008 5:41 pm

PS. one thing I forgot to ask.... how did you "find" this script?


I googled a bit, tried a few and ended up here:

http://www.hotscripts.com/Detailed/76885.html
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

Re: next three months

Postby MrRundog » Fri Apr 11, 2008 2:37 pm

First I Would like to say that this is a lovelly script - well done.

Ok I have the following default code...
Code: Select all
$the_months   =   array();
$k         =   $cur_month;
$j         =   0;

while($j<MONTHS_TO_SHOW){
   $this_month=sprintf("%02s",$k);
   $the_months[$this_month]=array("year"=>$cur_year,"month"=>$this_month);
   $j++;
   if($k==12){
      //   start new year and reset counter to 1 (jan)
      $cur_year=$cur_year+1;
      $k=1;
   }else{
      $k++;
   }
}

//   loop through months to draw calendar
$j=1;
$cal_months='';
foreach($the_months as $key=>$val){
   $cal_months.='<td valign="top" align="center">'.draw_cal(ID_ITEM,$val["month"], $val["year"], $booked_days,1).'</td>';
   if (($j % 3) == 0)$cal_months.="</tr><tr>";
   ++$j;
}


I would like to implement the code offered by Boldfish - What needs replacing here & would anything else need updating? (I keep losing track when i look back at previous posts!)

Cheers
User avatar
MrRundog
 
Posts: 14
Joined: Fri Apr 11, 2008 12:57 pm

Re: next three months

Postby chris » Fri Apr 11, 2008 2:50 pm

HI there, welcome to the forum and thanks for the comments :)

Which bit of what Boldfish has mentioned are you interested in? (over the last few days I have made so many changes and mods I myself am getting a bit confused)

Are you wanting to be able to move the calendar forward by X number of months or was it the fix for the 1 and 12 month display errors?

Let me know and I will try to explain the changes necessary step by step.

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

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron