Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/rooms_booking/rooms_booking.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function rooms_booking_edit_form($form, &$form_state, $booking) {

$form['data']['group_size_children'] = array(
'#type' => 'select',
'#title' => t('Children'),
'#title' => variable_get_value('rooms_booking_manager_children'),
'#options' => rooms_range(0, $persons),
'#default_value' => isset($booking->data['group_size_children']) ? $booking->data['group_size_children'] : '0',
'#description' => t('The number of children staying in this unit.'),
Expand All @@ -322,7 +322,7 @@ function rooms_booking_edit_form($form, &$form_state, $booking) {
for ($t = 1; $t <= $form_state['values']['data']['group_size_children']; $t++) {
$form['data']['childrens_age'][$t] = array(
'#type' => 'textfield',
'#title' => t('Age of child @num', array('@num' => $t)),
'#title' => variable_get_value('rooms_booking_age_of_child') . ' ' . $t,
'#size' => 5,
'#maxlength' => 5,
'#ajax' => array(
Expand All @@ -337,7 +337,7 @@ function rooms_booking_edit_form($form, &$form_state, $booking) {
foreach ($booking->data['childrens_age'] as $key => $age) {
$form['data']['childrens_age'][$key] = array(
'#type' => 'textfield',
'#title' => t('Age of child @num', array('@num' => $key)),
'#title' => variable_get_value('rooms_booking_age_of_child') . ' ' . $key,
'#size' => 5,
'#maxlength' => 5,
'#default_value' => $age,
Expand Down Expand Up @@ -448,7 +448,7 @@ function rooms_booking_edit_form($form, &$form_state, $booking) {
$unit_selected .= t('(Options: !options)', array('!options' => substr($options_list, 0, strlen($options_list) - 2)));
}
if (isset($booking->price)) {
$unit_selected .= '<br />' . t('Price') . ': ' .
$unit_selected .= '<br />' . variable_get_value('rooms_booking_price') . ': ' .
t('@currency_symbol @amount', array( // TODO: replace with a proper currency formatter
'@currency_symbol' => $currency_symbol,
'@amount' => number_format($booking->price / 100, 2, '.', ''),
Expand Down Expand Up @@ -689,7 +689,7 @@ function rooms_booking_edit_form($form, &$form_state, $booking) {

$form['availability_fieldset']['unit_fieldset']['options_fieldset']['price'] = array(
'#type' => 'textfield',
'#title' => t('Price'),
'#title' => variable_get_value('rooms_booking_price'),
'#default_value' => '',
'#size' => '10',
'#required' => TRUE,
Expand Down
50 changes: 50 additions & 0 deletions modules/rooms_booking/rooms_booking.variable.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* @file
* Variable API module. Definition for Rooms Booking variables
*/

/**
* Implements hook_variable_info().
*/
function rooms_booking_variable_info($options) {
$variables['rooms_booking_price'] = array(
'type' => 'string',
'title' => t('Price'),
'default' => t('Price'),
'description' => t('Change text : Price'),
'localize' => TRUE,
'group' => 'rooms_booking',
);
$variables['rooms_booking_subtotal'] = array(
'type' => 'string',
'title' => t('Subtotal'),
'default' => t('Subtotal'),
'description' => t('Change text : Subtotal'),
'localize' => TRUE,
'group' => 'rooms_booking',
);
$variables['rooms_booking_age_of_child'] = array(
'type' => 'string',
'title' => t('Age of Child'),
'default' => t('Age of Child'),
'description' => t('Change text : Age of Child'),
'localize' => TRUE,
'group' => 'rooms_booking',
);

return $variables;
}

/**
* Implements hook_variable_group_info().
*/

function rooms_booking_variable_group_info() {
$groups['rooms_booking'] = array(
'title' => t('Rooms Booking'),
'description' => t('Rooms Booking variables.'),
'access' => 'administer site configuration',
);
return $groups;
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function rooms_booking_availability_search_form_builder($form, &$form_state) {
if (variable_get('rooms_display_children', ROOMS_DISPLAY_CHILDREN_NO) == ROOMS_DISPLAY_CHILDREN) {
$form['rooms_fieldset']['group_size_children:1'] = array(
'#type' => 'select',
'#title' => t('Children'),
'#title' => variable_get_value('rooms_booking_manager_children'),
'#options' => rooms_assoc_range(0, 3),
'#default_value' => isset($booking_parameters[1]['children']) ? $booking_parameters[1]['children'] : 0,
);
Expand Down
37 changes: 18 additions & 19 deletions modules/rooms_booking_manager/rooms_booking_manager.module
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
if (empty($deposit_amount)) {
$form['price'] = array(
'#prefix' => '<div class="rooms-search-result__unit-base-price" id="unit_' . $unit->unit_id . '_base_price">',
'#markup' => rooms_string('<label>' . t('Base price') . ':</label> <span class="rooms-search-result__base-price-amount">' .
'#markup' => rooms_string('<label>' . variable_get_value('rooms_booking_manager_base_price') . ':</label> <span class="rooms-search-result__base-price-amount">' .
t('@currency_symbol @amount', array( // TODO: replace with a proper currency formatter
'@currency_symbol' => $currency_symbol,
'@amount' => $price,
Expand All @@ -877,11 +877,11 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
else {
$form['price'] = array(
'#prefix' => '<div class="rooms-search-result__unit-base-price" id="unit_' . $unit->unit_id . '_base_price">',
'#markup' => rooms_string('<label>' . t('Base price') . ':</label> <span class="rooms-search-result__base-price-amount">' .
'#markup' => rooms_string('<label>' . variable_get_value('rooms_booking_manager_base_price') . ':</label> <span class="rooms-search-result__base-price-amount">' .
t('@currency_symbol @amount', array( // TODO: replace with a proper currency formatter
'@currency_symbol' => $currency_symbol,
'@amount' => $price,
)) . '</span>' . '<label>' . ' - '. t('Payable now') . ':</label> <span class="rooms-search-result__base-price-amount">' .
)) . '</span>' . '<label>' . ' - '. variable_get_value('rooms_booking_manager_payable_now') . ':</label> <span class="rooms-search-result__base-price-amount">' .
t('@currency_symbol @deposit', array(
'@currency_symbol' => $currency_symbol,
'@deposit' => $deposit_amount,
Expand Down Expand Up @@ -909,7 +909,7 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
// Calculate the price per person per night, too.
$base_price = $price_per_person / $nights;

$form['price']['#markup'] = rooms_string(format_plural($nights, 'Book this unit for 1 night at <b>@price per person</b> (@base_price per person per night)', 'Book this unit for @count nights at <b>@price per person</b> (@base_price per person per night)', array(
$form['price']['#markup'] = rooms_string(format_plural($nights, variable_get_value('rooms_booking_manager_book_this_unit_for') . ' 1 night at <b>@price ' . variable_get_value('rooms_booking_manager_per_person') . '</b> (@base_price ' . variable_get_value('rooms_booking_manager_per_person_per_night') . ')', variable_get_value('rooms_booking_manager_book_this_unit_for') . ' @count nights at <b>@price ' . variable_get_value('rooms_booking_manager_per_person') . '</b> (@base_price ' . variable_get_value('rooms_booking_manager_per_person_per_night') . ')', array(
'@price' => t('@currency_symbol @amount', array( // TODO: replace with a proper currency formatter
'@currency_symbol' => $currency_symbol,
'@amount' => $price_per_person)),
Expand Down Expand Up @@ -956,7 +956,7 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_

$form['options'][$option_name . ':quantity'] = array(
'#type' => 'select',
'#title' => t('Quantity'),
'#title' => variable_get_value('rooms_booking_manager_quantity'),
'#options' => range(1, $option['quantity']),
'#ajax' => array(
'callback' => 'rooms_booking_manager_options_change_callback',
Expand Down Expand Up @@ -995,14 +995,14 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
if (variable_get('rooms_price_calculation', ROOMS_PER_NIGHT) == ROOMS_PER_PERSON) {
$form['persons'] = array(
'#type' => 'select',
'#field_suffix' => t('Guests'),
'#field_suffix' => variable_get_value('rooms_booking_manager_guests'),
'#options' => range($unit->min_sleeps, $unit->max_sleeps),
'#default_value' => $unit->max_sleeps - $unit->min_sleeps,
'#ajax' => array(
'callback' => 'rooms_booking_manager_quantity_change_callback',
'wrapper' => 'unit_' . $unit->unit_id . '_price',
),
'#title' => t('How many people in this unit (including adults and children)?'),
'#title' => variable_get_value('rooms_booking_manager_how_many_people'),
'#prefix' => '<div class="rooms-search-result__select-guests">',
'#suffix' => '</div>',
);
Expand All @@ -1019,8 +1019,8 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
if ($max_children > $unit->min_children) {
$form['children'] = array(
'#type' => 'select',
'#title' => t('How many of the guests are children?'),
'#field_suffix' => t('Children'),
'#title' => variable_get_value('rooms_booking_manager_how_many_guests_children'),
'#field_suffix' => variable_get_value('rooms_booking_manager_children'),
'#options' => range($unit->min_children, $max_children),
'#default_value' => 0,
'#ajax' => array(
Expand All @@ -1043,7 +1043,7 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
for ($t = 1; $t <= $form_state['values']['children']; $t++) {
$form['childrens_age'][$t] = array(
'#type' => 'select',
'#field_prefix' => t('Age of child @num', array('@num' => $t)),
'#field_prefix' => variable_get_value('rooms_booking_age_of_child') . ' ' . $t,
'#options' => range(0, 18),
'#ajax' => array(
'callback' => 'rooms_booking_manager_options_change_callback',
Expand Down Expand Up @@ -1111,7 +1111,7 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
if (empty($deposit_amount)) {
$form['new_price'] = array(
'#prefix' => '<div class="rooms-search-result__new-price" id="unit_' . $unit->unit_id . '_price">',
'#markup' => '<label>' . t('Cost') . ':</label> <span class="rooms-search-result__new-price-amount">' .
'#markup' => '<label>' . variable_get_value('rooms_booking_manager_cost') . ':</label> <span class="rooms-search-result__new-price-amount">' .
t('@currency_symbol @amount', array( // TODO: replace with a proper currency formatter
'@currency_symbol' => $currency_symbol,
'@amount' => $new_price['full_price'],
Expand All @@ -1123,11 +1123,11 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
else {
$form['new_price'] = array(
'#prefix' => '<div class="rooms-search-result__new-price" id="unit_' . $unit->unit_id . '_price">',
'#markup' => '<label>' . t('Cost') . ':</label> <span class="rooms-search-result__new-price-amount">' .
'#markup' => '<label>' . variable_get_value('rooms_booking_manager_cost') . ':</label> <span class="rooms-search-result__new-price-amount">' .
t('@currency_symbol @amount', array( // TODO: replace with a proper currency formatter
'@currency_symbol' => $currency_symbol,
'@amount' => $new_price['full_price'],
)) . '</span>' . '<label>' . ' - ' . t('Payable Now') . ':</label> <span class="rooms-search-result__new-price-deposit">' . t('@currency_symbol @deposit_amount', array (
)) . '</span>' . '<label>' . ' - ' . variable_get_value('rooms_booking_manager_payable_now') . ':</label> <span class="rooms-search-result__new-price-deposit">' . t('@currency_symbol @deposit_amount', array (
'@currency_symbol' => $currency_symbol,
'@deposit_amount' => $deposit_amount,
)) . '</span>',
Expand All @@ -1151,7 +1151,7 @@ function book_unit_form_builder($form_id, $form_state, $unit, $start_date, $end_
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Book This'),
'#value' => variable_get_value('rooms_booking_manager_book_this'),
'#submit' => $submit + array('book_unit_form_submit'),
);

Expand Down Expand Up @@ -1450,7 +1450,7 @@ function book_units_per_type_form($form, $form_state, $units_per_type, $start_da
// for all people in the room.
$unit_type_label = rooms_unit_get_types($units[$units_keys[$c - 1]]['unit']->type)->label;
if (variable_get('rooms_price_calculation', ROOMS_PER_NIGHT) == ROOMS_PER_PERSON) {
$label = rooms_string('Subtotal',
$label = rooms_string(variable_get_value('rooms_booking_subtotal'),
$context = array(
'#component' => 'units_per_type_form_subtotal_label',
'#purpose' => 'display_base_subtotal_label',
Expand All @@ -1463,7 +1463,7 @@ function book_units_per_type_form($form, $form_state, $units_per_type, $start_da
);
}
else {
$label = rooms_string('Price',
$label = rooms_string(variable_get_value('rooms_booking_price'),
$context = array(
'#component' => 'units_per_type_form_price_label',
'#purpose' => 'display_base_price_label',
Expand Down Expand Up @@ -1494,7 +1494,7 @@ function book_units_per_type_form($form, $form_state, $units_per_type, $start_da
$form[$type][$price]['fieldset'][$c]['price'] = array(
'#prefix' => '<div class="rooms-search-result__unit-price" id="' . $type . '_' . $price . '_' . $c . '_price"><label>' . $label . ':</label> <span class="rooms-search-result__unit-price-amount">',
// TODO: replace with a proper currency formatter.
'#markup' => t('@currency_symbol @amount - Payable now: @currency_symbol @deposit', array(
'#markup' => t('@currency_symbol @amount - ' . variable_get_value('rooms_booking_manager_payable_now') . ': @currency_symbol @deposit', array(
'@currency_symbol' => $currency_symbol,
'@amount' => $price,
'@deposit' => $deposit_amount,
Expand Down Expand Up @@ -1620,7 +1620,7 @@ function book_units_per_type_form($form, $form_state, $units_per_type, $start_da
// Replace old price with the new calculated value.
$form[$type][$price]['fieldset'][$c]['price']['#markup'] =
rooms_string(
t('@currency_symbol @amount - Payable now: @currency_symbol @deposit', array(
t('@currency_symbol @amount - ' . variable_get_value('rooms_booking_manager_payable_now') . ': @currency_symbol @deposit', array(
'@currency_symbol' => $currency_symbol,
'@amount' => $new_price,
'@deposit' => $deposit_amount,
Expand Down Expand Up @@ -2149,7 +2149,6 @@ function rooms_booking_manager_commerce_checkout_form_cancel_submit($form, &$for
* Implements hook_form_alter().
*/
function rooms_booking_manager_form_alter(&$form, &$form_state, $form_id) {

// Commerce checkout form alters.
if ($form_id == 'commerce_checkout_form_checkout') {
rooms_booking_manager_alter_commerce_checkout_form_checkout($form, $form_state, $form_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,14 @@ function _rooms_booking_manager_load_price_info($form, $type_obj, $type, $price,
// Calculate the price per person for the booking period.
$base_price = $units[$units_keys[0]]['price'] / $units[$units_keys[0]]['unit']->max_sleeps;
$form[$type][$price]['price']['#markup'] = format_plural(count
($units), '1 @unit_type unit available starting at @price per
person', '@count @unit_type units available starting at @price per person', array(
($units), '1 @unit_type ' . variable_get_value('rooms_booking_manager_unit_available_starting_at') . ' @price '. variable_get_value('rooms_booking_manager_per_person'), '@count @unit_type ' . variable_get_value('rooms_booking_manager_units_available_starting_at') . ' @price '. variable_get_value('rooms_booking_manager_per_person'), array(
'@unit_type' => $type_obj->label,
'@price' => t('@currency_symbol @amount', array( // TODO: replace with a proper currency formatter
'@currency_symbol' => $currency_symbol,
'@amount' => $base_price))
)
);
}

// Add form element to hold the price.
$form[$type][$price]['price_value'] = array(
'#type' => 'hidden',
Expand Down Expand Up @@ -283,7 +281,7 @@ function _rooms_booking_manager_handle_per_person_pricing($form, &$form_state, $
'callback' => 'rooms_booking_manager_quantity_change_callback',
'wrapper' => $type . '_' . $price . '_container',
),
'#title' => t('How many people in this unit (including adults and children)?'),
'#title' => variable_get_value('rooms_booking_manager_how_many_people'),
'#prefix' => '<div class="rooms-search-result__select-guests">',
'#suffix' => '</div>',
);
Expand All @@ -301,8 +299,8 @@ function _rooms_booking_manager_handle_per_person_pricing($form, &$form_state, $
if ($tmp_unit->max_children > 0) {
$form[$type][$price]['fieldset'][$c]['children'] = array(
'#type' => 'select',
'#title' => t('How many of the guests are children?'),
'#field_suffix' => t('Children'),
'#title' => variable_get_value('rooms_booking_manager_how_many_guests_children'),
'#field_suffix' => variable_get_value('rooms_booking_manager_children'),
'#options' => array_combine(
range($tmp_unit->min_children, $max_children),
range($tmp_unit->min_children, $max_children)),
Expand Down Expand Up @@ -334,7 +332,7 @@ function _rooms_booking_manager_handle_per_person_pricing($form, &$form_state, $
for ($t = 1; $t <= $children_number; $t++) {
$form[$type][$price]['fieldset'][$c]['childrens_age'][$t] = array(
'#type' => 'select',
'#field_prefix' => t('Age of child @num', array('@num' => $t)),
'#field_prefix' => variable_get_value('rooms_booking_age_of_child') . ' ' . $t,
'#options' => range(0, 18),
'#ajax' => array(
'callback' => 'rooms_booking_manager_options_change_callback',
Expand Down
Loading