next three months

Re: next three months

Postby siggy » Sat Apr 05, 2008 5:01 am

I did the copy/paste and - ALL works

now I will create SIX different calendars - one for each of six rooms

I have created a couple of new tables ( with different names ) - and these worked

then I saw some code referencing $_REQUEST["id_item"]
was this intended to be used in some way to identify
different calendars -- I am a little confused on how to use
the ID_ITEM --- and if I should be using this for different calendars
siggy
 
Posts: 13
Joined: Fri Mar 28, 2008 5:46 am

Re: next three months

Postby siggy » Sat Apr 05, 2008 8:49 am

I didn't see my last post.... ( maybe it was 'lost')

anyway -- it said
that your code works great... exactly as I had hoped...

my next task will be to create SIX different calendars,
one for each of six rooms-for-rent


siggy
siggy
 
Posts: 13
Joined: Fri Mar 28, 2008 5:46 am

Re: next three months

Postby chris » Sat Apr 05, 2008 11:22 am

Good I am glad to see that you got it working.

There is no need to set up separate database tables or even seperate versions of the script.
This script is designed to accept unlimited number of properties.

Al you have do do is change the "$_REQUEST["id_item"]" that it uses.
So if you have 6 properies, just identify each property with a number (eg 1,2,3,4,5,6) or, if you already have them in a database you should use their own unique id. Then send this id to the page (via form, url etc) and the calendar will automatically show the dates for that property.

One thing to remember is to add this id_item to the link or form that you are using to change the month blocks.

I hope this is clear.

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 siggy » Sat Apr 05, 2008 5:23 pm

that is what I guessed..... but clear ??

could you give me a little code snippet of an example
( including where to place this ).....

** I am an ASP guy who barely knows how to spell the word PHP

thanks
siggy
siggy
 
Posts: 13
Joined: Fri Mar 28, 2008 5:46 am

Re: next three months

Postby chris » Sat Apr 05, 2008 5:38 pm

well, to be honest it is not a question of php or asp,

just by calling the calendar (be it with a server side include or via an url etc) with the variable "id_item" set to the value for the property that you want to show the availability for.
Take a look at my demo:
http://www.cbolson.com/code/availabilit ... ersion2.0/
You will see that I have added a new select list of properties. By changing the selected property it changes the calendar to show.
To do this I have not touched the database at all, and I could add as many properties as I liked (you can even try it yourslef by just modifying the url to set id_item=XXXX - you will see that it "creates" a new empty calendar, the great thing being that it only saves booked dates to the database :)

So, for example I have added this code to change the selected property:
Code: Select all
<select name="id_item" onchange="this.form.submit()">
               <option value="6" >Property 6</option>
               <option value="7" >Property 7</option>
               <option value="8" >Property 8</option>
               <option value="9" >Property 9</option>

            </select>

As to how to catch the requested info in asp, I am afraid that I don't know how to do that but I imagine that it is fairly simple.
In my php version the code that detects and assigns the id_item is this:
Code: Select all
//   id of item to modify - this should be your id for the hotel/apartment/etc
if(isset($_REQUEST["id_item"]))       define("ID_ITEM",   $_REQUEST["id_item"]);   #   id sent via  url, form session etc
else                           define("ID_ITEM",   2);                  #   default used for demo



As to wher to place this, well that would depend on your web design, it doesn't really matter and it also depends on how you want your customer to access the calendar. If, for example, you have a seperate page for each property, well, you could either "hard code" the id into the page with something like define("IT_ITEM", "3"); (remember to remove the autodetect and capture code) or if you want to link to a specific property calendar in an url (eg for a popup window) you would use something like this: http://www.yourdomain.-com/calendar.php?id_item=3 where clearly "3" is the id of the property in question.

I hope this is getting clearer.... :)

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 siggy » Sun Apr 06, 2008 6:22 am

OK -- things are going reasonably well

except the ROOM calandar ( say id_item = 6 )
reverts back to default (id_item = 2)
whenever the month display range is changed

see: http://www.greenhectares.ca/calendar/bookings.php

when the page first opens - an empty calendar is displayed
after a user selects the room-of-interest the appropriate
calendar is displayed...
siggy
 
Posts: 13
Joined: Fri Mar 28, 2008 5:46 am

Re: next three months

Postby siggy » Sun Apr 06, 2008 8:58 am

I think I have somewhat solved my problem
by using a separate form for the date range selection and passing
the id_item as a hidden variable
siggy
 
Posts: 13
Joined: Fri Mar 28, 2008 5:46 am

Re: next three months

Postby chris » Sun Apr 06, 2008 11:00 am

HI there,
I can't quite understand why you are showing a "blank" calendar on intitial page load?
I would have thought that it would be confusing for the user to see a calendar that doesn't represent any property :(

To alter the default calender that is loaded, find these lines (assuking that you hacen't altered the code too much):
Code: Select all
//   id of item to modify - this should be your id for the hotel/apartment/etc
if(isset($_REQUEST["id_item"]))       define("ID_ITEM",   $_REQUEST["id_item"]);   #   id sent via  url, form session etc
else                           define("ID_ITEM",   2);                  #   default used for demo

and replace with this:
Code: Select all
//   id of item to modify - this should be your id for the hotel/apartment/etc
if(isset($_REQUEST["id_item"]))       define("ID_ITEM",   $_REQUEST["id_item"]);   #   id sent via  url, form session etc
else                           define("ID_ITEM",   3);                  #   default used for demo

This will load the "Red Barn - South Room" calendar.

Also there is no need to have seperate forms for the property selector and the "block" selector, unless your idea is to always send the user back to the initial block when changing the property? If they where both in the same block, you wouldn't need the hidden id_item field.
In the case that you do want the property select list to have the empty "select property" option at the beginning, then this option element should have an empty value like this:
Code: Select all
<option value="">Select - Room / Location</option>

and in the calendar code itself you should condition the displaying of the calendar so that if ID_ITEM is empty, then it doesn't show any calendar at all. something like this:
Code: Select all
if(empty(ID_ITEM)){
//no calendar
}else{
//calendar code......


I hope I am not confusing you too much with all this... ;)
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 siggy » Mon Apr 07, 2008 8:00 pm

I've got SIX calendars running at - for the general public to see :

http://www.greenhectares.ca/information.htm (availability calendars)
-- they are working just fine ( I THINK )

as well -- a password protected version where I select the ROOM etc...


I won't have a chance to look at your latest code suggestions
until later this week.... ( or the weekend )


siggy
siggy
 
Posts: 13
Joined: Fri Mar 28, 2008 5:46 am

Re: next three months

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

There's an issue with the current day highlighting - you need a tweak to account for the year.

I added:
Code: Select all
   $cur_year = date('Y');


to function draw_cal

and amended:
Code: Select all
if( ($day_counter==$cur_day) &&   ($month==$cur_month)  )   $border='style="border: 2px solid #99cc00"';


to
Code: Select all
if( ($day_counter==$cur_day) && ($month==$cur_month)  && ($year==$cur_year) )   $border='style="border: 2px solid #99cc00"';


did you say that and I missed it?

if not, here it is.

;)
Last edited by boldfish on Wed Apr 09, 2008 11:30 am, edited 1 time in total.
boldfish
 
Posts: 25
Joined: Fri Apr 04, 2008 10:04 am

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron