function rooms_pricing_bulk_pricing_management in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Page callback for Bulk Pricing Management.
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 pricing management page render array.
1 string reference to 'rooms_pricing_bulk_pricing_management'
- rooms_pricing_menu in modules/
rooms_pricing/ rooms_pricing.module - Implements hook_menu().
File
- modules/
rooms_pricing/ rooms_pricing.module, line 338 - Manages pricing for Bookable Units and displaying dates on the jquery FullCalendar plugin.
Code
function rooms_pricing_bulk_pricing_management($year = '', $month = '', $type = 'all') {
// Load FullCalendar and relevant js/css.
rooms_fullcalendar_loaded();
// If year is not set then give it the current date.
$year = $year == '' ? date('Y', time()) : $year;
$month = $month == '' ? date('n', time()) : $month;
$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 or not valid year.
$year_options = range(date('Y', time()) - 2, date('Y', time()) + 5);
if ($month < 1 || $month > 12 || !in_array($year, $year_options)) {
$year = date('Y', time());
$month = date('n', time());
}
$efq = new EntityFieldQuery();
$efq
->entityCondition('entity_type', 'rooms_unit');
$efq
->addTag('rooms_pricing_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;
}
}
// Return the full render array.
return array(
drupal_get_form('rooms_filter_month_form', $month, $year),
drupal_get_form('rooms_pricing_update_form', $month, $year, $type, $units),
array(
'#theme' => 'pager',
),
'#attached' => array(
'css' => array(
drupal_get_path('module', 'rooms_pricing') . '/css/rooms_pricing.css',
),
'js' => array(
drupal_get_path('module', 'rooms_pricing') . '/js/rooms_pricing_management.js',
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',
),
),
),
);
}