New at php/ajax and the availability calendar

New at php/ajax and the availability calendar

Postby lulachamba » Thu Dec 04, 2008 4:36 pm

Hi everybody,

I am totally new to this and have some questions therefore.

1. How do I use the calendar on a existing site/design/html?
I can not find the code to copy & paste into the already existing
html file. Which file do I have to open/copy?

2. Can anyone then change the state of the days or is there a
log-in for an administrator, because I could not find that, either?
There would be no sense, if anyone could. ;)

Thanks a lot in advance.

Lula
lulachamba
 
Posts: 5
Joined: Thu Dec 04, 2008 4:28 pm

Re: New at php/ajax and the availability calendar

Postby chris » Fri Dec 05, 2008 8:57 pm

Hi there,
This script is not designed to be just "copied & pasted", rather it it's original purpose was to be a starting point for developers to integrate a dynamic availability calendar into their site. To do so requires a certain amount of programming knowledge.
Also it can't be simply placed into an html file as it is a dynamic script which requires php or some other dynamic language such as asp to both create the calendar and do the database modifications via ajax.
If you want to include it in an html page, possibly the best solution would be to use an iframe to call the calendar php file directly.

Being a developers script, no login or admin panel is provided as it is assumed that it would be integrated into a current administration panel.
The code does have the ability to "turn-off" the linking by changing the last value in the draw_cal() function to "0" rather than "1" - so, if you have included this in your current administration panel, you would have this value set to "1" so as to be able to modify the date states, whereas if the calendar where being shown in the web, this value would need to be "0".
If you haven't got an admin panel or are not sure how to go about it, there is at least one other thread somewhere in this forum that discusses methods of doing this.

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

Re: New at php/ajax and the availability calendar

Postby lulachamba » Fri Dec 05, 2008 9:57 pm

Oh, is it really that difficult? I thought I could just add
it like those guys for example:

http://www.lanzluxuryvillas.com/propdetail.php?id=147

... and you are right, I do not know about an admin
panel. I just have a web server with PHP installed
(http://www.df.eu/europe/produkte/myhome.html -
the dynamic package). No Joomla or any other cms
with an admin panel. :-/

Greetings
lulachamba
 
Posts: 5
Joined: Thu Dec 04, 2008 4:28 pm

Re: New at php/ajax and the availability calendar

Postby chris » Sat Dec 06, 2008 12:22 pm

It isn't really very difficult, it just needs a very basic understanding of php.
The code can be simply included using the php function include();
Code: Select all
<?php include("calendar.php"); ?>
however the page that includes it must be a php page unless your server is configured to parse html pages as php which is very unlikly.

As you can see from the file extension, http://www.lanzluxuryvillas.com/propdetail.php?id=147 is a php page and I am sure that they had very few problems in integrating the script. That page in particular has an administration panel for the properties so it was just a matter of adding the calendar to the property admin page to be able to modify the dates, and in the web calendar (such as the url that you posted) have the parameter for linking set to "0"

Making a restricted admin page is very simple.
this post has a couple of links to online pages about creating login and restricted pages access.
The simplest method would be to use htaccess to protect the folder where you place the admin version.

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

Re: New at php/ajax and the availability calendar

Postby lulachamba » Wed Dec 10, 2008 6:43 pm

Well, I am working on it and I hope, I will manage to do it. =)

Two more questions:

1. I made a de.lang.php and added

Code: Select all
define("DEFAULT_LANG",   "de");         #   german


to config.inc.php. This does not work properly. If I visit the
page, it shows the text in German, but in the drop-down
there is only "en" and "es". If I change now the months from
3 to any other value, the German text is gone and everything
is back in English. So, it does not work. Changing back to 3
months made no difference.

2. draw_cal() function to "0" or "1 ... This means, I need the
file TWICE times? One for the admin, one for the public? But
if so, how can the public then see linked dates? *wonder*

Thank you very much in advance.

Nice greetings
lulachamba
 
Posts: 5
Joined: Thu Dec 04, 2008 4:28 pm

Re: New at php/ajax and the availability calendar

Postby chris » Wed Dec 10, 2008 7:24 pm

Hello,
...This does not work properly. If I visit the
page, it shows the text in German, but in the drop-down
there is only "en" and "es". If I change now the months from
3 to any other value, the German text is gone and everything
is back in English. So, it does not work. Changing back to 3
months made no difference.

To add the new language to the dropdown box you must add it to the array of languages which, in the demo version, currently holds "en" and "es":
Code: Select all
$languages=array("en","es");

This in on line 167 of the original calendar script page.
so either add your new language there like this:
Code: Select all
$languages=array("en","es","de");

Ideally the code could be easily extended to "detect" all the languages in the language folder but that is beyond the scope of this script.

2. draw_cal() function to "0" or "1 ... This means, I need the
file TWICE times? One for the admin, one for the public? But
if so, how can the public then see linked dates? *wonder*

No, you don't have to have the file twice, you could use a session variable or similar to detect whether the user has permission or not to be able to update the date states.
eg. (assuming that you have a session variable called "user" that was created when the allowed user logged in):
Code: Select all
if($_SESSION["user"]) $update_state="1";
else $update_state="0";

then in the draw_cal() function rather than hard coding the "1" or "0" you place this new variable $update_state

I hope this answers your questions :)
Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: New at php/ajax and the availability calendar

Postby lulachamba » Wed Dec 10, 2008 7:43 pm

Thank you very much. Actually, it was in line 120 ... and I did not change your script. Weird. =)
lulachamba
 
Posts: 5
Joined: Thu Dec 04, 2008 4:28 pm

Re: New at php/ajax and the availability calendar

Postby lulachamba » Wed Dec 10, 2008 10:23 pm

Hello,

It is me again and I think I have finished it nearly. Just
another two questions.

1. At the moment I have three months shown for the
users (not the admin, he has his interface). Is there
somewhere the variable to change this to six months?

2. I did not want to use the table, so I deleted it. My
problem now is, the three months are not shown in a
row from left to right, but in a line from up to down.
I would like to have the first three months from left
to right and another row with the other three monts.
Can you tell me what to change? I just do not understand
where/when the CSS file tells the PHP/HTML file how
to place them.

Here is my code up to now:

PHP file:
Code: Select all
<div id="cali">
      '.$cal_months.'
            <br>
            <img src="'.DIR_IMAGES.'demo_off.png"> '.$lang["key_available"].'
            &nbsp;<img src="'.DIR_IMAGES.'demo_on.png"> '.$lang["key_booked_all"].'
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            calendar script by <a href="http://www.cbolson.com">cbolson.com</a>
   </div>


CSS file:
Code: Select all
div#cali{
   float:left;
   width:600px;
   border:0;
   text-align:center;
   padding:0;
   color:#FFFFFF;
}

.side{
   text-align:right;
   padding-right:4px;
   background:#EEEEEE;
   border-right:6px solid #336699;
   width:140px;
   }
.data{
   border:1px solid #56db37;   

   }
/* END GENERAL LAYOUT STUFF */

/* CALENDAR */
thead td{
   text-align:center;
   color:#000000;
}
.cal_title{
   border:1px;
   background-color:#444;
   text-align:center;
   color:#FFFFFF;
   }
.cal_data{
   text-align:center;
   }
.cal_empty{
   text-align:center;
/*   border:10px solid #EEEEEE;*/
   }


Thank vou veeeeeeeery much in advance.
lulachamba
 
Posts: 5
Joined: Thu Dec 04, 2008 4:28 pm

Re: New at php/ajax and the availability calendar

Postby chris » Wed Dec 17, 2008 11:04 am

...Is there
somewhere the variable to change this to six months?

Yes, change the constant MONTHS_TO_SHOW
2. I did not want to use the table, so I deleted it. My
problem now is, the three months are not shown in a
row from left to right, but in a line from up to down.
I would like to have the first three months from left
to right and another row with the other three monts.
Can you tell me what to change? I just do not understand
where/when the CSS file tells the PHP/HTML file how
to place them.

Why have you removed the tables?
The calendar data consists of tablular data being represented in it's correct form ie. tables.
Anyway, I suggest that you read up on css and general html if you want to start moving things around.
Basically to get divs to align alongside each other you use "float:left" or "float:right".
To start a new line the best way is to place the calendar "divs" within an div holder and give this an exact width such as (eg) width:600px;. This will force the divs onto a new row when they reach the edge.
Alternatively you could use php to count the calendars shown and, if the counter =3 add a linebreak.

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


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron