Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
Did you know that
Elxis 5.x
uses HTML5, CSS3 and pure javascript without external libraries such as jQuery?
Home
Help
Login
Register
Elxis CMS Forum
»
Extensions
»
Components
»
IOSR Hotels v2.3
« previous
next »
Print
Pages:
1
2
[
3
]
4
5
Author
Topic: IOSR Hotels v2.3 (Read 39540 times)
jesusto
Jr. Member
Posts: 68
Re: IOSR Hotels v2.3
«
Reply #30 on:
May 24, 2016, 17:10:34 »
Hi, this is interesting,
Is there also a function like isHotelier?
Thank you
Logged
datahell
Elxis Team
Hero Member
Posts: 10356
Re: IOSR Hotels v2.3
«
Reply #31 on:
May 24, 2016, 19:26:41 »
Yes, IOSR has excellent libraries for such things. In this case we will use the
hotel owner library
(
iosrHotelowner
) of IOSR Hotels.
Quick version without full checks
$is_hotelier = false;
$hotowner = eRegistry::get('icore')->loadx('hotelowner', 'hotels');
$hoid = $hotowner->getHotelierId($elxis->user()->uid);
if ($hoid > 0 { $is_hotelier = true; }
Proper version with full checks
$is_hotelier = false;
if ($elxis->user()->uid > 0) {
$hotowner = eRegistry::get('icore')->loadx('hotelowner', 'hotels');
$hoid = $hotowner->getHotelierId($elxis->user()->uid);
if ($hoid > 0) {
if ($hotowner->load($hoid)) {
if ($hotowner->check(false)) { $is_hotelier = true; }
}
}
}
Notes
1. The
full check
makes sure that both his user and hotelier account is not blocked and not expired.
2. With
$hotowner
instance after successfull load and check you can get all hotelier's details like this:
$info = $hotowner->getHotelier();
3. If you work outside IOS Reservations (like in a module) you must create a function to load/get
IOSR core
instance. This is done with the help of
Elxis registry
library (
documentation here
). IOSR core is required to access any IOSR extension or library. The function below will just do that:
function loadgetIOSR() {
if (eRegistry::isLoaded('icore')) { return eRegistry::get('icore'); }
if (!file_exists(ELXIS_PATH.'/components/com_reservations/includes/ios.core.php')) { return false; }
elxisLoader::loadFile('components/com_reservations/includes/ios.core.php');
eRegistry::set(new iosCore(), 'icore');
return eRegistry::get('icore');
}
$iosr = loadgetIOSR();
«
Last Edit: May 24, 2016, 19:36:51 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
jesusto
Jr. Member
Posts: 68
Re: IOSR Hotels v2.3
«
Reply #32 on:
May 24, 2016, 22:54:19 »
Great tutorial Datahell,
It is very appreciated.
Good work!!
Thank you
Logged
MangPutra
Newbie
Posts: 3
Re: IOSR Hotels v2.3
«
Reply #33 on:
May 28, 2016, 05:40:29 »
To
Wieyoga:
Yes iam from bali, and iam not a developer, a web designer or a coding.
i hove anyone can help me for this. Suksma.
To
datahell
Yes you are right JoomlaHBS is very expensive.. that why i Choose your software.. not only cheap but very complete and powefull.
Could you help to develope the
channer manager
? and what is the cost for that work.
I am very sure with this feature we not lost our hotel partner than our competitor
«
Last Edit: May 28, 2016, 05:43:46 by MangPutra
»
Logged
juanon
Full Member
Posts: 109
Re: IOSR Hotels v2.3
«
Reply #34 on:
May 28, 2016, 15:47:19 »
Hi,
I need to get some hotel data in my
elxis default template
to show, for example, the title.
I have this code that isn´t working:
function loadgetIOSR() {
if (eRegistry::isLoaded('icore')) { return eRegistry::get('icore'); }
if (!file_exists(ELXIS_PATH.'/components/com_reservations/includes/ios.core.php')) { return false; }
elxisLoader::loadFile('components/com_reservations/includes/ios.core.php');
eRegistry::set(new iosCore(), 'icore');
return eRegistry::get('icore');
}
$hid = (defined('IOSR_HOTEL')) ? (int)IOSR_HOTEL : 0;
if ($hid > 0) {
$iosr = loadgetIOSR();
$helper = $iosr->loadOnce('hothelper', 'hotels');
echo '<p><strong>THE HOTEL NAME IS: </strong> '.$hotel->title.''."</p>\n";
}
Can someone tell me what I´m doing wrong, please?
Thanks a lot.
Logged
juanon
Full Member
Posts: 109
Re: IOSR Hotels v2.3
«
Reply #35 on:
June 01, 2016, 19:47:27 »
Any help, please?
Thank you
Logged
datahell
Elxis Team
Hero Member
Posts: 10356
Re: IOSR Hotels v2.3
«
Reply #36 on:
June 01, 2016, 21:50:10 »
There is no
$hotel
object defined in your code, so
$hotel->title
is wrong and will return error. You must first query the database to load hotel data, then use that data.
Simple example without multilingual content:
$hid = 23;//change with the id of the hotel you want to display
$db = eFactory::getDB();
$sql = "SELECT h.hid, h.title, h.seotitle AS seohotel, h.description, h.lid, h.stars, h.defimage, h.rscore, h.reviews, l.country, l.title AS location, l.seotitle, l.seolink"
."\n FROM ".$db->quoteId('#__res_hotels')." h"
."\n INNER JOIN ".$db->quoteId('#__res_locations')." l ON l.lid = h.lid"
."\n WHERE h.published = 1 AND h.hid = ".$hid;
$stmt = $db->prepareLimit($sql, 0, 1);
$stmt->execute();
$hotel = $stmt->fetch(PDO::FETCH_OBJ);
if (!$hotel) {
echo 'Hotel '.$hid.' not found!';
} else {
echo 'Hotel title: '.$hotel->title.'<br />';
echo 'Hotel location: '.$hotel->location.'<br />';
}
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
juanon
Full Member
Posts: 109
Re: IOSR Hotels v2.3
«
Reply #37 on:
June 01, 2016, 23:00:21 »
Thank you,
It works now!!
Could you please leave a multilingual example?
Thanks a lot
Logged
webgift
Elxis Team
Hero Member
Posts: 4193
Re: IOSR Hotels v2.3
«
Reply #38 on:
June 03, 2016, 11:40:48 »
You could use your template's language files by creating new elements on $_lang array. For
example the english version could be done:
File in language directory: en.tpl_mytpl.php
$_lang['HNOT_FOUND'] = 'Hotel %s not found!';
$_lang['HOT_TITLE'] = 'Hotel title:';
$_lang['HOT_LOCATION'] = 'Hotel location:';
Now edit the source code datahell's send you by changing the lines:
1.
echo 'Hotel '.$hid.' not found!';
to
echo sprintf($eLang->get('HNOT_FOUND'), %hid);
2.
echo 'Hotel title: '.$hotel->title.'<br />';
to
echo $eLang->get('HOT_TITLE').' '.$hotel->title.'<br />';
and 3.
echo 'Hotel location: '.$hotel->location.'<br />';
to
echo $eLang->get('HOT_LOCATION').' '.$hotel->location.'<br />';
Logged
Elxis Team •
Custom web design [EN]
-
[EL]
•
.GR Registrar
juanon
Full Member
Posts: 109
Re: IOSR Hotels v2.3
«
Reply #39 on:
June 03, 2016, 15:34:26 »
Hi,
Thanks a lot webgift.
But what I want is to get multilingual data from hotels.
For example hotel description in several languages.
Thanks a lot
Logged
datahell
Elxis Team
Hero Member
Posts: 10356
Re: IOSR Hotels v2.3
«
Reply #40 on:
June 03, 2016, 22:00:05 »
Translations require complex code and queries.
METHOD 1
I write an example below as a continue of my previous code.
There are many multilingual items on a hotel, I don't know what you want to display. This will set multilingual
hotel title
only. For location, description, etc, the query needs to be modified.
$elxis = eFactory::getElxis();
if ($elxis->getConfig('MULTILINGUISM') == 1) {
$lng = eFactory::getURI()->getUriLang();
if ($lng != '') {
$hid = $hotel->hid;
$trcat = 'com_reservations';
$elem = 'hottitle';
$sql = "SELECT ".$db->quoteId('translation')." FROM ".$db->quoteId('#__translations')
."\n WHERE ".$db->quoteId('category')." = :xcat AND ".$db->quoteId('element')." = :xelem"
."\n AND ".$db->quoteId('language')." = :lng AND ".$db->quoteId('elid')." = :xid";
$stmt = $this->db->prepareLimit($sql, 0, 1);
$stmt->bindParam(':xcat', $trcat, PDO::PARAM_STR);
$stmt->bindParam(':xelem', $elem, PDO::PARAM_STR);
$stmt->bindParam(':lng', $lng, PDO::PARAM_STR);
$stmt->bindParam(':xid', $hid, PDO::PARAM_INT);
$stmt->execute();
$trans = $stmt->fetchResult();
if ($trans) {
$hotel->title = $trans;
}
}
}
For everything in IOS Reservations the translation category is "com_reservations"
The element name for hotel title is
hottitle
, for hotel description is hotdesc, for location title is
loctitle
, for room title is
roomtitle
, for room description is
roomdesc
, etc...
Depending on which is the translation element the translation element id (
elid
) must be set to hotel id (hid), location id (lid), room id (rid), etc.
METHOD 2
The code below is superior than the previous example which used sql query to get hotel title. It uses
IOSR db model
to load all hotel translations without need to write sql queries:
$elxis = eFactory::getElxis();
if ($elxis->getConfig('MULTILINGUISM') == 1) {
$lng = eFactory::getURI()->getUriLang();
if ($lng != '') {
elxisLoader::loadFile('components/com_reservations/models/base.model.php');
elxisLoader::loadFile('components/com_reservations/ext/hotels/models/hotels.model.php');
$model = new hotelsIOSRM();
$translations = $model->elementTrans($hotel->hid, $lng);
if ($translations) {
foreach ($translations as $element => $translation) {
switch($element) {
case 'hottitle': $hotel->title = $translation; break;
case 'hotdesc': $hotel->description = $translation; break;
case 'hotterms': $hotel->terms = $translation; break;
default: break;
}
}
}
}
}
If you pick method 2 you can also use IOSR Hotels model to get the full hotel data without executing sql queries:
$hotel = $model->fetchHotel($hid);
//that's all!
To load hotel you can also use standard Elxis
database table
library:
elxisLoader::loadFile('components/com_reservations/ext/hotels/includes/db/hotels.db.php');
$hotel = new hotelsDbTable();
$hotel->load($hid);
This way you can load anything from db but for third party component requires first to include the x.db.php file. For Elxis tables you dont need that because Elxis does it automatically for you! For example to load an article with id 5 just use this:
$article = new contentDbTable();
$article->load(5);
«
Last Edit: June 03, 2016, 22:30:13 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
juanon
Full Member
Posts: 109
Re: IOSR Hotels v2.3
«
Reply #41 on:
June 04, 2016, 18:52:11 »
Great explanation, Datahell.
Thanks a lot for taking the time to write such a good tutorial.
Regards
Logged
webgift
Elxis Team
Hero Member
Posts: 4193
Re: IOSR Hotels v2.3
«
Reply #42 on:
June 05, 2016, 13:47:07 »
As far as i can see, using the 2nd method you can get translations for location and rooms
instead of hotels for example: loctitle, roomtitle, roomdesc!
Logged
Elxis Team •
Custom web design [EN]
-
[EL]
•
.GR Registrar
juanon
Full Member
Posts: 109
Channel managers will kill my business
«
Reply #43 on:
June 16, 2016, 12:33:15 »
Hi,
I´m a bit down with IOSR hotels right now. Due to "new rules in hotel marketing" it is not possible to earn a living or even get an extra income...
The system is really solid and the price is very very good, but I can´t bring new users to my portal and old ones are leaving...
They all want to use a channel manager and even a PMS integrated with the booking engine... They all are willing to pay more but don´t want to mantein availability in eight or ten different accounts... and I can understad that.
I would like to pay a develeper to integrate IOSR at least with booking.com and agoda but I can´t even find a developer booking.com API to achieve this.
What can I do? I know IOSR API is really good but it doesn´t seem to be enough with that.
Any ideas?
What´s your opinion?
Thanks
Logged
wieyoga
Jr. Member
Posts: 77
Re: Channel managers will kill my business
«
Reply #44 on:
June 17, 2016, 08:39:15 »
Hi Juanon,
From my point of view, The IOSR system is already support the connection ( XML API ).
what you need to do is contact the channel manager company to connect to IOSR
«
Last Edit: June 17, 2016, 08:42:03 by wieyoga
»
Logged
Online hotel reservation -
http://www.easyresv.com
Print
Pages:
1
2
[
3
]
4
5
« previous
next »
Elxis CMS Forum
»
Extensions
»
Components
»
IOSR Hotels v2.3