CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

agenda.js and multiple date ranges

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> PopCalendarXP Related
View previous topic :: View next topic  
Author Message
ginestra



Joined: 03 Jan 2006
Posts: 3

PostPosted: Mon Jan 09, 2006 3:16 pm    Post subject: agenda.js and multiple date ranges Reply with quote

Hello. Am currently using script on a development project, but having been playing with it for a few days, I'm wondering if I might be able to adapt the script for another site and a different use. I appreciate that I'd need to buy another licence, clearly!

The site offers a selection of rental properties, and now needs availabilty calendars for each property (100 plus properties). I'm wondering if I could use a different agenda.js file for each property (eventually tying this into a form>xml>agenda.js system for the site owner), and, in some way, add the availability data to the agenda.js file (they'd be treated in much the same way as an event, I guess).

Anyway, there would be 3 states - available, booked or optioned (possibly booked), and I'd just style the calendar accordingly. The available and optioned periods are always one week (7 days), or mulitples thereof, so I guess I'd need some way of adding multiple date ranges to the agenda.js, summed up like this:

Booked: 07/06/2005-14/06/2006;05/08/2006-12/08/2006;02/09/2006-16/09/2006

Optioned: 02/05/2006-09/05/2006;22/10/2006-29/10/2006.

Obviously, all dates not featured above would be 'available'. Rather than have a from-to range, I guess I could use a from+7 to represent a week?

Anyway, I hope what I'm wondering about is clear. Is it possible to have such strings of date ranges in agenda.js, and what is the syntax?

Thanks a lot.
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Mon Jan 09, 2006 4:02 pm    Post subject: Reply with quote

Well, first of all, it's very easy to implement the 3-states-agenda. All you need is to append the following code to your plugins.js:
Code:
function fAddWeekBooked(y,m,d) {
   var dt=new Date(y, m-1, d);
   for (var i=0; i<7; i++) {   
      fAddEvent(dt.getFullYear(),dt.getMonth()+1,dt.getDate(),"Booked",null,"red");
      dt.setDate(dt.getDate()+1);
   }
}
function fAddWeekOptioned(y,m,d) {
   var dt=new Date(y, m-1, d);
   for (var i=0; i<7; i++) {   
      fAddEvent(dt.getFullYear(),dt.getMonth()+1,dt.getDate(),"Optioned","","orange");
      dt.setDate(dt.getDate()+1);
   }
}
Now you can simply use fAddWeekBooked and fAddWeekOptioned in your agenda.js to mark a week starting with the supplied date. e.g.
Code:
fAddWeekBooked(2006,6,7); // booked week starting from June 7, 2006
fAddWeekOptioned(2006,5,2); // optioned week starting from May 2, 006

Next, to assign each property a different agenda, you'll need to follow the instructions in the agenda tutorial to make it a server-generated page and pass the property id in as a parameter (check "How to pass parameters to the script that generates the agenda file?" in the same tutorial).

Last, if you would like to have multiple properties in one page, you will have to define an individual <iframe> tag for each property that has a different agenda and differentiate them with an explict context-name (the same way to show calendars with different themes in one page - see FAQ). e.g.
Code:
<iframe name="gToday:normal:agenda.jsp?propId=1:gfPop_1" id="gToday:normal:agenda.jsp?propId=1:gfPop_1" ...></iframe>

<iframe name="gToday:normal:agenda.jsp?propId=2:gfPop_2" id="gToday:normal:agenda.jsp?propId=2:gfPop_2" ...></iframe>
Then use gfPop_1 and gfPop_2 instead the default gfPop to pop the calendar. e.g.
Code:
onclick="if(self.gfPop_1)gfPop_1.fPopCalendar(...)"

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.


Last edited by calendarxp on Tue Jan 17, 2006 1:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
ginestra



Joined: 03 Jan 2006
Posts: 3

PostPosted: Mon Jan 09, 2006 4:32 pm    Post subject: Reply with quote

Excellent, excellent - that looks like another sale then. I'll try that over the next day or so, but just one question - as I implied in the title, I'll need multiple, non-consecutive ranges in each agenda.js - let's say 2 weeks booked in July and August, 3 in October and then one in the following February, and these files will clearly be updated with each new booking.

What's the syntax for the multiple entries? You say:

Code:
fAddWeekBooked(2006,6,7); // booked week starting from June 7, 2006
fAddWeekOptioned(2006,5,2); // optioned week starting from May 2, 006


And that's clear, but to add to that ... would I just use semicolon seperators for each range, like this?

Code:
fAddWeekBooked(2006,6,7);(2006,6,21); // booked week starting from June 7, 2006
fAddWeekOptioned(2006,5,2); // optioned week starting from May 2, 006


... if I wanted to add a second booked week from the 21st of June?

Thanks again for your help and examples.

[Edited to change syntax - commas]
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Mon Jan 09, 2006 4:43 pm    Post subject: Reply with quote

You are welcome. In that case you just need to duplicate the call in agenda.js. e.g.
Code:
fAddWeekBooked(2006,6,7);
fAddWeekBooked(2006,6,21);

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
ginestra



Joined: 03 Jan 2006
Posts: 3

PostPosted: Thu Jan 12, 2006 3:27 pm    Post subject: Reply with quote

Back again. The above is all working fine, but there is now a different twist in things, one which I should really have thought about at the beginning.

Thing is, I don't need a date picker - I just need the display calendars, with the booked and optioned diplays as covered above. I don't need values returned, no form details, not even a clickable calendar - just the display calendars which can be cycled through one month at a time so that customers can see what's available per property.

I know that this is not the intended use, but is it possible to use the script in this way - either in a form with no inputs, or just as an on-click image that displays the calendar?

Hope I've explained, and thanks again.
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Thu Jan 12, 2006 7:11 pm    Post subject: Reply with quote

Well, I think what you need is the FlatCalendarXP instead of the pop one.

Simply download the FlatCalendarXP (suppose you have a valid license) and apply the same changes we discussed above. That should do it.

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> PopCalendarXP Related All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group