Thursday 16 February 2012

Changing Joomla Rentalotplus component to take multiple bookings on each unit

Suitable for single user booking systems only

The aim here is to take have a unit/training centre where we can book multiple places ( number set in admin ) on various dates.

As rentalot is a booking system it's designed to book for groups and families, in my scenario users will only be booking for themselves and never for groups .

If your system is for booking groups then the following hack is of no use.


When installed and using the Daily view the process works like

> You see the calendar that shows you available dates

> on the next page you select the dates and click on the 'availability' check

> this then activates the check. it's this check that I've changed and therefor

allowing multiple bookings on the same unit on the same day.


Following the breadcrumbs back from the view I found where to enter the solution in
administrator/components/com_rentalotplus/models/booking.php


if you add the following function to this class

[code]

function maxPeople()
{
$unit_id = $this->_data->unit_id;


$sql="SELECT max_people FROM m37hf_rentalot_plus_units WHERE id='".$unit_id."' ";
$this->_db->setQuery($sql);


$Result = $this->_db->loadObjectList();
//echo "$sql";
//print_r($Result); 
return $Result;




}

[/code]


and then find 'function checkForBookingOverlaps'


UNDER $count = count($rows);


ADD

[code]

//find out how many spaces in the unit
$unitspaces = $this->maxPeople(); //DJ
    $maxPeople=$unitspaces[0]->max_people;
 $maxPeople=$maxPeople-1;
[/code]


then find the condition ($count != 0' )

and change this to


($count > $maxPeople)


No comments: