Script in use

Re: Script in use

Postby vee » Mon Mar 17, 2008 12:09 am

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
vee
 
Posts: 2
Joined: Thu Feb 28, 2008 3:37 am

Re: Script in use

Postby chris » Mon Mar 17, 2008 12:43 am

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
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Script in use

Postby sylvia » Mon Mar 17, 2008 3:20 am

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 :)
sylvia
 
Posts: 3
Joined: Mon Mar 17, 2008 3:11 am
Location: Virginia, USA

Re: Script in use

Postby eccles » Mon Mar 17, 2008 9:12 am

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
eccles
 
Posts: 5
Joined: Tue Mar 04, 2008 6:06 pm

Re: Script in use

Postby chris » Mon Mar 17, 2008 11:23 am

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
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Script in use

Postby vee » Mon Mar 17, 2008 12:44 pm

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
vee
 
Posts: 2
Joined: Thu Feb 28, 2008 3:37 am

Re: Script in use

Postby chris » Mon Mar 17, 2008 1:24 pm

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
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Script in use

Postby sylvia » Mon Mar 17, 2008 4:20 pm

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
sylvia
 
Posts: 3
Joined: Mon Mar 17, 2008 3:11 am
Location: Virginia, USA

Re: Script in use

Postby chris » Mon Mar 17, 2008 4:28 pm

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
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Script in use

Postby chris » Mon Mar 17, 2008 4:42 pm

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;
}
User avatar
chris
Site Admin
 
Posts: 1088
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