Contents
- Index
The Booking Engine
This section is a brief discussion regarding the operation of the booking engine.
The booking engine in Jomres is an AJAX driven booking engine designed to make the process of finding available rooms in a property as simple as possible. We use AJAX because it allows the user to experiment with their requirements without having to use the tired old Click -> Submit routine that normally would be used to find and book a room on a truly real time system, or the substantial costs involved with interfacing with a GDS.
The booking engine's main goals are to be as simple as possible to use, removing as many decisions from the hands of the user as possible, guiding them through supplying all the information that they need to enable the system to take a booking from them.
The files
Whilst all operations in Jomres go through the file jomres.php the main files used to generate and perform the booking are done through
jomres.js
dobooking.php
handlereq.php
dobooking_functions.php and
j05000bookingobject.class.php
jomres.js contains all of the booking form Javascript (excluding the actual AJAX Javascript class).
dobooking.php generates the booking form when the user selects the booking link. It builds all of the data required to construct the booking form, initialises the booking data in the Jomres internal sessions and calls the booking form template file.
handlereq.php handles all the AJAX queries from the booking form.
dobooking_functions.php contains the booking object class
j05000bookingobject.class.php is called by dobooking.php and handlereq.php, extends the booking object found in dobooking_functions.php.
All of the booking engine functionality is provided by the jomres_booking class. This class isn't called directly, rather it is called and extended by the booking class which can be found in j05000bookingobject.class.php. The reason we don't call the file directly is fairly straightforward: by creating a new object booking and putting it into a minicomponent of it's own, it's simple enough to override the basic workings of the booking engine without actually editing any of the core Jomres files. To see an example of that install the bookingform_noroomtypeicons Internal Plugin and open j05000bookingobject.class.php in the components/com_jomres/remote_plugins/bookingform_noroomtypeicons directory.
How it works
When a user clicks on an element in the booking form, depending on the element selected the Javascript will trigger an AJAX query which will call the option com_jomres, and the task handlereq. The handlereq task then triggers the inclusion of handlereq.php.
handlereq.php determines the element changed in the booking form and puts this into the variable $field, then handlereq.php will call various class methods depending on which element was changed. When this is done available & selected rooms are returned as output to the booking form and then the show_log Javascript function is triggered. This again calls the handlereq task and any messages required are passed back to the user, as are pricing information and finally, if the booking form is judged to be complete, the Review Booking button is enabled.
The aim of the booking form is to construct a booking in the tmpbookings and tmpguests tables. *Updated: temporary data is now handled by session variables. There are two types of information that are passed to handlereq, Booking Particulars and 'other data'. Booking Particulars are details about the booking that will potentially cause the list of available rooms to change, either by changing guest numbers, smoking options or of course the dates of the booking itself. Other data would be guest names, selected extras etc.
When one of these particulars is changed the system will build the booking object and query all of the rooms on the system using the following methods:
getAllRoomUidsForProperty
findFreeRoomsInDateRange
checkPeopleNumbers
checkSmokingOption
removeFromSelectedRooms
removeRoomuidsAlreadyInThisBooking
getTariffsForRoomUids
The names of the methods are fairly descriptive, but in short all of the room ids are found, and by a gradual process of elimination all rooms who's various status fails to match a given set of criteria are dropped from the $freeRoomsArray variable. This last set of rooms is sent then to the getTariffsForRoomUids method, which will find any tariffs who's criteria also match the particulars of the booking. If a tariff passes then the room id is concatenated to the tariff id with a hat (^) symbol (eg. 3^20). An array of these rooms/tariff ids is built up and eventually this is passed back out of the method. This concatenation allows us to offer a room multiple times for as many tariffs as are valid in that period, so you can for example offer numerous different tariffs over the same time period, offering eg Simple Bed and Breakfast, or Bed, Breakfast and Evening meal tariffs for the same room over the same time period.
This array of room ids and tariff ids is then passed to the generateRoomsList method which actually creates the lists of available and selected rooms for display in the booking form.
Once the rooms list has been passed back show_log is called, and depending on what was previously changed it may or may not recalculate the price list. If Yes, then the generateBilling method is called, this will trigger the pricing calculations to be performed, then finally various data is returned to the jomres.js script and evaluated using mainly the getElementById Javascript function to set various divs in the booking form to the updated fields.