Page 2 of 3

Re: Script in use

PostPosted: Mon Mar 17, 2008 12:09 am
by vee
chris wrote:I trust that you had no problems using the "id" to identify each of your sites - as you will have been able to see, there really is no limit as to how many items this script can control.
Chris



Hi Chris & Eccles

Could you expand on this interesting topic a bit more please? When you say the script can control unlimited items, how does one do this? Looking at Eccles' site I see he has different names for what would be the index page of each caravan-pitch availability calander but does this mean there also has to be different database entry files etc? I can't quite see how the one script as-is could control multiple availability calendars. Obviously I'm not much of a coder though I can do the install ok!

Thanks for your help
Vee

Re: Script in use

PostPosted: Mon Mar 17, 2008 12:43 am
by chris
Hi there Vee and welcome to the forum :)

The way the calendar works as regards the database is that it uses 3 columns:
"id" - unique identifier key
"id_item" - this is the id if the apartment, camp site, etc
"date" - the date that is "booked"

In Version1, the database simply creates an entry for the days booked with the id_item.

If you check the code, you should see that it uses the variable "id_item" when drawing the calender and for updating.
Therefore, you could have as many "id_items" as you like/need just by altering this (numeric) value - ideally this would be the same value you as you are currently usiung to store other information about the "item".

You can check my calender out by comparing these 2 urls:
http://www.cbolson.com/code/availability-calendar/
http://www.cbolson.com/code/availabilit ... id_item=55

This second one is a completly new item that is automtically created when it recieves the new id - there is no need to change anything in the code for this work.

I hope this is clear and will help point you in the right direction for your needs ;)

Let me know how it goes.

Chris

Re: Script in use

PostPosted: Mon Mar 17, 2008 3:20 am
by sylvia
Hi Chris,

Thank you for creating the Availability Calendar. It's just what I needed for our community clubhouse. I modified the current version that you have to allow the month display to start on Sunday. You can see it here http://www.woodleamanor.org/activities/clubhouse.php
I'd like to add the option to select the number of months to view, but will wait until you have updated you zip files. Thanks again.

Sylvia :)

Re: Script in use

PostPosted: Mon Mar 17, 2008 9:12 am
by eccles
Vee

I have clipped the lines that Chris refers to which may help.

// id of item to modify
// NOTE - this should be your id for the hotel/apartment/etc
if(!isset($_REQUEST["id_item"])) $_REQUEST["id_item"]=1; (I have eight IDs, one for each item)

In the Body section I have:

<div id="wrapper">
<table width="100%">
<tr>
<td>
<h2><center>Chambre D\'Hotes Double Room Availability</h2> (The heading at the top of the page)
<ul>
Red dates are unavailable. Grey dates are available. (Any other text I want to add. Use <p> for a new line)
</center>
</ul>
</td>

Hope this makes sense.

Eccles

Re: Script in use

PostPosted: Mon Mar 17, 2008 11:23 am
by chris
Hi there Sylvia and welcome to the forum :)
I see that you are using the version 2 that is posted somewhere on this forum (I am getting a bit confused myself - I must try to synconise the versions) .

To be able to adjust the number of months to show, look for the "months_to_show" variable and adjust it to your needs, right now you must have it set at 12.

Chris

Re: Script in use

PostPosted: Mon Mar 17, 2008 12:44 pm
by vee
Hi Chris & Eccles

Thanks a lot guys - much appreciated! Slightly different in ver2 but works just fine.

One other question, how does one achieve the nice effect on Chris' demo page where one can select the number of months shown (ver.2)?

Thanks again (for the script and for the help 8-) )
Vee

Re: Script in use

PostPosted: Mon Mar 17, 2008 1:24 pm
by chris
Hi again, yes, I need to sort myself out and have only 1 current version :)

To create the select box I used a bit of php to create the select list:
Code: Select all
 Number of months to show:
<form method="get" action="">
<input type="hidden" name="id_item value="'.$_REQUEST["id_item"].'">
<select name="months_to_show" onchange="this.form.submit()">
';
for($k=1; $k<=12; $k++){
   echo '<option value="'.$k.'"';
   if($_REQUEST["months_to_show"]==$k) echo ' selected';
   echo '>'.$k.'</option>';
}
echo '
</select>
</form>


(this code "assumes" that you are placing it within php tags somewhere on your page)

On posting this form, unless you have modified the way the code works, it "should" show the number of months selected. As is, the code will NOT accept more than 12 months view due to the way the loop works for drawing the calendar - this would need to be modified to be able to show more months.

See if you can get this working ;)

Chris

Re: Script in use

PostPosted: Mon Mar 17, 2008 4:20 pm
by sylvia
Can you tell me where to put that piece of code that sets the number of months to view? If I assign it to $total-months_to_show, I don't get it to work. If I put it in the table html, it shows up nicely, but I don't know how to make it change the number of months displayed.

Thanks for your help!
Sylvia

Re: Script in use

PostPosted: Mon Mar 17, 2008 4:28 pm
by chris
can you post the code for this page:
clubhouse.php
I am not quite sure how you have it right now, so it is hard to say exactly where to put it.
Send me a pm rather than posting it here.

Chris

Re: Script in use

PostPosted: Mon Mar 17, 2008 4:42 pm
by chris
OK, in your code,
find this (ln 79):
Code: Select all
 $total_months_to_show=12;

and replace with this:
Code: Select all
if(isset($_REQUEST["months_to_show"])) $total_months_to_show=$_REQUEST["months_to_show"];
else $total_months_to_show=12; # default value

Then add the select form code that I posted to wherever you want to show it.

GIve it another try with this small alteration, if it still doesn't work I will repost your code that you pm'd me with the alterations and the form.

Chris
PS. by the way, seeing as you have now created the db table, you can now remove the db table check - no point in doing it every time the page is loaded ;)
Code: Select all
// check table exists,
if(!mysql_is_table(T_BOOKINGS)){
echo '
Database table <b>'.T_BOOKINGS.'</b> does not exist.
<br>Before you can run this script you need to create the availability table in your data base.
<br><br><a href="db_table_create.php">CREATE AVAILABILITY TABLE IN DATABASE</a>
';
exit;
}