Unique Calendar IDs?

Help with installation and general calendar setttings

Re: Unique Calendar IDs?

Postby chris » Thu Jul 07, 2011 11:35 pm

Sorry,
I should have explained it better.
The draw_cal() function is a php function and is the center part of the calendar script.
It can be found in ac-includes/functions.inc.php

You basically need to modify the mysql query so that it uses the id_ref_external field
So this:
Code: Select all
$sql = "
   SELECT
      t1.the_date,
      t2.class,
      t2.desc_".LANG." AS the_state
   FROM
      ".T_BOOKINGS." AS t1
      LEFT JOIN ".T_BOOKING_STATES." AS t2 ON t2.id=t1.id_state
   WHERE
      t1.id_item=".$id_item."
      AND MONTH(t1.the_date)=".$month."
      AND YEAR(t1.the_date)=".$year."
   ";

becomes this:
Code: Select all
$sql = "
   SELECT
      t1.the_date,
      t2.class,
      t2.desc_".LANG." AS the_state
   FROM
      ".T_BOOKINGS." AS t1
      LEFT JOIN ".T_BOOKING_STATES." AS t2 ON t2.id=t1.id_state
   WHERE
      t1.id_ref_external=".$id_item."
      AND MONTH(t1.the_date)=".$month."
      AND YEAR(t1.the_date)=".$year."
   ";

However, bear in mind that this function is also used by the admin panel so you will also need to modify the ac-admin/bookings.admin.php file so that it also passes this id_ref_external value as oposed to the default "id" field.
I'll let you take a look at that otherwise I will try to outline the changes required tomorrow (it is close to midnight here)
Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Unique Calendar IDs?

Postby JRC » Fri Jul 08, 2011 2:03 am

Chris:

Thanks, I knew it had to be in there somewhere. I will test this Friday morning and let you know the result. I presume that once this is resolved, the "id_ref_external" will work for both the iframe and php methods (which will be my final "cleaned up" version).

Beyond that, your Open Realty addon probably uses OR's "listingID" more directly.

Thanks,

John
JRC
 
Posts: 6
Joined: Thu Jul 07, 2011 8:08 pm

Re: Unique Calendar IDs?

Postby chris » Fri Jul 08, 2011 8:51 am

Hi,
Yes, my addon completley integrates in the OR admin panel and uses OR user and listing data.

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

Re: Unique Calendar IDs?

Postby JRC » Sat Jul 09, 2011 2:04 am

Chris:

I proceeded with your suggestion to change the function.inc.php file:

Code: Select all
$sql = "
   SELECT
      t1.the_date,
      t2.class,
      t2.desc_".LANG." AS the_state
   FROM
      ".T_BOOKINGS." AS t1
      LEFT JOIN ".T_BOOKING_STATES." AS t2 ON t2.id=t1.id_state
   WHERE
      t1.id_ref_external=".$id_item."
      AND MONTH(t1.the_date)=".$month."
      AND YEAR(t1.the_date)=".$year."
   ";

Unfortunately, this resulted in getting a correct heading description displayed on the calendar, but in drawing the calendar months this Error appears in place of each month:

"ERROR checking id item availability dates
Unknown column 't1.id_ref_external' in 'where clause'"

I reverted to the original "id_item" but started getting additional errors that seemed related to not getting the correct data for the "default_lang" variable (en in my situation). Very strange, but I compared all file changes and could not find any glitches. The errors were like:

Error "---- /calendar/ac-contents/lang/.lang.php not found"
which should have come out "/calendar/ac-contents/lang/en.lang.php"

I added a ".lang.php" file in order to continue debugging, and then got "Error getting states"

Then changed the cal.inc.php line 98+/- from 'id,class,desc_".LANG." ' to hard code "desc_en" and got back "Error getting item name" and so on.

So I proofed all the code back to original, and then hard coded in the "en" where needed in the functions.inc.php file (as in "t2.desc_en AS the_state"), and in the cal.inc.php file (as in "$sql="SELECT id,class,desc_en AS the_desc FROM..."), and etc. before I could get it running again.

The test site is running now, but only works with the OR listingID driving the "id_item" - hence they must match up to call the correct calendar.

Unfortunately, this kept me too busy to work on the "bookings.admin.php" file. I will continue some more this weekend and more on Monday.

Where can I get your Open Realty addon version? I do not find any references to it. Happy to pay for it too.

Thanks,

John
JRC
 
Posts: 6
Joined: Thu Jul 07, 2011 8:08 pm

Re: Unique Calendar IDs?

Postby chris » Sat Jul 09, 2011 8:49 am

Hi John,

It sounds like this is getting a bit messy :(
Where can I get your Open Realty addon version? I do not find any references to it. Happy to pay for it too.

I have not published my availability calendar addon anywhere so that is why you can not find any references to it.
It is used on a few sites however, most recently this one: http://www.championvillas.com/
As you are probably aware from your work so far, OpenRealty is quite a tricky system and installing this addon does require some php work.
I will send you a pm to my demo link for the addon so that you can take a look at it in action within the admin panel.

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

Re: Unique Calendar IDs?

Postby JRC » Mon Jul 11, 2011 8:44 pm

Chris:

Changing the ac-includes/functions.inc.php file so the WHERE clause is set to "id_ref_external" did not work out. Plus along the way the default language issue arose. I think I have solved these now.

1) the lang issue: found your admin logon correction and implemented that, then returned all the hardcoded "desc_en" changes back to the desc_".lang." -- seems to be working out.

2) To call the calendar using the "id_ref_external" (or someday just the Open Realty's "listingID"), I only needed to change the "ac-includes/cal.inc.php" file, plus a matching iframe call, as follows. The cal works fine in OR, and the cal admin works fine to add a calendar, modify it etc. One only needs to make sure that the "id_ref_external" is entered to match the OR's "listingID"

New iframe implementation:
Code: Select all
<!-- begin calendar iframe link - Note - can not set xhtml strict DTD for parent page -->
<?php
$listingID = $_GET["listingID"]; // needed to pass variable until htaccess is updated
// next line uses id_ref_external not id_item
echo "<iframe width=\"510\" height=\"600\" src=\"calendar/?id_ref_external=$listingID\" frameborder=\"0\" scrolling=\"no\"></iframe>";
?>
<!-- end calendar addon link -->


and revised ac-includes/cal.inc.php to set the id_ref_external, and then use it in the WHERE clause (WHERE id_ref_external=".$id_ref_external." AND state=1):
Code: Select all
// define id-ref-external
define("ID_REF_EXTERNAL",   $_REQUEST["id_ref_external"]);
//   define id of item to modify
if(isset($_REQUEST["id_item"]))       define("ID_ITEM",   $_REQUEST["id_item"]);   #   id sent via  url, form session etc
else{
   //   define default id manually
   //   define("ID_ITEM",   2);                  
   //   or
   //   get first item from list
   $sql="SELECT id FROM ".T_BOOKINGS_ITEMS." WHERE id_ref_external=".$id_ref_external." AND state=1 ORDER BY list_order ASC LIMIT 1";
   $res=mysql_query($sql) or die("Error checking items<br>".mysql_Error());
   if(mysql_num_rows($res)==0){
      //   no items in db
      $no_id=true;
   }else{
      $row=mysql_fetch_assoc($res);
      define("ID_ITEM",   $row["id"]);
   }
}


Along the way, one also needs to review doc types, as the Open Realty template I used was originally xhtml strict, which does not validate with an iframe. Since most of OR's template also was not valid strict, I changed to xhtml transitional and so-far, so-good.

Beyond this, it should be easy to convert the iframe to the php implementation method, and to use the OR listingID directly. Unfortunately, this method does not work when OR's pages are set to seo friendly url's, only when the listingID is set in the url. Oh well.

Thanks again. I'll look over the OR addon demo.

John
JRC
 
Posts: 6
Joined: Thu Jul 07, 2011 8:08 pm

Re: Unique Calendar IDs?

Postby Chris_J » Thu Oct 13, 2011 11:44 pm

Sorry to dredge up an old thread...

I'm trying to display two calendars (items) at once using the PHP implementation.

I understand that you can define a specific calendar using $_REQUEST["item_id"]=x.

What I'm not sure is how to do this to show two 'side by side'. I tried creating a separate include for each calendar with $_REQUEST["item_id"]=x defined at the top of each file and calling them but this only leads to the first calendar being shown.

Any help would be appreciated.

I can send some code it that's helpful.

Thanks,

Chris
Chris_J
 
Posts: 5
Joined: Thu Oct 13, 2011 11:35 pm

Re: Unique Calendar IDs?

Postby chris » Fri Oct 14, 2011 10:06 pm

I'm afraid that there is a lot more to this than meets the eye.
Even if you attempt to include the calendar code several times, php will actually only include it once as it uses require_once(). You could change this to simply require().

However then you will need to extensively modify the JavaScript code to tell it that it needs to modify two calendars.....

I would think that it might be better to modify the code to show the 2 calendars directly in one go but again that would require a fair amount of coding too.

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

Re: Unique Calendar IDs?

Postby Chris_J » Sat Oct 15, 2011 3:06 pm

Hi Chris,

Thanks for the quick response. I think I'll just settle for the drop-down option you've provided.

Cheers,

Chris
Chris_J
 
Posts: 5
Joined: Thu Oct 13, 2011 11:35 pm

Re: Unique Calendar IDs?

Postby andy-in-spain » Sun Dec 04, 2011 3:19 pm

chris wrote:Hi,
To define a calendar to show you simply need to pass the "id_item" to the calendar script.
If you are using an iframe you just append this to the url something like this:
Code: Select all
<iframe width="700px" height="400px" src="/calendar/index.php?id_item=2"></iframe>

If you are using the php implentation you need to define it before you include the cal.inc.php file like this:
Code: Select all
$_GET["id_item"]=2;


Chris


Hi Chris.
Where exactly does the $_GET["id_item"]=2; fit in? Is it supposed to go in the coding before the header?

I have tried several ideas but cannot get it to work so please give me a clue.

Thanks
Andy
andy-in-spain
 
Posts: 2
Joined: Sun Dec 04, 2011 3:13 pm

PreviousNext

Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests

cron