function rooms_availability_bulk_unit_management in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Form for the Bulk Availability Management.
Could receive date params for the interested interval to edit.
Parameters
string $year: Year to perform the operations.
string $month: Month to perform the operations.
string $type: Bookable unit type to perform the operation.
Return value
array Bulk availability management page render array.
1 string reference to 'rooms_availability_bulk_unit_management'
- rooms_availability_menu in modules/
rooms_availability/ rooms_availability.module - Implements hook_menu().
File
- modules/
rooms_availability/ rooms_availability.module, line 149 - Manages availability for Bookable Units and displaying dates on the jquery FullCalendar plugin.
Code
function rooms_availability_bulk_unit_management($year = '', $month = '', $type = 'all') {
// Load FullCalendar.
rooms_fullcalendar_loaded();
// Modal includes and style.
rooms_availability_modal_style();
// If year is not set then give it the current date.
$year = $year != '' && is_numeric($year) ? $year : date('Y', time());
$month = $month != '' && is_numeric($month) ? $month : date('n', time());
$type = $type == '' ? 'all' : $type;
// It's not a valid unit type.
if (rooms_unit_get_types($type) == FALSE) {
$type = 'all';
}
// It's not a valid month.
if ($month < 1 || $month > 12) {
$month = 1;
}
$efq = new EntityFieldQuery();
$efq
->entityCondition('entity_type', 'rooms_unit');
$efq
->addTag('rooms_availability_access');
if ($type != 'all') {
$efq
->entityCondition('bundle', $type, '=');
}
$efq
->pager(20);
$rooms_units = $efq
->execute();
$rooms_id = $units = array();
if ($rooms_units) {
$units = array_values(entity_load('rooms_unit', array_keys($rooms_units['rooms_unit'])));
$rooms_id = array();
foreach ($units as $value) {
$rooms_id[] = $value->unit_id;
}
}
$js_file = drupal_get_path('module', 'rooms_availability') . '/js/rooms_unit_management.js';
$css_file = drupal_get_path('module', 'rooms_availability') . '/css/rooms_availability.css';
// Show full day events on calendar.
if (variable_get('rooms_calendar_events_view', '0') == '1') {
$js_file = drupal_get_path('module', 'rooms_availability') . '/js/rooms_unit_management_full_day.js';
}
// Return the full render array.
return array(
drupal_get_form('rooms_filter_month_form', $month, $year),
drupal_get_form('rooms_availability_update_status_form', $month, $year, $type, $units),
array(
'#theme' => 'pager',
),
'#attached' => array(
'css' => array(
$css_file,
),
'js' => array(
$js_file,
drupal_get_path('module', 'rooms') . '/js/rooms_fullcalendar_singlerowmonth.js',
array(
'data' => array(
'roomsUnitManagement' => array(
'roomsNumber' => count($rooms_id),
'currentMonth' => $month,
'currentYear' => $year,
'roomsId' => $rooms_id,
),
),
'type' => 'setting',
),
),
),
);
}