Changing the start day

Changing the start day

Postby geoffC » Thu Sep 17, 2009 2:43 pm

Hello,

I'm trying to retro-fit this lovely script to an existing site.

The holiday cottage site, runs its bookings Fri-Fri.... is there an easy'ish way of getting your script to generate calenders Fri - Thurs?

Ta muchly

Geoff
geoffC
 
Posts: 3
Joined: Thu Sep 17, 2009 2:41 pm
Location: Bournemouth, UK

Re: Changing the start day

Postby chris » Thu Sep 17, 2009 4:03 pm

Hi,
What a strange day to start a calendar on! :)

I think I have got this working...

Open includes > functions.inc.php and find these lines within the draw_cal() function:
Code: Select all
if(CAL_START_DAY=="sun"){
   //$cal_row_counter=0;
   for($k=0; $k<7; $k++){
      $weekday = substr($lang["days"][$k],0,1);
      $the_cal.='<td class="cal_title" width="'.$td_width.'"> '.$weekday.'</td>';
   }
}else{
   //$cal_row_counter=1;
   if ($first_week_day == 0)   $first_week_day =7;
   for($k=1; $k<=7; $k++){
      if($k==7)    $weekday = substr($lang["days"][0],0,1);
      else      $weekday = substr($lang["days"][$k],0,1);
      $the_cal.='<td class="cal_title" width="'.$td_width.'"> '.$weekday.'</td>';
   }
}

Replace that whole block (or comment it out incase you change back at a later date) with this:
Code: Select all
//   friday start
$d=5;   # Friday is number 5
for($k=1; $k<=7; $k++){
   $the_cal.='<td class="cal_title" width="'.$td_width.'"> '.substr($lang["days"][$d],0,1).'</td>';
   ++$d;
   $d %= 7; # reset to 0
}

That sorts out the day titles, now for the actual calendar dates.
In fact the only thing that is needed is to adjust the padding days at the beginning of the month.

Find this code a few lines down from the last block:
Code: Select all
if(CAL_START_DAY=="sun")   $first_week_day_start   =   $first_week_day;   # start sunday
else                  $first_week_day         =   $first_week_day-1;   # current version starts monday

and change it to this:
Code: Select all
$first_week_day         =   $first_week_day+1;


All being well, that should be it.

Note - these changes completely override the var CAL_START_DAY defined in common,inc.php.

Let me know if you have any problems making the changes or if you spot something that I missed.

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

Re: Changing the start day

Postby geoffC » Thu Sep 17, 2009 4:31 pm

Hi Chris,

Firstly thank you hugely for the very swift reply.

Yep.. friday is an odd day to start with!

Your modifications.. almost work!

The first bit.. puts all the days in the right order F S S M T W T (hooray!), however unless I am being particularly dense the dates are still a little out of whack...

I think September should look something like:

F S S M T W T
_ _ _ _ 1 2 3
4 5 6 7 8 9 10

What I am getting is:

F S S M T W T
- - - 1 2 3 4
etc...

I've tried changing to +2
Code: Select all
$first_week_day         =   $first_week_day+2;


But that makes things a little more.. erm.. wobbly!

2 Screenshots..
http://www.flickr.com/photos/94443948@N00/3929214220 ---- +1
http://www.flickr.com/photos/94443948@N00/3929218306 ---- +2

Sorry for all the fuss... I'm sure it's just me being particularly dense today!

Geoff
geoffC
 
Posts: 3
Joined: Thu Sep 17, 2009 2:41 pm
Location: Bournemouth, UK

Re: Changing the start day

Postby chris » Thu Sep 17, 2009 5:06 pm

hmmm, I got this:
http://www.cbolson.com/code/availabilit ... ts/geoffc/

Must have done something else to the code.....

Have you made any other changes to functions.inc.php?

If you want I can send you a zipped copy of my modified file.

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

Re: Changing the start day

Postby chris » Thu Sep 17, 2009 5:09 pm

ah, a couple of lines down from the last change you probably have this:
Code: Select all
if($first_week_day!=7){
         for($week_day = 0; $week_day < $first_week_day; $week_day++){
            $the_cal.='<td class="cal_empty">'.$cal_no_day.'</td>';   
            $j++;
         }
      }

change that to this:
Code: Select all
if($first_week_day<6){
         for($week_day = 0; $week_day <= $first_week_day; $week_day++){
            $the_cal.='<td class="cal_empty">'.$cal_no_day.'</td>';   
            $j++;
         }
      }


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

Re: Changing the start day

Postby geoffC » Thu Sep 17, 2009 5:24 pm

Lovely that has worked a treat.

For my next trick.. I now want to add an editable price per week, at the end of each <tr...

Wish me luck!

Thank you again Chris for the cracking script, and all the support today.
geoffC
 
Posts: 3
Joined: Thu Sep 17, 2009 2:41 pm
Location: Bournemouth, UK

Re: Changing the start day

Postby Rawthey » Mon Jun 06, 2011 10:30 pm

I'm trying to set the start day to Friday with version 3.03.03. I've applied the changes described above and it nearly works. The calendar starts on the right days but the F S S M T W T strip along the top of each month isn't getting displayed.
There's an example at http://www.flickr.com/photos/rawthey/5805276081
Could you suggest what else I need to change to make this compatible with v3.03.03?

Here's the diffs between the original functions.inc.php and my mods:

===================================================================
RCS file: RCS/functions.inc.php,v
retrieving revision 1.2
diff -b -r1.2 functions.inc.php
41,50c41,42
< if(AC_START_DAY=="sun"){
< //$cal_row_counter=0;
<
< for($k=0; $k<7; $k++){
< $weekday = substr($lang["day_".$k.""],0,1);
< $list_day_titles.='<li class="cal_weekday"> '.$weekday.'</li>';
< }
< }else{
< //$cal_row_counter=1;
< if ($first_week_day == 0) $first_week_day =7;
---
> // friday start
> $d=5; # Friday is number 5
52,56c44,46
< //echo "<br>".$k;
< if($k==7) $weekday = substr($lang["day_0"][0],0,1);
< else $weekday = substr($lang["day_".$k.""],0,1);
< $list_day_titles.='<li title="'.$lang["day_".$k.""].'"> '.$weekday
< }
---
> $the_cal.='<td class="cal_title" width="'.$td_width.'"> '.substr($lang["days"][$d
> ++$d;
> $d %= 7; # reset to 0
59d48
<
61,65c50,51
< $j=1;
< if(AC_START_DAY=="sun") $first_week_day_start = $first_week_day; #
< else $first_week_day =
<
< if($first_week_day!=7){
---
> $first_week_day = $first_week_day+1;
> if($first_week_day<6){
68c54
< for($week_day = 0; $week_day < $first_week_day; $week_day++){
---
> for($week_day = 0; $week_day <= $first_week_day; $week_day++){
Rawthey
 
Posts: 4
Joined: Mon Jun 06, 2011 7:25 pm

Re: Changing the start day

Postby Rawthey » Tue Jun 07, 2011 11:30 am

OK, I've solved it now. I just found the post in the Version 3 Support section which shows the changes I need.

I should have spotted this in the first place but I'd had to trawl through the forum manually because I had problems with the search facility which produced the following message when I searched for Changing the start day:

The following words in your search query were ignored because they are too common words: changing start day the.
You must specify at least one word to search for. Each word must consist of at least 3 characters and must not contain more than 14 characters excluding wildcards.


... and searching for just Changing start had the same result :(
Rawthey
 
Posts: 4
Joined: Mon Jun 06, 2011 7:25 pm


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron