Currently when an availability search is performed (in the case of display rooms by type), and a booking for a number of rooms is completed by a user, the actual rooms allocated seem to be more or less random. For my use case, it would be better to have the rooms for a single booking to be in a consecutive block.

Is it possible to sort the initial results of an availability search prior to rooms being assigned to a booking, say by increasing order of unit_id? This would satisfy my use case.

Even better would be to add a field to the bookable_unit (eg booking_priority) and display this field in the unit's edit page [siteurl/admin/rooms/units/unit/1/edit]. That way the site administrator could have some control of the order in which units are booked via the web facing user interface (eg best available, or adjoining rooms), without needing to manually re-assign rooms according to in-house priorities. This would be a more customizable approach that would satisfy more use cases.

CommentFileSizeAuthor
#1 screenshot_dpm.jpg140.22 KB1an_m
#1 screenshot_booking_cart.jpg46.96 KB1an_m

Comments

1an_m’s picture

StatusFileSize
new46.96 KB
new140.22 KB

I've made some progress on the simpler version (sort by unit_id). I've figured out where I need to make the change .... but am not sure how to do it!

/modules/rooms_booking_manager/rooms_booking_manager.module
about line 1400

  $agent = new AvailabilityAgent($sd, $ed, $booking_parameters, $b_units, array());
  $agent->setValidStates(variable_get('rooms_valid_availability_states', array(ROOMS_AVAILABLE, ROOMS_ON_REQUEST)));

  $units_per_type = $agent->checkAvailability();
  // sort function needs to go here - to sort array of available units by increasing order of unit_id

  $j = 0;

  // We are going to check that this is still true - but let us try and service the order
  foreach ($order as $type => $price_serving) {

I put a dpm($units_per_type) at this point (see image) and the array $units_per_type consists of
bookable_unit_type
price
unit_id
I have added unit_id to the booking cart view, so it is possible to see that the array of units is added to the line items from the top of the array until the quantity required is satisfied.

I need to find a way to sort the array $units_by_type in ascending order of unit_id prior to allocating the units one by one to the line items, but am not sure how to do it.