How-To: Hotel Management System for Elastix

March 18, 2010 Chilling_Silence Elastix.org Blog

Two blog posts in 24 hours? We’re on a roll here!
Based off PIAF’s Hotel Management System, we’re going to make some minor adjustments to have this work with Elastix. This is a brilliant Hotel Room Management system with the ability to restrict the calls from Ext’s when they are not checked in, per-second billing, and more!

Contents:

  1. Installing the base system
  2. Updating the config
  3. Fixing up HTTPS
  4. Updating dial-plan
  5. Closing words

1) Installing the base system

First you’re going to need to ssh in to your Elastix PBX System.
Then, run the following:

cd /var/www/html
wget http://www.kefa.it/hotel.tar.gz
tar zxvf hotel.tar.gz
rm hotel.tar.gz
cd hotel
mysql -uroot -peLaStIx.2oo7 < Hotel.sql

Very similar to the default steps taken on the official documentation, except we’re going to use the Elastix SQL password rather than the script they’ve got there. This is also easier than the official doco, just one step instead of two.

2) Updating the config

We’re now going to modify the configuration file so that it works with Elastix due to the different Username / Passwords used between distributions.
Edit config.inc.php with your favorite editor. In my case I use nano:
nano -w config.inc.php

Now you’re going to modify the following three paragraphs so that they match below:

//Hotel database
$dbhost = "localhost";
$dbpass = "eLaStIx.2oo7";
$dbuser = "root";
$dbname = "Hotel";

//Asterisk database
$dbhost2 = "localhost";
$dbpass2 = "eLaStIx.2oo7";
$dbuser2 = "root";
$dbname2 = "asterisk";

//Asteriskcdrdb database
$dbhost3 = "localhost";
$dbpass3 = "eLaStIx.2oo7";
$dbuser3 = "root";
$dbname3 = "asteriskcdrdb";

Save and exit and you’re done with the config.

3) Fixing up HTTPS

When you visit the Elastix WebGUI, there’s a condition that rewrites the URL to include HTTPS. However, when this system tries to check the state of an Extension, it must do it via HTTP and not HTTPS, so we add an exception.

Edit /etc/httpd/conf.d/elastix.conf with your favorite editor and add these lines at the very bottom:

RewriteEngine Off

What this will do is add the /hotel directory as an exception so you don’t have to use HTTPS to get to it. We leave HTTPS on for the rest of the PBX, just because there’s no real reason for us to turn it off.
Now, restart apache with:

/etc/init.d/httpd restart

You should now be able to access your WebGUI without HTTPS at: http://pbxip/hotel/
If not, then go back and try again, as this part is crucial to the redirection to Reception when a phone is not Checked In

4) Updating dial-plan

Now we’re going to add in to the Dial-Plan and tell the PBX what calls can and cannot be made when the phone is not Checked-In.

Edit /etc/asterisk/extensions_custom.conf in your favorite editor and add the following underneath the [from-internal-custom] header:

;lets guests call other rooms without being checked in
exten => _XXX,1,Dial(SIP/${EXTEN})
exten => _XXX,n,Hangup()
;lets guests call freephonenumbers without being checked in
exten => _1800NXXXXXX,1,Goto(outbound-allroutes,${EXTEN},1)
exten => _1800NXXXXXX,n,Hangup()
exten => _X.,1,Set(result=${CURL(http://127.0.0.1/hotel/checkuser.php?Ext=${CALLERID(num)})})
exten => _X.,n,NoOp(Results: ${result})
exten => _X.,n,GotoIf($["${result}" = "OK"]?OK)
exten => _X.,n,GotoIf($["${result}" = "KO"]?KO)
exten => _X.,n(OK),Goto(outbound-allroutes,${EXTEN},1)
exten => _X.,n,Hangup()
;call front desk if not checked in
exten => _X.,n(KO),Dial(SIP/200) ; used for just one extension
;exten => _X.,n(KO),Goto(ext-group,0,1) ; used for ring groups
exten => _X.,n,Hangup()

If you want to allow additional free calling, just duplicate the lines with “1800” in them. Mines quite different for New Zealand, but I’ve left it as american to give you a good idea of what you can do there.
You’re also going to want to adjust the third-to-last line where it says “SIP/200”, replacing 200 with the Extension of Reception.
Or, you could just comment that line out, and uncomment the second-to-last line to use Ring Group 0 as your “Reception” extension. The choice is yours.
Save the file and run:

asterisk -rx "dialplan reload"

5) Closing words

From here, you’re on your own. It’s dead easy to log in and get started. You’ll first need to import all the rooms which it takes from the Ext Caller ID name, so it pays to give your Ext’s decent names like “Room 201” for Ext 201, just for example.
If you run into troubles, post here and myself or the Elastix team would be more than happy to assist.
If you get this successfully installed, just leave us a quick comment to say Hi and tell us you’ve done so, it’s always nice to know our time is appreciated.
Cheers

Chill.

Asterisk, check in, check out, Elastix, Hotel Integration,


Leave a Reply

Powered by WordPress. Designed by elogi.