function rooms_booking_manager_present_individual_rooms in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Prepares rooms on a per room basis for presentation.
1 call to rooms_booking_manager_present_individual_rooms()
- rooms_booking_manager_results_page in modules/
rooms_booking_manager/ rooms_booking_manager.module - Constructs the booking results page following an availability search.
File
- modules/
rooms_booking_manager/ rooms_booking_manager.module, line 745 - Rooms Booking Manager brings together all the pieces required to find a room and book it - including the DrupalCommerce integration
Code
function rooms_booking_manager_present_individual_rooms($units_per_type, $content, $start_date, $end_date, $booking_parameters) {
$content['style'] = ROOMS_INDIVIDUAL;
drupal_add_css(drupal_get_path('module', 'rooms_booking_manager') . '/css/booking_search.css');
foreach ($units_per_type as $type => $price_level) {
$type_obj = rooms_unit_type_load($type);
$content[$type] = array(
'#prefix' => '<h3 class="rooms-search-result__unit-type-name">',
'#markup' => t($type_obj->label),
'#suffix' => '</h3>',
);
// Sort by least expensive first.
ksort($price_level, SORT_NUMERIC);
foreach ($price_level as $price => $units) {
foreach ($units as $unit_id => $unit) {
// Load the unit and render.
$unit_obj = rooms_unit_load($unit_id);
$controller = entity_get_controller('rooms_unit');
$unit_content = $controller
->view(array(
$unit_id => $unit_obj,
));
$content['units_per_type'][$type][$price][$unit_id] = array(
'#theme' => 'container',
'#attributes' => array(
'class' => array(
'rooms-search-result__unit',
),
),
);
$content['units_per_type'][$type][$price][$unit_id]['unit'] = $unit_content;
// Add purchase form.
$form = 'book_unit_form_' . $unit_id;
$content['units_per_type'][$type][$price][$unit_id]['book_unit_form'] = drupal_get_form($form, $unit_obj, $start_date, $end_date, $booking_parameters, $unit['state'], $unit['price'], $unit['price_log']);
}
}
}
return $content;
}